Intel® Quartus® Prime Standard Edition User Guide: Scripting

ID 683325
Date 9/24/2018
Document Table of Contents The cmdline Package

You can use the cmdline package included with the Intel® Quartus® Prime software for more robust and self-documenting command-line argument passing. The cmdline package supports command-line arguments with the form -<option><value>.

cmdline Package

package require cmdline
variable ::argv0 $::quartus(args)
set options {
   { "project.arg" "" "Project name" }
   { "frequency.arg" "" "Frequency" }
set usage "You need to specify options and values"
array set optshash [::cmdline::getoptions ::argv $options $usage]
puts "The project name is $optshash(project)"
puts "The frequency is $optshash(frequency)"

If you save those commands in a Tcl script called print_cmd_args.tcl you see the following output when you type the following command at a command prompt.

Passing Command-Line Arguments for Scripts

quartus_sh -t print_cmd_args.tcl -project my_project -frequency 100MHz
The project name is my_project
The frequency is 100MHz

Virtually all Intel® Quartus® Prime Tcl scripts must open a project. You can open a project, and you can optionally specify a revision name with code like the following example. The example checks whether the specified project exists. If it does, the example opens the current revision, or the revision you specify.

Full-Featured Method to Open Projects

package require cmdline
variable ::argv0 $::quartus(args)
set options { \
{ "project.arg" "" "Project Name" } \
{ "revision.arg" "" "Revision Name" } \
array set optshash [::cmdline::getoptions ::argv0 $options]
# Ensure the project exists before trying to open it
if {[project_exists $optshash(project)]} {
	if {[string equal "" $optshash(revision)]} {
		# There is no revision name specified, so default
		# to the current revision
		project_open $optshash(project) -current_revision
	} else {
		# There is a revision name specified, so open the
		# project with that revision
		project_open $optshash(project) -revision \
} else {
	puts "Project $optshash(project) does not exist"
	exit 1
# The rest of your script goes here

If you do not require this flexibility or error checking, you can use just the project_open command.

Simple Method to Open Projects

set proj_name [lindex $argv 0]
project_open $proj_name

Did you find the information on this page useful?

Characters remaining:

Feedback Message