Académique Documents
Professionnel Documents
Culture Documents
[H&P §A.1] In the ideal situation, this could give a speedup equal to
the number of pipeline stages:
This is rarely the case, and anyway, pipelining does involve some
extra overhead.
An unpipelined RISC
For our examples, we’ll work with a simplified RISC instruction set. In
an unpipelined implementation, instructions take at most 5 clock
cycles. One cycle is devoted to each of—
• 2 cycles:
• 4 cycles:
• 5 cycles:
Instruction Fetch (IF) Instruction Decode (ID) Execute (EX) Memory (MEM) Write-
back
(WB)
ALU
MUX
4
ALU
NPC
PC A
IR
ALU
Instruction cond
Data LMD
(inst.
MUX
cache Regs cache
reg.)
MUX
Sign- Imm
extend
In this pipeline, the major functional units are used in different cycles,
so overlapping the execution of instructions introduces few conflicts.
We’ve omitted one thing from the diagram above: We need a place
to save values between pipeline stages. Otherwise, the different
instructions in the pipeline would interfere with each other.
Tunpipe
=T
unpipe
n + To'head . n
50n
IF/ID and MEM/WB
IF ID EX MEM WB
are unpipelined
50n
Pipeline IF ID EX MEM WB
50ns
MEM MEM
IF1 IF2 ID1 ID2 EX1 EX2 1 2 WB1 WB2 CPI_pipe=1
Pipelined
25ns
Pipeline hazards
A hazard reduces the performance of the pipeline. Hazards arise
because of the program’s characteristics.
Clock # 1 2 3 4 5 6 7 8 9 10
Load instr. IF ID EX MEM WB
Instr. i+1 IF ID EX MEM WB
Instr. i+2 IF ID EX MEM WB
Instr. i+3 stall IF ID EX MEM WB
Instr. i+4 IF ID EX MEM WB
Instr. i+5 IF ID EX MEM
Instr. i+6 IF ID EX