Mentor Graphics ModelSim EE (Version 5.2e)

New Auburn Users

On a SUN workstation, run the user-setup program, select the eda (electronic design automation) menu, and then click on the Mentor entry to select it. Then log out and log back in for this to become effective, setting up the paths and environment variables needed to run the various digital, analog, MCM, circuit board, and IC design tools from Mentor Graphics.

Preparing VHDL/Verilog Models for Simulation

The Project Directory
Create a working project directory, into which you will place your VHDL and Verilog source files and simulation command files.


Your Personal Design Library
The VHDL and Verilog compilers place all compiled files and related data into a special design library directory, named "work", which should be located within your project directory. The ModelSim EE simulator will automatically retrieve all models from this directory.


Creating VHDL models:
Use a text editor to create your VHDL models and place them in your working project directory. For each VHDL design unit, put its entity and architecture in a single file and use the entity name as the file name, with extension ".vhd".


Compiling VHDL models:
Compile each VHDL design unit with the vcom command in one of the following ways:

The second format displays a source line with each error message, while the first displays error messages only. The compiled model is automatically placed in your working library.

NOTE: A "make file" can be generated for your working library with the command: vmake. Executing this make file causes all out-of-date VHDL files in your library to be recompiled.

Using the ModelSim EE Simulator

Overview of VHDL Model Simulation

A modeled design unit is tested and evaluated by defining test stimuli to be applied to its inputs, simulating the operation of the unit as these stimuli are applied, and capturing values of outputs and other signals within the unit that can be examined to determine if the unit behaved properly.

The ModelSim EE simulator loads a compiled VHDL model, allows test stimuli (called "forces") to be defined, either interactively or via a "command file", and then simulates the operation of the design, displaying specified signals in list format and/or as timing diagram waveforms. Captured signal values may be examined within the simulator, or saved in files to be examined off-line. Any or all signals in a model may be captured and displayed. It is important to capture as much signal information as possible to simplify debugging of a model.

To debug a VHDL model, a user may interact with the simulator by defining "breakpoints", which stop simulation at selected VHDL statements within the model, at which time the user may examine signals and/or alter signal values. Simulation may then be resumed one VHDL statement at a time or continuously until the next breakpoint is reached.

As errors are located in a model, the VHDL source file may be edited, recompiled, and reloaded into the simulator. Simulation can then be repeated until desired results are obtained.

Typical simulation procedure:

  1. Invoke the simulator and load the VHDL model.
  2. Display the VHDL model by opening a Source Window.
  3. Display signals in the model by opening a Signals Window.
  4. Open a List Window to display captured signal values in tabular form during simulation, and/or a Wave Window to display signal values as logic analyzer waveforms.
  5. Define input stimuli ("forces") for each input signal.
  6. Run the simulation for the desired number of time units.
  7. Study the simulation results in the List/Wave Window.
  8. Save the List Window to a printable file.
  9. Resimulate with new input stimuli, or correct and recompile the model and then repeat the simulation.

Invoking the Simulator

The ModelSim EE Simulator Main Window

Invoking the ModelSim EE simulator produces the Main Window, shown below. Simulation commands may be entered via the menu bar along the top of the window, by typing them at the prompt within the window, or by reading them from a command file. (A Command Summary is given at the end of this document.)



The menu bar contains pull-down menus and buttons to load models, to display VHDL structures and source code, to display signals and variables and their values during simulation, and to run and restart simulations.

Displaying VHDL Models

While simulating and debugging a VHDL model, it is usually helpful to display the model hierarchy and VHDL statements in a Structure Window and a Source Window, respectively.

Displaying VHDL Signal Values

The purpose of simulation is to verify the correctness of a VHDL model. This is done by displaying the various signals within the model, applying stimuli to external input signals, observing signal values during simulation, and comparing observed values to expected values.

Defining Test Input Stimuli (Forces)

A "force value" is a value-delay pair that defines a stimulus to be applied to a signal and the time at which it is to be applied. The time is expressed as a delay from the current simulation time. Multiple time-delay pairs may be specified with a single "force" command, and a pattern may be repeated if desired.

Running the Simulation

A simulation may be run for a designated amount of time, run until there are no more scheduled events, or run until a breakpoint is reached.

Altering and/or Resimulating a VHDL Model

After performing a simulation, it may be desirable to resimulate the model with different input stimuli, or to resimulate the model after making corrections to it.

Resimulating the Same Model:
Simulation time may be reset to 0 and the model resimulated. However, all force statements must be reentered or else read from a command file.
Correcting and Resimulating a Model:
If an error is found in a model, correct it, recompile it, and then resimulate.

Command Files

A "command file" is a text file containing a list of simulator commands that can be executed by issuing a "DO" command. This provides a convenient way to develop a test for a VHDL model that can be reused for multiple simulation runs, as are usually needed during debugging. This saves the chore of retyping all commands for each simulation.

Example Command File:

  add list rd wr
  add list -hex abus dbus
  force wr 0 0
  force rd 0 0, 1 20 -rep 40
  force dbus ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 0
  force abus 16#000 0, 16#004 40, 16#008 80, 16#00c 120
  run 150

This command file opens a list window, displays one-bit signals "rd" and "wr", displays multi-bit signals "abus" and "dbus" in hexadecimal, creates waveforms for the four signals, and simulates for 150 time units.

Debugging VHDL Models

If a VHDL model does not behave as expected, the simulator provides a number of features to assist in tracking down the problems.

