0% found this document useful (0 votes)
161 views8 pages

Data Hazards and Its Handling Methods

Data hazards occur when an instruction depends on the result of a previous instruction before it has been computed. There are four types: read after write, write after read, write after write, and read after read. Data hazards are handled through forwarding, code reordering, and stall insertion. Forwarding adds circuits to bypass results to dependent instructions. Code reordering uses compilers to reorder instructions. Stall insertion inserts no-operation instructions to delay execution until operands are ready.

Uploaded by

Surya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
161 views8 pages

Data Hazards and Its Handling Methods

Data hazards occur when an instruction depends on the result of a previous instruction before it has been computed. There are four types: read after write, write after read, write after write, and read after read. Data hazards are handled through forwarding, code reordering, and stall insertion. Forwarding adds circuits to bypass results to dependent instructions. Code reordering uses compilers to reorder instructions. Stall insertion inserts no-operation instructions to delay execution until operands are ready.

Uploaded by

Surya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Data Hazards and

Its Handling
Methods
Data Hazards :

 It occur when an instruction depends on the result of previous


instruction and that result of instruction has not yet been
computed. whenever two different instructions use the same
storage. the location must appear as if it is executed in sequential
order. 
 There are four types of data dependencies: Read after Write
(RAW), Write after Read (WAR), Write after Write (WAW), and
Read after Read (RAR). These are explained as follows below . 
Read after Write (RAW) : 

 It is also known as True dependency or Flow dependency. It occurs when the


value produced by an instruction is required by a subsequent instruction.
For example:
ADD R1, --, --;
SUB --, R1, --;

 Stalls are required to handle these hazards.


Write after Read (WAR) :

 It is also known as anti dependency. These hazards occur when the output
register of an instruction is used right after read by a previous instruction.

For example:
ADD --, R1, --;
SUB R1, --, --;
Write after Write (WAW) :

 It is also known as output dependency. These hazards occur when the output
register of an instruction is used for write after written by previous instruction.

For example:
ADD R1, --, --;
SUB R1, --, --;
Read after Read (RAR) : 

 It occurs when the instruction both read from the same register.
For example:
ADD --, R1, --;
SUB --, R1, --;
 Since reading a register value does not change the register value, these Read
after Read (RAR) hazards don’t cause a problem for the processor
Handling Data Hazards :

 These are various methods we use to handle hazards: Forwarding,


Code recording, and Stall insertion.
 These are explained as follows below.
 Forwarding
 Code reordering
 Stall Insertion
Forwarding :
 It adds special circuitry to the pipeline. This method works because it takes less time for the
required values to travel through a wire than it does for a pipeline segment to compute its result.
Code reordering :
 We need a special type of software to reorder code. We call this type of software a hardware-
dependent compiler.
Stall Insertion :
 it inserts one or more installs (no-op instructions) into the pipeline, which delays the execution of
the current instruction until the required operand is written to the register file, but this method
decreases pipeline efficiency and throughput.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy