Engineering

Consider the following E20 assembly language program, which will find the largest number in an array. You've seen this program before.main:movi $1,0# ram [0]movi $7,0# ram [1]repeat:lw $2, array ($1)# ram [2]jeq $2, $0, done# ram [3]slt $5, $7, $2# ram [4]jeq $5, $0, next# ram [5]add $7, $0, $2next:# ram [6]addi $1, $1, 1# ram [7]j repeat# ram [8]done:halt# ram [9]array:.fill 53# ram [10]A conditional jump in the form of a jeq instruction can cause a control hazard because it's not clear which instruction should be put in the pipeline next. Each conditional jump may have one of two possible resolutions: either it will branch (i.e. the next instruction in the pipeline is the target of the jump) or it will not not branch (i.e. the next instruction in the pipeline is the instruction in the subsequent memory location after the conditional jump instruction).In all cases, if the next instruction is predicted wrong (a misprediction), it must be squashed from the pipeline, and the correct instruction fetched after a bubble. To avoid the penalty of frequent mispredictions, we want to choose the best possible branch predictor.In case of control hazards caused by a conditional jump instruction such as jeq, stalls can be reduced by using a branch predictor. In class, we discussed three kinds of branch predictors: Predict branch taken - After a conditional jump, the next instruction in the pipeline will the bethe target of the jump. Predict branch not taken - After a conditional jump, the next instruction in the pipeline will be the instruction at the subsequent memory address. Dynamic prediction - After a conditional jump, the next instruction will be chosen based on the resolution of the previous execution of the conditional jump. If there was no previous execution of the conditional jump, predict that the branch will not be taken.In answering the following questions about the above E20 program, assume that each misprediction results in a penalty of 3 clock cycles, occupied by a pipeline bubble while the correct instruction is executed. For the purposes of this exercise, you can ignore other hazards.(a) What will be the total misprediction penalty accrued in the above program, if it is run on a processor that always predicts branch taken? Justify your answer.(b) What will be the total misprediction penalty accrued in the above program, if it is run on a processor that always predicts branch not taken? Justify your answer.(c) What will be the total misprediction penalty accrued in the above program, if it is run on aprocessor that uses dynamic prediction based on the previous resolution? Justify your answer.