Intel® Quartus® Prime Pro Edition User Guide: Scripting

ID 683432
Date 12/13/2021
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.20.5. foreach_in_collection (::quartus::misc)

The following table displays information for the foreach_in_collection Tcl command:

Tcl Package and Version

Belongs to ::quartus::misc

Syntax foreach_in_collection [-h | -help] [-long_help] <variable_name> <collection> <body>
Arguments -h | -help Short help
-long_help Long help with examples and possible return values
<variable_name> Variable name
<collection> Collection
<body> Body
Description
Accesses each element of a collection.

Some Tcl commands return a collection. The following table shows
examples of commands that return a collection:

Tcl package                 Tcl commands (returning a collection)
--------------------------  ----------------------------------------
::quartus::project          get_all_quartus_defaults
                            get_all_global_assignments
                            get_all_instance_assignments
                            get_all_parameters
                            get_names
                            assignment_group (only for the "-get_members"
                                              and "-get_exceptions" options)

::quartus::chip_editor      get_nodes
                            get_iports
                            get_oports

The command is used in the following format:

foreach_in_collection <variable name> <collection> {

      # This is the body of "foreach_in_collection"
      ...
}

Unlike a Tcl list, a collection is a container specific to the Quartus
II software, whose elements can be accessed by using the
"foreach_in_collection" command.  
Example Usage
## Get a collection of global assignments
set collection_of_global_assignments [get_all_global_assignments -name *]
## Display the collection string representation
puts $collection_of_global_assignments
## Iterate through the collection and display
## the information for each global assignment
foreach_in_collection global $collection_of_global_assignments {

	set sect_id [lindex $global 0]
	set name [lindex $global 1]
	set value [lindex $global 2]

	## Now, display the content of the global assignment
	puts "Section ID ($sect_id)"
	puts "Assignment Name ($name)"
	puts "Assignment Value ($value)"
}

## Get a collection of instance assignments
set collection_of_instance_assignments [get_all_instance_assignments -name *]	
## Display the collection string representation
puts $collection_of_instance_assignments
## Iterate through the collection and display
## the information for each instance assignment
foreach_in_collection instance $collection_of_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]

	## Now, display the content of the instance assignment
	puts "Section ID ($sect_id)"
	puts "Source ($src)"
	puts "Destination ($dest)"
	puts "Assignment Name ($name)"
	puts "Assignment Value ($value)"
}

## Get a collection of parameters
set collection_of_parameters [get_all_parameters -name *]
## Display the collection string representation
puts $collection_of_parameters
## Iterate through the collection and display
## the information for each parameter
foreach_in_collection parameter $collection_of_parameters {

	set d