Friday, 9 January 2015

Design a Ripple Carry Adder using Full adders


An adder is a digital circuit that performs addition of numbers. These adders are not only used in Arithmetic and logic unit but also in various components of the computers. 

It is possible to create a logical circuit using multiple full adders to add N-bit numbers. Each full adder inputs a Cin, which is the Cout of the previous adder. This kind of adder is called a ripple-carry adder, since each carry bit "ripples" to the next full adder





Ripple carry adder verilog code:

module ripplecarryadder (a,b,cin,sum,cout);
input [3:0]a;
input [3:0]b;
input cin;
output [3:0]sum;
output  cout;
wire c1,c2,c3;
fulladder fa1(.a(a[0]),.b(b[0]),.c(cin),.sum(sum[0]),.carry(c1));
fulladder fa2(.a(a[1]),.b(b[1]),.c(c1),.sum(sum[1]),.carry(c2));
fulladder fa3(.a(a[2]),.b(b[2]),.c(c2),.sum(sum[2]),.carry(c3));
fulladder fa4(.a(a[3]),.b(b[3]),.c(c3),.sum(sum[3]),.carry(cout));

endmodule