Technical data

Tcl/Tk and ModelSim
126
-
ModelSim EE Lessons ModelSim EE Tutorial
Add widgets to display simulation information
Running the lights may be interesting, but not very useful - let’s add some displays
that will tell us what’s happening to the cars at the intersection.
Now you will add queue widgets to display the sum of the length of each pair of
queues as we simulate.
8
The East/West widget for displaying the total East/West queue length is already
provided. Let's edit the source to add a display for the North/South direction. Use the
notepad
:
notepad queues.tcl
The solution is commented out in
queues.tcl
.
The Queue Display widget consists of an enclosing frame with two label widgets.
The first label is a simple text string. The second label is the value of the queue
length. The text in the second label will be updated whenever the queue lengths
change.
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