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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

UM-542 B - <strong>ModelSim</strong> variables<br />

Simulator state variables<br />

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

Unlike other variables that must be explicitly set, simulator state variables return a value<br />

relative to the current simulation. Simulator state variables can be useful in comm<strong>and</strong>s,<br />

especially when used within <strong>ModelSim</strong> DO files (macros). The variables are referenced in<br />

comm<strong>and</strong>s by prefixing the name with a dollar sign ($).<br />

Variable Result<br />

argc returns the total number of parameters passed to the current macro<br />

architecture returns the name of the top-level architecture currently being<br />

simulated; for an optimized Verilog module, returns architecture<br />

name; for a configuration or non-optimized Verilog module, this<br />

variable returns an empty string<br />

configuration returns the name of the top-level configuration currently being<br />

simulated; returns an empty string if no configuration<br />

delta returns the number of the current simulator iteration<br />

entity returns the name of the top-level VHDL entity or Verilog module<br />

currently being simulated<br />

library returns the library name for the current region<br />

MacroNestingLevel returns the current depth of macro call nesting<br />

n represents a macro parameter, where n can be an integer in the range<br />

1-9<br />

Now always returns the current simulation time with time units (e.g.,<br />

110,000 ns) Note: will return a comma between thous<strong>and</strong>s<br />

now when time resolution is a unary unit (i.e., 1ns, 1ps, 1fs): returns the<br />

current simulation time without time units (e.g., 100000)<br />

when time resolution is a multiple of the unary unit (i.e., 10ns,<br />

100ps, 10fs): returns the current simulation time with time units<br />

(e.g. 110000 ns) Note: will not return comma between thous<strong>and</strong>s<br />

resolution returns the current simulation time resolution<br />

Referencing simulator state variables<br />

Variable values may be referenced in simulator comm<strong>and</strong>s by preceding the variable name<br />

with a dollar sign ($). For example, to use the now <strong>and</strong> resolution variables in an echo<br />

comm<strong>and</strong> type:<br />

echo "The time is $now $resolution."<br />

Depending on the current simulator state, this comm<strong>and</strong> could result in:<br />

The time is 12390 ps 10ps.<br />

If you do not want the dollar sign to denote a simulator variable, precede it with a "\". For<br />

example, \$now will not be interpreted as the current simulator time.

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

Saved successfully!

Ooh no, something went wrong!