Question: Part 2 Assume the code snippet is executed on a five - stage pipelined Datapath like the MIPS. Branch prediction occurs in decode stage. 1

Part 2
Assume the code snippet is executed on a five-stage pipelined Datapath like the MIPS. Branch prediction occurs in decode stage.
1. LW \$t0,\(0(\$ s 0)\); load a[0]
2. ADDI \$s1, zero, 2 ; \$s1=5
3. ADDI \$s0,\$s0,4; increment memory address
4. LOOP: ADDI \$t1,\$t0,0 ; a[i]= a[i-1]
5. BEQ \$t2,\$s3, JMARK ; Branch b1 ; if \$t2==2 goto JMARK
6. ADDI \$t1,\$t1,1 ; a[i]=a[i]+1
7. JMARK: SW \$t1,\(0(\$ \mathrm{~s}0)\); store a[i]
8. ADDI \$t2,\$t2,1 ; increment loop counter
9. ADDI \$s0,\$s0,4 ; increment memory address
10. ADDI \$t0,\$t1,0 ; a[i-1]= a[i]
11. BNEQ \$t1,\$s1, Loop ; Branch b2 ; if \$t1!=\$s1 goto Loop
a) If there is no forwarding or hazard detection, insert NOPs to ensure correct execution.
b) If the processor has forwarding, but we forgot to implement the hazard detection unit, what happens when the original code executes?
c) Assuming there is no forwarding, fill the table below. (add as many rows as needed)
d) Assuming there is forwarding, fill the table below. (add as many rows as needed)
e) Determine the latency of the branching instruction.
Hint: You have to detect and resolve the dependencies, assume Branch predictor is always right (no control hazards).
Part 2 Assume the code snippet is executed on a

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!