DLD LAB # 03
DLD LAB # 03
Lab report #: 03
Submitted by:
1
Objectives :
In-Lab Task 1:
Verify all the basic logic gates using the Xilinx ISE simulation tool and verify
your waveform with logic gates truth table.
i. Task 01: Write a Verilog code (Gate-Level) for NOT, OR, NOR,
NAND, XOR and XNOR.
ii. Task 02: Write a stimulus/test bench for Task 01 and show the
simulation results.
AND Gate:
2
a) Timing Diagram
AND Gate:
a) Timing Diagram:
3
NAND Gate:
b) Timing Diagram:
4
NOT Gate:
5
NOR Gate:
Timing Diagram:
6
XOR Gate:
Timing Diagram:
7
XNOR Gate:
c) Timing Diagram:
8
Truth Table:
A B A A OR A A A A A XNOR
NOT B NOR B NAND B XOR B AND B B
0 0 1 0 1 1 0 0 1
0 1 1 1 0 1 1 0 0
1 0 0 1 0 1 1 0 0
1 1 0 1 0 0 0 1 1
Explanation:
In Task 01, the objective is to write Verilog code using gate-level modeling to
represent six basic logic gates: NOT, OR, NOR, NAND, XOR, and XNOR.
Each gate is implemented as a separate module, which accepts one or two
input signals and produces a single output corresponding to the operation of
each gate. Gate-level modeling directly reflects the underlying hardware
design, allowing us to simulate the behavior of digital circuits in Verilog.
In Task 02, a test bench is written to validate the functionality of the logic
gates developed in Task 01. The test bench provides a set of input
combinations and monitors the outputs to verify correct behavior. The test
bench cycles through various input pairs for the two-input gates and a single
input for the NOT gate, displaying the results for each case. This test bench is
executed within a simulation tool, such as Xilinx ISE, which generates
waveforms to visualize the output for each gate. The waveforms are then
compared to the expected truth tables to confirm the gates’ accuracy.
Post-Lab:
Task 01: Write a Verilog code for the given Boolean function (e.g. 𝐹 = 𝑥 + 𝑥̅𝑦
+ 𝑦𝑧̅ ):
a) Using Gate-Level model (Provide Gate Level diagram and Truth Table)
9
Task 02: Write a stimulus/test bench for Task 01 and show the simulation
results.
10
Timing Diagram:
Truth Table:
x y z x’ Z’ (xy)’ yz’ F
0 0 0 1 1 0 0 0
0 0 1 1 0 0 0 0
0 1 0 1 1 1 1 1
0 1 1 1 0 1 0 1
1 0 0 0 1 0 0 1
1 0 1 0 0 0 0 1
1 1 0 0 1 0 1 1
1 1 1 0 0 0 0 1
Explanation:
11
In Task 02, we write a test bench to check if both models (Gate-Level and
Dataflow) work correctly. The test bench gives different combinations of inputs
x, y and z and compares the output (F) from both models. We use the
$display command to show the results and $finish to stop the simulation.
It shows the results match the truth table of the Boolean function, proving the
code works as expected.
12