Chapter 7 CPU and Memory 7-2CPU: 3 Major Components ALU arithmetic logic unit Performs calculations and comparisons data changed CU control unit: performs fetch/execute cycle Exa
Trang 1CHAPTER 7:
The CPU and Memory
The Architecture of Computer Hardware
and Systems Software:
An Information Technology Approach
3rd Edition, Irv Englander John Wiley and Sons 2003
Trang 2Chapter 7 CPU and Memory 7-2
CPU: 3 Major Components
ALU (arithmetic logic unit)
Performs calculations and comparisons (data changed)
CU (control unit): performs fetch/execute cycle
Example: Program counter (PC) or instruction pointer
determines next instruction for execution
Trang 3Chapter 7 CPU and Memory 7-3
System Block Diagram
Trang 4Chapter 7 CPU and Memory 7-4
The Little Man Computer
Trang 5Chapter 7 CPU and Memory 7-5
Concept of Registers
Small, permanent storage locations within the CPU used for a particular purpose
Manipulated directly by the Control Unit
Wired for specific function
Size in bits or bytes (not MB like memory)
Can hold data, an address or an instruction
How many registers does the LMC have?
Trang 6Chapter 7 CPU and Memory 7-6
Registers
Use of Registers
Scratchpad for currently executing program
Holds data needed quickly or frequently
Stores information about status of CPU and currently
executing program
Address of next program instruction
Signals from external devices
General Purpose Registers
Trang 7Chapter 7 CPU and Memory 7-7
Special-Purpose Registers
Program Count Register (PC)
Also called instruction pointer
Instruction Register (IR)
Stores instruction fetched from memory
Memory Address Register (MAR)
Memory Data Register (MDR)
Status Registers
Status of CPU and currently executing program
Flags (one bit Boolean variable) to track condition like arithmetic carry and overflow, power failure, internal computer error
Trang 8Chapter 7 CPU and Memory 7-8
Register Operations
Stores values from other locations
(registers and memory)
Addition and subtraction
Shift or rotate data
Test contents for conditions such as
zero or positive
Trang 9Chapter 7 CPU and Memory 7-9
Operation of Memory
Each memory location has a unique address
Address from an instruction is copied to the MAR which finds the location in memory
CPU determines if it is a store or retrieval
Transfer takes place between the MDR and memory
MDR is a two way register
Trang 10Chapter 7 CPU and Memory 7-10
Relationship between MAR,
MDR and Memory
Trang 11Chapter 7 CPU and Memory 7-11
MAR-MDR Example
Trang 12Chapter 7 CPU and Memory 7-12
Visual Analogy of Memory
Trang 13Chapter 7 CPU and Memory 7-13
Individual Memory Cell
Trang 14Chapter 7 CPU and Memory 7-14
Memory Capacity
Determined by two factors
1 Number of bits in the MAR
LMC = 100 (00 to 99)
2 K where K = width of the register in bits
2 Size of the address portion of the instruction
4 bits allows 16 locations
8 bits allows 256 locations
32 bits allows 4,294,967,296 or 4 GB
Important for performance
Insufficient memory can cause a processor to
work at 50% below performance
Trang 15Chapter 7 CPU and Memory 7-15
RAM: Random Access Memory
DRAM (Dynamic RAM)
Most common, cheap
Volatile: must be refreshed (recharged with power) 1000’s of times each second
SRAM (static RAM)
Faster than DRAM and more expensive than
DRAM
Volatile
Frequently small amount used in cache memory
for high-speed access used
Trang 16Chapter 7 CPU and Memory 7-16
ROM - Read Only Memory
Non-volatile memory to hold software that is not expected to change over the life of the
system
Magnetic core memory
Electrically Erasable Programmable ROM
Slower and less flexible than Flash ROM
Trang 17Chapter 7 CPU and Memory 7-17
Fetch-Execute Cycle
Two-cycle process because both
instructions and data are in memory
Decode or find instruction, load from
memory into register and signal ALU
Performs operation that instruction requires
Move/transform data
Trang 18Chapter 7 CPU and Memory 7-18
LMC vs CPU
Fetch and Execute Cycle
Trang 19Chapter 7 CPU and Memory 7-19
Load Fetch/Execute Cycle
1 PC -> MAR Transfer the address from the
PC to the MAR
2 MDR -> IR Transfer the instruction to the
IR
3 IR(address) -> MAR Address portion of the
instruction loaded in MAR
4 MDR -> A Actual data copied into the
accumulator
5 PC + 1 -> PC Program Counter incremented
Trang 20Chapter 7 CPU and Memory 7-20
Store Fetch/Execute Cycle
1 PC -> MAR Transfer the address from the
PC to the MAR
2 MDR -> IR Transfer the instruction to the
IR
3 IR(address) -> MAR Address portion of the
instruction loaded in MAR
4 A -> MDR* Accumulator copies data into
MDR
5 PC + 1 -> PC Program Counter incremented
*Notice how Step #4 differs for LOAD and STORE
Trang 21Chapter 7 CPU and Memory 7-21
ADD Fetch/Execute Cycle
1 PC -> MAR Transfer the address from the
PC to the MAR
2 MDR -> IR Transfer the instruction to the
IR
3 IR(address) -> MAR Address portion of the
instruction loaded in MAR
4 A + MDR -> A Contents of MDR added to
contents of accumulator
5 PC + 1 -> PC Program Counter incremented
Trang 22Chapter 7 CPU and Memory 7-22
PC + 1 PC
OUT
PC MAR MDR IR
A IOR
PC + 1 PC
HALT
PC MAR MDR IR
BRANCH
PC MAR MDR IR IR[addr] PC
BRANCH on Condition
PC MAR MDR IR
If condition false: PC + 1 PC
If condition true: IR[addr] PC
Trang 23Chapter 7 CPU and Memory 7-23
Bus
The physical connection that makes it possible
to transfer data from one location in the
computer system to another
Group of electrical conductors for carrying
signals from one location to another
Line: each conductor in the bus
Trang 24Chapter 7 CPU and Memory 7-24
Bus
Connect CPU and Memory
I/O peripherals: on same bus as
CPU/memory or separate bus
Physical packaging commonly called
backplane
Also called system bus or external bus
Example of broadcast bus
Part of printed circuit board called motherboard
that holds CPU and related components
Trang 25Chapter 7 CPU and Memory 7-25
Bus Characteristics
Protocol
Documented agreement for communication
Specification that spells out the meaning of each line and each signal on each line
Throughput, i.e., data transfer rate in
bits per second
Data width in bits carried simultaneously
Trang 26Chapter 7 CPU and Memory 7-26
Point-to-point vs Multipoint
Broadcast bus
Example: Ethernet
Plug-in
device
Shared among multiple devices
Trang 27Chapter 7 CPU and Memory 7-27
Motherboard
Printed circuit board that holds CPU and related
components including backplane
Trang 28Chapter 7 CPU and Memory 7-28
Typical PC Interconnections
Trang 29Chapter 7 CPU and Memory 7-29
PCI Bus Connections
Trang 30Chapter 7 CPU and Memory 7-30
Instructions
Instruction
Direction given to a computer
Causes electrical signals to be sent through specific circuits for processing
Instruction set
Design defines functions performed by the processor
Differentiates computer architecture by the
Number of instructions
Complexity of operations performed by individual instructions
Data types supported
Format (layout, fixed vs variable length)
Use of registers
Addressing (size, modes)
Trang 31Chapter 7 CPU and Memory 7-31
OPCODE: task
Source OPERAND(s)
Result OPERAND
Location of data (register, memory)
Explicit: included in instruction
Implicit: default assumed
OPCODE Source OPERAND Result OPERAND
Addresses
Trang 32Chapter 7 CPU and Memory 7-32
Instruction Format
Machine-specific template that specifies
Length of the op code
Trang 33Chapter 7 CPU and Memory 7-33
Instruction Formats: CISC
Trang 34Chapter 7 CPU and Memory 7-34
Instruction Formats: RISC
Trang 35Chapter 7 CPU and Memory 7-35
Instruction Types
Data Transfer (load, store)
Most common, greatest flexibility
Involve memory and registers
What’s a word ? 16? 32? 64 bits?
Boolean operators AND, OR, XOR, NOR, and NOT
Single operand manipulation instructions
Negating, decrementing, incrementing
Trang 36Chapter 7 CPU and Memory 7-36
More Instruction Types
Bit manipulation instructions
Flags to test for conditions
Shift and rotate
Program control
Stack instructions
Multiple data instructions
I/O and machine control
Trang 37Chapter 7 CPU and Memory 7-37
Register Shifts and Rotates
Trang 38Chapter 7 CPU and Memory 7-38
Program Control Instructions
Program control
Jump and branch
Subroutine call
and return
Trang 39Chapter 7 CPU and Memory 7-39
Stack Instructions
Stack instructions
LIFO method for organizing information
Items removed in the reverse order from that in which they are added
Trang 40Chapter 7 CPU and Memory 7-40
Fixed Location Subroutine
Trang 41Chapter 7 CPU and Memory 7-41
Stack Subroutine Return
Address Storage
Trang 42Chapter 7 CPU and Memory 7-42
Multiple Data Instructions
Perform a single operation on multiple pieces of data simultaneously
SIMD: Single Instruction, Multiple Data
Intel MMX: 57 multimedia instruction
Commonly used in vector and array processing applications