Concise Manual For The Modelsim/Questasim VHDL Simulator
Concise Manual For The Modelsim/Questasim VHDL Simulator
Concise Manual For The Modelsim/Questasim VHDL Simulator
Sabih H. Gerez University of Twente, Department of Electrical Engineering s.h.gerez@utwente.nl Version 6 (August 20, 2013)
This document provides a minimal set of instructions to work with the Questasim1 VHDL simulator produced by Model Technology. This is a powerful commercial simulator that can handle both the VHDL and Verilog hardware description languages. The manual is based on software version Release 10.1 for Linux. The information should be sufcient for the lab exercises related to the course Systemon-Chip Design.2
Contents
1 Preparations 2 Projects 3 Libraries 4 Compiling VHDL Files 5 Preparing for Simulation 6 Selecting the Signals to Be Traced
2 3 3 4 5 5
Version history: Version 1 was released in 2003, Version 2 in 2004, Version 3 in 2006, Version 4 in 2007, and Version 5 in 2011. 1 Questasim is an extended version of Modelsim. 2 For more information, see: http://wwwhome.ewi.utwente.nl/gerezsh/soc/index.html.
7 The Actual Simulation and Results Analysis 8 Gate-Level Simulations 9 Termination, Restarting and Loading New Designs 10 Printing and Editing VHDL
7 8 9 10
1 Preparations
Unless stated otherwise, the left mouse button should be used for all mouse actions. It is wise to keep all VHDL les belonging to one exercise in one directory. Go to that particular directory and type vsim in the Unix shell (command line). The graphical user interface of Questasim consists of a main Questasim window that hosts several of subwindows, called panes. A pane can be manipulated by clicking on the controls at its right: One can zoom (maximize) a pane using the plus symbol and restore its original size using the minus symbol. One can undock a pane using the symbol consisting of a square with an arrow pointing outward. This will separate the pane from the main window and make it a window of its own in the host operating system. The reverse operation of docking is also possible using a button consisting of a square and an arrow pointing inward. One can hide (remove) a pane by using the cross symbol. To restore a hidden pane, use the view menu. Suppose that you have hidden the objects pane, then: View Objects or its command-line equivalent: VSIM> view objects Questasim offers a lot of freedom to rearrange the relative positions of the panes by making it possible to drag the panes around grabbing them halfway their top bar. It is not recommended to change the initial rearrangement, though, as this makes it harder for an assistant to follow what you are doing. You can restore the default layout of panes with: Layout Reset The command prompt in the transcript pane changes from the Questasim> prompt into the VSIM> prompt when a design has been loaded for simulation indicating that a simulation can be started. c Sabih H. Gerez, University of Twente, The Netherlands
2 Projects
Questasims mechanism to keep all source les of a design together is called a project. Although you can compile and simulate outside projects, it is mandatory that you make use of the project mechanism for all exercises in the System-on-Chip Design course. The use of projects has the major advantage that Questasim keeps track of the order in which les have been compiled as well as the specic compiler options set for that le. It can recompile all source les in the right order and with the right options in case of problems (which saves quite some time compared to manual compilation). Create a project with an appropriate name using the command: File New Project . . . A window will pop up asking you to add les to the project. If you know what you are doing, you can proceed to add les. Otherwise, you can close this window and add the les later on (see Section 4). In future sessions, if your project is not yet open at start up, open it using (projects are stored in a text le with extension mpf on the le system): File Open . . . or: File Recent Projects . . . To recompile all les, use: Compile Compile All If necessary, you can change the compilation order by: Compile Compile Order You have the option of asking Questasim to nd out the compile order by pushing Auto Generate . Beware: the order generated by Questasim may not be correct, even when it reports that automatic ordering was successful.
3 Libraries
VHDL stores all compiled code in a library. Unless you explicitly require the use of another library, your les will be compiled into the library work. Questasim creates this library automatically when c Sabih H. Gerez, University of Twente, The Netherlands
you create a project (see Section 2). You can verify this by opening the library pane. It lists all libraries that are available. You will not need to create new libraries for the exercises. If it is necessary for some unforseen reason, use: File New Library . . . In the window that pops up, you can type a library name: work or any other name that is appropriate. The library name and the directory name in the le system to which it is mapped, are kept equal by default. Do not change this. You are now ready for compiling VHDL les, also in future invocations of Questasim. You should not create new libraries unless you are explicitly asked to do so. Note: during exercises you will also make use of other libraries, such as ieee. They are located in system directories to be accessed by all users. The global Questasim conguration should allow you to access them without problems.
Compile Compile Report . . . to see what went wrong (the command is also available through the right mouse button). In VHDL, it is important to compile (and recompile) les in the right order. Files containing denitions should be compiled before les that make use of these denitions. Respect this order when adding les to your project or correct this order (see also Section 2). Warning messages of the type No default binding . . . issued by the compiler can often be ignored. They are related to the fact that the compiler has more than a single choice for an architecture or conguration of an entity. The reason that it can be ignored is that a conguration declaration to be compiled at a later moment species the choice to be made.
of your design. A design unit is simply selected by clicking on it. Parts of the hierarchy can be hidden or displayed by clicking on the little squares containing a - or a + respectively. All signals of the selected design unit are listed in the Objects window. Using the Show command under the right mouse button, one can hide/unhide inputs, outputs, internal signals, etc. A single signal is selected by clicking on it in the Objects window. A range of signals is selected by selecting the rst and then pressing the Shift button on the keyboard in combination with the left mouse button after positioning the cursor on the last signal in the range. Adding signals to a given selection can be done using the Ctrl button on the keyboard while clicking with the left mouse button. Individual components of composite signals (e.g. of type array) can be displayed by clicking on the little squares at the left of the signal name. This allows e.g. the selection of individual parts for display in the Wave window. Selected signals are transferred to the Wave window with the command: Add: To Wave Selected signals If you are sure that you want to trace all signals of the currently selected design unit, use: Add: To Wave Wave Signals in region In the SoC Design course, you are supposed to be critical on which signals to display. Simply displaying all signals may affect your mark. An alternative way of transferring selected signals to the Wave window is to use drag & drop. Select rst the signals as described above and put the mouse cursor in the Objects window. Then click on the left mouse button and drag the selected objects to the Wave window without releasing the button. Release the button when the cursor has arrived at the desired location. This drag & drop mechanism also works within Wave itself e.g. to reorder the signals. Once all signals to be traced have been notied to the Wave window, the actual simulation can start. You may, however, want to modify the display properties of the signals. If you want e.g. to display a binary vector as a decimal number, you should rst select the signal in the Wave window and then execute: Wave Format Radix Decimal The radix can also be chosen via the right mouse button. In most cases, you will not need to modify the default radix of a signal. Sometimes, it is interesting to display a sequence of digital values as a continuous waveform. The easiest way to achieve this is by issuing the command: Wave Format Format Analog (automatic)
Signal names will be displayed with their full instantiation path. To reduce the length displayed execute: c Sabih H. Gerez, University of Twente, The Netherlands
Tools Window Preferences in the undocked Wave pane or Wave Wave Preferences in the docked Wave pane. Fill a small integer number unequal to zero in the eld Display signal path.
Add To Wave Cursor in the docked Wave pane or Add Cursor in the undocked Wave pane. When multiple time cursors are present, the time difference between each pair of cursors will automatically be displayed in the Wave window. Together with the possibility to snap on signal transitions, this gives the possibility of accurate timing measurements. Once you have selected a suitable range in which a specic behavior becomes visible, you might want to have a hardcopy of the waveforms or save the waveforms in a graphic le format. Use: File Print PostScript . . . for this purpose. In the window that pops up, you can set some properties of the page, especially which signals to plot and the time range. Click on Setup to display a Page Setup window in which you can congure the layout of the page to be printed. Pay special attention to choosing A4 paper size and a Scaling that ts to 1 page. Close the windows by clicking on Ok . You can convert PostScript to PDF with Linux command ps2pdf -sPAPERSIZE=a4. You can view PDF documents with the program okular.
8 Gate-Level Simulations
The procedure for performing a gate-level simulation, starts in the same way as described in Section 5. However, after selecting a conguration, one should specify the SDF le to be used. SDF stands for Standard Delay Format, a standardized text-le format that species delays in interconnections and gates. An SDF le can be generated by the Synopsys Design Compiler (this is the case for your exercises). In practice, more accurate delay data are available after layout design with placement and routing and an SDF le is generated by the layout tools. In order to link one or more SDF les to your design, select the SDF tab in the the multitab window that pops up after: Simulate Start Simulation . . . You should, of course, select rst the conguration to be simulated in the Design tab. Click on Add in the SDF tab. A new window pops up. Type the name of the SDF le to be used or select it by browsing. Note that the SDF le contains information on a synthesized block of hardware. The simulation model normally instantiates this block in a larger context, e.g. as a subblock of a testbench. In the second line indicated by Apply to region, you need to indicate the part of the design for which the SDF is meant. This is indicated by a directory style path. The path / is the root or top-level design. Subdesigns are selected by the instance names as used in VHDL structural descriptions (in the siso gen example, c Sabih H. Gerez, University of Twente, The Netherlands
the hardware has instance name duv and is part of the testbench instance tg; therefore the path to be used for SDF is /tg/duv). Once the conguration and SDF has been correctly specied click on OK twice. The Transcript pane should state SDF Backannotation Successfully Completed. From here on, the simulation can be carried out using the same approach as already described above.
10
10
In the environment set up for the System-on-Chip Design course, you can use the command vhd2pdf to generate PDF les of VHDL source les. At the Linux shell prompt you type vhd2pdf followed by one or more le names with extension .vhd located in the current directory. In order to use the built-in editor of Questasim, select the VHDL le to be edited in the Project tab and use the Edit option of the pop-up menu that is invoked by the right mouse button. It has the advantage of highlighting VHDL keywords. You can select a different font type or size with: Tools Edit Preferences Source Windows The public domain editor vim and its GUI variant gvim with syntax highlighting are suitable alternatives if you are familiar with the editors.