11 Processor Structure and Function 20 3 18
11 Processor Structure and Function 20 3 18
11 Processor Structure and Function 20 3 18
Lecture 11
CPU Structure and Function
CPU Structure
• CPU must:
—Fetch instructions: The processor reads an instruction
from memory (register, cache, main memory).
—Interpret instructions: The instruction is decoded to
determine what action is required.
—Fetch data: The execution of an instruction may
require reading data from memory or I/O module
—Process data: The execution of an instruction may
require performing some arithmetic or logical
operation on data
—Write data: The results of an execution may require
writing data to memory or I/O module.
CPU With Systems Bus
• ALU performs actual
computation or processing
of data.
• The control unit controls the
movement of data and
instructions into and out of
the processors, and controls
the operation of ALU
• Registers, minimal internal
memory consisting of a set
of storage locations
- processors need to store
some data temporarily while
execution of instructions as
it needs to remember the
location of last instruction to
get the next instruction
CPU Internal Structure
• Data transfer and logic control
paths are indicated (bold
arrow), including an element
labeled internal processor bus.
• Fetch
—PC contains address of next instruction
—Address moved to MAR
—Address placed on address bus
—Control unit requests memory read
—Result placed on data bus, copied to MBR, then to IR
—Meanwhile PC incremented by 1
Data Flow (Fetch Diagram)
Data Flow (Data Fetch)
• IR is examined
• If indirect addressing, indirect cycle is
performed
—Right most N bits of MBR which contain the operand
address, are transferred to MAR
—Control unit requests memory read
—Result (operand fetch) moved to MBR
Data Flow (Indirect Diagram)
Data Flow (Execute)
• May take many forms
• Depends on instruction being executed
• May include
—Read/write from memory or I/O
—Transferring data among register
—ALU operations
Data Flow (Interrupt)
• Simple
• Predictable
• Current PC saved to allow processor to resume
activity after interrupt
• Contents of PC copied to MBR to be written into
memory through data bus
• Special memory location reserved for this
purpose is loaded into MAR from the control unit
• PC loaded with address of interrupt handling
routine
• Next instruction (first of interrupt handler) can
be fetched
Data Flow (Interrupt Diagram)
Prefetch
• Fetch accessing main memory
• Execution usually does not access main memory
• Can fetch next instruction during
execution of current instruction
• Called instruction prefetch
Improved Performance
• But not doubled:
—Fetch usually shorter than execution
– Prefetch more than one instruction?
—Any jump or branch means that prefetched
instructions are not the required instructions
• Add more stages to improve performance
Pipelining
• Processors make use of instruction pipelining to
speed up execution.
• Pipeline involves breaking up the instruction cycle
into number of separate stages that occur in
sequence, such as fetch instruction, decode
instruction, calculate operands, fetch operands,
execute instruction, and write result (6)
• Overlap these operations
• Instructions move through these stages, as on an
assembly line, so that , each stage can work with
different instructions at the same time
Two-Stage Instruction Pipeline
• The pipeline has two independent stages
• The first stage fetches an instruction and buffers
it
• When the second stage is free, the first stage
passes it the buffered instruction
• While the second stage is executing the
instruction, the first stage takes advantage
of unused memory cycles to fetch and
buffer the next instruction
• This is called instruction fetch/fetch
overlap
Two-Stage Instruction Pipeline-contd..
• It should be clear that this process will speed up instruction
execution.
• If the fetch and execute stages were of equal duration, the
instruction cycle time would be halved, but unlikely for two
reasons:
(b)
• The pipeline is full at times 6 and
7.
• At time 7, instruction 3 is in
execution stage and executes a
branch to instruction 15
• At this point, instructions I4
through I7 are flushed from the
pipeline, so that at time 8, only
two instructions are in the
pipeline, I3 and I15
Speedup Factors
with Instruction
Pipelining