Technical data

Tcl/Tk and ModelSim
ModelSim EE/SE Tutorial 6-57
(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"
(p51)).
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
ModelSim prompt (after "Preparing for the Tcl/Tk examples" (p51)).
cd solutions
do traffic.do
1 Run the state machine with these commands:
source state-machine.tcl
draw_state_machine
Let’s make some changes to the light colors and transition arrows.
2 Open the source file with this command:
notepad state-machine.tcl
Note the "ModelSim EXAMPLE part 1" comments in the file. You can change
"both_red" state coordinates from x = 125 and y = 50 to any coordinates. (You
may need to uncheck the read only selection in the Edit menu before making
changes.)
3 Note the "ModelSim EXAMPLE part 2" comments in the file. You can change the
transition arrow coordinates to correspond with the new "both_red" state coordinates.
4 Note the "ModelSim EXAMPLE part 3" comments in the file. Change the active color
from "black" to "purple".