11
In the name of God Digital Logic – Shahid Beheshti University – fall semester 2011 ModelSim 6.5 Brief Tutorial Here are some tips for you to get used to Verilog Language and ModelSim 6.5 environment. After Installing ModelSim go to crk folder and run MentorKG then If it’s your first time opening ModelSim or if you encounter problems with licenses, you can run the license wizard: Start > All Programs > ModelSim SE > Licensing Wizard. Choose install a new license and select the file LICENSE.TXT in crk Folder, you must see a congratulation message that you cracked successfully! It’s time to see different parts of modelsim, we’ll go through it step by step with and example of designing a full adder module, I’ll explain important part to you when we encountered them. First you’ll see something like the picture below, start by choosing new Project, name it fullAdder:

98095835 SBU ModelSim 6 5 Tutorial 1

Embed Size (px)

DESCRIPTION

ModelSim Tutorials

Citation preview

Page 1: 98095835 SBU ModelSim 6 5 Tutorial 1

In the name of God

Digital Logic – Shahid Beheshti University – fall semester 2011 ModelSim 6.5 Brief Tutorial

Here are some tips for you to get used to Verilog Language and ModelSim 6.5 environment.

After Installing ModelSim go to crk folder and run MentorKG then If it’s your first time opening ModelSim or if you encounter problems with licenses, you can run the license wizard: Start > All Programs > ModelSim SE > Licensing Wizard.

Choose install a new license and select the file LICENSE.TXT in crk Folder, you must see a congratulation message that you cracked successfully!

It’s time to see different parts of modelsim, we’ll go through it step by step with and example of designing a full adder module, I’ll explain important part to you when we encountered them.

First you’ll see something like the picture below, start by choosing new Project, name it fullAdder:

Page 2: 98095835 SBU ModelSim 6 5 Tutorial 1

ok, now choose new file, name it whatever you like, consider to choose Verilog, the default is VHDL, now you’ll see your file and the status is ? it means it didn’t compile yet,

first of all let’s sharpen our tools by choosing right component in modelSim, so go to view tab and be sure the Library, Objects , Project , Transcript and Wave are selected.

Page 3: 98095835 SBU ModelSim 6 5 Tutorial 1

Library: A directory that contains compiled design units, such as modules.

Projects: A collection of various files for designs under test, such as Verilog source files, local working libraries, references to resource libraries, and simulation configuration (*.mpf files).

Objects: is where you can find you variables, input outputs, etc.

Wave: Here you can see the input/outputs of your module in waveform.

Transcript: this tool will allow you to execute your commands by typing (something like command prompt in window)

e.g. instead of click a file to compile you can type

vlog –work [working library] [filename.v]

Example: vlog –work work fullAdder.

Page 4: 98095835 SBU ModelSim 6 5 Tutorial 1

That’s enough till now, let’s start coding :-D

Here you can see a full adder:

go to Project component and double click the Verilog file to change it

we want to create a fullAdder Module.

Page 5: 98095835 SBU ModelSim 6 5 Tutorial 1

I wrote code and name it FullAdder.v and I explained different code part by commenting it, if you want to use my code instead of creating new file you can choose add existing file and choose my file, you must then compile that, but I strongly suggest you for first time write your code on your own to get familiar with Verilog.

Page 6: 98095835 SBU ModelSim 6 5 Tutorial 1

ok, go to project and compile the file, if your code doesn’t have compile error you’ll see a check mark in status.

Note: After any change in your code you must save it then compile it, it won’t save automatically, after you type use ctl+s shortcut key then recompile it.

Consider that when you compiled a module correctly it will be added to your Work library with Module name you defined in your code here is: fullAdder

Well then, time to simulate

In simulate tab click start simulation

Page 7: 98095835 SBU ModelSim 6 5 Tutorial 1

in work library find fullAdder Module

Page 8: 98095835 SBU ModelSim 6 5 Tutorial 1

Click Ok, now in Object Component you must see all of you inputs and outputs to and from module

we want to see the waveform of these signals so by right clicking and:

Add->To wave->Signal in Regions

You’ll add all signals(if you want to select some signals you can choose your signals and then choose selected signals(for example sometimes you just interested in outputs)

Now they are added in wave

Page 9: 98095835 SBU ModelSim 6 5 Tutorial 1

HiZ means high impedance, because we didn’t set any input yet. X in output means it doesn’t have any value yet

Next step we should set the inputs,

Force values:

Force follows this type: Force [variable] [value] [time] value means the constant you want to set. time means after how much time change will occur. So here I set these force a 1 force b 0 force b 1 100 ns force Cin 1 Now it’s time to run, so from time 0 to time 100 the outputs should be: S = 0 , Cout = 1

Page 10: 98095835 SBU ModelSim 6 5 Tutorial 1

From time 100 to 500 the outputs should be: S = 1, Cout = 1 (times are in nano second scale by using ns suffix) to run simply type: Run 500 ns

Page 11: 98095835 SBU ModelSim 6 5 Tutorial 1

NOTE: when you type run it’ll not start from 0 time , it’ll start from current time, so after previous run if I type run 120 wave form will show you 500 to 620 .In general after run when you type anything it’ll effect the changes after that time For example here If I write this: force a 0 50 ns force b 0 run 120 I’ll see this:

Note: if you want to restart all waves and back to time zero with HiZ simply type : restart –f

reference : Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science

Instructor: Dr.Abbaspour

TA: Aryan Yaghoubian

www.sites.google.com/site/sbudigitalogic