246,578 views
7 votes
7 votes
4.20 Problem in this exercise refer to the following instructions sequence: a. ADD R1, R2, R3 LW R2, 0(R1) LW R1, 4(R1) OR R3, R1, R2. b. LW R1, 0(R1) AND R1, R1, R2 LW R2. 0(R1) LW R1, 0(R3). 4.20.1[5]<4.7> Find all data dependences in this instruction sequences. 4.20.2[10]<4.7> Find all hazards in this sequence for a 5-stage pipeline with and then without fowarding.

User Erez Ben Harush
by
2.6k points

1 Answer

8 votes
8 votes

Solution :

Given :

a). ADD
$R1,R2,R1$

LW
$R2, 0(R1)$

LW
$R1, 4(R1)$

OR
$R3,R1,R2$

Without forwarding

Only the RAW dependencies can cause data hazards.

The dependencies are :

RAW dependency between instruction 1 and 2 on R1

RAW dependency between instruction 1 and 3 on R1

RAW dependency between instruction 3 and 4 on R1

RAW dependency between instruction 2 and 4 on R2

With forwarding

The result after the execution phase of first instruction is forwarded to second instruction.

So there would not be any dependencies among instruction 1 and 2 and also 1 and 3.

With forwarding the RAW dependencies that can exit only from load to next instruction.

So the dependencies that exit is only between 3 and 4.

The dependencies are RAW dependencies between instruction 3 and 4 on R1.

b). LW
$R1,0(R1)$

AND
$R1,R1,R2$

LW
$R2,0(R1)$

LW
$R1,0(R3)$

Only RAW dependencies can cause data hazards

The dependencies are

RAW dependency between instruction 1 and 2 on R1

RAW dependency between instruction 1 and 3 on R1

RAW dependency between instruction 2 and 3 on R1

With forwarding

The result after the execution phase of second instruction is forwarded to third instruction.

So there won't be RAW dependencies among instruction 2 and 3.

With forwarding the RAW dependencies that can exist only from load to next instruction.

So dependencies that exists is only between 1 and 2.

Therefore dependencies are RAW dependency between instruction 1 and 2 on R1.

User Ege Akpinar
by
2.6k points