Intel® Quartus® Prime Pro Edition User Guide: Scripting

ID 683432
Date 10/04/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 dest [lindex $parameter 0]
	set name [lindex $parameter 1]
	set value [lindex $parameter 2]

	## Now, display the content of the parameter
	puts "Destination ($dest)"
	puts "Parameter Name ($name)"
	puts "Parameter Value ($value)"
}

## Get a collection of all node name ids from a successful 
## compilation
set collection_of_name_ids [get_names -filter *]
## Display the collection string representation
puts $collection_of_name_ids
## Iterate through the collection and display
## the information for each name id
foreach_in_collection name_id $collection_of_name_ids {

	set parent_name_id [get_name_info -info parent_name_id $name_id]
	set base_name [get_name_info -info base_name $name_id]
	set entity_name [get_name_info -info entity_name $name_id]
	set instance_name [get_name_info -info instance_name $name_id]
	set full_path [get_name_info -info full_path $name_id]
	set short_full_path [get_name_info -info short_full_path $name_id]
	set node_type [get_name_info -info node_type $name_id]
	set creator [get_name_info -info creator $name_id]
	set signaltapii [get_name_info -info signaltapii $name_id]
	set file_location [get_name_info -info file_location $name_id]

	## Now, display information about the name
	puts "Parent Name Id ($parent_name_id)"
	puts "Base Name ($base_name)"
	puts "Entity Name ($entity_name)"
	puts "Instance Name ($instance_name)"
	puts "Full Path ($full_path)"
	puts "Short Full Path ($short_full_path)"
	puts "Node Type ($node_type)"
	puts "Creator ($creator)"
	puts "Signaltapii ($signaltapii)"
	puts "File location ($file_location)"
}

# Display the members of a particular assignment group named "tg1"
foreach_in_collection member [assignment_group "tg1" -get_members] {

	# Print the name of the member
	puts $member
}

# Display the exception to a particular assignment group named "tg1"
foreach_in_collection exception [assignment_group "tg1" -get_exceptions] {

	# Print the name of the exception
	puts $exception
}
Return Value Code Name Code String Return
TCL_OK 0 INFO: Operation successful

Did you find the information on this page useful?

Characters remaining:

Feedback Message