in CO and Architecture edited by
15,430 views
46 votes
46 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$
in CO and Architecture edited by
15.4k views

4 Comments

sir, I have small doubt about WAW Dependency

what if the last instruction was "LOAD R6,X" instead of "STORE R6,X"

at that time how many WAW Dependencies will occur due To R6? and what are they?

@Arjun @Deepak Poonia @Sachin Mittal 1

0
0

what if the last instruction was "LOAD R6,X" instead of "STORE R6,X"

at that time how many WAW Dependencies will occur due To R6? and what are they?

@viniit 2 WAW dependencies in that case.

1: $Mul -Div$

2: $Div – Load$

NOTE that $Mul-Load$ would not be a WAW dependency because in between $Div$ is writting into $R_6.$

 

2
2
understood sir, thank you
0
0

2 Answers

53 votes
53 votes
Best answer

(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

4 Comments

consider, instead of 4 stage , 5 stage pipeline is used then

RAW will be 6,

The 4 which are mentioned and

I1- I4

I2- I5

 

Correct me, if i am wrong
0
0
Is there any difference between dependency and hazard? If I remember correctly, dependency is what‘s been calculated in this question, but hazards will not be the same. They will be only those dependencies that are actually affecting our pipeline (i.e those dependencies which are causing stalls).

Are my concepts wrong? Can anyone please clarify?
1
1
Yes you are right
0
0
0 votes
0 votes
C : as RAW dependency is 4.
Answer:

Related questions