For the following MIPS assembly code to be executed using the pipelined datapath
ID: 3763566 • Letter: F
Question
For the following MIPS assembly code to be executed using the pipelined datapath, identify all of the data dependences (which register in which instruction needs the result register value from another instruction?) and enumerate them (give them numbers as 1,2,...). Which dependences are data hazards that will be resolved via forwarding and without a stall (you can specify the numbers) from the part a)? Which dependences are data hazards that will cause a stall (you can specify the number(s) from the part a)?Explanation / Answer
Answer:
Label the given instructions as follows:
a add $t2, $t1, $t4
b lw $t3, 4($t2)
c sub $t8, $t2, $t5
d sub $t9, $t3, $t8
e lw $t7, 8($t8)
f add $t4, $t3, $t7
a)
According to pipeline data path, the dependencies are,
1 $t2 is dependencies in instruction b and c
2 $t4 is dependencies in instruction f.
3 $t3 is dependencies in instruction d and f
4 $t8 is dependencies in instruction d and e
5 $t7 is dependencies in f
b)
The data hazards that can be resolved via forwarding and without stalls are
1 $t2 can be forwarded from instruction a to b.
2 $t4 can be forwarded from instruction a to f
3 $t3 can be forwarded from instruction b to d to f
4 $t8 can be forwarded from instruction c to d and e.
5 $t7 can be forwarded.
c)
1 $t2 has to be loaded from instruction a and then be used in instruction b.
4 $t8 has to be loaded from instruction c and then be used in instruction d.
5 $t7 has to be loaded from instruction e and then be used in instruction f.