Download Xilinx Command Line Tools User Guide
Transcript
Appendix C: Tcl Reference
This example compares the contents of two collections.
•
The first command assign a collection of instances to the collection variable colVar_1.
•
The second command assigns another collection of filtered instance names to the collection variable colVar_2.
•
The third command compares the two collections. The dollar sign ($) syntax is used to obtain the values of
the collection variables. In this case, the values of colVar_1 and colVar_2 to determine if they are equal.
Tcl Return
0 if the collections are not the same, 1 if the collections are the same.
For More Information
•
% help collection
•
% help object
•
% help search
collection foreach (iterate over elements in a collection)
This command iterates over each object in a collection through an iterator variable. The iterator variable specifies
the collection to iterate over and the body specifies the set of commands or script to apply at each iteration.
Syntax
% collection foreach iterator_variable collection_variable {body}
collection is the Tcl command name.
foreach is the subcommand name.
iterator_variable specifies the name of the iterator variable.
collection_variable specifies the name of the collection to iterate through.
body specifies a set of commands or script to execute at each iteration.
Caution! You cannot use the standard Tcl-supplied foreach command to iterate over collections. You must use
the Xilinx®-specific collection foreach command. Using the Tcl-supplied foreach command may cause the
collection to be deleted.
Example
% set colVar [search * -type instance]
% collection foreach itr $colVar {puts [object name $itr]}
This example iterates through the objects of a collection.
•
The first command assigns a collection of instances to the colVar collection variable.
•
The second line iterates through each object in the colVar collection, where itr is the name of the iterator
variable. Curly braces { } enclose the body, which is the script that executes at each iteration. Note that the
object name command is nested in the body to return the value of the iterator variable, which is an instance
in this case.
Tcl Return
An integer representing the number of times the script was executed
For More Information
•
% help collection
•
% help object
•
% help search
Command Line Tools User Guide
UG628 (v 11.4) December 2, 2009
www.xilinx.com
365