Technical data
Tcl/Tk and ModelSim
6-56 ModelSim EE/SE Tutorial
The update is accomplished by using a when statement.
9 After you have added your North/South widget, run your program by invoking this
command:
source queues.tcl
draw_queues
According to the traffic indicators, the cars are leaving the intersection at the same
rate. That seems fair, but if you are designing an intersection that responds to the
traffic flow into the intersection you might want to change the light cycles.
Perhaps one of the directions has more incoming traffic than the other.
Adding controls, in the form of scale widgets, allows you to quickly change the
assumptions about traffic flow into the intersection.
Add "scale" widgets to control the simulation
Next you will add Tk "scale" widgets that will control the arrival rates and the
length of the lights.
10 The East/West widget for controlling the East/West queue inter-arrival time is
provided. You'll edit the source code to add controls for the North/South direction. Use
this command:
notepad controls.tcl
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 ModelSim’s GUI. Check the Source
window to view the VHDL files, and add signals to a Wave window