Hazards in pipeline

2,067 views 9 slides Aug 17, 2021
Slide 1
Slide 1 of 9
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9

About This Presentation

these slides explains hazards in instruction pipeline. Types of hazards and how to avoid it.


Slide Content

Hazards in Pipeline
Prepared by : Ms. Snehalata Agasti
CSE department

Hazards
Hazards means problem occurs in instruction pipeline (or) if two or more
microoperations occurred at same time than hazards occurs.
It isofthreetypes.
-Data hazards
-Control hazards
-Structural hazards
e.g. multiple instructions wants to access single ALU or memory. These are
called stall in pipeline.
➢Hazards can be avoided by using operand forwarding, renaming , branch
prediction technique or by introducing some stall cycles.

Structural hazards
Structural hazards occurs when more than one instructions in pipeline and
they need same resource.
It is also known as resource hazards.
This problemcanbesolvedbyincreasingtheresources.
F D W
F D W
F D W
t
0 t
1 t
2
I
1
I
2
I
3
Both micro
operations need
memory
operations

Control hazards
Whenbranchinstructionisexecutedandsomewrongpredictionshappened
thensomeinstructionsbroughtintopipeliningcanbediscarded,thatis
calledcontrolhazards/branchhazards.E.g.
100:gotolb:
101:Instruction1;
102:Instruction2;
103:Instruction3;
104lb:
Instruction4;
Byusingbranchpredictionsorbyincreasinglatency,controlhazardscanbe
avoided.
Instruction1 and
Instruction2 is
loaded in pipeline
Wrong
prediction

Data hazards
When data dependency is present in instructions that is called data hazards.
Data is modified in different stages.
It isofthreetypes
-RAW
-WAR
-WAW
E.g.instruction-1: C=A+B;
instruction-2: E=C+D
Data hazards can be avoided by using Operand forwarding.

RAW(Read After Write)
RAWdatahazardsoccurswhenourrequiredresultisnotfoundafterthe
executionofinstructions.
E.gI
1-:R
2R
7+R
5
I
2-:R
4R
2+R
3
Instrution-2shouldbeexecutedafterthecompleteexecutionofinstruction-
1.IfR
2inI
2isreadbeforewritingoperationperformedinI
1thenRAWdata
hazardscanbeoccurred.

WAR(Wite After Read)
WARdatahazardsoccurswhenourawaitedresultisnotfoundafterthe
executionofinstructions.
E.gI
1-:R
2R
7+R
5
I
2-:R
5R
2+R
3
Instrution-2shouldbeexecutedafterthecompleteexecutionofinstruction-
1.IfR
5inI
2isstoredbeforereadingoperationperformedinI
1thenWAR
conflictcanbeoccurred.

WAW(Write After Write)
WARdatahazardsoccurswhenourproperresultisnotfoundafterthe
completeexecutionofinstructions.
E.gI
1-:R
4R
1+R
5
I
2-:R
4R
1+R
3
Instrution-2shouldbeexecutedafterthecompleteexecutionofinstruction-
1.IfR
4inI
2isstoredbeforewritingoperationperformedinI
1thenWAWdata
hazardscanbeoccurred.