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

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: 
IF,ID,EXE,MEM,WB 
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
0
Is ans 4??
0
3 is the given answer.
btw, can you explain?
0

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

0
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?
+1
@srestha, RAW dependecies are 4 but RAW hazard are 3 only,

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

i hadn't seen I2-I4, there will be 4 RAW hazard.
0
@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.
0
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?
0

@ 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

0

@joshi_nitish

I think

if there is stall, there shouldnot be any WAW hazard

See herehttps://gateoverflow.in/753/gate2001-12

But is there be any stall??

0
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)
0
I2-I4 also for R2
0
while counting RAW hazards, we will consider only adjacent instructions.

Related questions

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


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
164,207 comments
65,849 users