Computing Library › Classical Logic Gates
Classical Logic Gates

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

ABCinCoutSUM
00000
00101
01001
01110
10001
10110
11010
11111

The gate equations

In code

python

def full_adder(a, b, cin):
    s = a ^ b ^ cin
    cout = (a & b) | (cin & (a ^ b))
    return s, cout

Building 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.