Technical data
Tcl/Tk and ModelSim
116
-
ModelSim EE Lessons ModelSim EE Tutorial
How Tcl/Tk works with Model
Sim
Model
Sim
incorporates Tcl as an embedded library package. The Tcl library
consists of a parser for the Tcl language, routines to implement the Tcl built-in
commands, and procedures that allow Tcl to be extended with additional
commands specific to Model
Sim
.
Model
Sim
generates Tcl commands and passes them to the Tcl parser for
execution. Commands may be generated by reading characters from an input
source, or by associating command strings with Model
Sim
’s user interface
features, such as menu entries, buttons, or keystrokes.
When the Tcl library receives commands it parses them into component fields and
executes built-in commands directly. For commands implemented by Model
Sim
,
Tcl calls back to the application to execute the commands. In many cases
commands will invoke recursive invocations of the Tcl interpreter by passing in
additional strings to execute (procedures, looping commands, and conditional
commands all work in this way).
Model
Sim
gains a programming advantage by using Tcl for its command
language. Model
Sim
can focus on simulation-specific commands, while Tcl
provides many utility commands, graphic interface features, and a general
programming interface for building up complex command procedures.
By using Tcl, Model
Sim
need not re-implement these features, a benefit that
allows it’s graphic interface to remain consistent on all platforms. (The only
vestige of the host platform’s graphic interface is the window frame manager.)