User`s manual
10-248 Tcl and ModelSim ModelSim Xilinx User’s Manual
Tcl relational expression evaluation
When you are comparing values, the following hints may be useful:
• Tcl stores all values as strings, and will convert certain strings to numeric values
when appropriate. If you want a literal to be treated as a numeric value, don't
quote it.
if {[exa var_1] == 345}...
The following will also work:
if {[exa var_1] == "345"}...
• However, if a literal cannot be represented as a number, you must quote it, or
Tcl will give you an error. For instance:
if {[exa var_2] == 001Z}...
will give an error.
if {[exa var_2] == "001Z"}...
will work okay.
• Don't quote single characters in single quotes:
if {[exa var_3] == ’X’}...
will give an error
if {[exa var_3] == "X"}...
will work okay.
• For the equal operator, you must use the C operator "==" . For not-equal, you
must use the C operator "!=".
Variable substitution
When a $<var_name> is encountered, the Tcl parser will look for variables that
have been defined either by VSIM or by you, and substitute the value of the
variable.
Note: Tcl is case sensitive for variable names.
To access environment variables, use the construct:
$env(<var_name>)
echo My user name is $env(USER)