How A Computer Works
How A Computer Works
This part of the reading will examine the CPU, Buses, Controllers, and Main Memory.
Other sections will examine input devices, output devices, and secondary memory.
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.
A computer can simultaneously test for more than one condition. In fact, a logic unit can
usually discern six logical relationships: equal to, less than, greater than, less than or
equal to, greater than or equal to, and not equal.
The symbols that let you define the type of comparison you want the computer to
perform are called relational operators. The most common relational operators are the
equal sign(=), the less-than symbol(<), and the greater-than symbol(>).
How do data and instructions get from an input device into memory? The control
unit sends them. Likewise, when the time is right, the control unit sends these
items from memory to the arithmetic/logic unit, where an arithmetic operation or
logical operation is performed. After being processed, the information is sent to
memory, where it is hold until it is ready to he released to an output unit.
The chief characteristic of memory is that it allows very fast access to instructions
and data, no matter where the items are within it. We will discuss the physical
components of memory-memory chips-later in this chapter.
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 process of making the salad is then: bring the veggies from the fridge to the
counter top; place some veggies on the chopping board according to the recipe;
chop the veggies, possibly storing some partially chopped veggies temporarily on
the corners of the cutting board; place all the veggies in the bowl to either put
back in the fridge or put directly on the dinner table.
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.
Modern computers are designed with this hierarchy due to the characteristics
listed in the table. It has been the cheapest way to get the functionality. However,
as RAM becomes cheaper, faster, and even permanent, we may see disks
disappear as an internal storage device. Removable disks, like Zip disks or CDs
(we describe these in detail in the online reading on storage devices) will probably
remain in use longer as a means to physically transfer large volumes of data into
the computer. However, even this use of disks will probably be supplanted by the
Internet as the major (and eventually only) way of transferring data. Floppy disks
drives are already disappearing: the new IMac Macintosh from Apple does not
come with one. Within the next five years most new computer designs will only
include floppy drives as an extra for people with old floppy disks that they must
use.
For more detail on the computer's memory hierarchy, see the How Stuff Works
pages on computer memory.. This is optional reading.
How the CPU Executes Program Instructions
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.
The control unit eventually directs memory to release the result to an output
device or a secondary storage device. The combination of I-time and E-time is
called the machine cycle. Figure 3 shows an instruction going through the
machine cycle.
Each central processing unit has an internal clock that produces pulses at a fixed
rate to synchronize all computer operations. A single machine-cycle instruction
may be made up of a substantial number of sub-instructions, each of which must
take at least one clock cycle. Each type of central processing unit is designed to
understand a specific group of instructions called the instruction set. Just as there
are many different languages that people understand, so each different type of
CPU has an instruction set it understands. Therefore, one CPU-such as the one for
a Compaq personal computer-cannot understand the instruction set from another
CPU-say, for a Macintosh.
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?