EE-421 Digital System Design Lab (Fall 2016) : Or, Not
EE-421 Digital System Design Lab (Fall 2016) : Or, Not
Lab01
Instructor: Muhammad Awais Bin Altaf
TA: Mirza Athar Baig
Objective:
using
Ports: Ports provide the module with a means to communicate with other modules or its
environment. A module can have a port list. Ports in the port list must be declared as input,
output, or inout.When instantiating a module, port connection rules are enforced by the Verilog
simulator.
Test bench/Stimulus: The module functionality is tested by creating a stimulus in which the
inputs are defined to drive the outputs. Stimulus is not synthesized.
end
endmodule
Identifiers and Keywords: Identifiers are the names given to the objects so that they can be
referred anywhere in the design while keywords are special identifiers used to describe the
language constructs.
Registers and Nets: Registers (reg) are used to store values. Usually inputs are given the name
reg. Nets or wires do not store values they just pass on them to the other part of the design.
Outputs are named wires in a design.
Gate level modeling Using predefined primitives (AND, OR, NOT etc) to design a logic.
Simulation:
Simulators are available from many vendors, at all price points. For desktop/personal use, Aldec,
Mentor, LogicSim, SynaptiCAD,TarangEDA Altera Quartus and others offer <$5000 USD toolsuites.
In this lab, we will be using ModelSim by Mentor Graphics. ModelSim is an easy-to-use yet
versatile VHDL/(System)Verilog/SystemC simulator by Mentor Graphics. It supports behavioral,
register transfer level, and gate-level modeling. ModelSim supports all platforms used here at the
Department of Pervasive Computing (i.e. Linux, Solaris and Windows) and many others too.
ModelSim can be found preinstalled on Department's computers.
Open ModelSim
2.
3.
This window will pop up. Name your project something useful, in this case
Project1 was the name chosen. Add the name of the project onto the project location. This
keeps the project in an easy to find place.
4.
If this is the first project most likely you will want to create a new file. Click the
Create New File button and a window pops up. A project can have more than one files so
name this file according to its functionality.
5.
Right click the file name and select edit. Now you are going to write Verilog
code in this file, Use the following code, This is 2 input and gate.
//This module designs the 2 input and one output and gate.
module andgate (a, b, y);
input a, b;
output y;
and a2(y,a,b);
endmodule
6.
After you complete the code, Right click on file name and select compile. This step
will compile the Verilog file.
7.
Now create another Verilog file to write the testbench for you code. Use the
following code for the test bench of AND gate Verilog file.
#5
t_a = 1'b1;
t_b = 1'b0;
#5
t_a = 1'b1;
t_b = 1'b1;
end
endmodule
8.
9.
Compile the testbench file using step 6 again. Make sure you get no error.
Go to simulate option and select start simulation.
10.
11.
Following window will pop up. Right click on test bench file and select Add
wave.
12.
Select Run. Make sure you get green colored wave forms and check your logic
as well.
Lab Tasks:
1. Simulate four input OR, XOR and XNOR gates using 2 input primitive gates
2. Simulate the given design using gate level modeling.
Figure 1 4 to 1 multiplexer
Appendix
Description
N-input AND gate
N-input NAND gate
N-input OR gate
N-input NOR gate
N-input XOR gate
N-input XNOR gate
One input NOT gate
The name of these gates are keywords and cannot be used as identifiers (like variable name in c).
Example:
Write Verilog description for 3 input one output and gate using gate primitive
and a2(y,a,b,c)