I need solution for Question.1 on word file. please avoid handwriting. 1. Given
ID: 3704633 • Letter: I
Question
I need solution for Question.1 on word file. please avoid handwriting.
1. Given two MIPS instructions: addi $s0, St0, 1 sub t1, $s0, $t2 a. [10 points] Identify any data hazard(s) b. [10 points] Show how you can use "bubbles" to eliminate the hazard(s) c. [10 points] Are "bubbles" the only way to eliminate the hazard(s)? Why or why not? 2. Given two MIPS instructions: lw $s0, 48($t0) subi t1, $s0, 5 a. [10 points] Identify any data hazard(s) b. [10 points] Show how you can eliminate the hazard(s) with as few "bubbles" as possible 3. Given three MIPS instructions: add $s4, $s5, $s6 beq $s1, Ss2, L or s7, $s8, $s9 a. [10 points] Identify any control hazard(s) b. [10 points] Show how you can eliminate the hazard(s) with as few "bubbles" as possible 4. Given the following instruction sequence sub $2, $1,$3 and $12,$2,$5 or $13,$6,$2 add $14,$2,$2 sw $15,100($2) a. [10 points] Identify all the data dependencies and data hazard(s) b. [10 points] Show how you can eliminate the data hazard(s) with forwarding c. [5 points] Are the data dependencies the same as the data hazard(s)? Why or why not?Explanation / Answer
a) The data hazard is that the second 'sub' instruction is using the result of the first 'addi' instruction. the result '$s0' will not be available for use in the 'sub' statement.
b) Bubbles can be used as below to solve this data hazard :
addi $s0, $t0, 1 IF -> ID -> EX -> MEM -> WB
sub $t1, $s0, $t2 IF -> bub -> bub -> bub -> ID -> EX -> MEM -> WB
Here bub is a "bubble"(no operation cycle)
c) Bubbles are not the only way to eliminate the hazard. Forwarding also can be used.Forwarding means to pass values of an instruction cycle before the cycle completes directly to the functional unit that requires it in a different instruction cycle.The result goes from output of one unit to input of another.