#LAB1
#LAB1
Computer Systems
Engineering
Handout#01
Gate-Level Modelling and Simulation
Note: Submit the lab report (solved activities and exercises) before the next lab.
Lab Hardware and Software Required:
Background Theory:
Gate-level Modelling:
Verilog is both a structural and behavioral language. Internals of each module can be
defined at four levels of abstraction, depending on the need of the design. There are four
levels of abstraction which include switch-level, gate-level, data flow, and behavioral or
algorithm level.
The switch-level is the lowest abstraction level, where module can be implemented
in terms of switches, storage nodes, and interconnections between them.
Verilog allows the designer to mix and match all four levels of design methodologies in
design. The modules behave identically to the external world identically irrespective of
the level of abstraction at which module iss described. Therefore, internals of the
modulecan be changed without any change in the environment.
In the digital design community, the term register transfer level (RTL) is used for Verilog
description that uses a combination of behavioral and data flow modelling. Normally, the
higher level of abstraction, design will be more flexible and technology independent.
Although, the lower-level description provides high performance therefore as the design
matures, high level modules are replaced with the gate-level modelling.
Lab Activity:
We are going to use testbench listing 1.7 (2-bit comparator design and its test vector) you
have covered in chapter#1 of the textbook.
Steps:
1. Open https://www.edaplayground.com/.
2. Write your testbench code at the left and required modules on the right.
3. Add these two lines after initial begin
$dumpfile("eq2_tb.vcd"); // simulator generates output file for the waveforms data
$dumpvars;
Also, replace $stop with $finish.
Design a full adder circuit along with its test bench. You may give four input vectors (from
the table) in the test bench and observe the output from waveforms.
Additionally, you are required to attach the input and output waveforms in your lab report.
Solution:
Module:
module full_adder (
);
endmodule
testbench:
module testbench;
initial begin
// Open VCD file for waveform
$dumpfile("full_adder_tb.vcd");
$dumpvars;
// Test vector 1
a = 1; b = 0; c_in = 0;
#10;
// Test vector 2
a = 1; b = 1; c_in = 0;
#10;
// Test vector 3
a = 1; b = 0; c_in = 1;
#10;
// Test vector 4
a = 1; b = 1; c_in = 1;
#10;
endmodule