How do we add two numbers using logic gates?

Apr 9, 2017

See explanation...

Explanation:

Suppose you have $3$ bits, represented by Boolean values $a$, $b$ and $c$. That is true represents $1$ and false represents $0$.

The result of adding $a$, $b$ and $c$ modulo $2$ is:

$\left(a \wedge b \wedge c\right) \vee \left(a \wedge \neg b \wedge \neg c\right) \vee \left(\neg a \wedge b \wedge \neg c\right) \vee \left(\neg a \wedge \neg b \wedge c\right)$

In fact, if you denote exclusive or by $\oplus$ then an alternative expression for this is simply:

$a \oplus b \oplus c$

In logic gates this looks like:

The overflow/carry bit resulting from adding $a$, $b$ and $c$ is:

$\left(a \wedge b\right) \vee \left(a \wedge c\right) \vee \left(b \wedge c\right)$

In logic gates this expression could be implemented like this:

The combination of these two arrangements of logic gates implement a $1$ bit binary adder with carry in and out.

When you add two binary numbers using long addition, for each column (starting from the rightmost column) take $a$ from the first number, $b$ from the second number and $c$ from the carry from the previous column.

Then the two complex operations we found will give you the result digit and the carry digit for the next column.

To add more than one binary column at a time, you can chain as many one bit adders as you require together.