Home / Expert Answers / Computer Science / 1-beq-2-0-endloop-2-add-3-0-1-3-add-4-2-0-4-loop-addi-4-4-1-5-lw-1-pa290

(Solved): 1 beq $2 , $0 , endloop 2 add $3 , $0 , $1 3 add $4 , $2 , $0 4 loop : addi $4 , $4 , 1 5 lw $1 ...



1 beq $2 , $0 , endloop 2 add $3 , $0 , $1 3 add $4 , $2 , $0 4 loop : addi $4 , $4 , −1 5 lw $13 , 0 ( $3 ) 6 s l t $14 , $13 , $0 7 bne $14 , $0 , e n d i f 8 sub $15 , $13 , $4 9 sw $15 , 0 ( $3 ) 10 e n d i f : addi $3 , $3 , 4 11 bne $4 , $0 , loop 12 endloop : j r $31 For this question assume that pipelining has been implemented. Assume that each stage takes 1 cycle to complete. a) Identify the pipeline hazards present in this code, i.e. situations that would generate stall bubbles. In the case of data hazards, identify the two lines of code involved. (b) Assume that this program is run using the array frontend, and that register $1 contains the address of the first element of the array, and $2 contains the size of the array. Assume that the size of the array is 2, and that the numbers [4, -7] have been placed in the array. Assuming that no pipeline optimizations have been implemented, i.e. no forwarding or branch prediction, determine the number of cycles it takes to complete the execution of this program. Justify your answer using a pipeline diagram formatted like the picture attached. It may be helpful to use a spreadsheet to draw the diagram. (c) Suppose forwarding and static branch prediction have been implemented. Given the same array, when compared to the answer in part (b): • how many cycles would be saved due to forwarding? • how many cycles would be saved due to static branch prediction? Consider each case (forwarding and branch prediction) separately. In each case, identify which lines of stall bubbles from your diagram in part (b) will be eliminated. (d) Suppose you ran the same code with an array [-5, 0, 2, -8, 3]. Would there be any difference between the number of stall bubbles saved using static branch prediction compared to the number of stall bubbles saved using dynamic branch prediction for the branch instruction at Line 7? Briefly justify your answer.



We have an Answer from Expert

View Expert Answer

Expert Answer


We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe