This exercise is intended to help you understand the relationship between delay slots, control hazards, and branch

Question:

This exercise is intended to help you understand the relationship between delay slots, control hazards, and branch execution in a pipelined processor. In this exercise, we assume that the following MIPS code is executed on a pipelined processor with a 5-stage pipeline, full forwarding, and a predict-taken branch predictor:

1w r2,0(r1) labell: beq r2,r0,label2 # not taken once, then taken 1w r3,0(r2) beq r3,r0,1abell # taken add r1,r3,rl labe

1. Draw the pipeline execution diagram for this code, assuming there are no delay slots and that branches execute in the EX stage.

2. Repeat 4.14.1, but assume that delay slots are used. In the given code, the instruction that follows the branch is now the delay slot instruction for that branch.

3. One way to move the branch resolution one stage earlier is to not need an ALU operation in conditional branches. The branch instructions would be €œbez rd,label€ and €œbnez rd,label€, and it would branch if the register has and does not have a zero value, respectively. Change this code to use these branch instructions instead of beq. You can assume that register R8 is available for you to use as a temporary register, and that an seq (set if equal) R-type instruction can be used.

4. Using the first branch instruction in the given code as an example, describe the hazard detection logic needed to support branch execution in the ID stage as in Figure 4.62. Which type of hazard is this new logic supposed to detect?

Figure 4.62

and $12, $2, $5 beq $1, $3,7 sub $10, $4, $8 befores1> before<2 FFlush Hazard datoction unit EX EXMEM MEMWE IFID Ragista

5. For the given code, what is the speedup achieved by moving branch execution into the ID stage? Explain your answer. In your speedup calculation, assume that the additional comparison in the ID stage does not affect clock cycle time.

6. Using the first branch instruction in the given code as an example, describe the forwarding support that must be added to support branch execution in the ID stage. Compare the complexity of this new forwarding unit to the complexity of the existing forwarding unit in Figure 4.62.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

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