National University of Computer and Emerging Sciences, Lahore Campus
National University of Computer and Emerging Sciences, Lahore Campus
a. What must be changed in the pipelined datapath to add this instruction to the MIPS ISA?
b. Which new control signals must be added to your pipeline?
c. Does support for this instruction introduce any new hazards? Are stalls due to existing
hazards made worse?
The calculation for the branch instruction has been moved to decode stage which helps to reduce
the number of stalls from 3 to 1 due to control hazard. But this move affects the existing
forwarding logic. Consider the following two cases.
add R1, R1, 8
beq R1, R2, 30
ld R1, R3, 4
beq R1, R2, 30
In class we have only implemented exe to exe and mem to exe forwarding but in these cases we
may need to extend forwarding so that we can forward to decode stage as well.
Analyze above two cases and design a new unit in decodes stage that will cater these cases.
Draw the changes required in the below MIPS architecture along-with addition in the detection
and forwarding logic.
Question3:
Consider the following MIPS assembly language loop. Assume that we run this code on the five
stages pipelined data path. [20 marks]
a) Find all possible hazards in the above code. Fill the following table by writing lines and
register in front of particular hazard. For example if a WAR hazard exist between
instruction 1 and 2 due to register R0 then write 1 & 2 in column “Lines” and Register
number R0 in column “Register”.
WAW
RAW
c) Reschedule the code to remove as many stalls as possible with forwarding. How
many stalls are still required?
Question 4: 15 marks
Determine the accuracy of various branch predictors for the following pattern of branch
outcomes. These are the actual outcomes.
a. What is the accuracy of always-taken and always-not-taken predictors for this sequence
of branch outcomes?
b. What is the accuracy of the two-bit predictor for the first 4 branches in this pattern,
assuming that the predictor starts off from state (predict not taken)?
c. What is the accuracy of the two-bit predictor if this pattern is repeated forever?
Question 5: 15 marks
Consider the following clock cycle times for a 5-stage pipelined datapath
a. What is the total execution time of the above code sequence when pipeline without
forwarding is used? [5]
b. What is the total execution time of the above code sequence when pipeline with ALU-ALU
forwarding is used? [5]
c. What is the total execution time of the above code sequence when pipeline with full
forwarding is used? [5]