Display all signals
Capture and display in a List/Wave Window all signals that might be related to the part of the model containing the error. There is no need to "guess" what a signal might be doing when its actual values can be displayed and examined!
Use Breakpoints
A "breakpoint" is a location in the model at which simulation can be temporarily suspended. While simulation is suspended, the state of the model can be examined and/or altered and simulation continued.
The Process Window
You can monitor which processes are active and which are scheduled to execute via the Process Window, which displays a list of processes and their VHDL path names. You may select (via two buttons):

Additional information displayed to left of process names:



ModelSim EE Simulator Command Summary

ABORT
Halt execution of a macro file
BD <filename> <line>
Delete breakpoint at indicated line of VHDL source file
BP [<filename>] [<line>] [<command> {;<command>}]
Set breakpoint at indicated line of VHDL source file and execute one or more simulation commands. List all breakpoints if no filename/line given.
CHANGE <variable> <value>
Change the value of a variable or signal. (Simulator must be paused at a breakpoint or after STEP)
CONTINUE
Continue execution after a STEP command or breakpoint.
DESCRIBE <variable_name>
Display info about the type of a variable or signal
DO <filename> {<parameter_value>...}
Execute commands from a macro file. Can pass up to nine parameters, designated in the macro file as $1 ... $9.
DRIVERS <signal_name>
Display the current value and scheduled future values for all drivers of the specified signal.
ECHO <text_string>
Display a message in the Transcript window.
ENVIRONMENT [<pathname>]
Display or change the current signal environment.
EXAMINE <name>
Display current value of named signal. (Simulator must be paused at a breakpoint or after STEP)
EXIT [-FORCE]
Exit simulator. If -FORCE specified, then quit without asking if you want to save data.
FIND [-RECURSIVE] [-IN] [-OUT] [-INOUT] [-INTERNAL] [-PORT] <signal_name>
Display full pathnames of all signals whose names match the signal name specification.
FORCE <signal_name> <value> [<time>] {,<value><time>} [-REPEAT period]
Force signal to indicated values at indicated times. Optionally repeat the pattern. (eg. for clocks)
Example
     FORCE x1 0                   -- set x1<=0 now FORCE x1 0 100 set x1<="1" 100 time units hence FORCE x1 0 10, 0 20 Rep 40 set x1<="0" at time 10, 1 at time 20 then repeat every 40 time units 
FORMAT LIST <filename> and
 
FORMAT WAVE <filename>
Record list of signal names currently in List/Wave window to a file. This file may be invoked with a DO command to recreate the window.
IF <expression> {<command>} {;<command>} {ELSE {<command>} {;<command>} ENDIF
Execute selected commands if certain conditions are true.
LIST [-STROBE [<first_strobe>,]<period>] [-COLLAPSE] [-DELTA | -NODELTA] [{-RECURSIVE -IN -OUT -INOUT -INTERNAL -PORT -<radix> -TRIGGER -NOTRIGGER -WIDTH <n> {<signal_name> ...}]
List signals and their values in the List Window.
LOG [-RECURSIVE] [-IN] [-OUT] [-INOUT] [-PORT] [-INTERNAL] <signal_name> {<signal_name>...}
Create a log file containing simulation data for all listed signals. All signals in List/Wave Windows are automatically included. (The log file is the source of data for List/Wave windows.)
NOFORCE <signal_name> {<signal_name>...}
Cancel a repeating force on a signal.
NOLIST <signal_name> {<signal_name>...}
NOWAVE <signal_name> {<signal_name>...}
Remove signals from List/Wave Window.
ONBREAK [<command> ; {<command>}]
Specify command to be executed when a breakooint is encountered during simulation.
QUIT [-FORCE]
Exit simulator without saving data, after confirmation. (Confirmation not requested if -FORCE specified.)
RESTART [-FORCE] [-NOBREAKPOINT] [-NOLIST] [-NOLOG] [-NOWAVE]
Reload design and reset simulation time to 0.
RESUME
Resume execution of a macro file after a breakpoint.
RUN [<time_units>...] [-all]
Execute the simulation for the specified number of time units. If no time specified - run for default time. If -all specified, run until there are no events scheduled.
SET [<variable_name> <value>]
Create a user-defined variable and set it to the indicated value. If no argument - display all current user-defined variables.
SHIFT
Shift macro parameter values down one place. (Parameter $2 is assigned to $1, $3 to $2, etc.)
SHOW [<pathname>]
List signals and subregions visible from the current signal environment.
SOURCE [<filename>]
Display VHDL source file.
STEP [-OVER]
Step to the next VHDL statement. If -OVER specified, treat procedures/functions as single statements (do not step through them).
SYSTEM <unix_command>
Execute one UNIX shell command.
Ex. >SYSTEM cp vector2.dat vectors.dat
TB
Display stack trace for the current process.
TRANSCRIPT [ON | OFF]
Echo to Transcript window commands being executed from a macro file.
VIEW [LIST] [PROCESS] [SIGNAL] [SOURCE] [STRUCTURE] [VARIABLE] [WAVE]
Open one or more designated simulation windows. "VIEW *" will open ALL of the above windows.
WAVE {[-RECURSIVE] [-IN] [-OUT] [-INOUT] [-INTERNAL] [-PORT] [-<radix> -<format> [-OFFSET <n>] [-SCALE <n>] [-COLOR <color_name>] {<signal_name>...}}
Add signals to a Wave Window.
WHERE
Display info about system environment (current directory, project file, and work library.)
WRITE LIST <filename>
Record contents of List Window in an output file.
WRITE REPORT <filename>
Print summary of design being simulated to output file.
WRITE WAVE <filename>
Record contents of Wave Window in an output file in PostScript format.