The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+2 votes

Consider the following Instruction sequence 
I1: ADD R1,R2,R1
I2: LW R2,0(R1)
I3: LW R1,4(R1)
I4: OR R3,R1,R2
And assume following five stage pipeline with following stages: 
The no of RAW hazards in the above Instruction sequence is? 
(A) 3 
(B) 2 
(C) 4 
(D) 1

Note:- I think there are 2 RAW hazards, b/w I1 & I2 and I3&I4.

asked in CO & Architecture by Boss (17.2k points) | 174 views
Is ans 4??
3 is the given answer.
btw, can you explain?

I got I1-I2 , I1-I3 ,I2-I4 ,I3-I4

yes i'm also getting 4 RAW hazards.but i think in instruction second after loading a word from memory location we can eliminate dependency at third instruction isn't it?
@srestha, RAW dependecies are 4 but RAW hazard are 3 only,

b/w I1-I2, I1-I3 and I3-I4
I havenot got u?
I4 of R2  is still dependent on I2
So, why not I2-I4??
yes, sorry.

i hadn't seen I2-I4, there will be 4 RAW hazard.
@nitish don't you think, when instruction I3 needs R1, I1 would update it, why is RAW hazard then?

because I2 will stall pipeline until I1 updates R1, and when I3 executes it will get updated value of R1.
Can someone answer why is there a hazard between I1 and I3, because until I2 completes I3 can't complete.
and I2 completes after I1 updates R1, right?

@ Vijay Thakur

I  understand ur point

A very good point u cited

But where is stall in I2 ?? and why there should be stall?? each instruction need 1 cycle only right?

Can u draw it plz



I think

if there is stall, there shouldnot be any WAW hazard

See here

But is there be any stall??

Correct me If I am wrong :

Considering absence of Operand Forwarding (because, it is not given in the question), I think there are 3 RAW hazards between I1-I2, I2-I4 and I3-I4.

1 Answer

0 votes

RAW Hazards----> Read After Write hazard is created when the instruction "j" tries to read the data before the instruction "i" writes it. It is also called True data dependency. It checks only for adjacent instructions.

In the above question,

there are 2 RAW hazards between I1,I2 and I3,I4.

option b.

answered by Junior (677 points)
I2-I4 also for R2
while counting RAW hazards, we will consider only adjacent instructions.

Related questions

0 votes
0 answers
asked Nov 14 in CO & Architecture by Na462 Loyal (7.4k points) | 41 views
+1 vote
2 answers

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

44,265 questions
49,758 answers
65,849 users