Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

If no branch hazard reduction techniques are implemented in a pipeline, includin

ID: 663995 • Letter: I

Question

If no branch hazard reduction techniques are implemented in a pipeline, including stalling, a branch instruction might cause pipeline flushing to occur.

Assume the standard 5-stage MIPS pipeline is being used on this code:

label:         addi   $10, $10, 1

sub    $11, $12, $13

                  sw     $10, 100($9)

ori    $14, $15, 56                  

                                    bne    $10, $0, label

                  and    $16, $12, $13

       slt    $8, $9, $12

a. Using the above code in your explanation, explain the situation in which the pipeline will need to be flushed. Include in your explanation:

What kind of value would be stored in register $10 before this code begins to cause a pipeline flush?

When will the branch be evaluated? What instructions will be in the pipeline?

Which instructions would need to be flushed when this happens?

b. Using the above code in your explanation, explain the case when flushing would NOT occur. Include in your explanation:

What kind of value would be stored in register $10 before this code begins to prevent needing a pipeline flush?

What happens when the branch is evaluated and how does it affect the pipeline?

One way to prevent branch hazards and flushing is to stall until the branch decision is made. This causes a delay in the pipeline.

c. Another way of reducing the branch delay is to use “branch delay slots". Explain how the above code segment could be re-arranged to implement “branch delay slots", and eliminate the branch delays.

d. Another branch delay prevention/reduction method is prediction.

Which type of prediction would best reduce the branch delays in the above code segment (explain)?   

Would any delays still remain in the above code segment using this type of prediction?

Explanation / Answer

The pipeline will be flushed when the branch instruction will be executed in the program sequence. The branch will be evaluated on the bne instruction. Since it is a standard 5 stage pipeline architecture and,slt instruction will be in the pipeline.

Both the instruction will be flushed.

b)

The flushing will not occur if the branch prediction is correct. When the branch is evaualted it checks and decides whether to take the branch or not. If branch is taken then pipeline flush will happen otherwise it will continue with the program execution.

c)

Branch delay slots can be used here and it will help and and instruction will always be executed irrepsective of the condition in the branch instruction.

d)

Prediction can help here as all the branches are forward so it will imrpove the performance of the pipeline and no flush/stall will happen.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote