Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PROBLEM 2 Assume that the following code segment is run on a MIPS like processor with hazard detection and forwarding, in order, 5 stages pipeline
PROBLEM
Assume that the following code segment is run on a MIPS like processor with hazard detection and forwarding, in order, stages pipeline F instruction fetch D instruction decode E execute M memory access, W writeback static not taken branch prediction branches are always predicted as not taken etc.. Below is the code segment that is running on the processor.
# code segment
beq $R $R L
L: sw $R$R # $R M$R
shl $R $R
beq $R $R L
L: lw $R$R # M$R $R
addi $R $R
addi $R $R
beq $R $R L
L: END
Note: END is an assembly directive, not an instruction and should not be counted as an instruction.
a How many cycles does this program take? Assume all data and instructions are already in the cache, and that all register values are initially The branches are always going to be evaluated as not taken and they require two stall clock cycles each.
b An optimizing compiler is used to reorder the code for faster execution. Given that the branches are always going to be not taken how would the new code look like? How many cycles would the code take?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started