Quick Overview of a Computer

Diagram

We want to create a computer that is as simple as possible, so that it's easy to understand.

In particular, our computer consists of a CPU, memory, and a bus to connect the two.

The CPU contains a handful of registers (usually, no more than 100, and sometimes as little as 4, depending on the kind of CPU), which acts like local variables. The CPU runs instructions and performs computations, mostly by the ALU (arithmetic-logic unit). However, there's very little memory on the CPU itself (we'll ignore cache for now). The registers are the only memory the CPU has. Register memory is very fast for the CPU to access, since it resides on the CPU itself.

In addition to the CPU is memory (more specifically, RAM). Memory is basically a large array of bytes. Memory stores data, instructions (i.e., programs) and garbage (i.e., not every memory location stores useful information). The CPU can read or write to the memory, but it's much slower than accessing registers. Nevertheless, you need memory because registers simply hold too little information.

What the CPU does

If you take an introductory course in programming, you might be told that the CPU is the "brains" of the computer.

However, I don't like the idea of referring to the CPU as a brain because it brings up all sorts of issues related to artificial intelligence. Are computers intelligent? What defines intelligence? Does a CPU model a human brain?

I prefer to think of a computer as simple a device that computes. Computers run instructions. Instructions are low-level commands like add, subtract, or compare two numbers, and run some instruction if the comparison is true, and run some other instruction if it's false.

Instructions are, in general, very simple. By the time a CPU is processing an instruction, it is in binary format. That is, the instruction is encoded in 0's and 1's.

However, the CPU has rather limited memory (if we ignore cache). All the local memory it uses is in registers. It has very fast access to registers, which are on-board the CPU. It has much slower access to RAM.

The bulk of the memory is stored in a separate device called RAM (often called physical memory). RAM stores programs as well as data. In essence, the CPU fetches an instruction in RAM (to a register), determines what instruction it has, and executes the instruction.

Executing the instruction may require loading data from RAM to the CPU or storing data from the CPU to RAM.

Memory

Most of the memory is in RAM, which can be thought of as a large array of bytes. In an array, we can refer to individual elements using an index. In computer organization, indexes are more commonly referred to as addresses.

Most memory is byte-addressable, meaning that each address refers to one byte of memory.

Bus

The CPU and RAM are connected by a bus. A bus is essentially a bunch of wires. We subdivide the bus into three categories: a data bus, an address bus, and a control bus (which is not shown on the diagram above).

For example, to fetch an instruction, the CPU writes the address of the instruction in RAM on the address bus. It then sends a control signal to RAM alerting it that it wants to read from the RAM.

The RAM responds to the signal by reading the address from the address bus, then writing the contents of memory at that address on the data bus. The contents of memory at that address is an instruction. The RAM then sends a signal back to the CPU alerting the CPU that it has placed valid data on the data bus.

The CPU then fetches the instruction off the data bus, and places it into a register. It can then begin excuting the instruction it has just read. This may involve loading or storing data in RAM.

Notice that fetching data and fetching instructions is identical. The only difference is where in memory the data is located and where in memory the instructions are located.

A More Realistic Picture

We're missing several components of a real computer. For example, there's no disk (hard drive), nor any I/O devices (monitor, keyboard, mouse, etc). Often, the bus is somewhat more complicated, becaues of I/O devices.

I/O devices often run on their own bus, and that bus is connected to the main bus.

With many devices on a bus, there's a problem. Only one device should write to the bus at any one time (see class notes on bus). There may need to be a device which arbitrates which device can write to the bus at any given time.

Why Separate the CPU from Memory

Perhaps the simplest reason to have CPU separate from memory is flexibility. As time passes, you may wish to increase memory. If it were part of the CPU, you'd have to replace CPU and memory.

Also, if you've ever bought memory, you know that it's physically quite large compare to the CPU. The CPU is usually squarish, perhaps as much as 2 inches, or maybe 5 cm, to a side, while memory comes in a card that's perhaps 8 inches wide (20 cm).

In any case, the CPU is almost always a separate device from memory, and so we model a computer where the CPU and memory are different.

There's also a big difference in performance. The CPU almost always operates much, must faster than memory. Accessing memory from RAM is usually about several hundred times slower than accessing memory from registers.

Thus, memory is often the bottleneck in performance. The real problem is that memory speeds have not kept up with processor speeds. Processors have been increasing in speed at a faster pace than RAM. Still, with the use of cache (which is fast, small memory), such speed problems are allieviated to some degree.

Summary

A simple computer consists of a CPU and physical memory (called RAM). The CPU performs the computations, while the memory stores the information to do the computations with, as well as the instructions on what to compute.

Web Accessibility