simulation using model sim

17
VHDL 360 © by: Amr Ali

Upload: amraldo

Post on 07-Nov-2014

5.502 views

Category:

Documents


3 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Simulation using model sim

VHDL 360©

by: Amr Ali

Page 2: Simulation using model sim

CopyrightsCopyright © 2010 to authors. All rights reserved• All content in this presentation, including charts, data, artwork and

logos (from here on, "the Content"), is the property of Amr Ali or the corresponding owners, depending on the circumstances of publication, and is protected by national and international copyright laws.

• Authors are not personally liable for your usage of the Content that entailed casual or indirect destruction of anything or actions entailed to information profit loss or other losses.

• Users are granted to access, display, download and print portions of this presentation, solely for their own personal non-commercial use, provided that all proprietary notices are kept intact.

• Product names and trademarks mentioned in this presentation belong to their respective owners.

VHDL 360 © 2

Page 3: Simulation using model sim

Objective

• Using ModelSim to compile and simulate a given design unit

• Skills gained:– Identify basic Simulator commands

VHDL 360 © 3

Page 4: Simulation using model sim

Outline

• Command Line Simulation– Compile and Simulate– Add Signals to Wave– Applying Inputs

• Interactive Simulation

VHDL 360 © 4

Page 5: Simulation using model sim

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

VHDL 360 © 5

Page 6: Simulation using model sim

Command Line Simulation• Create VHDL file

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

VHDL 360 © 6

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 7: Simulation using model sim

Compile and Simulate

vlib work

vcom <VHDL files>

vsim <top level>

VHDL 360 © 7

• 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 8: Simulation using model sim

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

VHDL 360 © 8

Page 9: Simulation using model sim

Applying Inputs

• RMB on input port force

VHDL 360 © 9

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

• Apply inputs to other inputs

Page 10: Simulation using model sim

Run Simulation

• Press run button

• Monitor the output

VHDL 360 © 10

Page 11: Simulation using model sim

Make Files

On 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

VHDL 360 © 11

Page 12: Simulation using model sim

Interactive Simulation

• File new project• Insert project name

and location; leave other fields with defaults

VHDL 360 © 12

Page 13: Simulation using model sim

Interactive Simulation

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

• Insert file name• Make sure to select

VHDL

VHDL 360 © 13

Page 14: Simulation using model sim

Interactive Simulation• Create VHDL file

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

VHDL 360 © 14

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 15: Simulation using model sim

Compile VHDL files

• Select the file RMB compile selected

VHDL 360 © 15

Page 16: Simulation using model sim

Simulation

• Simulate menu Start Simulation

• Expand work library and select andgate OK

VHDL 360 © 16

Page 17: Simulation using model sim

Contacts

• You can contact us at:– http://www.embedded-tips.blogspot.com/

VHDL 360 © 17