Copyright © Prentice Hall 2000

advertisement
The Central Processing
Unit
Chapter 3
What Goes on Inside the
Computer
Copyright © Prentice Hall 2000
1
Functions of Computer
Systems
Recall that there are four main
functions of computer systems:
Secondary
Storage
Input
Copyright © Prentice Hall 2000
Processing
Output
2
Processing
In this chapter, we will focus on the
central processing unit (CPU) in
more detail.
Secondary
Storage
Input
Copyright © Prentice Hall 2000
Processing
Output
3
The CPU
The CPU interacts
closely with
memory (primary
storage).
CPU
Memory, however,
is not part of the
CPU.
Memory
Copyright © Prentice Hall 2000
4
Parts of the CPU
The CPU consists of a variety of parts
including:
• Control unit
Control
Unit
ALU
Registers
Copyright © Prentice Hall 2000
• Arithmetic/logic
unit (ALU)
• Registers
5
The Control Unit…
directs the other parts of the computer
system to execute stored program
instructions.
Control
Unit
Copyright © Prentice Hall 2000
The control unit
communicates with the
ALU and memory.
6
The Arithmetic/Logic Unit
(ALU)…
performs mathematical operations as
well as logical operations.
ALU
Copyright © Prentice Hall 2000
7
Mathematical Operations
The ALU can perform four kinds of
mathematical calculations:
•
•
•
•
Copyright © Prentice Hall 2000
addition
subtraction
multiplication
division
8
Logical Operations
The ALU can perform logical
operations.
Logical operations can test for these
conditions:
• Equal-to (=)
• Less-than (<)
• Greater-than (>)
Copyright © Prentice Hall 2000
9
Equal-to Condition
In a test for this condition, the ALU
compares two values to determine if
they are equal.
If
=
Then
=
Copyright © Prentice Hall 2000
10
Less-than Condition
In a test for this condition, the ALU
compares values to determine if one
value is less than another.
If
=
Then
<
Copyright © Prentice Hall 2000
11
Greater-than Condition
In a test for this condition, the ALU
compares values to determine if one
value is greater than another.
If
=
Then
>
Copyright © Prentice Hall 2000
12
Registers…
are temporary
storage areas
for data or
instructions.
Registers
Copyright © Prentice Hall 2000
Data held
temporarily in
registers can be
accessed at
greater speeds
than data stored
in memory.
13
Memory (Primary Storage)
Memory is the
part of the
computer that
stores data and
program
instructions for
processing.
Copyright © Prentice Hall 2000
CPU
Memory
14
Memory…
is also referred to as
RAM (randomaccess memory).
RAM is temporary,
finite, and more
expensive than
secondary storage.
Copyright © Prentice Hall 2000
CPU
Memory
15
Executing Program
Instructions
Before the CPU can execute a
program, program
instructions and data must
be placed into memory from
an input device or storage
device.
Input
Copyright © Prentice Hall 2000
Secondary
Storage
Processing
16
Executing Program
Instructions
Once the necessary data and
instructions are in memory, the CPU
performs the following steps for each
instruction:
•
•
•
•
Fetching
Decoding
Executing
Storing
Copyright © Prentice Hall 2000
CPU
Memory
17
Fetching Instructions
Control
Unit
ALU
Registers
The control unit
fetches (gets)
the
instruction
from memory.
Memory
Copyright © Prentice Hall 2000
18
Decoding Instructions
The control unit
decodes the
instruction
and directs
that the
necessary data
be moved from
memory to the
ALU.
Copyright © Prentice Hall 2000
Control
Unit
ALU
Registers
Memory
19
Executing Arithmetic/Logic
Operations
Control
Unit
ALU
Registers
The ALU performs
the arithmetic
or logical
operation on the
data.
Memory
Copyright © Prentice Hall 2000
20
Storing Results
The ALU stores
the result of
its operation
on the data in
memory or in
a register.
Control
Unit
ALU
Registers
Memory
Copyright © Prentice Hall 2000
21
Executing Program
Instructions
Secondary
Storage
Control
Unit
ALU
Registers
Eventually, the
control unit sends
the results in
memory to an
output device or
secondary storage.
Memory
Output
Copyright © Prentice Hall 2000
22
Instruction Time
The time it takes to fetch an instruction
and decode it is called instruction time.
Control
Unit
Memory
Copyright © Prentice Hall 2000
Control
Unit
ALU
+
Memory
23
Execution Time
The time it takes to execute an ALU
operation and then store the result is
called execution time.
ALU
ALU
+
Registers
Memory
Copyright © Prentice Hall 2000
24
Machine Cycle
The combination of I-time and E-time
is called the machine cycle.
Itime
Copyright © Prentice Hall 2000
Etime
Machine
Cycle
25
Memory Locations and Addresses
The control unit
can find data
and
instructions
because each
location in
memory has an
address.
Copyright © Prentice Hall 2000
Control
Unit
Memory
26
Storage Locations
Each location in
memory is
identified by an
address.
Memory
Each location has
a unique address.
Copyright © Prentice Hall 2000
27
Symbolic Addresses
The choice of the
location in
memory is
arbitrary.
Addresses can
only hold one
number or word.
Copyright © Prentice Hall 2000
17
$
%
Memory
Pat
364
28
Data Representation
The system in which all computer data
is represented and manipulated is
called the binary system.
Copyright © Prentice Hall 2000
29
Binary System
The binary system has only two digits
to represent all values.
This corresponds to the two states of
a computer’s electrical system —on
and off.
Copyright © Prentice Hall 2000
30
Off/On Switches
The computer can represent data by
constructing combinations of off or
on switches.
off
Copyright © Prentice Hall 2000
or
on
31
Zero or One?
The binary system can also be
represented by the digits zero and one.
0
or
1
Zero (off) and one (on) make up the
two digits in the binary system.
Copyright © Prentice Hall 2000
32
The Bit
one bit
two bits
three bits
Copyright © Prentice Hall 2000
Each 0 or 1
in the
binary
system is
called a
bit.
33
The Byte
A group of 8 bits is called a byte.
0
1
Copyright © Prentice Hall 2000
0
0
1
0
1
0
34
One Character of Data
Each byte represents one character of
data (a letter, digit, or special
character).
0
1
0
Copyright © Prentice Hall 2000
0
1
0
1
0
= J
35
Storing Bytes
Storage and memory capacity is
expressed in the number of bytes
they can hold:
1 kilobyte = 210 or 1024 bytes
1 megabyte = 220 or 1,048,576 bytes
1 gigabyte = 230 or 1,073,741,824
bytes
Copyright © Prentice Hall 2000
36
Computer Word
A computer word is defined as the
number of bits that constitute a
common unit of data.
Copyright © Prentice Hall 2000
37
Computer Word Length
Word length varies by computer. For
example:
8 bits = 1 byte = one word length
64 bits = 8 bytes = one word length
Copyright © Prentice Hall 2000
38
Coding the Computer
A code for determining which group of
bits represent which characters on
a keyboard is called ASCII.
Copyright © Prentice Hall 2000
39
ASCII
ASCII has been adopted, as the
standard, by the U.S. government and
is found in a variety of computers.
0 1 0 0 1 0 1 0 =
ASCII-8 code
Copyright © Prentice Hall 2000
J
Keyboard character
40
Inside the Computer
The flat board within the personal
computer that holds the computer
circuitry is the motherboard.
Copyright © Prentice Hall 2000
41
The Motherboard
The motherboard includes:
• Microprocessor
• Memory components
Copyright © Prentice Hall 2000
42
The Microprocessor…
is the CPU of the personal computer.
It looks like a computer chip.
The microprocessor
contains tiny
electronic switches
(transistors).
Copyright © Prentice Hall 2000
43
Microprocessor Switches
If electric current passes through a
transistor, the switch is on.
If no current can pass, the switch is
off.
A combination of transistors can
stand for a combination of bits.
Copyright © Prentice Hall 2000
44
Memory…
components are also chips.
This form of semiconductor
memory stores data in binary
form (off/on or zero/one).
Storage can be temporary (RAM)
or permanent (ROM).
Copyright © Prentice Hall 2000
45
RAM…
means random-access memory.
RAM chips can be accessed
easily and fast—regardless of
where the data is stored.
RAM is usually volatile storage in that if
the power is shut off, the contents are lost.
Copyright © Prentice Hall 2000
46
ROM…
is read-only memory.
ROM chips contain programs
and data that are permanently
etched on the chip.
The contents do not disappear when
the power is turned off.
Copyright © Prentice Hall 2000
47
Computer Speed and
Power
Speed and power are determined by:
•
•
•
•
•
•
Microprocessor speed
Bus lines
Cache
Flash memory
RISC
Parallel processing
Copyright © Prentice Hall 2000
48
Microprocessor Speeds
Microprocessor speeds can be
measured in a variety of ways:
• Megahertz
• MIPS
• Megaflops
Copyright © Prentice Hall 2000
49
Megahertz
One measure of microprocessor speed
is megahertz (MHz) which is one
million machine cycles per second.
Copyright © Prentice Hall 2000
50
MIPS
Another measure of microprocessor
speed is MIPS which is one million
instructions per second.
Copyright © Prentice Hall 2000
51
Megaflops
Megaflops, or one million floatingpoint operations per second, is still
another measure of microprocessor
speed.
Copyright © Prentice Hall 2000
52
Bus Lines
A bus line is a set of parallel
electrical paths. A bus is like a
mode of transportation for data.
Copyright © Prentice Hall 2000
53
Bus Width
The amount of data that can be
carried at one time is bus width
(wider = more data).
Copyright © Prentice Hall 2000
54
Cache
Cache is a relatively small block of
very fast memory.
The data and instructions stored in
cache are those that are most
recently or most frequently used.
Cache speeds up the internal transfer
of data and software instructions.
Copyright © Prentice Hall 2000
55
Flash Memory
Accessing data and instructions from
within the CPU is fast but not when
it comes from a secondary storage
device.
Flash memory is nonvolatile (like
secondary storage) but allows fast
access (like RAM).
Copyright © Prentice Hall 2000
56
RISC
New RISC computers have chips with
fewer instructions as a means of
making them run faster.
Older, slower machines have chips
(called CISC) with instructions that
are seldom or never used.
Copyright © Prentice Hall 2000
57
Parallel Processing
Using several processors at the same
time (in parallel) greatly increases
processing speed.
When parallel processing, the
computer can be starting other
tasks before the sequence of fetchdecode-execute-store is complete.
Copyright © Prentice Hall 2000
58
Conclusion
Regardless of the design and
processing strategy of a computer,
its goal is the same: to turn raw
data into useful information.
Copyright © Prentice Hall 2000
59
Download