Exp 2
Exp 2
Half Adder:
test bench :
module half_adder_tb;
// Inputs
reg a;
reg b;
// Outputs
wire s;
wire c;
initial begin
// Initialize Inputs
a = 0;b = 0;#100;
a = 0;b = 1;#100;
a = 1;b = 0;#100;
a = 1;b = 1;#100;
$finish;
end
endmodule
WAVFORMS:
FULL Adder:
Test bench:
module full_adder_tb;
// Inputs
reg a;
reg b;
reg c;
// Outputs
wire sum;
wire carry;
initial begin
// Initialize Inputs
a = 0;b = 0;c = 0;#100;
a = 0;b = 0;c = 1;#100;
a = 0;b = 1;c = 0;#100;
a = 0;b = 1;c = 1;#100;
a = 1;b = 0;c = 0;#100;
a = 1;b = 0;c = 1;#100;
a = 1;b = 1;c = 0;#100;
a = 1;b = 1;c = 1;#100;
$finish;
endmodule
WAVFORMS:
To be Drawn after the execution of the Experiment
HALF SUBTRACTOR:
Test bench:
module half_sub_tb;
// Inputs
reg a;
reg b;
// Outputs
wire d;
wire bo;
initial begin
// Initialize Inputs
a = 0;b = 0;#100;
a = 0;b = 1;#100;
a = 1;b = 0;#100;
a = 1;b = 1;#100;
$finish;
endmodule
WAVFORMS:
FULL SUBTRACTOR:
Test bench:
module full_sub_tb;
// Inputs
reg a;
reg b;
reg bi;
// Outputs
wire d;
wire bo;
initial begin
// Initialize Inputs
a = 0;b = 0;bi = 0;#100;
a = 0;b = 0;bi = 1;#100;
a = 0;b = 1;bi = 0;#100;
a = 0;b = 1;bi = 1;#100;
a = 1;b = 0;bi = 0;#100;
a = 1;b = 0;bi = 1;#100;
a = 1;b = 1;bi = 0;#100;
a = 1;b = 1;bi = 1;#100;
$finish;
end
endmodule
WAVFORMS:
modulefa(
inputa,b,c,
outputregs,co
);
always@ (a,b,c)
begin
s = a ^ (b ^ c);
co = ((a ^ b) & c) | ( a & b);
end
endmodule
IC DIAGRAM:
INTERNAL DIAGRAM:
\TRUTH TABLE:
INPUTS OUTPUTS
A b C C(0) S(0)
0 0 0 0 0
0 0 1 0 1
0 1 0 0 1
0 1 1 1 0
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1
RESULT: The half adder, full adder,half subtrator and full subtrator has been
successfully designed and implemented.