The anatomy of a computer (Part 1 of 4)

A idealist, macroscopic overview

Jack Holland
Understanding computer science
6 min readMar 6, 2014

--

This is an ongoing series. Please check out the collection for the rest of the articles.

Alas, dear reader! Today we say goodbye to our beloved friend Cake, the imaginary programming language we have used thus far. But don’t mourn too much because I eventually plan on reviving Cake when we learn to create our own programming language. In the very long meantime, we have more basic matters to discuss.

This sequence is designed to introduce you to the anatomy of a computer. Much like Robert Burton’s The Anatomy of Melancholy, this is a metaphorical anatomy. Much unlike human anatomy, computer anatomy is carefully designed, allowing us to make broad statements about each component’s structure and purpose without losing too much accuracy.

With that in mind, I need to clear up a common misconception before actually starting; what follows is a description of modern electronic computers and by no means does justice to the dizzyingly myriad different computer designs. I discussed this in a bit more detail before, but I want to make sure it’s fresh in your mind. I’m choosing to discuss modern electronic computers before other kinds simply because they’re the most relevant kind for what we’re trying to learn.

Without further ado, here is a basic model of a computer, called the Von Neumann architecture:

The vast complexity of computers is hidden behind a beautifully simple model

For now, ignore the pink boxes and focus on the four major components:

  1. Central processing unit (CPU)
  2. Memory unit (RAM)
  3. Input device (the “I” in I/O)
  4. Output device (the “O” in I/O)

Real computers have more than four components, but this model provides an excellent picture of what computers basically consist of. The central processing unit, usually abbreviated CPU, does virtually all of the computation. It has a certain number of basic instructions, like +, -, *, /, and, or, and others, and computes everything in terms of them. It’s important to note that the CPU performs all of this computation through circuitry; it isn’t software, it’s hardware — as in, a series of logic gates built out of transistors, capacitors, and other electronic components. All of the software (the operating system and applications) works on top of this hardware. Remember, this is a general overview, so you don’t have to understand the physics behind a capacitor to understand what I’m trying to say; absorb the overall structure, not the minute details.

A schematic and the circuit that it represents

The memory unit is commonly referred to as the “RAM”, which stands for random-access memory. random-access indicates that any part of the memory can be read as easily as any other; any part of the memory can be retrieved at random without affecting performance (excepting memory locality). The memory unit keeps track of all of the information that the computer needs. The operating system controls the memory and gives pieces of it to programs that need it; numbers, strings, arrays, and all other program data need to be stored somewhere in memory.

Each unit of memory gets an address, which is just a number, and programs store data by making requests like “store the number 5 at memory address 12345" and “load whatever number is at memory address 12345". Obviously the requests aren’t in English, but they work like these examples suggest.

Why are these requests necessary? Modern memory units have millions to billions of memory addresses for use. This balances the limitation of CPUs; most modern CPUs can store only 64 values at once, a handful of which are reserved for special purposes. In the past CPUs could store even fewer values. But many programs use thousands, millions, or even billions of values. This means that programs must load from memory the values they currently need and unload the ones they no longer need by making requests to the memory unit. Luckily for us, much of this process is automated, but understanding the process is essential to designing efficient programs. No matter how complicated a program is, it cannot force the CPU to store more than 64 values at once; if the program needs more, it must store them in the memory unit and request them when needed.

A slightly simplified model of the brain

A rough analogy for CPU vs RAM is short-term vs long-term memory. Short-term memory is easy to work with and almost immediate. Long-term memory may take a while to summon. But short-term memory can hold only a handful of objects at a time, so if we want to solve more complicated problems mentally, we must move things to and from long-term memory. Of course, we can’t control our brains precisely enough to consciously move objects to and from long-term memory — that process happens mostly behind the scenes. But in computers the process is very deliberate and is the only way to solve complicated problems; the CPU can hold only so many values and must store things in RAM when it doesn’t immediately need them. Fortunately for us programmers, RAM doesn’t fade with time like human memory!

The final components in this model are the input and output devices, commonly referred to as “I/O”, which stands for input/output. I/O is a big theme in computer science and this is a good context in which to introduce it. I/O solves the problem of how computers interact with their environment; if the only components of a computer were the CPU and memory unit, the computer would have no way of exchanging information with the outside world.

The first mouse ever, invented by Douglas Engelbart

There are many ways to give input to a computer. Here are some of the most common ways:

There are also many ways to get output from a computer. Again, here are some of the most common ways:

Some devices act as both input and output:

A close-up of a network adapter, which enables communication with the rest of the Internet

These lists are not comprehensive, but they provide a solid idea of what I/O consists of and how it’s achieved. The focus of these lists has been on personal computers, laptops, cell phones, and other general computers. More specific computers, like those that control microwaves, cars, and egg-timers, may have very different kinds of input and output. An egg-timer, for example, accepts an egg as one of its inputs.

Next post, we’ll introduce some computer components that don’t appear in ideal models but are very necessary when actually designing computers.

--

--