Simulation Using Modelsim
Simulation Using Modelsim
ModelSim
Course: COEN 6501
Prepared by: Rokibul Hasan Bhuiyan
1
For Scientific Linux Kernel in Lab
• Open Xterm
• To connect to server.
ssh –X (your encs user name)@login.encs.Concordia.ca
2
Objective: We will simulate a half-adder circuit using structural VHDL in ModelSim
3
Start ModelSim on your computer
4
• Go to file menu
• Move your cursor to New
• Select project…
5
This window will pop up.
• Fill Project Name
• Fill Library name if you want to change
the name or it can be kept as work by default
• Click OK
6
• Click Create New File
7
• Put File Name
• Click OK
8
I am adding a Xor gate to
project as I am building a half
adder which has xor gate as
component
9
If you click twice on the file then
a notepad will show up in the right Write your code here
where we have to write the code
10
Can click on this icon to compile
or
11
• If you haven’t saved
the file you will get this
window to save your
changes before
compiling.
• It is a good practice to
save the file after
every change.
• Click Yes
12
We have some errors in code.
So, the compiler could not compile.
14
Status
Transcript
15
Now we are going to add component and gate
You can along with main file Half adder.
also use
this button
to add new
file
16
We have added and gate
following the same
procedure for xor gate
17
You can use this
button to compile all
files in project or
follow the procedure
how you have
compiled xor_2 file .
Just select “compile
all” option.
18
Click on this one to go to
You can also use
Start simulation window
Simulate
To go to Start
simulation window
19
Alternative method to simulate or page 18 is in next page
20
2. Select the file and double click
21
You can see input output of the design
22
1.Right click on the file name “half_adder_structural”
2.Add
3. To wave
4.All items in region
Now we have added all the input and outputs in the waveshape
23
This one run the simulation for all the
test cases if you have a testbench.
This one is the
This one will run the
simulation time. You
simulation for
can change it
specified time cycle
such as 200ns which is
written in simulation
time.
24
Right Click
here on “0”
to get this
options
Now we would give
some input values
to see output using
“Force..” option
25
• Change the value. I am changing it to “1”.
• Press OK
26
Input Current value on 113 ns
and
outputs • So I have forced value of a to
be 1 and value of b to be 0.
Then I run it for 200ns .
• We can see that the output we
got are sum=1 and cry=0.
27
• So I have forced value of a to
be 1 and value of b to be 1.
Click anywhere in Then I run it for 200ns .which
this space to see will start from 201 ns and
the input output finish at 400ns.
values for that • We can see that the output we
time. got are sum=0 and cry=1 for
that cycle.
• So it is supporting truth table
of half adder circuit
28
Further Reading: How to use testbench to simulate half adder circuit
Contact: [email protected]
Ref:
1. https://users.encs.concordia.ca/~asim/COEN_6501/Lecture_Notes/L7_Slides.pdf
2. https://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Half_Adder.svg/1920px-Half_Adder.svg.png
29