Latest Post

Ads

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

Verilog Code for Full Subtractor Structural/Gate Level Modelling

module full_sub(borrow,diff,a,b,c);
output borrow,diff;
input a,b,c;
wire w1,w4,w5,w6;
xor (diff,a,b,c);
not n1(w1,a);
and a1(w4,w1,b);
and a2(w5,w1,c);
and a3(w6,b,c);
or o1(borrow,w4,w5,w6);
endmodule

//Testbench code for Full Subtractor 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:


RTL Schematic:
Full Subtractor Verilog

Other Verilog Programs:

Go to Index of Verilog Programming

Comments

Ads

Popular posts from this blog

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

VLSI: 4-1 MUX Dataflow Modelling with Testbench

VLSI: Half Subtractor and Full Subtractor Gate Level Modelling

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