Consider the following loop loop lw r1 0r1 and r1 r1 r2 1 w

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\'.

Solution

\\begin{table}[hp]

\\caption{Third Iteration}\\label{tab:iteration}

\\begin{center}

\\begin{tabular}{cccccccccccccc}

\\toprule

\\textbf{Iter} & \\textbf{1} & \\textbf{2} & \\textbf{3} & \\textbf{4} & \\textbf{5}

& \\textbf{6} & \\textbf{7} & \\textbf{8} & \\textbf{9} & \\textbf{10} & \\textbf{11}

& \\textbf{12} & \\textbf{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 \\\\

\\bottomrule

\\end{tabular}

\\end{center}

\\end{table}

\\subsection{2}

\\begin{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.

 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 s
 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 s

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site