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

15 points) 3. Assume a processor that always predicts that conditional branches

ID: 3916870 • Letter: 1

Question

15 points) 3. Assume a processor that always predicts that conditional branches are not taken. What percentage of the time would it predict correctly for the following block of code? i $ro, 10 topOfLoop beq $ro, Szero, endLoop add Sr1, $rO, $r1 addi $ro, Sro,-1 br topOfLoop endLoop Percentage Correct If we modify the hardware so that the first time it encounters a conditional branch it predicts that it is not taken but after that it predicts it will do whatever it did on the previous time it ex will be the percentage of the time it will predict correctly? ecuted the loop. What Modified Percentage Correct

Explanation / Answer

The conditional branching statement is : beq $r0 , $zero , endLoop

$r0 starts with a value 10 and in each loop , it is decremented by 1 .

Hence the conditional branching statement is checked 11 times for $r0 values from 10 to 0

and the prediction fails on the 11 th time .

Therefore the correct prediction of conditional branches are not taken is 10 times .

The percentage being 10/11* 100 = 90.91 % approximate ( Correct )

In the second case also for the first time it predicts that conditional branches are not taken and is true . And hence it keeps on predicting that it will not take the conditional branch as the conditional branch is actually not taken . Till $r0 has a value 1 it is true but as it becomes 0 the prediction is false and the program counter goes to endLoop

Therefore there is no modification in the percentage value and

The modified Correct prediction percentage being 10/11* 100 = 90.91 % approximate ( Zero modification )

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