Professional Documents
Culture Documents
1. CONCEPT OF PIPELINING 3
5. CONTROL HAZARD 1
6. REFERENCES 1
WHAT IS PIPELINING??
S1 S2 S3 S4
Time Time
(Break the tasks into smaller stages)
1 2 3 4 5
IF i1 i2 i3
ID i1 i2 i3
EX i1 i2 i3
WB i1 i2
Hazard??
problems with the instruction pipeline in CPU microarchitectures
when the next instruction cannot execute in the following clock
cycle.
TYPES OF HAZARDS
Three common types of hazards :
Data hazards
Structural hazards
Control hazards (branching hazards).
1 2 3 4 5
IF i j
ID ADD SUB
OF R2 R3 R1 R6
EX R2+ R3 R1-R6
WB R1 ←Result
Inconsistency
• SOLUTION: Delay the pipe
• IDEA: Delay the execution of operand fetch till the result gets stored in
the register which is the cause of inconsistency
1 2 3 4 5 6 7 8
IF I J
ID ADD SUB
DELAY
OF R2 R3 R1 R6
EX R2+R3 R1-R6
WB R1← RESULT R4 ← RESULT
Condition for checking read after write (WR) hazard: If i<j &
Wi ∩Rj ≠ 0
Example:
i= ADD R1,R2,R3 j=SUB R4,R1,R6
If jth instruction gets executed before the ith instruction, then the
ith instruction would add into R1 a modified value of R2 & thus
it would produce an incorrect result. This is called RW hazard.
1 2 3 4 5 6
IF i1 i2 i3
WB R1 ←RESULT R1 ←RESULT
• Here R1 is used for two purposes, fetching the previous value
and storing the result also in clock cycle 4. That will lead to the
incorrect value.
• Solution:Firstly,store the result in R1 in cc4 and delay the pipe
and then fetch the value of R1 for next instruction.
1 2 3 4 5 6 7 8
IF i1 i2 I3 i4 i6
i3
ID i1 if(cond.) i6
EX i1 false i6
WB i1 i6
References: