Friday, April 21, 2006

Tcl Script to Automate Quartus II Compilation

Below is a sample Tcl script that I use to automate the compilation of my Quartus II projects overnight or over the weekend. You can easily find more information about the usage by just typing "tcl" on the Altera search column in www.altera.com and you can easily get some examples over there. The most relevant reading material for Quartus II tool specific scripts would be the Tcl Scripting chapter of the Quartus II Handbook.


############################################
## auto_compile.tcl
## date created : April 9, 2006
## author : http://fpgaforum.blogspot.com
############################################


###Assume that the objective of this script is to compile
###a similar project twice, one with a minimum current strength
###and the other with a maximum current strength.
###(Sometimes you need to do some characterization of the current
###strength on your hardware!)
###The final product is two sof files, one for the minimum
###current strength and the other one for the maximum
###current strength. This means that this script will also rename
###the sof file for after every compilation to avoid being overwritten
###on the next compilation cycle

###go to project folder in command prompt
### Then type quartus_sh -s
### Verify the Quartus II Version number is as targeted, if you have multiple
### versions of Quartus II on your PC
### After verified, type the following command:
### source (This filename.tcl)
### OR
### Open the Quartus II project, then open up the Quartus II Tcl Console by
### go to View->Utility Windows->Tcl Console
### In the Quartus II Tcl Console, type the following command if the tcl script
### is placed in the project folder:
### source (This filename.tcl)

########## TCL script starts #################

####### Auto Compilation TCL Script ############
#change the following line according to your Quartus II project folder##
##assume the 1st project that I want to compile is in the following folder
cd D:/data/project1

##This is to set the minimum current strength
set project_name project1
set revision_name project1
project_open -revision $revision_name $project_name;
set_global_assignment -name Family StratixII
set_global_assignment -name DEVICE EP2S60F1020C3ES

#some assignments to the pins. Of course, I am not going to list all
set_instance_assignment -name CURRENT_STRENGTH_NEW "MINIMUM CURRENT" -to data_bus[0]
set_instance_assignment -name CURRENT_STRENGTH_NEW "MINIMUM CURRENT" -to data_bus[1]

load_package flow
execute_flow -compile
project_close

set sof [pwd]/project1.sof
if [file exists $sof] {
file rename $sof project1_MIN.sof
} else {
puts "ERROR! RENAME $sof to project1_MIN.sof"
}

###======================================

##This is to set the maximum current strength
set project_name project1
set revision_name project1
project_open -revision $revision_name $project_name;
set_global_assignment -name Family StratixII
set_global_assignment -name DEVICE EP2S60F1020C3ES

#some assignments to the pins. Of course, I am not going to list all
set_instance_assignment -name CURRENT_STRENGTH_NEW "MAXIMUM CURRENT" -to data_bus[0]
set_instance_assignment -name CURRENT_STRENGTH_NEW "MAXIMUM CURRENT" -to data_bus[1]

load_package flow
execute_flow -compile
project_close

set sof [pwd]/project1.sof
if [file exists $sof] {
file rename $sof project1_MAX.sof
} else {
puts "ERROR! RENAME $sof to project1_MAX.sof"
}

###======================================
########## TCL script ends #################

2 comments:

Anonymous said...

Ola, what's up amigos? :)
Hope to get some help from you if I will have some quesitons.
Thanks and good luck everyone! ;)

Anonymous said...

hi everybody


Just saying hello while I read through the posts


hopefully this is just what im looking for looks like i have a lot to read.