Вы находитесь на странице: 1из 1

Assignment #1 (Due: After Eid)

1) Given the following code.


Loop: LW R1, 0(R2)
DADDI R1, R1, #1
LW R3, 0(R4)
SW R1, 0(R3)
DADDI R2, R2, #4
DSUBI R5, R5, #1
BNEZ R5, Loop
a. Give the pipeline timing diagram (Do some research on the instructions). Assume, there
is no forwarding available. Branches are handled as soon as it is determined in the ID
stage by flushing the pipeline. Show all the steps in the first iteration plus the first
instruction of the next iteration.
b. Repeat part a assuming this time forwarding is available and branches are handled
assuming branch not taken. It cancels the next instruction if the branch is taken.
c. Schedule the code to remove all or as many stalls as you can using the assumptions in
part b. Also try to fill the branch delay slot.
d. Given the loop executes 100 times,
i) For code in part b over part a, How much faster is it?
ii)Calculate the same for part c over part a?

2) Consider a benchmark consists of,


ALU operations 34%
Loads 33%
Stores 19%
Conditional branches 12%
Unconditional branches 2%

Assume that ALU operations (20% of total) require a value loaded in the immediately
preceding instruction, ALU operations (30% of total) require a value computed in the
immediately preceding ALU instruction, and store operations (80% of total) immediately
follow the ALU operation that computes the value to be stored. Further, assume that
conditional branches (60% of total) use a register that is computed in the immediately
preceding instruction. Running on the MIPS pipeline, calculate average CPI assuming

a. Forwarding is not available and branches are completed in the MEM stage?
b. Forwarding is available and branches are completed in the ID stage by assuming
branches are not taken? Also assume 25% of all conditional branches are not taken.

Please Note:
1. Hand written answer sheets will be collected after eid. (Do not copy)
2. Assignment marks are strictly proportional to the percentage of class performance.

CSE 305
Shahrear Iqbal

Вам также может понравиться