Professional Documents
Culture Documents
Lecture # 9 & 10
Course Instructor: Dr. Afshan Jamil
Outline
• An overview of pipelining
• Pipelining analogy
• RISC-V Pipeline
• Pipeline performance example
• Pipeline speedup
• Pipeline and ISA design
• Pipeline hazards
• Structural hazard
• Data hazard
• Control hazard
• Pipeline summary
An overview of pipelining
• Pipelining is an implementation technique in which
multiple instructions are overlapped in execution.
• All steps in a task, called stages in pipelining, operate
concurrently.
• If we have separate resources for each stage, we can
pipeline the tasks.
• Pipelining improves performance by increasing
instruction throughput, as opposed to decreasing the
execution time of an individual instruction.
CONTD…
– Load/store addressing
• Can calculate address in 3rd stage, access memory
in 4th stage
– Alignment of memory operands
• Memory access takes only one cycle
Pipeline Hazards
I n s tr u c tio n D a ta
ld x9 , 4 0 0 ( x22 ) R eg ALU R eg
2 ns f e tc h acces s
2 ns 2 ns 2 ns 2 ns 2 ns
13 cycles 11 cycles
CONTD…
• Reordered code:
ld x6, 0(x22)
ld x8, 4(x22)
sd x9, 4(x22)
Interchanged
sd x8, 0(x22)
Control Hazards
Prediction
correct
Prediction
incorrect
More-Realistic Branch Prediction
• Static branch prediction
– Based on typical branch behavior
– Example: loop and if-statement branches
• Predict backward branches taken
• Predict forward branches not taken
• Dynamic branch prediction
– Hardware measures actual branch behavior
• e.g., record recent history of each branch
– Assume future behavior will continue the trend
• When wrong, stall while re-fetching, and update history
Pipeline Summary
The BIG Picture