Lab3复杂流水化实验
Experiment1: To study the basics of forwarding. For all the programs please select Stall Detection and Forwarding should be ON.
(a)Write a sample program that forwards between EXE stage and MEM stage on
upper input of the the program below and show forwarding with arrow. Test it on the simulator and mention what value is being forwarded. DO NOT USE LW INSTRUCTION.
其中ADD指令中在MEM阶段的ALUout-555(R2+R3)前递到SUB指令的EXE阶段的upper input。
(b)Write a sample program that forwards between EXE stage and WB stage on upper
input of the the program below and show forwarding with arrow. Test it on the simulator and mention what value is being forwarded. DO NOT USE LW INSTRUCTION.
其中ADD指令中在WB阶段的输出555(R2+R3)前递到SUB指令的EXE阶段的upper input。
(c)Write a sample program that forwards between EXE stage and MEM stage on
lower input of the the program below and show forwarding with arrow. Test it on the simulator and mention what value is being forwarded. DO NOT USE LW INSTRUCTION.
其中ADD指令中在MEM阶段的ALUout-555(R2+R3)前递到SUB指令的EXE阶段的upper input。
(d) Write a sample program that forwards between EXE stage and WB stage on lower input of the the program below and show forwarding with arrow. Test it on the simulator and mention what value is being forwarded. DO NOT USE LW INSTRUCTION.
其中ADD指令中在WB阶段的输出555(R2+R3)前递到SUB指令的EXE阶段的upper input。
(e) Write a sample program that forwards between MEM stage and WB stage. Write the program below and show forwarding with arrow. Test it on the simulator and mention what value is being forwarded.
其中ADD指令在WB阶段的输出555(R2+R3)前递到SW指令的MEM阶段。
(f) Write a program that causes Load Use Delay Stall. See what data is to be moved and notice exactly when the required Data is passed on to the waiting instruction. Show it as an arrow on the following diagram.
BRANCH HAZARDS. (Lab Experiment 2)
(a) Let us now study some branch hazard. First of all make sure that the Aggressive branching option is OFF, Stall Detection is ON and Forwarding is ON. Select Always Flush option from the branch Policy and write the following program. Does this program work properly. If not modify the program so that it works properly. It fills 10 memory locations memory with a value 222. Check what should be the values of all the registers if this program work is to properly (no useful instruction turning into NOP or getting flushed). Carefully note the use of SLTI instruction in the following loop.
ADDI R3, R0, 0
ADDI R1, R0, 0
ADDI R2, R0, 222
Loop: Addi R1, R1, 4
SW R2, 100(R1)
ADDI R3, R3, 1
SLTI R5, R3, 10
BNEQ R5, R0, loop
ADDI R7, R1, 10
ADDI R8, R2, 5
ADDI R2, R2, 100
(i)Calculate the CPI for this program. 61/65
(ii)What changes can we make to this program so that it works properly (useful instructions
after the program do not flush) 可以在BNEQ跳转后面加3条ADD R0,R0,R0
(iii)Run the same program with Predict NT option in Branch Policy. What difference do you see
when loop completes.
Predict NT:循环执行完了顺序执行了剩下3条语句。
Always Flush:循环执行完了依然将剩下3条语句flush掉了。
(b) This problem is similar to problem A-1 at the end of the book. (Exercise A-1.)
Note that you need to calculate the offset in the actual program in terms of number of instructions.
Offset = -6
(A)Processor Configuration. Stall Detection ON., Forwarding: OFF, Aggressive Branching: YES, Branch Policy: Always Flush. Run the above program and fill the following table for the instructions in the loop body for first 2 or 3 iterations. Total Clock cycles to run the program ____
(b) Redo the part (a) with forwarding ON and other processor configuration is same. Total clock cycles ___
实验心得:
通过本次实验,我更加深刻的理解了流水线中的前递技术的实现,以及不同类型的指令在不同的阶段前递,方式也不同。
同时,我对branch指令数据冒险的解决也有了一个更加清晰的认识,branch 类型主要通过循环内改写和循环展开这两种方式,通过不同的实例,清楚地知道不同情况下考虑策略的不同。
通过实验,更加清晰的理解了课上的理论内容,也对复杂流水化有了一个更加全面系统的认知,收获很大。