The Processor�Introduction to Pipelining
Chapter 4
Sections: 4.6
Outline
2
Prof. Iyad Jafar
Idea of Pipelining
3
Prof. Iyad Jafar
Introduction
4
Prof. Iyad Jafar
Idea of Pipelining
5
Cycle 1
Cycle 2
Cycle 3
Cycle 4
Cycle 5
IFetch
Dec
Exec
Mem
WB
LW
Cycle 7
Cycle 6
Cycle 8
SW
IFetch
Dec
Exec
Mem
WB
R-Type
IFetch
Dec
Exec
Mem
WB
IFetch
Dec
Exec
Mem
WB
IFetch
Dec
Exec
Mem
WB
Prof. Iyad Jafar
Idea of Pipelining
6
Prof. Iyad Jafar
Comparison
7
Multiple Cycle Implementation:
Clk
Cycle 1
IFetch
Dec
Exec
Mem
WB
Cycle 2
Cycle 3
Cycle 4
Cycle 5
Cycle 6
Cycle 7
Cycle 8
Cycle 9
Cycle 10
IFetch
Dec
Exec
Mem
lw
sw
IFetch
R-type
lw
IFetch
Dec
Exec
Mem
WB
Pipeline Implementation:
IFetch
Dec
Exec
Mem
WB
sw
IFetch
Dec
Exec
Mem
WB
R-type
Clk
Single Cycle Implementation:
lw
sw
Waste
Cycle 1
Cycle 2
R-type
Prof. Iyad Jafar
Pipelining Performance
8
Prof. Iyad Jafar
Why Pipelining?
9
I
n
s
t
r.
O
r
d
e
r
Time (clock cycles)
Inst 1
Inst 2
Inst 3
Inst 5
Inst 4
ALU
IM
Reg
DM
Reg
ALU
IM
Reg
DM
Reg
ALU
IM
Reg
DM
Reg
ALU
IM
Reg
DM
Reg
ALU
IM
Reg
DM
Reg
Once the pipeline is full, one instruction is completed every cycle, so CPI = 1 (similar to Single-cycle)
Time to fill the pipeline
Prof. Iyad Jafar
Example 1
10
Prof. Iyad Jafar
Example 1
11
Single-cycle
TimeSC = 1000 ps x 1000000 = 1,000,000,000 ps
Pipelining
TimePP = 1000 ps + 200 ps x 999999 = 200,000,800 ps
Speeup = 1,000,000,000 / 200,000,800 = 4.99998
(very close to the number of stages)
Prof. Iyad Jafar
Example 1
12
Pipelining
Single-cycle
TimeSC = 1000 x 3 = 3000 ps
TimePP = 200 x 5 +200 + 200 = 1400 ps
Speeup = 3000 / 1400 = 2.14
(less than the number of stages)
Prof. Iyad Jafar
Example 1
CCSC = 200 + 100 + 200 + 200 + 100 = 800 ps
CCPP = 200 ps
13
For 1,000,000 instructions
TimeSC = 800 x 1,000,000 = 800,000,000 ps
TimePP = 1000+ 200x999,999 = 200,000,800ps
Speeup = 800,000,000/ 200,000,600 = 3.99998 (<5)
For 3 instructions
TimeSC = 800 x 3 = 2400 ps
TimePP = 1000 + 200x 2 = 1400 ps
Speeup = 2400/ 1400 = 1.71 (<5)
Prof. Iyad Jafar
Example 1 Summary
14
Prof. Iyad Jafar
Pipelined Datapath
15
Prof. Iyad Jafar
What do we need to implement pipelining?
16
Prof. Iyad Jafar
Pipelined Datapath and Control
17
Prof. Iyad Jafar