Free Online Training Events
Free Technical Resources
Altera Quartus II has a thorough implementation, with many extra Tcl commands added for Quartus. To allow easy access, they are organised into Tcl packages which may be imported when needed.
Altera Quartus II provides a Tcl prompt, so you can directly type in commands, or source (read in) Tcl commands from an external file.
Let's look at using Tcl to set pin locations, using the Tcl command window in the Graphical User Interface (GUI).
You'll need a Tcl file with commands to set pin locations. Here is an example from the Doulos Comprehensive VHDL course:
############################################################################### # tornado.tcl # # This script makes the pin assignments to ALSE Tornado Developement Board # # Unused pins are tristated # ############################################################################### puts "Tornado Board - Pin assignment ..." # SW1 set custom_pins(42) SEL\[0\] # SW2 set custom_pins(47) SEL\[1\] # SW6/1 set custom_pins(5) A # SW6/2 set custom_pins(6) B # SW6/3 set custom_pins(7) C # SW6/4 set custom_pins(11) D # LD1 set custom_pins(59) F puts "Tornado Board - Pin assignment done!"
Let's assume you've already run Quartus, and synthesised your design. The next step is to set the pin constraints before place and route. To use the above Tcl file, you would need to follow these instructions:
source tornado.tcl
That's it! Now you can complete the compile for your design.
Well, that's almost it - the command will only work if the pin file is in your Quartus project folder. If it's in a different folder you will have to specify the path. The path can be a full path such as "c:/users/training/vhdlfpga/exo2/source/board_support/tornado.tcl" or it could be a relative path such as "../source/board_support/tornado.tcl" - Note that Tcl always uses the forward slash in paths, whether on Windows or Unix/Linux. Note also that you will need to surround the path in double quotes if it contains spaces.
If you are new to Tcl, Quartus has a powerful feature which can get you started by creating a file of settings for you. It's then an easy job to turn that file into a simple script.
Firstly, now you've run your project using the GUI, you can store the settings using the menu:
Project > Generate Tcl File for Project...
A dialogue box will pop up allowing you to store the Tcl file. Here's what happened when we ran that command on Comprehensive VHDL exercise 2:
# Quartus II: Generate Tcl File for Project # File: ex02proj.tcl # Generated on: Wed Feb 11 17:56:59 2009 # Load Quartus II Tcl Project package package require ::quartus::project set need_to_close_project 0 set make_assignments 1 # Check that the right project is open if {[is_project_open]} { if {[string compare $quartus(project) "ex02proj"]} { puts "Project ex02proj is not open" set make_assignments 0 } } else { # Only open if not already open if {[project_exists ex02proj]} { project_open -revision MUX4 ex02proj } else { project_new -revision MUX4 ex02proj } set need_to_close_project 1 } # Make assignments if {$make_assignments} { set_global_assignment -name FAMILY Cyclone set_global_assignment -name DEVICE EP1C6T144C6 set_global_assignment -name ORIGINAL_QUARTUS_VERSION 8.1 set_global_assignment -name PROJECT_CREATION_TIME_DATE "17:44:38 FEBRUARY 11, 2009" set_global_assignment -name LAST_QUARTUS_VERSION 8.1 set_global_assignment -name USE_GENERATED_PHYSICAL_CONSTRAINTS OFF -section_id eda_blast_fpga set_global_assignment -name DEVICE_FILTER_PIN_COUNT 144 set_global_assignment -name DEVICE_FILTER_SPEED_GRADE 6 set_global_assignment -name VHDL_FILE ../source/mux4.vhd set_global_assignment -name MIN_CORE_JUNCTION_TEMP 0 set_global_assignment -name MAX_CORE_JUNCTION_TEMP 85 set_global_assignment -name PARTITION_NETLIST_TYPE SOURCE -section_id Top set_global_assignment -name PARTITION_COLOR 16764057 -section_id Top set_global_assignment -name LL_ROOT_REGION ON -section_id "Root Region" set_global_assignment -name LL_MEMBER_STATE LOCKED -section_id "Root Region" set_global_assignment -name RESERVE_ALL_UNUSED_PINS AS_INPUT_TRI_STATED set_global_assignment -name GENERATE_RBF_FILE ON set_instance_assignment -name PARTITION_HIERARCHY root_partition -to | -section_id Top set_location_assignment PIN_5 -to IN0 set_location_assignment PIN_6 -to IN1 set_location_assignment PIN_7 -to IN2 set_location_assignment PIN_11 -to IN3 set_location_assignment PIN_59 -to OUT0 set_location_assignment PIN_60 -to OUT1 set_location_assignment PIN_61 -to OUT2 set_location_assignment PIN_144 -to OUT3 # Commit assignments export_assignments # Close project if {$need_to_close_project} { project_close } }
So far so good... but this is only the project settings: how do we turn it into a compile script? It is actually surprisingly easy. Firstly, we must modify the end of the file as follows:
# Quartus II: Generate Tcl File for Project # File: ex02proj.tcl # Generated on: Wed Feb 11 17:56:59 2009 # Load Quartus II Tcl Project package package require ::quartus::project # ... lots of code cut out ... execute_flow -compile # Close project if {$need_to_close_project} { project_close } }
This uses the Quartus execute_flow command to carry out the compile. However if you try and run this script, it won't work as it cannot find that command. We need to import an additional package at the top of the script, i.e.
# Quartus II: Generate Tcl File for Project # File: ex02proj.tcl # Generated on: Wed Feb 11 17:56:59 2009 # Load Quartus II Tcl Project package package require ::quartus::project # Add the next line to get the execute_flow command package require ::quartus::flow # ... lots of code cut out ... execute_flow -compile # Close project if {$need_to_close_project} { project_close } }
Et voilà a Quartus script!
To run it, you can put it in the project directory and use the source command as above from the GUI. Or you can run it from the command line as follows:
You'll find scripts like this used in our training course Comprehensive VHDL.