4 Bit Adder
4 Bit Adder
4 Bit Adder
parameter n = 7;
output reg [n:0] f;
output reg cOut;
input [n:0] a;
input [n:0] b;
input cIn;
always @(a, b, cIn)
{cOut, f} = a + b + cIn;
endmodule
module tb_4ba;
wire [7:0] f;
wire cOut;
reg [7:0] a = 8'b00000000;
reg [7:0] b = 8'b00000000;
reg cIn = 1'b0;
nBitAdder UUT (
.f(f),
.cOut(cOut),
.a(a),
.b(b),
.cIn(cIn));
initial begin
// ------------- Current Time: 100ns
#100;
cIn = 1'b1;
b = 8'b00000100;
// ------------------------------------// ------------- Current Time: 200ns
#100;
a = 8'b00000010;
b = 8'b00000101;
// ------------------------------------// ------------- Current Time: 300ns
#100;
a = 8'b00000011;
// ------------------------------------// ------------- Current Time: 400ns
#100;
b = 8'b00000010;
// ------------------------------------// ------------- Current Time: 500ns
#100;
a = 8'b00000001;
b = 8'b00000011;
// ------------------------------------// ------------- Current Time: 700ns
#200;
a = 8'b00000011;
b = 8'b00000001;
// ------------------------------------// ------------- Current Time: 800ns
#100;
b = 8'b00000010;
end
endmodule