Solution:
Given instruction sequences:
I1: ADD R1, R2, R1
I2: LW R2, 0(R1)
I3: LW R1, 4(R1)
I4: OR R3, R1, R2
(1) In given instruction sequences, the following data dependencies occur:
RAW: Read-After-Write
WAR: Write-After-Read
WAW: Write-After-Write
These data dependencies are given in Table 1 with instruction sequences:
Table 1: Data
dependencies
|
Instruction Sequences |
RAW |
WAR |
WAW |
|
I1: ADD R1, R2, R1 I2: LW R2, 0(R1) I3: LW R1, 4(R1) I4: OR R3, R1, R2 |
(R1) I1 to I2, I3 (R2) I2 to I4 (R1) I3 to I4 |
(R2) I1 to I2 (R1) I1, I2 to I3 |
(R1) I1 to I3 |
With forwarding and without forwarding, only RAW dependence from a load to the very next instruction become data hazards and any RAW dependence from an instruction to one of the
following 3 instructions becomes a hazard respectively.
RAW dependencies with or without data hazards are given in Table 2:
Table 2
|
Instruction Sequence |
With Forwarding |
Without Forwarding |
|
I1: ADD R1, R2, R1 I2: LW R2, 0(R1) I3: LW R1, 4(R1) I4: OR R3, R1, R2 |
(R1) I3 to I4 |
(R1) I1 to I2, I3 (R2) I2 to I4 (R1) I3 to I4 |
|
Instruction Sequence |
With Forwarding |
Without Forwarding |
|
I1: ADD R1, R2, R1 I2: LW R2, 0(R1) I3: LW R1, 4(R1) I4: OR R3, R1, R2 |
(R2) I2 to I4 (R1) I3 to I4 |
(R1) I1 to I2, I3 (R2) I2 to I4 (R1) I3 to I4 |
No comments:
Post a Comment