CPU Structure and Function
CPU Structure and Function
CPU Structure and Function
fornacia@elet.polimi.it
www.elet.polimi.it/~fornacia
www.elet.polimi.it/~fornacia
CPU Structure
CPU must:
Fetch instructions
Interpret instructions
Fetch data
Process data
Write data
CPU With Systems Bus
General Purpose
Data
Address
Condition Codes
General Purpose Registers (1)
Between 8 - 32
Fewer = more memory references
More does not reduce memory references and takes
up processor real estate
See also RISC
How big?
Program Counter
Instruction Decoding Register
Memory Address Register
Memory Buffer Register
A set of bits
Includes Condition Codes
Sign of last result
Zero
Carry
Equal
Overflow
Interrupt enable/disable
Supervisor
Supervisor Mode
Stallings Chapter 12
Manufacturer web sites & specs
Instruction Cycle
Revision
Stallings Chapter 3
Indirect Cycle
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 (Data Fetch)
IR is examined
If indirect addressing, indirect cycle is performed
Right most N bits of MBR transferred to MAR
Control unit requests memory read
Result (address of operand) moved to MBR
Simple
Predictable
Current PC saved to allow resumption after
interrupt
Contents of PC copied to MBR
Special memory location (e.g. stack pointer) loaded
to MAR
MBR written to memory
PC loaded with address of interrupt handling routine
Next instruction (first of interrupt handler) can be
fetched
Improved Performance
Fetch instruction
Decode instruction
Calculate operands (i.e. EAs)
Fetch operands
Execute instructions
Write result
Branch in a Pipeline
Six Stage Instruction Pipeline
Alternative
Pipeline
Depiction
Speedup Factors with
Instruction Pipelining
Multiple Streams
Prefetch Branch Target
Loop buffer
Branch prediction
Delayed branching
Multiple Streams
Predict by Opcode
Some instructions are more likely to result in a jump
than thers
Can get up to 75% success
Taken/Not taken switch
Based on previous history
Good for loops
Branch Prediction (3)
Delayed Branch
Do not take jump until you have to
Rearrange instructions
EFLAGS Register
Control Registers
Interrupts
Maskable
Nonmaskable
Exceptions
Processor detected
Programmed
Interrupt vector table
Each interrupt type assigned a number
Index to vector table
256 * 32 bit interrupt vectors
5 priority classes
Processor examples
Stallings Chapter 12
Web pages etc.