




















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A graduate project presentation about using tcl/tk with modelsim to create powerful visualization and debugging interfaces for microelectronic systems. The presentation covers the reasons for using tcl, an introduction to modelsim and tcl/tk, and the creation of a custom visualization tool for a device or a board. The project includes a tutorial on simulating an altera up-2 demo board and creating an animation of a traffic signal controller.
Typology: Study Guides, Projects, Research
1 / 28
This page cannot be seen from the preview
Don't miss anything!





















Microelectronic Systems--University of Tennessee (^11)
Prepared by Narayanan Raghuraman
Department of Electrical Engineering University of Tennessee - Knoxville
Microelectronic Systems--University of Tennessee (^22)
Definitions
Why TCL?
TCL is a scripting language hence it is at a higher level of programming. This implies that this is easier to program than languages like C or C++.
TCL can be used to send commands to interactive programs such as simulators and debuggers.
TCL is easy to learn and applications can be implemented very fast
TCL is platform independent and is programmable
Programmability ensures that new commands can be added to TCL. This feature is of immense use in simulators where customized commands can simplify complex problems.
Microelectronic Systems--University of Tennessee (^44)
There are three problem areas for extending ModelSim with TCL to create a custom visualization tool for a device or a board.
Suppose you are simulating a device that will drive a small full-graphic display panel, for instance on a mobile phone. Using Tcl/Tk you can create a window displaying the panel's appearance, allowing you to visualise the simulation results directly instead of having to interpret the display controller's output signals.
When creating this kind of extension to ModelSim there are three distinct problem areas.
•A Tcl/Tk program must be written to create the display, based on the simulator's output data. Tcl/Tk's canvas widget is so powerful and easy to use that this task is usually quite straightforward.
•The Tcl/Tk display generator must be provided with the necessary signal data, extracted from the simulation results. ModelSim's "examine" command makes it very easy to get hold of the required data, but...
•The whole extension must be hooked into the ModelSim GUI environment so that it behaves in an intuitive and convenient way. This means, for example, making the display generator update correctly in response to changes in the position of a cursor in ModelSim's wave window. It's also necessary to add appropriate menu items or toolbar buttons so that the new functionality is readily accessible from the familiar ModelSim GUI.
Microelectronic Systems--University of Tennessee (^55)
These four commands are the basic requirements in using TCL to animate and debug VHDL designs using ModelSim. The same can be done with Verilog designs too.
In the example provided, the syntax is described as follows.
Force (signal_name) value1 time1, value2 time2 –rep period
The signal indicated in signal_name is varied between value1 and value2. The period of change is specified after ‘-rep’. At ‘time1’ seconds inside the period, the signal is at value1. At ‘time2’, the signal’s value is changed to ‘value2’.
Microelectronic Systems--University of Tennessee (^77)
In the ECE 551 course, the Altera UP-2 Demo board is used to introduce the students to the world of FPGA’s. The Altera Demo Board has some user interface features which are
These features are used to simulate the operation of the board. The seven segment displays are simulated by utilizing seven different ‘line’ objects. Each such ‘line’ object is connected to one bit of the output signal. The color of the line object is changed when the corresponding bit changes between ‘1’ and ‘0’.
The dip switches are also used to provide input to the VHDL testbench. Each switch is simulated a checkbox. A function bound to the checkbox is executed every time it changes state. If it is pressed it provides a value of ‘1’ to the corresponding test bench input.
The two push buttons are named ‘Start’ and ‘Reset’ for convenience.
Microelectronic Systems--University of Tennessee (^88)
Before I go on to detail the states of the simulator, I shall explain the TCL/TK Interface a bit.
In TCL/TK, the root window is specified as ‘.’. All subcomponents of the root window are called widgets.
The canvas is the area of the window where sub-widgets are placed and it can contain signal lights, cars, buttons, radio buttons, check boxes, labels and the slide controls. The canvas normally encompasses the whole window. The above mentioned components including the canvas are TCL/TK widgets.
This slide depicts the Simulator in it’s counting up state.
Two of the eight dip switches are utilized in this design.
The dip switch ‘dip1’ signifies this state. The dip switch ‘dip2’ sets the ‘enable’ input of the testbench.
The ‘Start’ button is pressed to initialize the simulation. The ‘start’ button is bound with a function
Microelectronic Systems--University of Tennessee (^1010)
In this slide, the dip switch ‘dip2’ is in its depressed state. Hence the input to the ‘enable’ signal in the testbench is set to ‘0’. Hence the Counter stops counting and the value of the lower byte remains at ‘C’ as shown in the simulation interface as well as the waveform window.
Microelectronic Systems--University of Tennessee (^1111)
**1. Open the file ‘altera.tcl’.
This page details the steps to be taken to add a button named ‘Reset’ and a custom seven segment display widget name ‘display_l’.
The complete tcl design has been done in a single file named ‘altera.tcl’. This file contains several functional procedures which are used to handle individual functions such as updating seven segment display, sending changes in the checkboxes or buttons to the inputs of the VHDL design and so on.
More details about the changes made are provided in the next slide.
Microelectronic Systems--University of Tennessee (^1313)
In this slide, it can be seen that the new seven segment display and the new ‘Reset’ button have been added. The switches dip1 and dip2 are in the pressed state, Hence the counter proceeds in the upward counting state.
Microelectronic Systems--University of Tennessee (^1414)
This waveform shows the waveform for the up-counting state. It can be seen that the output value keeps increasing for every second that passes in the simulation. The value of the counting interval is specified in a function procedure called ‘run_clock’. It is from this procedure that the procedure ‘update_display’ which handles the updating of the displays gets called.
Microelectronic Systems--University of Tennessee (^1616)
Microelectronic Systems--University of Tennessee (^1717)
Inputs to the VHDL Design
Outputs from the VHDL Design
- East – West , North – South and Turn signals
The various input and output signals used in the VHDL Design are shown in this slide. The North – South car sensor and the Turn car sensors are set when a car comes to rest in a particular section of the respective roads.
Immediately after the cars come to rest, a waiting time counter is set into action. This counter is provided as an input to the VHDL design and is useful in determining which of NS and Turn sensors were activated first. Based on this the state machine changes from EW green to NS or Turn states.
The inputs to the Green, Yellow and Red state times are initialized to a default value. They can also be set using ‘scale’ widgets which are described later.
The outputs from the VHDL design are used to set the various signals in their green, yellow or red states.
Microelectronic Systems--University of Tennessee (^1919)
VHDL Files
TCL Files
These are the various files that have been created for the Simulator/Animator design.
The traffic_new.vhd file has the state-machine design and the assigning of the signals to the output ports according to the different states.
The testbench file provides the mapping to the VHDL file. ModelSim provides an interface wherein the various signals and variables in the loaded design are accessible to TCL scripts sourced in the ModelSim command line.
The TCL files have been programmed as functions.
The functions for building the intersection and the lights(build_intersection in Intersection.tcl) and the controls(light_controls controls.tcl) are executed on startup. The lights are connected to the simulation design by using when statements which are executed by the function connect_lights(lights.tcl).
The file cars.tcl controls the movement of the cars. It has several flags each of which are set inside loops initialized by ‘when’ statements.
Recursive loops are used to move the cars.
An important point to note here is that the ‘when’ statements should not be used inside the functions because they are very slow and return only when the signals in the testbench change state. If they are used inside recursive loops, it will make the simulation very slow.
Microelectronic Systems--University of Tennessee (^2020)
‘when’ when {/light_ew} { set flag1 [examine light_ew] } ‘move’ $root move $ta [expr -$pos_curr1] 0 ‘after’ after $tim movecar_ew $root $ta $tim $constr $flag ‘create’ $root create line $x1 $y1 $x2 $y2 -fill $color -tag $tag -width 60 ‘delete’ $root delete line -tags $ta
These are some of the important commands used in this simulation.
Some other commands are ‘configure’ which can be used to change the attributes of a created widget and ‘catch’ which can be used to check if a particular widget is available or not.