5.2 The Structure of a Computer, Seen Through the CPU and Memory

This book follows a single question: how does the code we write actually run inside a computer? The answer lies in understanding the computer and, above all, the inside of the chip that runs the code. We started from transistors and gates and worked our way, step by step, up to circuits that compute, select, and remember precisely so that we could understand the circuits that make up a computer from the ground up. But just as staring at the engine alone won’t tell you how a car drives, circuits alone can’t show everything about how code runs. So, with those circuits in hand, let’s turn our attention back to the computer as a whole.

A computer is made up of a great many parts, but here we’ll again look at an abstract structure that keeps only the essentials. Let’s approach it in this section in two stages. First, we’ll see how the three kinds of circuits from Section 5.1 fit into this abstract structure. Then we’ll find out how that structure connects to the parts of a real computer.

A computer containing a CPU chip (computing circuit, control circuit, and registers as storage circuits) and memory chips (DRAM storage circuits) exchanging addresses and data, with input and output on either side
Figure 5-3. Computer structure: CPU chip + memory chips

Figure 5-3 redraws the abstract, function-level picture of the computer from Figure 2-1 in Chapter 2, this time in terms of chips. What actually does the work between input and output is two chips: the CPU chip (a system semiconductor), which handles computation, and the memory chip (a memory semiconductor), which handles remembering.

So where in this structure are the three circuits from Section 5.1? As Figure 5-3 shows, the computing circuit and control circuit are inside the CPU chip, and the storage circuit is in the memory chips. Of course, as we saw in Sections 2.3 and 4.8, the CPU chip also contains small storage circuits called registers. But the large storage space that holds the values used in calculations and their results is memory, so here let’s keep it simple: the computing and control circuits = the CPU, and the storage circuit = memory (DRAM). The activity of the three circuits we saw in Figure 5-2 then becomes an exchange between two chips. The control circuit in the CPU sends an address to the memory chip to fetch a value, the computing circuit in the CPU computes with that value, and the result is stored back in the memory chip. This is why these two chips, which divide the three circuits between them, are regarded as the core components of a computer. (Not every device splits things into two chips this way, by the way. In small devices, they are sometimes put together on one chip.)

So far we’ve looked at the two chips that are the core components of a computer, the three circuits they contain, and how those circuits work together, exchanging addresses and data between the two chips. Now, for the second stage, let’s see what this abstract structure looks like in a real computer.

Figure 5-4 shows the inside of a typical computer, as you’d see it with the side panel of a desktop case removed. (This one is a desktop, but the smart devices described in Chapter 1, such as smartphones and tablets, are all computers too, so apart from the size of the parts, the overall makeup is similar.) At first glance the electronic parts look hopelessly tangled, but with a little abstraction, the core components described above (the CPU, memory, and so on) start to stand out. Drawing the main electronic parts visible in Figure 5-4 in abstract form gives us Figure 5-5.

A photo of the inside of a desktop computer, with numbered labels for (1) the CPU location under the cooler, (4) memory, (5) the graphics adapter, and (6) storage (an SSD)
Figure 5-4. Inside a computer (actual photo)
A diagram in which the CPU (registers and ALU) connects to memory over the memory bus, while the mouse, keyboard, graphics adapter with monitor, and storage connect over the I/O bus
Figure 5-5. The main components of a computer

In Figure 5-5, you can see the CPU ① at the top left and memory ④ at the top right. Figure 5-4 marks the actual CPU and memory with the same numbers. Note, though, that the round part you see at the CPU ① position in the photo is the cooler; the actual CPU chip is hidden beneath it. These are the two core electronic components of a computer that we looked at earlier.

Inside the CPU, the ALU (Arithmetic Logic Unit) corresponds to the computing circuit, and although it isn’t shown, the control circuit is there inside the CPU as well.

We’ve called memory ④ the representative storage circuit, but as we briefly noted about registers, memory spaces are divided into several layers (Section 2.3). Inside the CPU there are also registers (② in Figure 5-5), which briefly hold values just before and after a computation, and cache, which holds copies of part of memory. You’ll likely recall that since there are only a few registers, they sit right beside the computing circuits and are wired to them directly, so values travel the shortest distance and registers are the fastest. Storage devices such as SSDs, which keep their data even when the power is off, are also a kind of storage circuit — that’s the storage device ⑥ at the bottom right of Figure 5-5. As we saw in Section 4.8, although the elements and methods for holding 1 bit differ, these are all circuits that store information.

By the way, the bus in Figure 5-5 is the set of wires that carries electrical signals (information) between physically separate parts — in other words, a “connecting passage.” It acts as a kind of road, and it falls broadly into two types according to its use.

One is the memory bus, which connects the CPU and memory. The addresses and data that passed between the CPU chip and the memory chip in Figure 5-3 travel over this memory bus in a real computer.

The other is the I/O bus, which leads to input devices such as keyboards and mice and output devices such as monitors. The signal from a key press comes into the computer along this path, and the data to be drawn on the screen goes out along this path to the graphics adapter ⑤, where it is turned into signals the monitor understands and then displayed (see how the Tetris screen was drawn in Section 2.4).

In this section, we matched the three circuits from Section 5.1 to the abstract structure of a CPU chip and memory chip (Figure 5-3), and then found those parts inside a real computer (Figures 5-4 and 5-5). The circuits we learned about in earlier chapters make up every corner of a real computer in just this way.

So what does the CPU look at to decide which values to fetch and what to compute? Let’s now turn to the key to that question: instructions.

Leave a question or comment

Questions, corrections, or thoughts about this section are welcome. Your first comment will appear after review. (Privacy Policy)