Technical data
Tcl/Tk and ModelSim
ModelSim EE Tutorial ModelSim EE Lessons
-
125
For our example, the desired condition is the state of the lights. Whenever the state
of the light in the simulation changes, we want to change the color of the light on
the screen.
4
Load the VHDL libraries you compiled in preparation for these examples using this
command at the Model
Sim
prompt:
vsim tb_traffic
Be sure you invoke this command before the start of the connect_lights
procedure, if you don't load the libraries, you won't have a design to simulate.
5
Connect the lights to the simulation with this command and procedure:
source lights.tcl
connect_lights
Try running the simulation now; select either run button on the intersection (select
Break
if you used the
Run Forever
button - notice how the Source window opens
and indicates the next line to be executed). Only the East/West lights are working.
You can make both lights work by editing the
lights.tcl
file.
6
Edit
lights.tcl
with the
notepad
to add a
when
statement for the North/South light.
notepad lights.tcl
You need to add this because the current statement is for the East/West light only.
You’ll find the solution commented. (Remember to change the read-only status of
the file so you can edit it.)
You’ll find the code commented-out toward the end of the file (try Edit >Find
again).
7
After you have made the changes, reload and run the simulation again.
source lights.tcl
connect_lights
Both lights are now working.
Note:
Remember, if you need to return to the original Tcl files (maybe you’ve edited the file and it doesn’t
work right) you’ll find the files in the
tcl_tutorial/originals
directory.