Latest Post

Ads

Verilog: 4 Bit Full Adder Structural/Gate Level Modelling with Testbench

Verilog Code for 4 Bit Full Adder Structural/Gate Level Modelling

module four_bit_full_adder(
    input [3:0]a,b,
    input c,
    output [3:0]sum,
    output carry,
               wire c0,c1,c2
    );
               fulladder f0(sum[0],c0,a[0],b[0],c);
               fulladder f1(sum[1],c1,a[1],b[1],c0);
               fulladder f2(sum[2],c2,a[2],b[2],c1);
               fulladder f3(sum[3],carry,a[3],b[3],c2);
endmodule

module fulladder(sum,carry,a,b,c4);
output sum,carry;
input a,b,c4;
wire p,q,r;
xor(p,a,b);
and(r,a,b);
xor(sum,p,c4);
and(q,p,c4);
or(carry,q,r);
endmodule

//Testbench code for Full Adder Structural/Gate Level Modelling

initial begin
// Initialize Inputs
a = 0;b = 0;c = 0;
// Wait 100 ns for global reset to finish
#100;
// Add stimulus here
#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;
end


Output:
VLSI: 4 Bit Full Adder Structural/Gate Level Modelling with Testbench

Comments

Ads

Popular posts from this blog

VLSI: 1-4 DEMUX (Demultiplexer) Dataflow Modelling with Testbench

VLSI: BCD to Excess 3 and Excess 3 to BCD Dataflow Modelling

VLSI: 2 Bit Magnitude Comparator Dataflow Modelling

1 to 4 DEMUX (Demultiplexer) Verilog CodeStructural/Gate Level Modelling with Testbench

Full Subtractor Verilog Code in Structural/Gate Level Modelling with Testbench