Modelsim Tutorial
Modelsim Tutorial
There are two modes in which to compile designs in QuestaSim / ModelSim, classic/traditional
mode and project mode. This guide will give you a short tutorial in using classic/traditional
mode. From the perspective of this class, ModelSim's GUI is a subset of QuestaSim's.
Menu
Buttons
Other
Windows
Command /
Library Window Transcript Window
Copyright © 1999 - 2013 by SynthWorks Design Inc. All rights reserved Rev 1306 QuestaSim - 1
Using ModelSim
Note if a simulation is active, you cannot run change directory. First you must end the simulation
with the QuestaSim menu pull down "Simulate > End Simulation".
Before compiling your design, you must create the work library. Use the QuestaSim menu
command "File > New > Library" to create the work library. The library pop-up window should
look like the following when you are done.
Copyright © 1999 - 2013 by SynthWorks Design Inc. All rights reserved Rev 1306 QuestaSim - 2
Using ModelSim
After compiling your design successfully (check transcript window for error messages), close the
pop-up dialog box by pressing "Done".
The key to understanding error messages is to realize that the message is produced after the
compiler gets lost. In the example below (note this is not your lab design), the entity Adder8 has
a ‘;’ after the last port declaration. Most often this means that the error message will be
generated on line 43. This is common, so make sure when you get an error message to read the
specific error message and realize the root cause may be something done on the previous line that
causes the compiler to "detect" the error on the current line.
39 -- Not the lab design
39 entity Adder8 is
40 port (
41 A, B : In std_logic_vector(7 downto 0);
42 Y : Out std_logic_vector(7 downto 0); -- error
43 );
44 end Adder8 ;
Also note that when you get an error message, you can double click on it and the QuestaSim
editor will take you to the line in error.
Copyright © 1999 - 2013 by SynthWorks Design Inc. All rights reserved Rev 1306 QuestaSim - 3
Using ModelSim
When the simulation loads, the simulation window will overlay the library window as shown
below. You can switch back and forth between the two windows using the "sim" and "library"
tabs. Close the Objects and Process windows by pressing on the "X" in the right corner.
Press X
to close
Sim and
library
Tabs
Copyright © 1999 - 2013 by SynthWorks Design Inc. All rights reserved Rev 1306 QuestaSim - 4
Using ModelSim
Design Under Test Specify default run length here Press here to undock wave window
Alternately, bring up a wave window by selecting "View > Wave" in the QuestaSim menu.
Select a design (such as U_Inc) in the "sim" tab of the QuestaSim workspace and click and drag
the design to the wave window.
Note that it is quite normal to see warning messages at the start of the simulation. Most
messages that occur before a design is initialized and/or reset can be ignored. For example, the
following warning results from the A input being initialized to "UUUUUUUU" at time 0:
Note that if you forgot to display your waveforms before running the simulation or find a bug
during simulation, you will need to re-run the simulation. See the next section for details.
Copyright © 1999 - 2013 by SynthWorks Design Inc. All rights reserved Rev 1306 QuestaSim - 5
Using ModelSim
To re-run a simulation, instead of starting a simulation, use the restart command. Restarting a
simulation sets the time to 0, reloads any recompiled designs, and maintains the current context
(such as signals in the wave window). Restart a simulation by using QuestaSim menu item
"Simulate > Restart". This will cause the following pop-up to appear. Press the Restart button.
At this point you can set breakpoints, display additional signals, and run the simulation (using the
Run command described previously).
Copyright © 1999 - 2013 by SynthWorks Design Inc. All rights reserved Rev 1306 QuestaSim - 6
Using ModelSim
2.7.2 Zooming
When in the wave portion of the waveform window, pressing the right mouse button allows
the following zoom options: In 2x, Out 2x, Full, Last, and Range. In addition, zooming to
an area can be done by clicking the middle mouse button and then dragging in a horizontal
direction.
2.7.3 Radix
The radix of the selected signal (or signals) can be specified using one of the following
waveform menu commands.
Format > Radix > Hexadecimal
Format > Radix > Unsigned (decimal, unsigned value)
Format > Radix > Decimal (signed, 2's complement value)
Alternately you can access a similar menu with the right mouse button when selecting the
signal(s).
Copyright © 1999 - 2013 by SynthWorks Design Inc. All rights reserved Rev 1306 QuestaSim - 7
Using ModelSim
To accurately place a cursor, use the find next change symbols (shown below) to move the
active cursor to the next change of the selected signal. Alternately dragging a cursor over
an edge of the selected signal will cause the cursor to try to snap to the edge.
Copyright © 1999 - 2013 by SynthWorks Design Inc. All rights reserved Rev 1306 QuestaSim - 8
Using ModelSim
Note that if the next lab is in a different directory that you need to end the simulation with the
QuestaSim menu command "Simulate > End Simulation", before you can use the
change directory menu command "File > Change Directory".
Copyright © 1999 - 2013 by SynthWorks Design Inc. All rights reserved Rev 1306 QuestaSim - 9
Using ModelSim
Simulation Resolution
Note this is not the default run length.
Chipper
Exit out of the simulator. In the directory vhdl_src, keep all of your VHDL (*.vhd) files and
delete the rest. Delete the subdirectory work.
Start the simulator. Use "File > Change Directory" to go to the directory
VhdlIntro/Chipper/sim_mti. Execute the script (for Lab6 it is: TbLedFlasher_lab6.tcl) using
"Tools > TCL > Execute Macro …".
Copyright © 1999 - 2013 by SynthWorks Design Inc. All rights reserved Rev 1306 QuestaSim - 10