2 bit Full Subtractor using NAND:
We know that full subtractor takes 3 input and produces 2 output as difference and borrow. So using the circuit diagram of 1-bit full subtractor, we designed a 1-bit full subtractor using NAND gate. In order to make 2-bit full subtractor, we instantiate 1-bit full subtractor and takes the input and output as 2-bit. Hence, the 2-bit full subtractor is implemented.
Verilog code for 2 bit full subtractor using NAND:
module full_sub(diff,bout,a,b,bin);
output diff,bout;
input a,b,bin;
wire d1,d2,d3,d4,d5,d6,d7;
nand n1( d1,a,b);
nand n2(d2,a,d1);
nand n3(d3,b,d1);
nand n4(d4,d2,d3);
nand n5(d5,bin,d4);
nand n6(d6,d5,d4);
nand n7(d7,bin,d5);
nand n8(diff,d6,d7);
nand n9(bout,d7,d3);
endmodule
module full_sub_2bit(diff,bout,a,b,bin);
output[1:0] diff;
output bout;
input[1:0] a,b;
input bin;
wire b1;
full_sub fs0(diff[0],b1,a[0],b[0],bin);
full_sub fs1(diff[1],bout,a[1],b[1],b1);
endmodule
OUTPUT:
We know that full subtractor takes 3 input and produces 2 output as difference and borrow. So using the circuit diagram of 1-bit full subtractor, we designed a 1-bit full subtractor using NAND gate. In order to make 2-bit full subtractor, we instantiate 1-bit full subtractor and takes the input and output as 2-bit. Hence, the 2-bit full subtractor is implemented.
Verilog code for 2 bit full subtractor using NAND:
module full_sub(diff,bout,a,b,bin);
output diff,bout;
input a,b,bin;
wire d1,d2,d3,d4,d5,d6,d7;
nand n1( d1,a,b);
nand n2(d2,a,d1);
nand n3(d3,b,d1);
nand n4(d4,d2,d3);
nand n5(d5,bin,d4);
nand n6(d6,d5,d4);
nand n7(d7,bin,d5);
nand n8(diff,d6,d7);
nand n9(bout,d7,d3);
endmodule
module full_sub_2bit(diff,bout,a,b,bin);
output[1:0] diff;
output bout;
input[1:0] a,b;
input bin;
wire b1;
full_sub fs0(diff[0],b1,a[0],b[0],bin);
full_sub fs1(diff[1],bout,a[1],b[1],b1);
endmodule
OUTPUT:
0 Comments