Consider the following instruction sequence in a single-issue in-order 5-stage pipeline (IF, ID, EX, MEM, and WB).

Opcode Destination Source1 Source2  
ADD R1 R2 R3 ← First instruction to enter the pipeline
SUB R2 R3 R1  
MUL R1 R2 R3 ← Last instruction to enter the pipeline

The number of data hazards that the ID stage need to detect for this instruction sequence is _____________.

Answer hidden

priyanka gautam @priyankagautam
18 Jan 2017 11:43 am

i think 5 should be the answer data hazards include war,raw,waw so here 2 raw,2 wae nd 1 waw depandency correct me whr m getting wrong ??

Sudarshana Tripathy @sudarshanatripa
18 Jan 2017 11:49 am

Can someone please explain this ?


Niharika @dniharika
20 Jan 2017 09:45 pm

There are 3 types of Data Hazards means some dependency while executing on the DATA

Here 2 RAW means reading value after writing .In instruction 1 we are writing value to R1 and in instruction 2 we are reading,so dependency

Similarly for R2 in innstruction 2 we are writing and in instruction 3 we are Reading

Now WAR means R2 in 1st instruction reading value to perform addition and store in R3 and in second instruction we are writing in to R2 .so dependency

In R1 we are writing the value in instruction 1 and also instruction 3 sothere is a WAW dependency b/w this two instructions

Lokesh @lokeshkumar
19 Jan 2017 10:40 am

5 should be the answer


PratikS @pratikshende
19 Jan 2017 02:00 pm

ans has to be 5