It's important to understand there's a difference between a half-adder and a full-adder.
A half-adder is the simplest. It has 2 inputs and 2 outputs. It's basically a XOR.
The primary output is only 1 if one of both inputs is 1, but not if both are 1. That's Sum
. The second output is only 1 if both inputs are 1. That's Carry
.
That's nice, but only if you're adding two bits. If you need more bits, you'll have to combine some adders together. Here's where full-adders come into play. The Least Significant Adder is a half-adder, every More Significant will be a full-adder which will take the Carry
of the previous adder.
A B Cin Cout Sum
0 0 0 0 0
1 0 0 0 1
0 1 0 0 1
1 1 0 1 0
0 0 1 0 1
1 0 1 1 0
0 1 1 1 0
1 1 1 1 1
(shamelessly copied from Wikipedia.
If Carry in
is 0
, the behaviour of a full-adder is identical to a half-adder.
However, if Carry in
is 1
, the behaviour of Sum
is inversed and the behaviour of Carry out
changes into a OR. As long as any of the inputs is 1, Carry out
is `.
Carry in
is required to turn a basic 2-bit adder into a multiple-bit counter. That's the purpose of Carry in
.