# Quartus® II Tcl Example: Non-Default Global Assignments

By

It can be useful to review global assignments in your design to see whether any of your assignments are different than the default setting. For example, if the performance of your design is not what you expect, you can see whether you changed a setting accidentally from its default value.

This example creates a custom report panel that lists your project's non-default global assignment settings. The commands to create custom report panels are available beginning with version 4.1 of the Quartus II software (version 2.0 of the ::quartus::report package). This example uses the cmdline Tcl package to process command-line arguments.

load_package report
package require cmdline
set options {\
{ "project.arg" "" "Project name" } \
{ "revision.arg" "" "Revision name" }
}
array set opts [::cmdline::getoptions quartus(args) $options] project_open$opts(project) -revision $opts(revision) load_report set panel_name "Non-Default Global Settings" set panel_id [get_report_panel_id$panel_name]

# You must delete the panel if it exists, before creating it.
if { -1 != $panel_id } { delete_report_panel -id$panel_id
}

set panel_id [create_report_panel -table $panel_name] # Column headings for the new report panel add_row_to_table -id$panel_id \
{ "Assignment" "Default Value" "Design Value" }

foreach_in_collection asgn [get_all_quartus_defaults] {

foreach { section_id name default_value } $asgn { break } set current_value [get_global_assignment -name$name]

# If the values are different, add a row to the table.
if { ! [string equal -nocase $current_value$default_value] } {
add_row_to_table -id $panel_id \ [list$name $default_value$current_value]
}
}

save_report_database
project_close


At a system command prompt, you can run a script that contains the code as shown here:

quartus_sh -t script.tcl -project myproject -revision myrevision

## Improving the Sample Code

One way to improve the code is to make it run automatically at the end of every compilation. To do this, add a new assignment to your project and change the way the command-line arguments are processed.

The assignment name is POST_FLOW_SCRIPT_FILE. For more information on this assignment, refer to the Automatic Script Execution examples. Assuming the script is named script.tcl, add the following assignment to your Quartus II Settings File (.qsf):

set_global_assignment -name POST_FLOW_SCRIPT_FILE quartus_sh:script.tcl


Because of the way the script is run with the POST_FLOW_SCRIPT_FILE assignment, you must change the commands at the top of the script that open the project. The script is run with three predefined positional arguments: the flow, project, and revision names. Using the cmdline package is unnecessary in this case.

Modify the top of the script as follows:

load_package report

foreach { flow_name project revision } $quartus(args) { break } project_open$project -revision \$revision


The script runs automatically at the end of every compilation, regardless of whether you start the compilation in the Quartus II GUI, at a system command prompt, or in a script.