8.Week
8.Week
Processor Requirements:
• Fetch instruction
– The processor reads an instruction from memory (register, cache, main memory)
• Interpret instruction
– The instruction is decoded to determine what action is required
• Fetch data
– The execution of an instruction may require reading data from memory or an 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 an I/O module
• In order to do these things the processor needs to store some data
temporarily and therefore needs a small internal memory
Arithmetic and Logic Unit
Status Flags
Registers
Shifter
Arithmetic
and
Boolean
Logic
Control
Unit
Control
Paths
(a) M C68000
Figure:Figure
Example Microprocessor
16.2 Example M icroprocessor Register Organizations
Register Organizations
Instruction
Cycle Includes the following
stages:
Multiple Multiple
operands results
Interrupt
I nterrupt
PC M AR
M emory
Control
Unit
IR M BR
M AR
M emory
Control
Unit
M BR
Figure: Data
Figure 16.6 Flow, Indirect
Data Flow, Cycle
I ndirect Cycle
CPU
PC M AR
M emory
Control
Unit
M BR
Discard
(b) Expanded view
Figure: Two-Stage
Figure 16.8 Two-StageInstruction Pipeline
I nstruction Pipeline
Figure: Simplified Pipeline Architecture
Additional Stages
1 2 3 4 5 6 7 8 9 10 11 12 13 14
I nstruction 1 FI DI CO FO EI WO
I nstruction 2 FI DI CO FO EI WO
I nstruction 3 FI DI CO FO EI WO
I nstruction 4 FI DI CO FO EI WO
I nstruction 5 FI DI CO FO EI WO
I nstruction 6 FI DI CO FO EI WO
I nstruction 7 FI DI CO FO EI WO
I nstruction 8 FI DI CO FO EI WO
I nstruction 9 FI DI CO FO EI WO
1 2 3 4 5 6 7 8 9 10 11 12 13 14
I nstruction 1 FI DI CO FO EI WO
I nstruction 2 FI DI CO FO EI WO
I nstruction 3 FI DI CO FO EI WO
I nstruction 4 FI DI CO FO
I nstruction 5 FI DI CO
I nstruction 6 FI DI
I nstruction 7 FI
I nstruction 15 FI DI CO FO EI WO
I nstruction 16 FI DI CO FO EI WO
Decode
DI I nstruction
Calculate
CO Operands
Yes Uncon-
ditional
Branch?
No
Fetch
FO Operands
Execute
EI I nstruction
Update Write
PC
WO Operands
Empty
Pipe Yes Branch No
or
I nter
-rupt?
1 I1 1 I1
2 I2 I1 2 I2 I1
3 I3 I2 I1 3 I3 I2 I1
4 I4 I3 I2 I1 4 I4 I3 I2 I1
5 I5 I4 I3 I2 I1 5 I5 I4 I3 I2 I1
6 I6 I5 I4 I3 I2 I1 6 I6 I5 I4 I3 I2 I1
Time
7 I7 I6 I5 I4 I3 I2 7 I7 I6 I5 I4 I3 I2
8 I8 I7 I6 I5 I4 I3 8 I 15 I3
9 I9 I8 I7 I6 I5 I4 9 I 16 I 15
10 I9 I8 I7 I6 I5 10 I 16 I 15
11 I9 I8 I7 I6 11 I 16 I 15
12 I9 I8 I7 12 I 16 I 15
13 I9 I8 13 I 16 I 15
14 I9 14 I 16
10 k = 12 stages
Speedup factor
8
k = 9 stages
6
k = 6 stages
4
0
1 2 4 8 16 32 64 128
Number of instructions (log scale)
(a)
14
12
n = 30 instructions
10
Speedup factor
8 n = 20 instructions
6
n = 10 instructions
4
0
0 5 10 15 20
Number of stages
(b)
Also referred to as a
pipeline bubble
Clock cycle
1 2 3 4 5 6 7 8 9
I1 FI DI FO EI WO
I nstrutcion
I2 FI DI FO EI WO
I3 FI DI FO EI WO
I4 FI DI FO EI WO
Clock cycle
1 2 3 4 5 6 7 8 9
I1 FI DI FO EI WO
I nstrutcion
I2 FI DI FO EI WO
I3 I dle FI DI FO EI WO
I4 FI DI FO EI WO
I3 FI DI FO EI WO
I4 FI DI FO EI WO
Drawbacks:
• With multiple pipelines there are contention delays for
access to the registers and to memory
• Additional branch instructions may enter the pipeline
before the original branch decision is resolved
Prefetch Branch Target
• When a conditional branch is recognized, the target of the
branch is prefetched, in addition to the instruction following
the branch
Decode stage 1
All opcode and addressing-mode 3 bytes of instruction are passed to the D1 D1 decoder can then direct the D2 stage to
information is decoded in the D1 stage stage from the prefetch buffers capture the rest of the instruction
Decode stage 2
Also controls the computation of the more complex addressing
Expands each opcode into control signals for the ALU
modes
Execute
Write back
Updates registers and status flags modified during the preceding execute stage
Figure: Approaches to Pipeline Organization
Figure: Improved Pipeline Organization
Interrupt Processing
I ncrementer Sign
R15 (PC) extend
Rd
User Register File (R0 - R15)
Rn Rm Acc
I nstruction register
Barrel
shifter
I nstruction
decoder
M ultiply/
ALU
accumulate
Control
unit
CPSR