Technical data

Tcl/Tk and ModelSim
ModelSim EE Tutorial ModelSim EE Lessons
-
127
You can remove the comments in the code to make this change.
Similarly, add the North/South widget for controlling the length of the lights. The
East/West widget for light control is provided. (You can remove the comments in
the code to make this change as well.)
These control widgets are implemented using the Tk "scale" widgets, enclosed in
a frame.
When the value of the scale widget changes, it calls the command specified with
the
-command
option on each scale.
11
After you have added your North/South widgets, run your program with this
command:
source controls.tcl
draw_controls
Now you have a complete intersection interface. Try the run buttons and the slider
scales. You can also view the simulation with Model
Sim
’s GUI. Check the Source
window to view the VHDL files, and add signals to a Wave window
(
add wave *
). You can also change the run length in the Main window. Try using
the Run buttons in the Main window and the intersection window.
Keep the intersection simulation running to complete the next example. If you
want to recreate the final intersection environment quickly, invoke these
commands from the ModelSim prompt (after "Preparing for the Tcl/Tk examples"
(p121)).
cd solutions
do traffic.do
Example 4 - draw a state machine that represents the simulation
In this final example you will draw a state machine representing the simulation,
and connect it to the state signal inside the traffic light controller. Each transition
that the controller makes is displayed as it happens.
The intersection environment from the previous example needs to be running for
this example. To get it running quickly, invoke these commands from the
Model
Sim
prompt (after "Preparing for the Tcl/Tk examples" (p121)).
cd solutions
do traffic.do
1
Run the state machine with these commands:
source state-machine.tcl
draw_state_machine