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

Consider the following loop. loop: lw r1, 0(r1) and r1, r1, r2 1 w r1, 0(r1) 1 w

ID: 3937139 • Letter: C

Question

Consider the following loop. loop: lw r1, 0(r1) and r1, r1, r2 1 w r1, 0(r1) 1 w r1, 0(r1) beq r1, r0, loop Assume that perfect branch prediction is used (no stalls due to control hazards), that there are no delay slots, and that the pipeline has full forwarding support. Also assume that many iterations of this loop are executed before the loop exits. Show a pipeline execution diagram for the third iteration of this loop, from the cycle in which we fetch the first instruction of that iteration up to (but not including) the cycle in which we can fetch the first instruction of the next iteration. Show all instructions that are in the pipeline during these cycles (not just those from the third iteration). Note that there are no stalls caused by control hazards. The branch prediction is perfect. If there are any pipeline stalls, explain why. For example, 'Stall in cycle 3: WAR on R1 in ADD'.

Explanation / Answer

egin{table}[hp]

caption{Third Iteration}label{tab:iteration}

egin{center}

egin{tabular}{cccccccccccccc}

oprule

extbf{Iter} & extbf{1} & extbf{2} & extbf{3} & extbf{4} & extbf{5}

& extbf{6} & extbf{7} & extbf{8} & extbf{9} & extbf{10} & extbf{11}

& extbf{12} & extbf{13} \

midrule

lw3 & WB \

beq & ID & EX & MEM & WB \

lw1 & IF & ID & EX & MEM & WB \

and & & & IF & ID & EX & MEM & WB \

lw2 & & & & IF & ID & EX & MEM & WB \

lw3 & & & & & & IF & ID & EX & MEM & WB \

beq & & & & & & & & & IF & ID & EX & MEM & WB \

lw1 & & & & & & & & & & IF & ID & EX & MEM \

and & & & & & & & & & & & & IF & ID \

lw2 & & & & & & & & & & & & & IF \

ottomrule

end{tabular}

end{center}

end{table}

subsection{2}

egin{fancyquotes}

end{fancyquotes}

So, if we consider that the loop will run a lot of times, then the useful cycles is $3/5=60%$ of all.

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