|
|
![]() |
| Figure 1: The Central Processing Unit |
Before we discuss the control unit and the
arithmetic/logic unit in detail,
we need to consider data storage and its relationship to the central
processing unit. Computers use two types of storage: Primary storage
and secondary
storage. The CPU interacts closely with primary storage, or main
memory, referring to it for both instructions and data. For this reason
this part of
the reading will
discuss memory in the context of the central processing unit.
Technically,
however, memory is not part of the CPU.
Recall that a computer's memory holds data only temporarily, at the time
the computer is executing a program. Secondary storage holds permanent
or semi-permanent data on some external magnetic or optical medium. The
diskettes and CD-ROM disks that you have seen with personal computers
are secondary storage devices, as are hard disks. Since the physical attributes of
secondary storage devices determine the way data is organized on them, we will
discuss secondary storage and data organization together in
another part of our on-line readings.
Now let us consider the components of the central processing unit.
The control unit of the CPU contains circuitry that uses electrical signals to direct
the entire computer system to carry out, or execute, stored program
instructions. Like an orchestra leader, the control unit does not execute
program instructions; rather, it directs other parts of the system to do so.
The control unit must communicate with both the arithmetic/logic unit
and memory.
The arithmetic/logic unit (ALU) contains the electronic circuitry that executes
all arithmetic and logical operations.
The arithmetic/logic unit can perform four kinds of arithmetic
operations, or mathematical calculations: addition, subtraction,
multiplication,
and division. As its name implies, the arithmetic/logic unit also
performs
logical operations. A logical operation is usually a comparison. The
unit
can compare numbers, letters, or special characters. The computer can
then take action based on the result of the comparison. This is a very
important capability. It is by comparing that a computer is able to
tell, for
instance, whether there are unfilled seats on airplanes, whether
charge-
card customers have exceeded their credit limits, and whether one
candidate for Congress has more votes than another.
Logical operations can test for three conditions:
Memory is also known as primary storage, primary memory, main storage,
internal storage, main memory, and RAM (Random Access Memory); all these terms
are used interchangeably by people in computer circles. Memory is the part of the computer that
holds data and instructions for processing. Although closely associated
with the central processing unit, memory is separate from it. Memory stores
program instructions or data for only as long as the program they pertain to
is in operation. Keeping these items in memory when the program is not
running is not feasible for three reasons:
To see how registers, memory, and second storage all work together, let us
use the analogy of making a salad. In our kitchen we have:
The refrigerator is the equivalent of secondary (disk) storage. It can store high volumes of veggies for long periods of time. The counter top is the equivalent of the computer's motherboard - everything is done on the counter (inside the computer). The cutting board is the ALU - the work gets done there. The recipe is the control unit - it tells you what to do on the cutting board (ALU). Space on the counter top is the equivalent of RAM memory - all veggies must be brought from the fridge and placed on the counter top for fast access. Note that the counter top (RAM) is faster to access than the fridge (disk), but can not hold as much, and can not hold it for long periods of time. The corners of the cutting board where we temporarily store partially chopped veggies are equivalent to the registers. The corners of the cutting board are very fast to access for chopping, but can not hold much. The salad bowl is like a temporary register, it is for storing the salad waiting to take back to the fridge (putting data back on a disk) or for taking to the dinner table (outputting the data to an output device).
Now for a more technical example.
let us look at how a payroll program uses all three types of
storage. Suppose the program calculates the salary of an employee. The
data representing the hours worked and the data for the rate of pay are
ready in their respective registers. Other data related to the salary
calculation-overtime hours, bonuses, deductions, and so forth-is waiting
nearby in memory. The data for other employees is available in secondary
storage. As the CPU finishes calculations about one employee, the
data about the next employee is brought from secondary storage into
memory and eventually into the registers.
The following table summarizes the characteristics of the various kinds of
data storage in the storage hierarchy.
| Storage | Speed | Capacity | Relative Cost ($) | Permanent? |
| Registers | Fastest | Lowest | Highest | No |
| RAM | Very Fast | Low/Moderate | High | No |
| Floppy Disk | Very Slow | Low | Low | Yes |
| Hard Disk | Moderate | Very High | Very Low | Yes |
For more detail on the computer's memory hierarchy, see the How Stuff Works pages on computer memory.. This is optional reading.
Let us examine the way the central processing unit, in association with
memory, executes a computer program. We will be looking at how just one
instruction in the program is executed. In fact, most computers today can
execute only one instruction at a time, though they execute it very quickly.
Many personal computers can execute instructions in less than one-millionth
of a second, whereas those speed demons known as supercomputers
can execute instructions in less than one-billionth of a second.
Before an instruction can be executed, program instructions and data
must be placed into memory from an input device or a secondary storage
device (the process is further complicated by the fact that, as we noted earlier,
the data will probably make a temporary stop in a register). As Figure
2 shows, once the necessary data and instruction are in memory, the central
processing unit performs the following four steps for each instruction:

Figure 2: The Machine Cycle
![]() |
| Figure 3: The Machine Cycle in Action |
It is one thing to have instructions and data somewhere in memory and
quite another for the control unit to be able to find them. How does it do
this?
The location in memory for each instruction and each piece of data is
identified by an address. That is, each location has an address number, like
the mailboxes in front of an apartment house. And, like the mailboxes, the
address numbers of the locations remain the same, but the contents
(instructions and data) of the locations may change. That is, new instructions or
new data may be placed in the locations when the old contents no
longer need to be stored in memory. Unlike a mailbox, however, a memory
location can hold only a fixed amount of data; an address can hold only
a fixed number of bytes - often two bytes in a modern computer.

Figure 4: Memory Addresses Like Mailboxes
Figure 4 shows how a program manipulates data in memory. A payroll
program, for example, may give instructions to put the rate of pay in location
3 and the number of hours worked in location 6. To compute the
employee's salary, then, instructions tell the computer to multiply the data
in location 3 by the data in location 6 and move the result to location 8.
The choice of locations is arbitrary - any locations that are not already spoken
for can be used. Programmers using programming languages, however,
do not have to worry about the actual address numbers, because each data
address is referred to by a name. The name is called a symbolic address. In
this example, the symbolic address names are Rate, Hours, and Salary.
Now that we see conceptually how a computer works, we will look at the hardware components that make up the internals os a modern computer. Click here to continue the required reading.