CO-Grand Test 1-Q12

+1 vote

Consider the following instruction 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


How many data hazards does the ID stage need to detect for this instruction sequence?

(A) 1

(B) 2

(C) 3

(D) 4

asked Jun 25 in Computer Organization by gbeditor (21,290 points)
reshown Jun 26 by gbeditor

1 Answer

0 votes
Best answer
For ID stage the data hazard detected is

1. RAW in second instruction (wrt to R1 in 1st instruction)

Hence stall the pipeline.

2. Now while executing , second ins, ID stage in third ins detects RAW R2.

Hence stall pipeline.


Hence, 2  data hazards are to be detected.
answered Jul 2 by gbmentor (73,570 points)
why WAR in instruction 2 and 3 of register R1 is not considered