24.03.2013 Views

ModelSim SE User's Manual - Electrical and Computer Engineering

ModelSim SE User's Manual - Electrical and Computer Engineering

ModelSim SE User's Manual - Electrical and Computer Engineering

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

set comm<strong>and</strong> syntax<br />

Tcl comm<strong>and</strong> syntax UM-477<br />

The Tcl set comm<strong>and</strong> reads <strong>and</strong> writes variables. Note that in the syntax below the "?"<br />

indicates an optional argument.<br />

Syntax<br />

set varName ?value?<br />

Description<br />

Comm<strong>and</strong> substitution<br />

Returns the value of variable varName. If value is specified, then sets the value of varName<br />

to value, creating a new variable if one doesn't already exist, <strong>and</strong> returns its value. If<br />

varName contains an open parenthesis <strong>and</strong> ends with a close parenthesis, then it refers to<br />

an array element: the characters before the first open parenthesis are the name of the array,<br />

<strong>and</strong> the characters between the parentheses are the index within the array. Otherwise<br />

varName refers to a scalar variable. Normally, varName is unqualified (does not include<br />

the names of any containing namespaces), <strong>and</strong> the variable of that name in the current<br />

namespace is read or written. If varName includes namespace qualifiers (in the array name<br />

if it refers to an array element), the variable in the specified namespace is read or written.<br />

If no procedure is active, then varName refers to a namespace variable (global variable if<br />

the current namespace is the global namespace). If a procedure is active, then varName<br />

refers to a parameter or local variable of the procedure unless the global comm<strong>and</strong> was<br />

invoked to declare varName to be global, or unless a Tcl variable comm<strong>and</strong> was invoked<br />

to declare varName to be a namespace variable.<br />

Placing a comm<strong>and</strong> in square brackets [ ] will cause that comm<strong>and</strong> to be evaluated first <strong>and</strong><br />

its results returned in place of the comm<strong>and</strong>. An example is:<br />

set a 25<br />

set b 11<br />

set c 3<br />

echo "the result is [expr ($a + $b)/$c]"<br />

will output:<br />

"the result is 12"<br />

This feature allows VHDL variables <strong>and</strong> signals, <strong>and</strong> Verilog nets <strong>and</strong> registers to be<br />

accessed using:<br />

[examine - name]<br />

The %name substitution is no longer supported. Everywhere %name could be used, you<br />

now can use [examine -value - name] which allows the flexibility of specifying<br />

comm<strong>and</strong> options. The radix specification is optional.<br />

<strong>ModelSim</strong> <strong>SE</strong> User’s <strong>Manual</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!