A ripple carry adder is an arithmetic circuit which adds two N-bit binary numbers and outputs their N-bit binary sum and a one bit carry.
We can build a N-bit ripple carry adder by linking N full adders together.
Each full adder is used to generate the sum and carry bits for one bit of the two inputs.
The full adder for the least significant bit has a carry input of 0
.
All of the other full adders have their carry input wired to the carry output of the full adder which deals with the
immediately less significant input bits.
The carry output of the full adder dealing with the most significant input bits becomes the carry output of the ripple carry adder.
The sum outputs of the N full adders forms the ripple carry adder's N-bit sum output.
The name "ripple carry" comes from the fact the the carry ripples from one full adder to the next.
The following Verilog code shows a 4-bit ripple carry adder. The code for the full adder is also shown for completeness.
module ripple_carry_adder(S, C, A, B);
output [3:0] S; // The 4-bit sum.
output C; // The 1-bit carry.
input [3:0] A; // The 4-bit augend.
input [3:0] B; // The 4-bit addend.
wire C0; // The carry out bit of fa0, the carry in bit of fa1.
wire C1; // The carry out bit of fa1, the carry in bit of fa2.
wire C2; // The carry out bit of fa2, the carry in bit of fa3.
full_adder fa0(S[0], C0, A[0], B[0], 0); // Least significant bit.
full_adder fa1(S[1], C1, A[1], B[1], C0);
full_adder fa2(S[2], C2, A[2], B[2], C1);
full_adder fa3(S[3], C, A[3], B[3], C2); // Most significant bit.
endmodule // ripple_carry_adder
module full_adder(S, Cout, A, B, Cin);
output S;
output Cout;
input A;
input B;
input Cin;
wire w1;
wire w2;
wire w3;
wire w4;
xor(w1, A, B);
xor(S, Cin, w1);
and(w2, A, B);
and(w3, A, Cin);
and(w4, B, Cin);
or(Cout, w2, w3, w4);
endmodule // full_adder
When given test inputs, the 4-bit ripple carry adder generated the following waveform:
Mano, M. Morris, and Kime, Charles R. Logic and Computer Design Fundamentals. 2nd Edition. Prentice Hall, 2000.
Copyright © 2014 Barry Watson. All rights reserved.