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-480 20 - Tcl <strong>and</strong> macros (DO files)<br />

List processing<br />

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

In Tcl a "list" is a set of strings in curly braces separated by spaces. Several Tcl comm<strong>and</strong>s<br />

are available for creating lists, indexing into lists, appending to lists, getting the length of<br />

lists <strong>and</strong> shifting lists. These comm<strong>and</strong>s are:<br />

Comm<strong>and</strong> syntax Description<br />

lappend var_name val1 val2 ... appends val1, val2, etc. to list var_name<br />

lindex list_name index returns the index-th element of list_name; the first element is 0<br />

linsert list_name index val1 val2 ... inserts val1, val2, etc. just before the index-th element of list_name<br />

list val1, val2 ... returns a Tcl list consisting of val1, val2, etc.<br />

llength list_name returns the number of elements in list_name<br />

lrange list_name first last returns a sublist of list_name, from index first to index last; first or<br />

last may be "end", which refers to the last element in the list<br />

lreplace list_name first last val1, val2, ... replaces elements first through last with val1, val2, etc.<br />

Two other comm<strong>and</strong>s, lsearch <strong>and</strong> lsort, are also available for list manipulation. See the<br />

Tcl man pages (Help > Tcl Man Pages) for more information on these comm<strong>and</strong>s.<br />

See also the <strong>ModelSim</strong> Tcl comm<strong>and</strong>: lecho (CR-188)<br />

<strong>ModelSim</strong> Tcl comm<strong>and</strong>s<br />

These additional comm<strong>and</strong>s enhance the interface between Tcl <strong>and</strong> <strong>ModelSim</strong>. Only brief<br />

descriptions are provided here; for more information <strong>and</strong> comm<strong>and</strong> syntax see the<br />

<strong>ModelSim</strong> Comm<strong>and</strong> Reference.<br />

Comm<strong>and</strong> Description<br />

alias (CR-62) creates a new Tcl procedure that evaluates the specified comm<strong>and</strong>s;<br />

used to create a user-defined alias<br />

find (CR-176) locates incrTcl classes <strong>and</strong> objects<br />

lecho (CR-188) takes one or more Tcl lists as arguments <strong>and</strong> pretty-prints them to the<br />

Transcript pane<br />

lshift (CR-193) takes a Tcl list as argument <strong>and</strong> shifts it in-place one place to the left,<br />

eliminating the 0th element<br />

lsublist (CR-194) returns a sublist of the specified Tcl list that matches the specified<br />

Tcl glob pattern<br />

printenv (CR-224) echoes to the Transcript pane the current names <strong>and</strong> values of all<br />

environment variables

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

Saved successfully!

Ooh no, something went wrong!