Question: Q 1 6 . Pipelining [ 1 3 marks ] Refer to the following MIPS code which is the same as the one in question

Q16. Pipelining [13 marks]
Refer to the following MIPS code which is the same as the one in question 15. Here, we look only at instructions I1 to I19. Pay attention to the assumptions (underlined) given below.
```
add $t0, $0, $0 # I1; i =0
addi $t1, $a1,0 # I2; $t1= &A[0]
addi $t2, $a2,0 # I3; $t2= &B[0]
sll $t3, $a0,2 # I4
loop: slt $t4, $t0, $t3 # I5
beq $t4, $0, end # I6
lw $s1,0($t1) # I7
lw $s2,0($t2) # I8
slt $t4, $s1, $s2 # I9
beq $t4, $0, skip # I10
add $t9, $s1, $0 # I11
add $s1, $s2, $0 # I12
add $s2, $t9, $0 # I13
skip: sw $s1,0($t1) # I14
sw $s2,0($t2) # I15
addi $t0, $t0,4 # I16
addi $t1, $t1,4 # I17
addi $t2, $t2,8 # I18
j loop # I19
end:
```
Assuming a 5-stage MIPS pipeline, and all elements in array \( A \) are smaller than all elements in array \( B \), answer the parts below. You need to count until the last stage of instruction I19.
(a) How many cycles does this code segment take to complete its execution in the first iteration (I1 to I19) in an ideal pipeline, that is, one with no delays?
For parts (b) to (d) below, given the assumption for each part, how many additional cycles does this code segment (I1 to I19) take to complete its execution in the first iteration as compared to an ideal pipeline computed in (a)? Note that the jump instruction (j) computes the target address to jump to in its ID stage (stage 2). No delayed branching is used.
Write the total number of additional delay cycles for each of the parts (b) to (d). For example, if part (a) takes 10 cycles and part (b) takes 30 cycles, then you should write +20 for part (b).
(b) Assuming without forwarding and branch decision is made at MEM stage (stage 4). No branch prediction is made.
(c) Assuming with forwarding and branch decision is made at MEM stage (stage 4). No branch prediction is made.
(d) Assuming with forwarding and branch decision is made at ID stage (stage 2).
Branch is predicted not taken.
(e) Assuming the setting in part (b) above (without forwarding and branch decision at MEM stage), without affecting the correctness of the code, is it possible to move one instruction to somewhere else to reduce the number of delay cycles? If so, indicate which instruction to move, where to move it to, and how many delay cycles are reduced by moving it. If it is not possible, explain.
Q 1 6 . Pipelining [ 1 3 marks ] Refer to the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!