An 8-Bit ALU, Entirely From NAND Gates

One of the things that every student of digital electronics learns, is that every single logic function can be made from a combination of NAND gates. But nobody is foolhardy enough to give it a try, after all that would require a truly huge number of gates!

Someone evidently forgot to tell [Notbookies], for he has made a complete 8-bit ALU using only 4011B quad NAND gates on a set of breadboards, and in doing so has created a minor masterpiece with his wiring. It’s inspired by a series of videos from [Ben Eater] describing the construction of a computer with the so-called SAP (Simple As Possible) architecture. The 48 4011B DIP packages sit upon 8 standard breadboards, with an extra one for a set of DIP switches and LEDs, and a set of power busbar breadboards up their sides. He leaves us with the advice borne of bitter experience: “Unless your goal is building a NAND-only computer, pick the best IC for the job“.

We have covered countless processors and processor components manufactured from discrete logic chips over the years, though this makes them no less impressive a feat. The NedoNAND has been a recent example, a modular PCB-based design. TTL and CMOS logic chips made their debut over 50 years ago so you might expect there to be nothing new from that direction, however we expect this to be  well of projects that will keep flowing for may years more.

Via /r/electronics/.

18 thoughts on “An 8-Bit ALU, Entirely From NAND Gates”

1. An ALU is an interesting piece of circuitry. But I am though curious to what bit wise functions this one is implementing.

Since there is no formal definition in the industry of what is required for a circuit to be an ALU, it could be an adder and a selectable AND gate and it would likely count as an ALU as far as I know.

But I guess most people would also like to see OR, Not, and maybe an XOR function as well. And likely some bit shifting too.

1. Steven Clark says:

My guess is just selectable add and subtract with configurations or ways of interpreting the outputs for signed and unsigned. I’m mostly going off the minimum of parts I’ve seen use the ALU schematic symbol.

1. excessible says:

Which appears to be about right. There is the following line in the article: “My ALU is about as simple as one can be as it can only add and subtract 8 bit numbers, but as we’ll see even this is pretty complicated when you are doing it with quad-NAND gates.”

2. Mark says:

RTFP. He talks about adding and subtracting, and the schematic shows only one control bit and not even a carry-in. So there are 0 bit-wise functions built in.

1. Winston says:

Very cool.

2. bufferscotch says:

Great job, Olivier :D

2. Winston says:

If you look at the full sized image of the breadboarded ALU:

https://hobbyundecided.files.wordpress.com/2018/01/alu.jpg

you’ll see that he is using what looks like two pin 0.1″ headers to connect adjacent pins on the ICs, the headers inserted upside down with the longer pins bent together and soldered providing the connectivity and something to grab to place and remove the shorts. A great idea I’ve never seen before.

1. Thanks. They’re actually inserted long side down – I bent the short side together with some pliers.

2. He uses those headers to make an inverter from a 2in NAND. He could have saved a lot of chips if he had used XOR gates like a 7486.

1. paul says:

He could have even saved more chips if he used an tiny AVR.

3. jb says:

This certainly isn’t an ALU – it’s an adder/subtractor, which is somewhat simpler than an ALU. To be an ALU it would, in my opinion, need to do at least AND and OR as well.

While all projects of this king are interesting building computers from a single type of logic element isn’t new. The best know computer using a single logic element was the Apollo Guidance Computer which was made from 3-input NOR gates.

1. It does some arithmetic it’s based on logic IC’s when all mashed together on a bread board it has created a unit has all the signs of an ALU. do the wires have to dance ?

4. An ALU needs to contain (at a minimum) Add, Nand.

With Nand we can invert an input, since
~(a&1) = ~a.

Thus, subtraction: a-b = a+~(b&1)+1 is then possible.
And = ~( ~(a&b) &1).
Or = ~( ~(a&1) & ~(b&1)).
XOR = (a+b)-2(a&b) = (a+b)+2*~(a&b)+1.

5. Ren says:

The 2 bit adder I built for class pales in relation to this!

6. Xeon says:

absolutely love builds like this, you can learn so much,

This site uses Akismet to reduce spam. Learn how your comment data is processed.