Consider the fragment of MIPS assembly below: sd $s5, 12($s3) Id $s5, 8($s3) sub $s4, $s2, $s1

Question:

Consider the fragment of MIPS assembly below:

sd $s5, 12($s3)

Id $s5, 8($s3)

sub $s4, $s2, $s1

beqz $s4, label

add $s2, $s0, $s1

sub $s2, $s6, $s1


Suppose we modify the pipeline so that it has only one memory (that handles both instructions and data). In this case, there will be a structural hazard every time a program needs to fetch an instruction during the same cycle in which another instruction accesses data.

1. Draw a pipeline diagram to show were the code above will stall.

2. In general, is it possible to reduce the number of stalls/NOPs resulting from this structural hazard by reordering code?

3. Must this structural hazard be handled in hardware? We have seen that data hazards can be eliminated by adding NOPs to the code. Can you do the same with this structural hazard? If so, explain how. If not, explain why not.

4. Approximately how many stalls would you expect this structural hazard to generate in a typical program?

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: