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 is of three types.
-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 problem can be solved by increasing the resources.
F D W
F D W
F D W
t0 t1 t2
I1
I2
I3
Both micro
operations need
memory
operations
Control hazards
 When branch instruction is executed and some wrong predictions happened
then some instructions brought into pipelining can be discarded, that is
called control hazards/branch hazards. E.g.
100: goto lb:
101: Instruction1;
102: Instruction2;
103: Instruction3;
104lb:
Instruction4;
 By using branch predictions or by increasing latency , control hazards can be
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 is of three types
-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)
 RAW data hazards occurs when our required result is not found after the
execution of instructions.
 E.g I1 -: R2  R7 + R5
I2 -: R4  R2 + R3
 Instrution-2 should be executed after the complete execution of instruction-
1. If R2 in I2 is read before writing operation performed in I1 then RAW data
hazards can be occurred.
WAR(Wite After Read)
 WAR data hazards occurs when our awaited result is not found after the
execution of instructions.
 E.g I1 -: R2  R7 + R5
I2 -: R5  R2 + R3
 Instrution-2 should be executed after the complete execution of instruction-
1. If R5 in I2 is stored before reading operation performed in I1 then WAR
conflict can be occurred.
WAW(Write After Write)
 WAR data hazards occurs when our proper result is not found after the
complete execution of instructions.
 E.g I1 -: R4  R1 + R5
I2 -: R4  R1 + R3
 Instrution-2 should be executed after the complete execution of instruction-
1. If R4 in I2 is stored before writing operation performed in I1 then WAW data
hazards can be occurred.
Hazards in pipeline

Hazards in pipeline

  • 1.
    Hazards in Pipeline Preparedby : Ms. Snehalata Agasti CSE department
  • 2.
    Hazards  Hazards meansproblem occurs in instruction pipeline (or) if two or more microoperations occurred at same time than hazards occurs.  It is of three types. -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.
  • 3.
    Structural hazards  Structuralhazards occurs when more than one instructions in pipeline and they need same resource.  It is also known as resource hazards.  This problem can be solved by increasing the resources. F D W F D W F D W t0 t1 t2 I1 I2 I3 Both micro operations need memory operations
  • 4.
    Control hazards  Whenbranch instruction is executed and some wrong predictions happened then some instructions brought into pipelining can be discarded, that is called control hazards/branch hazards. E.g. 100: goto lb: 101: Instruction1; 102: Instruction2; 103: Instruction3; 104lb: Instruction4;  By using branch predictions or by increasing latency , control hazards can be avoided. Instruction1 and Instruction2 is loaded in pipeline Wrong prediction
  • 5.
    Data hazards  Whendata dependency is present in instructions that is called data hazards. Data is modified in different stages.  It is of three types -RAW -WAR -WAW  E.g. instruction-1: C=A+B; instruction-2: E=C+D  Data hazards can be avoided by using Operand forwarding.
  • 6.
    RAW(Read After Write) RAW data hazards occurs when our required result is not found after the execution of instructions.  E.g I1 -: R2  R7 + R5 I2 -: R4  R2 + R3  Instrution-2 should be executed after the complete execution of instruction- 1. If R2 in I2 is read before writing operation performed in I1 then RAW data hazards can be occurred.
  • 7.
    WAR(Wite After Read) WAR data hazards occurs when our awaited result is not found after the execution of instructions.  E.g I1 -: R2  R7 + R5 I2 -: R5  R2 + R3  Instrution-2 should be executed after the complete execution of instruction- 1. If R5 in I2 is stored before reading operation performed in I1 then WAR conflict can be occurred.
  • 8.
    WAW(Write After Write) WAR data hazards occurs when our proper result is not found after the complete execution of instructions.  E.g I1 -: R4  R1 + R5 I2 -: R4  R1 + R3  Instrution-2 should be executed after the complete execution of instruction- 1. If R4 in I2 is stored before writing operation performed in I1 then WAW data hazards can be occurred.