14
MODELSIM Training in Mohali E2MATRIX CALL: +91 9056051501,9915525860 WEB: WWW.E2MATRIX.COM EMAIL:MOHALI. [email protected] E2MATRIX

Modelsim Training In Mohali

Embed Size (px)

Citation preview

Page 1: Modelsim Training In Mohali

MODELSIM Training in Mohali

E2MATRIXCALL: +91 9056051501,9915525860WEB: WWW.E2MATRIX.COMEMAIL:MOHALI. [email protected]

E2MATRIX

Page 2: Modelsim Training In Mohali

Outline Command Line Simulation

◦ Compile and Simulate◦ Add Signals to Wave◦ Applying Inputs

Interactive Simulation

2

Page 3: Modelsim Training In Mohali

Command Line Simulation Make sure Modelsim exists in the path by doing the following◦Windows:

◦ Start run -> cmd◦ In cmd window:

vsim -version◦Linux:

◦ In any shell: vsim -version

3

Page 4: Modelsim Training In Mohali

Command Line Simulation Create VHDL file

◦ Edit the file my_demo1.vhd◦ Insert the text and save

4

LIBRARY ieee; USE ieee.std_logic_1164.all;

ENTITY andgate IS port (a, b: in std_logic_vector(2 downto 0); c: out std_logic_vector(2 downto 0) ); END ENTITY;

ARCHITECTURE behav OF andgate ISBEGIN c <= a and b; END ARCHITECTURE;

Page 5: Modelsim Training In Mohali

Compile and Simulatevlib work

vcom <VHDL files>

vsim <top level>

5

• vlib: creates a library to compile and simulate the code with

• vcom: compiles VHDL files, the files should be ordered in a hierarchal way [leaf level first then top]

• vsim: starts the simulator to simulate the top level module

Page 6: Modelsim Training In Mohali

Add signals to Wave RMB on any signal in the Objects window Add to Wave signals in Region

Now start applying inputs and monitor outputs

6

Page 7: Modelsim Training In Mohali

Applying Inputs RMB on input port force

7

• In the “value” field, insert an appropriate value OK

• Apply inputs to other inputs

Page 8: Modelsim Training In Mohali

Run Simulation Press run button

Monitor the output

8

Page 9: Modelsim Training In Mohali

Make FilesOn Unix:

If you changed the code you will have to recompile the design files again. A make file is used to do repetitive compilation and simulation tasks; “Make” knows which files have been edited and automatically compiles only changed files.

ModelSim offers a simple way to automatically generate a Makefile for your design hierarchy. vmake work > Makefile

To recompile code at anytime just type make

9

Page 10: Modelsim Training In Mohali

Interactive Simulation File new project Insert project name and location; leave other fields with defaults

10

Page 11: Modelsim Training In Mohali

Interactive Simulation In “Add items to the project” window choose “Create new file”

Insert file name Make sure to select VHDL

11

Page 12: Modelsim Training In Mohali

Interactive Simulation Create VHDL file

◦ Edit the file my_demo1.vhd◦ Insert the text and save

12

LIBRARY ieee; USE ieee.std_logic_1164.all;

ENTITY andgate IS port (a, b: in std_logic_vector(2 downto 0); c: out std_logic_vector(2 downto 0) ); END ENTITY;

ARCHITECTURE behav OF andgate ISBEGIN c <= a and b; END ARCHITECTURE;

Page 13: Modelsim Training In Mohali

Compile VHDL files Select the file RMB compile selected

13

Page 14: Modelsim Training In Mohali

Simulation Simulate menu Start Simulation

Expand work library and select andgate OK

14