Full Adder
A full adder adds three bits, two operands and a carry in, producing a sum and a carry out for chaining into multi-bit adders.
What it does
A full adder adds three one-bit values: operand bits A and B and a carry in, Cin, from the previous position. It outputs a sum bit and a carry out, Cout, that feeds the next higher position. This carry input is what makes multi-bit addition possible.
Truth table
| A | B | Cin | Cout | SUM |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 1 |
| 0 | 1 | 0 | 0 | 1 |
| 0 | 1 | 1 | 1 | 0 |
| 1 | 0 | 0 | 0 | 1 |
| 1 | 0 | 1 | 1 | 0 |
| 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 1 |
The gate equations
- SUM = A XOR B XOR Cin, the parity of the three inputs.
- Cout = (A AND B) OR (Cin AND (A XOR B)), a majority of the three inputs.
- It can be built from two half adders and one OR gate.
In code
python
def full_adder(a, b, cin):
s = a ^ b ^ cin
cout = (a & b) | (cin & (a ^ b))
return s, coutBuilding a wide adder
Chaining n full adders, each carry out feeding the next carry in, yields a ripple-carry adder for n-bit numbers. It is simple but slow, because the carry must ripple through every stage; the worst-case delay grows with the word width.
Faster carry schemes
To beat the ripple limit, carry-lookahead, carry-select, and carry-save adders compute or anticipate carries in parallel. All are built from full adders arranged to shorten the carry path, trading more gates for less delay.