This flashback is slightly unusual, in that, instead of discussing an old photograph, I’m thinking about something that, back in the 1970s, seemed to me to be a technological miracle. Learning how it worked, and how to design even more complex devices, provided a valuable lesson in how amazingly complex systems can be built from simple components. The image above is my drawing of the first “digital computer” that my family ever owned: a Commodore 776M calculator.

This article explains how, in the space of less than 10 years, I went from regarding computers as mysterious marvels, to learning not only how they work, but also how to design and build them. I even obtained patents for my own new digital circuitry inventions. I’ve tried to keep the technical discussion as basic as possible, while still trying to show how complex systems are built up from simple components.

As I mentioned in a previous post, when I was at school I studied Advanced-Level Math and Physics, but much of what we were taught, even in Physics, was very theoretical, and it wasn’t at all clear how the principles applied to real-world technology, or indeed how real devices worked. To learn how real systems worked, I often had to resort to teaching myself.

## Computers as Black Boxes

The same was true for understanding how computers worked. I was very excited when I was told that, as part of the Physics syllabus, we were going to learn to understand computers, but I was quite disappointed by what we were actually taught.

The teacher explained to us that digital computers use binary arithmetic (the value of every digit can only be 0 or 1), and that computers are built from simple circuits such as so-called “AND” and “OR” gates. The binary 0 and 1 values are represented in the computer by “low” and “high” voltages respectively.

We were able to play around with pluggable electronic “black box” modules that implemented these functions, and we confirmed the results of combining them. We could use **Boolean Logic** to combine the outputs from these gates.

But I *still* thought, “How do you get from *that* to a digital calculator?”

The answer (as I was to learn later on) is by *combining thousands or millions of those basic gates together* to make devices of increasing complexity.

Even after a career of designing digital electronic systems and the software associated with them, I still find it really astonishing how extremely complex devices can be created from such simple basic blocks.

## Building Everything from NAND Gates

There are three basic types of digital computer logic circuit or “gate”:

- NOT gate. The output level is the opposite of the single input level.
- OR gate. The output level is high if
*any*of the input levels is high. A NOR gate is the same but with the output inverted (i.e., an OR gate plus a NOT gate). - AND gate. The output level is high only if
*all*the input levels are high. A NAND gate is the same but with the output inverted (i.e., an AND gate plus a NOT gate).

It turns out that *all* three basic types of digital computer circuit can be built by combining one basic type of circuit, the NAND Gate.

### A Real NAND Gate

My Advanced-Level Physics studies did *not* include electronic circuit design, of course, so it would have been unreasonable to expect to be taught exactly how these gates were implemented. I learned the details later on while studying for my Electronics degree.

The actual circuit for a *real* NAND Gate, implemented as Transistor-Transistor Logic (TTL) is as shown below. This is the diagram for one quarter of the **Texas Instruments 7400** NAND Gate (because the actual chip contained 4 such circuits).

At the time that I began designing hardware, during the 1980s, TTL logic such as this was still the standard way of implementing many designs. I used these gates myself for many designs, starting with my undergraduate final-year project at Imperial College.

To avoid all the circuit details, the entire NAND gate can be represented with a symbol, as below.

The diagram below shows how the connections on the symbol correspond to those in the actual circuit.

## Memory from NAND Gates

To create a useful computer, you need to be able to store numbers in some type of memory.

It turns out that, by combining together a few NAND gates, you can create a simple memory for **one bit** of information. The combination is called a **bistable** circuit (*aka* a **flip-flop**), because (while the power is on) it remains in one of two stable states until an input causes it to change state. This allows you to store the outputs from logic circuits. Each bistable circuit allows you to store 1 bit of binary data.

Here is a diagram of a bistable 1-bit memory circuit, constructed entirely from NAND gates.

The “Clock” input in this circuit can be obtained from *another* simple circuit constructed from NAND gates; the astable circuit, whose output continually oscillates between low and high states.

By lining up 8 bistables in parallel, you can store one **byte** of data.

## From Gates to Functions

Well, that seemed simple enough, but I still didn’t understand how to get from *that* to a digital calculator.

Building a set of flip-flops gives you a way to store a number, but how do you *combine* numbers together? After all, the device is called a “computer” so how does it actually “compute”?

Well it turns out that you can also construct *arithmetic* circuits from—you’ve guessed it!—NAND gates. For example, you can build an adding circuit (called a **Full Adder**) to add together two 1-bit numbers, as shown below.

The circuit adds two 1-bit numbers, A and B, and accepts a carry-in bit from another adder (C_{in}). It generates the sum of the bits and the C_{in } at S, and also a carry-out at C_{out}. By arranging any number of these adding circuits in parallel, and connecting their C_{in} inputs and C_{out} outputs to each other, you can build an adding circuit for numbers of any size.

## Displaying Numbers

When you’ve constructed all the circuitry to allow users to type in numbers and compute the results, you still need a way to display the result to the user, because your calculator will be fairly useless without that.

Those early calculators used “seven segment” displays, which are sets of light-emitting diodes arranged so that, by switching segments on and off, any digit between 0 and 9 can be displayed in a human-readable form.

So, how do you make the segments light up to display a particular number? Well, as you may have guessed by now, the answer is *another* logic circuit, called a **Seven-Segment Display Driver**. Texas Instruments also produced an integrated circuit to provide this function; the 7447 IC.

## Complexity in Biology

Learning how complex computers (such as the device on which you’re reading *this* article) can be built from large numbers of very simple components made it easier for me to understand how the same principle could apply in other fields.

For example, in biology, evolution has created incredibly complex organisms (such as humans) from huge numbers of very basic cellular components. It’s much easier to understand such processes when you know how other complex systems are created, even though the results remain astonishing in all cases.