Building a 4-bit adder from transistors

Overview

During lockdown, I decided to build a simple calculator from transistors which had been on my bucket list for some time. Given my limited supply of electrical components and breadboards, I ultimately decided to limit the computer’s operations to 4-bit addition and incorporate a byte of memory to store the input numbers in. The final electrical circuit required only the following components:

Breadboard computer from transistors
Top view onto the calculator. The first three breadboards from the left contain the addition circuit (1 half adder and 3 full adders). The fourth breadboard contains 1 byte of flip-flop memory that stores the two input numbers. The right-most breadboard contains the switches that set the input bits, memory reset switches, and LEDs to display the sum. [View uncompressed]

The addition circuit

The rules of binary and decimal arithmetic are quite similar, with the primary difference being the base of the number system used. When adding two binary numbers, one starts by adding the rightmost column of bits and works towards the left. Bit sums greater than 1 are carried over to the next column. This process, known as “carry propagation,” results in two outputs: the sum and the carry bit. The carry bit is subsequently used as a third summand in the addition of the next pair of digits. The table below shows how to add two bits

ABCarry-inSumCarry-out
00000
00110
01010
01101
10010
10101
11001
11111

The logic circuit used to add A, B, and the carry-in bit is known as a full adder, which is more complex than the simpler half-adder used for adding the rightmost bit column that does not have a carry-in bit. The standard logic circuit for half adders consists of only an AND and XOR gate, however, these circuits require a lot of electrical components.

XOR-AND half adder vs. NOR half adder
Half adders can be constructed from AND and XOR gates (see left). However, the more complicated version using only NOR gates (see right) requires fewer electrical components. [View uncompressed]

Here is a table with some bit operations on A and B for reference.

ABANDNANDORNORXOR
0001010
0101101
1001101
1110100

A key consideration in designing my calculator was the construction of the addition circuit using logic gates while minimizing the number of electrical components needed. I eventually found that building the half and full adders entirely out of NOR gates minimizes the number of electrical components needed as each NOR gate requires only one transistor and three resistors. This approach allowed me to build half and full adders using only 5 and 9 transistors, respectively. An added benefit of this approach was that using only one type of logic gate kept the final circuit more organized.

Full adder from XOR, AND, and OR gates
This is the standard logic circuit for a full adder. Building this circuit requires a lot of electrical components. [View uncompressed]

Full adder from NOR gates
Alternatively, the full adder can be built entirely from NOR gates. Each NOR gate requires only 1 transistor. [View uncompressed]

Logic circuit of 4-bit adder
A 4-bit adder circuit can be created by chaining together a half-adder and three full adders. Specifically, the carry-out terminal of an adder is connected to the next adder's carry-in terminal. [View uncompressed]

To create a 4-bit adder, multiple adders are chained together by connecting their carry-out terminal to the next adder’s carry-in terminal as shown in the figure above. The first adder in the chain does not have a carry-in and, thus, the simpler half-adder is used. The carry-out bit of the last adder in the chain is considered to be part of the sum.

NOR gates from transistors

NAND and NOR gates from transistors
The right circuit shows the simplified version of the NOR gate I used for my circuit. It is based on the left and middle circuits which are taken from the book 'Engineer's Mini-notebook: Digital Logic Circuits' (Radio Shack, 1985). [View uncompressed]

The “Engineer’s Mini-notebook: Digital Logic Circuits” (Radio Shack, 1985) on page 6 shows how to build simple logic gates using resistor–transistor logic (RTL). The middle circuit in the figure above shows their version of a NOR gate which was constructed from 2 NPN transistors and 3 resistors. I used a simplified version of the NOR gate which only used one transistor (see the right circuit above).

Connecting both inputs to a single transistor base does not impact the circuit in most cases. However, when a voltage is applied to both inputs A and B, the base current will be twice as high as that of the 2-transistor NOR gate. This wasn’t much of an issue though since my PN2222A transistors can handle higher currents than my power source could produce. Additionally, the transistor’s specifications indicate that its collector current is nearly invariant to changes in the base current once the transistor is saturated.

For more complex logic circuits, it may be appropriate to calculate the optimal resistance values using specialized software that takes into account fan-out, optimal operating voltages, etc.

The memory circuit

Circuit diagram for flip-flop memory
This logic circuit for flip-flop memory requires only 2 NOR gates. Applying a voltage to S will set M to 1. Applying a voltage to R will reset set M back to 0. [View uncompressed]

To store my calculator’s input numbers, I used a simple flip-flop whose logic circuit you can see above. Just like the half and full adders, I built the flip-flop entirely from NOR gates. According to Wikipedia, “Static RAM (SRAM) consists of flip-flops, a bistable circuit composed of four to six transistors.” However, since I used a simplified version of the standard NOR gate, I was able to build mine out of only 2 transistors. As the GIF below demonstrates, the memory worked as expected.

Setting and resetting flop-flop memory
I connected the reset terminals (R in the figure above) so that I could reset all bits for each input number at once. The memory's output is fed directly into the addition circuit.

The completed calculator

Circuit adding binary numbers
Each input can represent 16 numbers (0-15) yielding a total of 256 different input combinations. The green and blue LEDs show the binary representation of the two summands and the red lights show the sum.

Complex breadboard circuit
The white jumper cables carry the memory values into the half and full adders. The red wires on the breadboard connect the NOR gates to form the half and full adders. The red jumper cables are used for carry propagation. The black jumper cables carry the sum bits to the red output LEDs. [View uncompressed]

Breadboard computer with LEDs
[View uncompressed]

Electrical circuit with LEDs glowing in the dark
[View uncompressed]

Breadboard design template

Breadboard design template
My breadboard design template. [View uncompressed]

I made this breadboard design template to sketch out some designs and optimize the layout of my circuits prior to building them. It can be imported into GoodNotes or printed out -I made a light version of it too. The breadboard template can be downloaded using this link.