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

SHORT ANSWER: Given the following MIPS code: lw $s1, 0($s5) add $t0, $s1, $s2 be

ID: 3890288 • Letter: S

Question

SHORT ANSWER:

Given the following MIPS code:

                        lw         $s1, 0($s5)

                        add      $t0, $s1, $s2

                        beq      $t0, $t1, next

                        sub      $t2, $t1, $t0

                        addi     $t2, $t2, 1

                        j           after

            next:    sw       $s1, 20($t1)

            after:    sw       $t0, 0($s5)

How many nanoseconds will it take to run the code on a single cycle datapath processor with a cycle time of 10 nanoseconds if the branch IS taken?

Explanation / Answer

lw         $s1, 0($s5)

add      $t0, $s1, $s2

beq      $t0, $t1, next

next:    sw       $s1, 20($t1)

Let

c1 = no. of cycles to run lw

c2 = no. of cycles to run add

c3 = no. of cycles to run beq

c4 = no. of cycles to run sw

So total number of nanoseconds = (c1+c2+c3+c4) * 10 ns