Intel® Quartus® Prime Pro Edition User Guide: Scripting

ID 683432
Date 6/20/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

3.1.163.1.16.1. Example of a Tcl Script

----------------------
Example Tcl Script
----------------------

#--------------------------------------------------------------#
# 
# The following Tcl script instructs the Quartus Prime 
# software to create a project (or open it if it already 
# exists), make global assignments for family and device, 
# and include timing and location settings.
#
# There are two ways to compile a project after making 
# assignments. The first method, and the easiest, is 
# to use the ::quartus::flow package and call the Tcl 
# command "execute_flow -compile".
# 
# The second method is to call the Tcl command 
# "export_assignments" to write assignment changes to the 
# Quartus Prime Settings File (.qsf) before compiling the 
# design. Calling "export_assignments" beforehand is 
# necessary so that the command-line executables detect 
# the assignment changes.
# 
# After compilation, with either method, the script then 
# instructs the Quartus Prime software to write the project 
# databases and to compile using the command-line executables. 
# The script obtains the fmax result from the report database. 
# Finally, the script closes the project.
# 
#--------------------------------------------------------------#

#------ Get Slack from the Report File ------#

proc get_slack_from_report {} {
	global project_name

	load_report $project_name
	set panel "Timing Analyzer||Setup Summary"
	set panel_id [get_report_panel_id $panel]
	set slack [get_report_panel_data -col_name Slack -row 1 -id $panel_id]

	unload_report $project_name

	return $slack
}

proc report_slack {} {
	set setup_slack [get_slack_from_report]
	set seed [get_global_assignment -name SEED]
	puts ""
	puts "-----------------------------------------------------"
	puts "Setup Slack for Seed $seed: $setup_slack"
	puts "-----------------------------------------------------"
}

#------ Set the project name to chiptrip ------#
set project_name chiptrip 

#------ Create or open project ------#
if [project_exists $project_name] {

#------ Project already exists -- open project -------#
	project_open $project_name -force
} else {

#------ Project does not exist -- create new project ------#
	project_new $project_name
}

#------ Make global assignments ------#
set_global_assignment -name family STRATIX
set_global_assignment -name device EP1S10F484C5
set_global_assignment -name SEED 1

#------ Compile using ::quartus::flow ------#
execute_flow -compile

#------ Report Slack from report ------#
report_slack

# -----------------------------------------------------------
# An alternative method is presented in the following script
# -----------------------------------------------------------

set_global_assignment -name SEED 2

#------ Manually recompile and perform timing analysis again using qexec ------#

# Write these assignments to the
# Quartus Prime Settings File (.qsf) so that
# the Quartus Prime command-line executables
# can use these assignments during compilation
export_assignments

# Compile the project and
# exit using "qexit" if there is an error
if [catch {qexec "[file join $::quartus(binpath) quartus_fit] $project_name"} result] {
	qexit -error
}
if [catch {qexec "[file join $::quartus(binpath) quartus_sta] $project_name"} result] {
	qexit -error
}

#------ Report Slack from report ------#
report_slack

#------ Close Project ------#
project_close