0% found this document useful (0 votes)
19 views3 pages

LPE1 Lab Report

The document contains a lab performance evaluation for a four-bit subtractor implemented in Verilog. It includes the code for the four-bit subtractor and a test bench, but ends with an error message indicating a problem during simulation. The code demonstrates the use of full adders to perform subtraction and includes various test cases.

Uploaded by

sajeebmahmud3962
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views3 pages

LPE1 Lab Report

The document contains a lab performance evaluation for a four-bit subtractor implemented in Verilog. It includes the code for the four-bit subtractor and a test bench, but ends with an error message indicating a problem during simulation. The code demonstrates the use of full adders to perform subtraction and includes various test cases.

Uploaded by

sajeebmahmud3962
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Roll No: 2003102

Lab Performance Evaluation 2


Lab Task Q1
Question: 1

Solution (Code/Add all circuits diagrams):

Question: 2

Solution (Code/Add all circuits diagrams):


module four_bit_subtractor(
input [3:0] A, B,
input Cin,
output [3:0] Diff,
output Cout
);

full_adder fa0(A[0], B[0], Cin, Diff[0], Cout0);


full_adder fa1(A[1], B[1], Cout0, Diff[1], Cout1);
full_adder fa2(A[2], B[2], Cout1, Diff[2], Cout2);
full_adder fa3(A[3], B[3], Cout2, Diff[3], Cout);

endmodule

module full_adder(
input A, B, Cin,
output Sum, Cout
);
endmodule

Test Bench:

module four_bit_subtractor_tb;

reg [3:0] A;
reg [3:0] B;
reg Bin;
wire [3:0] Diff;
wire Bout;

full_subtractor uut (
.A(A),
.B(B),
.Bin(Bin),
.Diff(Diff),
.Bout(Bout)
);

initial begin

$display("Time\t A\t B\t Bin\t Diff\t Bout");


$monitor("%0dns\t %b\t %b\t %b\t %b\t %b", $time, A, B, Bin,
Diff, Bout);

A = 4'b0111; B = 4'b0011; Bin = 1'b0;


#10;

A = 4'b1100; B = 4'b1000; Bin = 1'b0;


#10;

A = 4'b0101; B = 4'b1010; Bin = 1'b0;


#10;

A = 4'b1111; B = 4'b1111; Bin = 1'b0;


#10;

A = 4'b0000; B = 4'b0001; Bin = 1'b1;


#10;

$finish;
end
endmodule
Output/Simulation Result (Screenshot/SnapShot):

Error

You might also like