Computer Engineering 465 / Electrical Engineering 543

DIGITAL VLSI SYSTEMS

Introducing Mentor Graphics’ Modelsim


Introduction

The objective of this tutorial is to introduce the Mentor Graphics’ Modelsim tool that is to be used for compilation and simulation of VHDL files. This documentation describes in detail all the steps required to carry out the  projects. This involves writing the source code in a text file, compiling it, and then doing the simulation. You are expected to roughly follow the same steps in your VHDL projects.
 

Environment Setup


Project Creation

On creating a new project, Modelsim automatically creates a design library with the name "work" in the project directory inside the project’s home to hold all future project designs.


Compiling a VHDL File (Vcom)

 

vcom <filename.vhd>

 

where <filename.vhd> is the name of the file to compile.

Or simply select Design => Compile from the main window's menu, and then select the file to compile.

If there are any syntactical errors in the code, they will be reported by line number with a description of the error. You can go directly to the line with the error in the editor by clicking on the error message.


Simulating a Design (Vsim)

 

vsim <work.entityname(architecturename)>

 

Or simply select Design => Load New Design from the main window's menu, and then select the entity and the architecture you want to simulate from the popup window. (Commands for the simulator are not case-sensitive.)

 

view *

 

Or simply select View => All from the main window's menu. You could select a certain window from View from the main window's menu.

Here is a brief description for each of these eight windows:

1.      Source window. This shows the VHDL source for the current design region. An arrow in the window points to the next VHDL statement to be simulated.

2.      Structure window. This displays the structural hierarchy in the design. The source code for the selected design region appears in the Source window. Packages are always shown immediately under the top level.

3.      Signals window. This window displays names and current values of the signals in the current region. (the part of the design that you have selected in the Structure window.) To add all the top-level signals, enter the following command at the command prompt in the main window:

 

list *

 

4.      Process window. This has two modes. When Active is selected, the window displays only a list of the processes that are scheduled to execute in this simulation cycle. When In Region is selected, the window lists all processes in the current region.

5.      Variable window. This displays generics, constants, and variables that are visible in the current process.

6.      List window. This displays a tabular listing of values for signals you have selected. To choose signals to list, select View => List => Signals in Region from the Signals window’s menu.

7.      Wave window. This window displays waveforms, names, and current values for signals that are selected. To add a signal to this window, drag it from the Signals window and drop it in the Wave window. Or simply to add all signals in the region, select View => Wave => Signals in Region from the Signals window's menu.

You can also add a new cursor to the Wave window by selecting from the Cursor => Add Cursor from the Wave window’s menu. Using a number of cursors you can do a lot of time measurements. For example, moving the cursor probes signal values, whereas clicking on a signal moves the cursor to the nearest edge.


8.      Dataflow window. This window allows signal tracing throughout the design. It can show either a signal on the center of the window with all the processes that drive the signal on the left and all the processes that read the signal on the right side of the window. It can also show a process with all the signals read by the process shown as inputs on the left of the window, and all the signals driven by the process on the right side of the window. Which form is displayed depends on whether a signal or a process is selected in the corresponding window.

You can also apply a stimulus to an input signal using the force command at the command prompt in the main window. For example, the following line:

 

force -freeze clock 1 25, 0 50 -repeat 75

 

forces the clock value to be 1 at 25 ns after the current time, and 0 at 50 ns from now. The -repeat tells the simulator to repeat this cycle every 75 ns. The -freeze forces this value on the clock signal and does not change it unless another freeze force is given by the user.

Freezing is one kind of forcing values on signals. Other kinds include:

·        Drive: assigns a certain value to the signal at an instant of time. However, if the VHDL code is forcing another value, the final value will be calculated with a resolution function.

·        Deposit: puts a value on a signal, which remains the same till when a transition on the same signal occur on another driver.

The default kind of forceing is freeze.

 

view *
list *
force -freeze clk 1 0, 0 50  -repeat 100
force select 1
force -deposit enable 1 0
force -drive data 01010111 0, 11110011 25, 10101100 50
run

 

To execute the do file, enter the following command at the command prompt in the main window:

 

do <filename.do>

 

where <filename.do> is the name of the do file to execute.

Or simply select Macro => Execute Macro from the main window’s menu. Then, select the do file to execute.

 

quit -force

 

This exits the simulator without saving data.


Getting More Help

To get a quick guide to Modelsim, select Help => PE Documentation => PE Quick Guide from the main window's menu.


Home Return back to the course home page.