edited by
24,468 views
64 64 votes

A pipelined processor uses a $4-$stage instruction pipeline with the following stages: Instruction fetch (IF), Instruction decode (ID), Execute (EX) and Writeback (WB). The arithmetic operations as well as the load and store operations are carried out in the EX stage. The sequence of instructions corresponding to the statement $X = (S - R * (P + Q))/T$ is given below. The values of variables $P, Q, R, S$ and $T$ are available in the registers $R0, R1, R2, R3$ and $R4$ respectively, before the execution of the instruction sequence.
$$\begin{array}{ll} \text{ADD} & \text{R5, R0, R1} && \text{; R5 ← R0 + R1} \\  \text{MUL} & \text{R6, R2, R5} && \text{; R6 ← R2 * R5} \\   \text{SUB} & \text{R5, R3, R6} && \text{; R5 ← R3 - R6} \\  \text{DIV} & \text{R6, R5, R4} && \text{; R6 ← R5/R4} \\ \text{STORE} & \text{R6, X} && \text{; X  ← R6} \\ \end{array}$$
The number of Read-After-Write (RAW) dependencies, Write-After-Read( WAR) dependencies, and Write-After-Write (WAW) dependencies in the sequence of instructions are, respectively,

  1. $2, 2, 4$
  2. $3, 2, 3$
  3. $4, 2, 2$
  4. $3, 3, 2$

4 Answers

Best answer
68 68 votes

(C) is the correct option for this question:

RAW

  1. I1 - I2 (R5)
  2. I2 - I3 (R6)
  3. I3 - I4 (R5)
  4. I4 - I5 (R6)


WAR 

  1. I2 - I3 (R5)
  2. I3 - I4 (R6)


WAW

  1. I1 - I3 (R5)
  2. I2 - I4 (R6)
edited by
0 0 votes

Instruction sequence (rewrite clearly)

InstrInstructionRegisters READRegisters WRITTEN
I1ADD R5, R0, R1R0, R1R5
I2MUL R6, R2, R5R2, R5R6
I3SUB R5, R3, R6R3, R6R5
I4DIV R6, R5, R4R5, R4R6
I5STORE R6, XR6X (memory)    
  • I1 → I2 :

    • I1 writes R5, I2 reads R5 → ✅ RAW

  • I2 → I3 :

    • I2 writes R6, I3 reads R6 → ✅ RAW

  • I3 → I4 :

    • I3 writes R5, I4 reads R5 → ✅ RAW

  • I4 → I5 :

    • I4 writes R6, I5 reads R6 → ✅ RAW

Total RAW = 4 

 

 

  • I2 reads R5, I3 writes R5 → ✅ WAR

  • I3 reads R6, I4 writes R6 → ✅ WAR

Total WAR = 2

 

 

  • I1 writes R5, I3 writes R5 → ✅ WAW

  • I2 writes R6, I4 writes R6 → ✅ WAW

Total WAW = 2

 

 

 

1 flag:
✌ (js__)
Answer:
Position:
Show:

Related questions

67 67 votes
6 answers 6 answers
32.0k
32.0k views
Ishrat Jahan asked Nov 1, 2014
31,988 views
A pipelined processor uses a 4-stage instruction pipeline with the following stages: Instruction fetch (IF), Instruction decode (ID), Execute (EX) and Writeback (WB). The...
78 78 votes
11 answers 11 answers
33.2k
33.2k views
go_editor asked Sep 28, 2014
33,167 views
Consider a $6$-stage instruction pipeline, where all stages are perfectly balanced. Assume that there is no cycle-time overhead of pipelining. When an application is exec...
196 196 votes
8 answers 8 answers
76.5k
76.5k views
Kathleen asked Sep 22, 2014
76,457 views
A $5$ stage pipelined CPU has the following sequence of stages:IF – instruction fetch from instruction memoryRD – Instruction decode and register readEX – Execute: ALU op...
74 74 votes
4 answers 4 answers
35.0k
35.0k views
Kathleen asked Sep 12, 2014
34,963 views
Which of the following are NOT true in a pipelined processor?Bypassing can handle all RAW hazardsRegister renaming can eliminate all register carried WAR hazardsControl h...