Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 beq $ 2 , $ 0 , endloop 2 add $ 3 , $ 0 , $ 1 3 add $ 4 , $
beq $ $ endloop
add $ $ $
add $ $ $
loop : addi $ $
lw $ $
s l t $ $ $
bne $ $ e n d i f
sub $ $ $
sw $ $
e n d i f : addi $ $
bne $ $ loop
endloop : j r $
For this question assume that pipelining has been
implemented. Assume that each stage takes cycle to complete.
a Identify the pipeline hazards present in this code, ie situations that would generate stall bubbles. In the case of data hazards, identify the two lines of code involved.
b Assume that this program is run using the array frontend, and
that register $ contains the address of the first element of the
array, and $ contains the size of the array. Assume that the size
of the array is and that the numbers have been
placed in the array. Assuming that no pipeline optimizations
have been implemented, ie no forwarding or branch prediction,
determine the number of cycles it takes to complete the
execution of this program.
Justify your answer using a pipeline diagram formatted like the
picture attached. It may be helpful to use a spreadsheet to draw the diagram.
c Suppose forwarding and static branch prediction have been
implemented. Given the same array, when compared to the
answer in part b:
how many cycles would be saved due to forwarding?
how many cycles would be saved due to static branch
prediction?
Consider each case forwarding and branch prediction
separately. In each case, identify which lines of stall bubbles
from your diagram in part b will be eliminated.
d Suppose you ran the same code with an array
Would there be any difference between the
number of stall bubbles saved using static branch prediction
compared to the number of stall bubbles saved using dynamic
branch prediction for the branch instruction at Line
Briefly justify your answer.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started