DLD Lab Manual 15
DLD Lab Manual 15
DLD Lab Manual 15
EXPERIMENT NO. : 15
Objective:
To understand how to implement half adder and full adder using Verilog.
PROCEDURE:
Write and draw the Digital logic system.
Write the Verilog code for above system.
Enter the Verilog code in Model Sim software.
Check the syntax and simulate the above Verilog code (using Model Sim or
Xilinx) and verify the output waveform as obtained.
Test Module:
The Verilog module defined above is not executable in any sense. In order to use the
module, it must be combined with additional Verilog code. We will now create another
Verilog module that generates test cases for the half-adder. We implement the test case
generator within a Verilog test module. The test module is written using Verilogs
behavioral constructs, shown below:
Output:
Digital Logic Design, EE Department, Wah Engineering College
PART (B)
Implementation and verification of Full adder in Verilog
Full Adder
module fulladder(a,b,c,sum,carry);
input a,b,c;
output sum,carry;
wire sum,carry;
endmodule
Test bench:
module main;
reg a, b, c;
wire sum, carry;
fulladder add(a,b,c,sum,carry);
always @(sum or carry)
begin
$display("time=%d:%b + %b + %b = %b, carry =
%b\n",$time,a,b,c,sum,carry);
end
initial
begin
a = 0; b = 0; c = 0;
#5
a = 0; b = 1; c = 0;
#5
a = 1; b = 0; c = 1;
#5
a = 1; b = 1; c = 1;
end
endmodule
Digital Logic Design, EE Department, Wah Engineering College
Output:
Digital Logic Design, EE Department, Wah Engineering College
Lab task:
1. Write a Verilog code for half adder using data flow modelling. (Give the first
two alphabets followed by ha to the identifier of module e.g ad_ha(portlist);)
2. Write a Verilog code for full adder using Gate Level modelling. Draw the
logic diagram depicting the following information. (Give the first two
alphabets followed by fa to the identifier of module e.g ad_fa(portlist); Also use
the first two alphabets as an optional name for gate instantiation. ).
Digital Logic Design, EE Department, Wah Engineering College
Comments:
Conclusion: