How Computers Work: The CPU and Memory: Figure 0: Inside The Computer
How Computers Work: The CPU and Memory: Figure 0: Inside The Computer
o CD-
ROM
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.
2
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.
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(>).
3
Computers usually assign special roles to certain registers, including
these registers:
o An accumulator, which collects the result of computations.
o An address register, which keeps track of where a given
instruction or piece of data is stored in memory. Each storage
location in memory is identified by an address, just as each
house on a street has an address.
o A storage register, which temporarily holds data taken from or
about to be sent to memory.
o A general-purpose register, which is used for several functions.
• Memory and Storage
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:
o Most types of memory only store items while the computer is
turned on; data is destroyed when the machine is turned off.
o If more than one program is running at once (often the case on
large computers and sometimes on small computers), a single
program can not lay exclusive claim to memory.
o There may not be room in memory to hold the processed data.
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.
4
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.
5
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.
Relative Cost
Storage Speed Capacity Permanent?
($)
Registers Fastest Lowest Highest No
RAM Very Fast Low/Moderate High No
Floppy
Very Slow Low Low Yes
Disk
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.
6
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
Figure 2: The Machine Cycle
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:
7
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?
8
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.