User`s manual
10-246 Tcl and ModelSim ModelSim Xilinx User’s Manual
set command syntax
The Tcl set reads and writes variables. Note that in the syntax below the "?"
indicates an optional argument.
Syntax
set varName ?value?
Description
Returns the value of variable varName. If value is specified, then set the value of
varName to value, creating a new variable if one doesn’t already exist, and return
its value. If varName contains an open parenthesis and ends with a close
parenthesis, then it refers to an array element: the characters before the first open
parenthesis are the name of the array, and the characters between the parentheses
are the index within the array. Otherwise varName refers to a scalar variable.
Normally, varName is unqualified (does not include the names of any containing
namespaces), and the variable of that name in the current namespace is read or
written. If varName includes namespace qualifiers (in the array name if it refers
to an array element), the variable in the specified namespace is read or written.
If no procedure is active, then varName refers to a namespace variable (global
variable if the current namespace is the global namespace). If a procedure is
active, then varName refers to a parameter or local variable of the procedure
unless the global command was invoked to declare varName to be global, or
unless a Tcl variable command was invoked to declare varName to be a
namespace variable.
More Tcl commands
All Tcl commands are documented from within ModelSim. Select Help > Tcl
Help from the Main window menus.
Command substitution
Placing a command in square brackets [ ] will cause that command to be evaluated
first and its results returned in place of the command. An example is:
set a 25
set b 11
set c 3
echo "the result is [expr ($a + $b)/$c]"
will output:
"the result is 12"