Question: Problem 6 Consider the following RISC - V code running on the standard 5 - stage pipeline. LW x 2 , 4 ( x 3

Problem 6
Consider the following RISC-V code running on the standard 5-stage pipeline.
LW x2,4(x3) ;; Instruction X
SW x2,0(x3) ;; Instruction A
OR x1, x2, x3 ;; Instruction B
BEQ x2, x1, L ;; Instruction C
OR x2, x2, x0 ;; Instruction D
L: ADD x4, x1, x3 ;; Instruction E
Part(a) Identify all control and RAW data hazards. If you think there is a RAW data hazard between instructions A and B due to register x2, then you should say
A B RAW Data Hazard on Register x2
You will get -2 point for each wrong answer to prevent random guessing an(d)/(o)r listing all dependencies hoping some would be correct.
Part (b) Rewrite the above program inserting the minimum number of NOPs (stalls) so that the program runs correctly on the 5-stage RISC-V pipeline that does NOT have any forwarding logic. However, the register file is written in first half of the cycle and read in the second half of the cycle. You can assume that branches are resolved in ID stage, which means the register comparison and computation of the branch target address takes place in ID stage, and the correct instruction is available in the following cycle. There is NO branch prediction.
Part (c) Now assume with full forwarding and branch prediction we eliminated ALL the stall(s)/(N)OPS. What is the average CPI of the program?

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!