How a computer works — the short version

You can get a rough appreciation for how a computer works just by grasping a small hundful of ideas.

1. Numbers flow along busses

Computers represent numbers using electricity. They do this by turning circuits on or off. For example, imagine you have a bundle of 4 wires, each of which can be independently turned on or turned off. Now, we could turn all 4 wires on. Or we could turn all of them off. Or we could turn the left-most one on and all the others off. Or we could turn the two outermost wires off and the two in the middle on. Or several other possible combinations.

If we take all possible on/off patterns and number them, then we could set our 4 wires to (say) the 5th combination, and say that that represents the number 5. With 4 wires, there are 16 combinations mathematically possible. (Trust me, I counted.) So with our bundle of 4 wires, we can represent 16 possible numbers.

Incidentally, rather than writing “on, on, off, off”, we use the number 0 to signify a wire that’s off, and 1 to signify a wire that’s on. Now we can just write 1100, which is quite a bit shorter. If you’ve ever seen long patterns of 1s and 0s used in relation to computers, this is what it’s talking about; each 1 literally represents an electronic circuit somewhere inside the computer that’s switched on, while each 0 denotes such a circuit that’s switched off.

A “bunch of wires” which are used to convey a number from place to place is called a bus. Using busses, we can make numbers flow from place to place like water (or… electricity, actually).

2. Registers store numbers

There is a device known as a latch. A latch has an output wire, which reads whether the latch is currently on or off. It also has some input wires.

The most basic kind of latch is a set/reset latch or SR latch. It has two input wires, labelled “set” and “reset”. If you turn on the set-wire, the latch switches on. If you turn off the set-wire, the latch stays switched on. Similarly, if you turn on the reset-write, the latch turns off. If you can off the reset-wire, the latch stays switched off.

In this way, a latch “remembers” whether the last signal it received as a set signal or a reset signal. This allows it to store a 0 or a 1. But on its own, that’s not terribly impressive.

There’s a more complicated kind of latch called a data latch or D latch. This has a “data” input. The idea is that when the data input is on, the latch turns on, and when the data input is off, the latch turns off. But that would mean that the latch doesn’t actually “remember” anything. So the latch actually has two inputs; one is data, the other is a “write enable” input. When write enable is on, the latch sets its output equal to the data input. But when write enable is off, the latch ignores the data input completely and just remembers whatever it was last set to.

Suppose, now, that we have a row of 4 identical D latch circuits. We can connect each of their outputs to a wire, and this bunch of wires now forms an output bus that lets us read the current state of all the latches at once. We can then connect the data input of each latch to an input bus. Finally, we connect all the write enable wires together, given us a single write enable wire that controls all the latches at once.

In this way, this row of latches stores a 4-digit code, which we can write using the output bus. We can send whatever code we like through the input bus, but the latches ignore it until we turn on the (common) write enable wire. This row of latches thus “remembers” what was on the input bus the last time writing was enabled.

A row of latches such as this is called a register, and is basically how computers store numbers. A typical register has an output bus, which lets you read the current contents of the register, an input bus, and a write enable wire, which let you overwrite the contents of the register.

3. Busses have junction points

There is a device called a multiplexer. It’s rather like the junction points on a train track. Two busses go in, and one bus comes out. A control wire selects which input bus the output bus gets connected to. If the control wire is off, the left input bus is connected to the output bus. If the control wire is on, the right input bus is connected to the output bus.

In this way, a computer can have a tangle of busses running all over the place, connected together by a maze of multiplexers. By sending the right combination of control signals to all the multiplexers, you can route signals wherever you want them to go.

4. Computing is routing

Somewhere, burried away inside the computer, is an adding circuit. Two busses flow in, one bus flows out. Whatever numbers are on the input busses, the output bus has the sum of those two numbers. This happens even when the input busses are disconnected; in that case, all the input wires are off, signifying 0. Since 0 + 0 = 0, the output bus wires are all off as well. But even when disconnected, the adder circuit is constantly adding.

To make the computer “add two numbers”, all you have to do is send the right control signals to route the first number to the left input of the adding circuit, and then route the second number to the right input of the adding circuit, and then route the output of the adding circuit to wherever you want to store the total.

You know how you subtract two numbers? Exactly the same way, except this time you route the signals through a subtracting circuit rather than an adding circuit. You want to take a guess how you multiply two numbers?

So, in a very real sense, to make the computer do the right calculations, you just need to generate the right combination of control signals to route the numbers where you want them to go.

5. Controlling is sequencing

All the control lines route back to a master control unit. This, then, is where all the “intelligence” is, right?

In fact, it turns out that all you really need is a sequencer matrix. This works something like a mechanical music box, or those fairground organs that are operated by punch cards.

You have all the control wires in the system come in as horizontal wires, and you have a bunch of vertical timing wires. On each clock cycle, you turn on the next timing wire in the sequence. (And when you get to the end last wire, you go back to the beginning again.) If a particular control line is supposed to turn on during a particular step, you connect that timing wire to that control line. Otherwise you don’t make that particular connection. In this way, at each step, the right combination of control lines turn on.

Leave a Reply