0% found this document useful (0 votes)
6 views39 pages

CH 07

Chapter 7 discusses the architecture of the CPU and memory, detailing components such as the ALU, CU, and various types of registers. It explains the fetch-execute cycle, memory operations, and the classification of instructions, including data movement and arithmetic operations. Additionally, it covers memory types like RAM and ROM, and the importance of instruction formats and addressing modes.

Uploaded by

dryrobot17
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views39 pages

CH 07

Chapter 7 discusses the architecture of the CPU and memory, detailing components such as the ALU, CU, and various types of registers. It explains the fetch-execute cycle, memory operations, and the classification of instructions, including data movement and arithmetic operations. Additionally, it covers memory types like RAM and ROM, and the importance of instruction formats and addressing modes.

Uploaded by

dryrobot17
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 39

CHAPTER 7

CPU AND MEMORY

The Architecture of Computer


Hardware,
Systems Software & Networking:
An Information Technology Approach
6th Edition, Irv Englander and Wilson Wong

COPYRIGHT 2021 JOHN WILEY & SONS, INC


OVERVIEW
Components of the CPU
Registers
Memory Unit
Fetch-Execute Cycle
Instructions

COPYRIGHT 2021 JOHN WILEY & SONS, INC 2


CPU AND MEMORY
Every instruction executed by the CPU
requires memory access
Primary memory holds program
instructions and data
Secondary storage is used for long term
storage
 Data is moved from secondary storage to
primary memory for CPU execution

COPYRIGHT 2021 JOHN WILEY & SONS, INC 3


CPU
MAJOR COMPONENTS
ALU (arithmetic logic unit)
 Performs calculations and comparisons
CU (control unit)
 Performs fetch/execute cycle
 Runs program instructions and issues commands
to the ALU
 Moves data to and from CPU registers and other
hardware components
 Subcomponents
 Memory management unit
supervises fetching instructions and data from
memory
 I/O Interface: sometimes combined with the
4
memory management unit as the Bus Interface
COPYRIGHT 2021 JOHN WILEY & SONS, INC
SYSTEM BLOCK DIAGRAM

COPYRIGHT 2021 JOHN WILEY & SONS, INC 5


THE LITTLE MAN COMPUTER

COPYRIGHT 2021 JOHN WILEY & SONS, INC 6


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 in MB like
memory)
Can hold data, an address, or an
instruction
How many registers does the LMC have?
COPYRIGHT 2021 JOHN WILEY & SONS, INC 7
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
 User-visible or program-visible registers
 Hold intermediate results or data values, e.g., loop
counters
 Equivalent to LMC’s calculator
 Typically several dozen in current CPUs
COPYRIGHT 2021 JOHN WILEY & SONS, INC 8
SPECIAL-PURPOSE REGISTERS
Program Counter Register (PC)
 Also called instruction pointer (IP)
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
conditions like arithmetic carry and over
COPYRIGHT 2021 JOHN WILEY & SONS, INC 9
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

COPYRIGHT 2021 JOHN WILEY & SONS, INC 10


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
COPYRIGHT 2021 JOHN WILEY & SONS, INC 11
RELATIONSHIP BETWEEN
MAR, MDR AND MEMORY
Addres Data
s

COPYRIGHT 2021 JOHN WILEY & SONS, INC 12


MAR-MDR EXAMPLE

COPYRIGHT 2021 JOHN WILEY & SONS, INC 13


VISUAL ANALOGY OF MEMORY

COPYRIGHT 2021 JOHN WILEY & SONS, INC 14


INDIVIDUAL MEMORY CELL

COPYRIGHT 2021 JOHN WILEY & SONS, INC 15


MEMORY CAPACITY AND ADDRESSING
LIMITATIONS
Determined by two factors
1. Number of bits in the MAR
 LMC = 100 (00 to 99)
 2K 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
 64 bits allows 16 EB (exabytes)

COPYRIGHT 2021 JOHN WILEY & SONS, INC 16


RAM
RANDOM ACCESS MEMORY
DRAM (Dynamic RAM)
 Most common, cheap, less electrical power,
less heat, smaller space
 Volatile: must be refreshed (recharged with
power) 1000’s of times each second
SRAM (static RAM)
 Faster and more expensive than DRAM
 Volatile
 Small amounts are often used in cache
memory for high-speed memory access
COPYRIGHT 2021 JOHN WILEY & SONS, INC 17
NONVOLATILE MEMORY
ROM
 Read-only Memory
 Holds software that is not expected to change
over the life of the system such as firmware
used for the system BIOS
Flash Memory
 Inexpensive nonvolatile secondary storage
 Useful for nonvolatile portable computer
storage, digital cameras, tablets, smartphones
 Slower rewrite time compared to RAM

COPYRIGHT 2021 JOHN WILEY & SONS, INC 18


FETCH-EXECUTE CYCLE
Two-cycle process because both
instructions and data are in memory
Fetch
 Decode or find instruction, load from memory
into register and signal ALU
Execute
 Performs operation that instruction requires
 Move/transform data

COPYRIGHT 2021 JOHN WILEY & SONS, INC 19


LMC VS. CPU
FETCH AND EXECUTE CYCLE

