In this puzzle, you will learn how to perform basic arithmetic using a logic circuit called a full adder.
Background
Why are adders important? Lots of basic computation and math is dependent on addition and multiplication, making adders a crucial circuit for computers. And while doing basic arithmetic may seem to be a solved problem, there is actually lots of ongoing research on how to optimize adders. When so many of a computer’s instructions rely on addition, even tiny improvements can make a big difference!
So how are adders built? Let’s first think about the problem:
Puzzle
So let’s check out the full adder design below. This circuit implements a two-bit adder, where each input has one bit.
A + B + Cin = S with Cout
While there is an OR gate in the design, there are several other logic gates too. Using the truth table below, can you make sense of the other logic gates?
Switch # | |
---|---|
1 | A |
2 | B |
3 | Cin |
Cin | A | B | S | Cout |
---|---|---|---|---|
0 | 0 | 0 | 0 | 0 |
0 | 0 | 1 | 1 | 0 |
0 | 1 | 0 | 1 | 0 |
0 | 1 | 1 | 0 | 1 |
1 | 0 | 0 | 1 | 0 |
1 | 0 | 1 | 0 | 1 |
1 | 1 | 0 | 0 | 1 |
1 | 1 | 1 | 1 | 1 |
Extra credit: using this circuit, can you build a four-bit full adder? This circuit needs to accept two two-bit values, A and B, and a carry-in bit. It needs to output a two-bit value, S, and a carry-out bit.
Feel free to play around to try to figure it out. You can always return to the logic gate tutorial if you need a refresher.
You can also check out the solution.