Arithmetic Unit

A project log for CPU parts made from discrete components

Prototyping some processor functions using logical gates made of discrete transistors, resistors and diodes

PavelPavel 01/22/2019 at 06:460 Comments

The ALU (Arithmetic Logic Unit) is arguably is a heart of any CPU, which is doing the operations on the bits and bytes of data.

Here I am making an Arithmetic half of it, the circuit which, in my case, is going to do additions and subtractions on 8-bit binary numbers.

For it I am using only NAND gates, which are the smallest DTL gates I can make from discrete components -- and these already 7 parts per gate.

Lets start to build up this unit.

Here is the classical schematic for a full adder:

Here no NAND gate in sight. But theoretically, one can make any other gate from NANDs, so this should not discourage us. We can substitute XORs by groups of 4 NAND gates:

And we can also easily substitute AND-OR combination with NAND-NAND, and logical function will stay the same:

And now, one can see that highlighted pairs of NAND gates are doing exactly the same work, and we can safely eliminate two of them without compromising the whole circuit:

For the unit to do subtractions, we need a way to conditionally invert the B input - and this can be done with just one other XOR gate, which in this case will also be 4 NAND gates instead:

After stacking 8 of these units, and making conditional inverting on Carry in +adding C_in enable we are having a full-fledged 8-bit ripple adder-subtractor. If we are also  using output from the middle XOR group (right before C_in input), we than have a "free" XOR/XNOR functionality.

On the completion of this stacking we are getting this:

This configuration of gates is almost exactly the same as on the actual board.

Implementing this the way I do, the board looks like this:

On the photo is a complete board during testing. The only additional parts are L7805 voltage regulator with a pair of caps on the lower right, near alligators.

Pin headers are used as convenient connection points; this was done for connecting with some other boards in the future, most prominently, with control panel, which will be described in the next log.

Here is parts count for this board:

Part namecount
Perfboard 78*36 holes1
2N2222A npn transistor110
1N4148 diode218
Resistor 10k110
Resistor 20k109
Resistor 47k109
Red LED (clear)109
L7805 Voltage regulator1
Capacitor 0.1uF1
Capacitor 0.33uF1
Pin headers x84
Pin headers x41
Power connector1
Total parts775