COPYRIGHT 2021 JOHN WILEY & SONS, INC 20


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]  Address portion of the
MAR instruction loaded in MAR
4. MDR  A Actual data copied into the
accumulator
5. PC + 1  PC Program Counter
incremented
COPYRIGHT 2021 JOHN WILEY & SONS, INC 21
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]  Address portion of the
MAR 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
COPYRIGHT 2021 JOHN WILEY & SONS, INC 22
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]  Address portion of the
MAR instruction loaded in MAR
4. A + MDR  A Contents of MDR added to
contents of accumulator
5. PC + 1  PC Program Counter
incremented

COPYRIGHT 2021 JOHN WILEY & SONS, INC 23


LMC FETCH/EXECUTE
SUBTRACT INPUT BRANCH HALT
PC  MAR PC  MAR PC  MAR PC  MAR
MDR  IR MDR  IR MDR  IR MDR  IR
IR[addr]  MAR IOR  A IR[addr] 
A – MDR  A PC + 1  PC PC
PC + 1  PC

OUTPUT BRANCH on Condition


PC  MAR PC  MAR
MDR  IR MDR  IR
A  IOR If condition true: IR[addr] 
PC + 1  PC PC
If condition false: PC + 1 
COPYRIGHT 2021 JOHN WILEY & SONS, INC PC 24
CLASSIFICATION OF INSTRUCTIONS
 Data Movement (load, store)
 Most common, greatest flexibility
 Involve memory and registers
 What’s the size of a word? 16, 32, or 64 bits?
 Arithmetic
 Operators + - / * ^
 Integers and floating point
 Boolean Logic
 Often includes at least AND, XOR, and NOT
 Single operand manipulation instructions
 Negating, decrementing, incrementing, set to 0

COPYRIGHT 2021 JOHN WILEY & SONS, INC 25


MORE INSTRUCTION
CLASSIFICATIONS
Bit manipulation instructions
 Flags to test for conditions
Shift and rotate
Program control
Stack instructions
Multiple data instructions
I/O and machine control

COPYRIGHT 2021 JOHN WILEY & SONS, INC 26


REGISTER SHIFTS AND ROTATES

COPYRIGHT 2021 JOHN WILEY & SONS, INC 27


PROGRAM CONTROL INSTRUCTIONS
Program
control
 Jump and
branch
 Subroutine
call
and return

COPYRIGHT 2021 JOHN WILEY & SONS, INC 28


STACK INSTRUCTIONS
 Stack instructions
 LIFO method for organizing information
 Items removed in the reverse order from how they are
added

Push Pop

COPYRIGHT 2021 JOHN WILEY & SONS, INC 29


FIXED LOCATION SUBROUTINE
RETURN ADDRESS STORAGE: OOPS!

COPYRIGHT 2021 JOHN WILEY & SONS, INC 30


STACK SUBROUTINE RETURN ADDRESS STORAGE

COPYRIGHT 2021 JOHN WILEY & SONS, INC 31


BLOCK OF MEMORY AS A STACK

COPYRIGHT 2021 JOHN WILEY & SONS, INC 32


MULTIPLE DATA INSTRUCTIONS
 Perform a single operation on multiple pieces of
data simultaneously
 SIMD: Single Instruction, Multiple Data
 Commonly used in multimedia, vector and array
processing applications

COPYRIGHT 2021 JOHN WILEY & SONS, INC 33


INSTRUCTION ELEMENTS
OPCODE: task
Source OPERAND(s)
Addresses
Result OPERAND
 Location of data (register, memory)
 Explicit: included in instruction
 Implicit: default assumed

Source Result
OPCODE OPERAND OPERAND

COPYRIGHT 2021 JOHN WILEY & SONS, INC 34


INSTRUCTION FORMAT
Machine-specific template that specifies
 Length of the op code
 Number of operands
 Length of operands

Simple 32-
bit
Instruction
Format

COPYRIGHT 2021 JOHN WILEY & SONS, INC 35


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)
COPYRIGHT 2021 JOHN WILEY & SONS, INC 36
INSTRUCTION WORD SIZE
Fixed vs. variable size
 Pipelining has mostly eliminated variable
instruction size architectures
Most current architectures use 32-bit or
64-bit words
Addressing Modes
 Direct
 Mode used by the LMC
 Register Deferred
 Also immediate, indirect, indexed
COPYRIGHT 2021 JOHN WILEY & SONS, INC 37
INSTRUCTION FORMAT EXAMPLES

COPYRIGHT 2021 JOHN WILEY & SONS, INC 38


COPYRIGHT 2021 JOHN WILEY &
SONS
All rights reserved. Reproduction or translation of
this work beyond that permitted in section 117 of
the 1976 United States Copyright Act without
express permission of the copyright owner is
unlawful. Request for further information should
be addressed to the Permissions Department, John
Wiley & Sons, Inc. The purchaser may make back-
up copies for his/her own use only and not for
distribution or resale. The Publisher assumes no
responsibility for errors, omissions, or damages
caused by the use of these programs or from the
use of the information contained herein.
COPYRIGHT 2021 JOHN WILEY & SONS, INC 39

You might also like