Solution :
Given :
a). ADD [tex]$R1,R2,R1$[/tex]
LW [tex]$R2, 0(R1)$[/tex]
LW [tex]$R1, 4(R1)$[/tex]
OR [tex]$R3,R1,R2$[/tex]
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 [tex]$R1,0(R1)$[/tex]
AND [tex]$R1,R1,R2$[/tex]
LW [tex]$R2,0(R1)$[/tex]
LW [tex]$R1,0(R3)$[/tex]
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.