4.4 A 1-Bit Calculator: The Adder
In the previous section, we decided the inputs and outputs of the calculator circuit. Now, at last, it’s time to look inside. So, where should we start?
Trying to understand a 4-bit calculator (one that handles −8 to 7) all at once can feel pretty daunting. In fact, that isn’t easy for anyone. So let’s change strategy and start with a simpler form: a 1-bit calculator. There’s a reason for this. Once you understand the 1-bit calculator, the 4-bit calculator is simply four of them joined together. Looking at the small piece first and then moving on to the big picture will turn out to be a rather clever approach.
One more thing before we go on. We’ve been saying “calculator,” but the operations we actually want to handle are limited to addition and subtraction. On top of that, as we saw in Section 4.1, adding a negative number written in two’s complement performs subtraction, so the heart of it all is a circuit that adds. That’s why the circuit we’ll look at is really a 1-bit adder. Let’s take a look inside together.
A 1-bit adder is a circuit that takes two 1-bit inputs, performs the operation, and outputs the result. It might sound complicated, but since each input can only be in one of two states, 0 or 1, there aren’t many possible input combinations. Table 4-3 lists every one of them. From the table, you can see at a glance which output should come out for each input. The thing to notice is the output. It’s normally expressed as 1 bit (Sum), but when both inputs are 1, the result of the addition can’t be expressed in 1 bit. So it’s split out with an extra bit for the carry, called Cout (Carry-Out, the carry output). If carrying feels unfamiliar, it may help to look back at the binary addition in Figure 4-1.
| Input X | Input Y | Output Cout | Output Sum |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 0 |
Let’s read Table 4-3 one row at a time. Adding 0 and 0 naturally gives 0, and adding 0 and 1 or 1 and 0 gives 1. That appears on the output called Sum. The case of adding 1 and 1 deserves a closer look: the result is 10 in binary, which is 2 in decimal — exactly what we’d expect. However, the circuit’s single-bit Sum output can’t hold all of 10, so you can see it split into two: the lower digit, 0, on the Sum output, and the upper digit, 1, on the Cout (carry) output.
Now we have our direction. In the end, a 1-bit adder is a circuit that gives the matching output for each input in Table 4-3. So what does a circuit that does this actually look like? The answer lies in combining the basic logic gates we learned earlier: AND, OR, and XOR.
Figure 4-5 is a circuit diagram of a 1-bit adder built by connecting basic logic gates so that it produces the results in Table 4-3. It has three inputs (X, Y, Cin) and two outputs (Cout, Sum), and it’s made by connecting two AND gates, one OR gate, and two XOR gates. Of course, this isn’t the only way; circuits with the same behavior can be built in many different shapes. What stands out here is probably the third input, Cin (Carry-in, the carry input), which wasn’t in Table 4-3. This input receives the carry passed up from the calculation in the digit just below. In the next section, when we look at a 4-bit adder made by chaining several 1-bit adders together, it will be connected to a Cout and play a key role. For now, you can simply assume it is always 0. Table 4-3 above is exactly the set of results with this Cin held at 0.

Now let’s check for ourselves whether this circuit really works. As we saw earlier, an expression like X=1, Y=0 doesn’t mean we put numbers into the circuit; it means a high voltage is applied to X and a low voltage to Y. Keep in mind the mapping between numbers and voltage states from Section 4.2 as we follow the circuit.
For the input X=1, Y=0 — the output we expect is Sum=1, Cout=0. When X=1 and Y=0 enter the first XOR gate, the two inputs differ, so its output is 1. This output goes to one input of the second XOR gate, and the other input, Cin, is 0, so again the two inputs differ and the output is 1 — this is the final value of Sum. Following the Cout path, the first AND gate gets X=1, Y=0, so its output is 0; the second AND gate also outputs 0; and since the final OR gate’s inputs are 0 and 0, Cout is 0. Sum=1, Cout=0 — exactly the values we expected.
How about tracing the input X=1, Y=1 yourself? With a little time, you’ll see that Cout=1 and Sum=0 come out. In decimal, that’s 1 + 1 = 2 — just the result we were hoping for.
The remaining two cases (X=0, Y=0 and X=0, Y=1) are much simpler, so you’ll be able to check them quickly. By checking all four input combinations with Cin held at 0, you can verify for yourself that the circuit in Figure 4-5 gives the correct output in every case in Table 4-3. The case where Cin is 1 will come up naturally in the next section, when we chain adders together.
How about that? Just by wiring up a few basic logic gates, we have a genuine electronic circuit that can add, producing exactly the outputs Table 4-3 calls for. Looking back on the road from the transistor to here, it feels quite remarkable. Now that we have this 1-bit adder in hand, the next section looks at the 4-bit adder made by lining up four of them side by side.