Agenda
-Other Tcl Scripting Commands
-Accessing Command Line Options
-Using Tcl in Quartus II Software
-Getting More Help
::quartus::misc Package
-Utility and Miscellaneous Commands
Loaded by Default in Every Executable
-Some Commonly Used Commands
escape_brackets
post_message
escape_brackets Command
-Many Quartus II Tcl Commands Allow Regular Expressions in Option Arguments
-Improperly Escaping Bus Names Is a Common Error
address\[10\]
Regular Expression Matches address0 or address1
-Square Brackets Must Be Escaped Twice
address\\\[10\\\]
-Use escape_brackets Command For Convenience
-Example:Get All Location Assignments for Bus address[]
Example:
set address_names "address\[*\]"
set address_locations [get_all_instance_assignments \
-to [escape_brackets $address_names] -name LOCATION]
post_message Command
-Formats Text Like Quartus II Message Types
-Specify Message Type and Text
info,extra_info,warning,critical_warning,error
Tcl Collections
-Some Tcl Commands Return Large Sets of Data
-Collection Is Container for Large Data Sets
Specific to Quartus II Tcl API
-Access Collection Elements with foreach_in_collection Command
Same Syntax as foreach Tcl Command
-Packages with Commonds that Return Collections Include foreach_in_collection
-No Need to Load Separate Package
Tcl Collection Example
-Print Details of All Instance Assignments
set instance_assignments [get_all_instance_assignments -name *]
foreach_in_collection instance $instance_assignments {
set sect_id[lindex $instance 0]
set src[lindex $instance 1]
set dest[lindex $instance 2]
set name[lindex $instance 3]
set value[lindex $instance 4]
puts "Section ID ($sect_id)"
puts "Source ($src)"
puts "Destination ($dest)"
puts "Assignment Name ($name)"
puts "Assignment value ($value)"
}
Access Command-Line Options
-Quartus II Version 4.1 Supports argv,argc,and argv0
Earlier Versions Pass Arguments in quartus(args) Variable
quartus(args) Still Supported
Version 4.1 Variable |
Earlier Version Equivalent |
argv |
quartus(args) |
argc |
llength $quartus(args) |
argv0 |
info nameofexecutable |
Command-Line Options Example
-cmdline Package Provides Flexible Access to Command-Line Options
More Robust than Hard-Coded Indexing into List of Command_Line Options
Include with Quartus II
-Example with cmdline Package
quartus_sh -t myscript.tcl -project my_project -revision second
-Open Project with Optional Revision Name
package require cmdline
set options {\
{"project.arg""""Project Name"}\
{"revision.arg""""Revision Name"}\
}
array set optshash [::cmdline::getoptions ::argv $options "Options:"]
if{[string equal "" $optshash(revision)]}{
#No revision is specified
project_open $optshash(project)
}else{
project_open $optshash(project) -revision $optshash(revision)
}
#The rest of your script follows here
Using Tcl in Quartus II
-Command-Line Executables
Batch Mode to Execute Script Files
Interactive Shell
Quick Tcl Evaluation of Command Arguments
-Tcl Console in GUI
Interactive Shell
View Menu(View->Unity windows->Tcl console)
Using Tcl at the Command Line
-Run Script File
quartus_sh -t <script file> [<script arguments>]
quartus_sh -t myscript.tcl Stratix
-Interactive Tcl Shell
quartus_sh -s
-Direct Tcl Evaluation
quartus_sh --tcl_eval <tcl command>
quartus_sh --tcl_eval help -pkg flow
-Same Syntax for Other Executable
Running Tcl Scripts
-Command-Line Executables Supporting Tcl
Name |
Common Uses |
quartus_sh |
Assignments,General Reporting,Compiling,Simple Shell |
quartus_tan |
Timing Reporting,Advanced Timing Analysis |
quartus_cdb |
Back Annotation,LogicLock Regions,Chip Editor Functions |
quartus_sim |
Simulate with Tcl Testbenches |
Why Different Executables?
-Different Executables Support Different Functionality
Different Tcl Packages Available
-Example
quartus_cdb Supports LogicLock Functions,
Not Timing Analysis Functions
Basic Project Functions Supported by All
-Executable and Package Matrix in Tcl Script Chapter of Quartus II Handbook
Also Type help at Tcl Shell Prompt for List
Quartus II Tcl Scripts
-Tcl Scripts Included with Quartus II
Design Space Explorer(DSE)
QHelp Unility
QFlow Script
-Scripts Listed in Tcl Scripts (Tools menu)
-Modify to Suit Needs
Pop Quiz
-List Three Ways to Use Tcl Scripts and Commands with Quartus II software
Pop Quiz Answer
-Tcl Console in Quartus II GUI
-Interactive Tcl Shell in Command-Line Executable
Batch Mode of Command-Line Executables
Direct Execution Mode of Command-Line Executable
-Tcl Toolbar Buttions(Not Covered in Presentation)