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

The following code adds integers in two arrays (whose address is $s0 and $s1) an

ID: 3771253 • Letter: T

Question

The following code adds integers in two arrays (whose address is $s0 and $s1) and stores the results in the first array. $s2 is initialized to 0. $s3 is 100. I1 : lw $t0 , 0( $s0 ) I2 : lw $t1 , 0( $s1 ) I3 : addu $t0 , $t0 , $t1 I4 : sw $t0 , 0( $s0 ) I5 : addi $s0 , $s0 , 4 I6 : addi $s1 , $s1 , 4 I7 : addi $s2 , $s2 , 1 I8 : bne $s2 , $s3 , I1 I9 : sll $0 , $0 , 0 Assume MIPS processors with a 5-stage pipeline. Assume the processor has all the forwarding paths needed. The conditional branch is resolved in the ID stage. show the pipeline diagram from the IF stage of I1 to the IF stage of I1 in the next iteration and compute the number of cycles needed for the loop. Scheduling instructions can remove some hazards that cannot be handled by hardware without pipeline stalls. Schedule the instructions in the above problem to reduce pipeline stalls. How many cycles do you need for your scheduled code?

Explanation / Answer


Loop Pipeline stages Useful reads   % Useful addi $6,$6,4   ID EX ME WB 5.60%    addi $5,$5,-4 ID EX ME WB (2/(6 × 6)) beq $5,$0,Loop ID ** EX ME WB lw $1,40($6) IF ** ID EX ME WB 0 ($6 fw) add $5,$5,$1 IF ** ID ** ** EX ME WB 0 ($1, $5 fw) sw $1,20($5) IF ** ID ** ** ** EX ME WB 0 ($1, $5 fw) addi $6,$6,4 IF ** ** ** ID EX ME WB 1 addi $5,$5,-4 IF ** ** ** ID EX ME WB 0 ($5 fw) beq $5,$0,Loop          IF ** ** ** ID ** EX ME WB 1 ($5 fw)


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