Technical data
Tcl/Tk and ModelSim
ModelSim EE/SE Tutorial   6-47
The custom-traffic-light interface
The subject of our main Tcl/Tk lesson is a simple traffic-light controller. The 
system is comprised of three primary components: a state machine, a pair of traffic 
lights, and a pair of traffic sensors. The components are described in three VHDL 
files: traffic.vhd (the state machine), queue.vhd (the traffic arrival queue) and 
tb_traffic.vhd (the testbench).
You could, of course, simulate this system with ModelSim’s familiar interface, but 
Tcl/Tk provides us the option to try something different. Since we’re simulating 
something most of us have seen and experienced before, we can create an intuitive 
interface unique to the simulation. 
Assumptions
The example assumes that source files were previously compiled. Here’s how it 
works:
VHDL source files 
describe the system 
Tcl procedures create and 
connect the interface, plus the 
source files, to ModelSim 
ModelSim commands are run 
via the new interface using the 
Tcl procedures 
draw_intersection
traffic.vhd
queue.vhd
tb_traffic.vhd
connect_lights vsim -lib vhdl/work tb_traffic
examine -value <light_timing>
draw_queues
draw_controls force -freeze $var $val ns










