



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Date assigned: February 14, 2008 Due date: February 26, 2008 (11:59 pm) Due date for UF EDGE: March 4, 2008 (11:59 pm)
Total Points: 100 pts
(Important: if the exercise is from case studies of textbook, please read the case study description carefully before solving problem)
Appendix A
Exercise 1 (20pts)
Identify all possible hazards in the following instructions and show clearly which instructions are involved in what type of hazard (data-WAW, data-WAR, data-RAW and control) and why? Consider a simple 5-stage MIPS pipeline as shown in Figure A.18 for this exercise.
ADDI R8, R0, # ADDI R6, R0, # SW R6, 800(R0) ADDI R7, R0, # SW R6, 800(R7) ADDI R10, R0, # ADDI R3, R10, #- LW R1, 800(R3) ADDI R4, R10, #- LW R2, 800(R4) ADD R5, R1, R SW R5, 800(R10) ADDI R10, R10, # BEQ R10, R8, # J # NOP BREAK
Solution:
(10pts) data-RAW: R6: ADDI R6, R0, #1 -> SW R6, 800(R0) R7: ADDI R7, R0, #4 -> SW R6, 800(R7) R6: ADDI R6, R0, #1 -> SW R6, 800(R7) Assume Register File is written at the first half cycle and is read at the second half, this data hazard would not exist. R10: ADDI R10, R0, #8 -> ADDI R3, R10, #- R3: ADDI R3, R10, #-18 -> LW R1, 800(R3) R4: ADDI R4, R10, #-4 -> LW R2, 800(R4) R2: LW R2, 800(R4) -> ADD R5, R1, R R5: ADD R5, R1, R2 -> SW R5, 800(R10) R10: ADDI R10, R10, #4 -> BEQ R10, R8, #
(5pts) Since the 5-stage pipeline is in-order issue and in-order execution pipeline, there is no WAR or WAW hazard.
(5pts) Control: BEQ R10, R8, # J #
Exercise 2 (20pts)
Following is a simple pipeline; with a bypass from the output of the MEM stage (i.e., the MEM/WB latch) to the EX stage. (Note: There is no bypass from the EX stage, i.e., the EX/MEM latch, back to the EX stage.) Assume that the register file is written in the first half and read in the second half of the clock cycle. Hence, a register value can be written and read in the same cycle.
(a) What’s the purpose of bypassing?
Chapter 2
Exercise 3 (40pts)
The execution cycles for various instructions are given in the following table. All units are pipelined. Loads and stores require the Integer ALU for address generations and the load/store unit for accessing memory.
Instruction Cycle Number of unit Integer ALU 1 2 Load/Store 3 2 ADD.D/SUB.D 4 2 DIV.D 10 1 Simulate the execution of two loop iterations in the provide table. The execution is carried out on a two-issue dynamic-scheduling pipeline microarchitecture without/with speculations respectively. With speculation a reorder buffer (infinite size) is included to enforce in-order commit with up to 2 commits per cycle. A single CDB broadcasts/writebacks results after executions. Note that stores do not access memory until commit.
Without specification, we prefer assuming the instruction issued earlier has higher priority to get CDB. For HW2, you could assume the instruction finishes Memory stage earlier has higher priority to get CDB. Table 1 Without speculation. Assume the instruction issued earlier has higher priority to get CDB Iter .
Instruction Issue Execute Memory Write-CDB
1 L.D F0, 0(R1) 1 2 3-5 6 (2pts) 1 DIV.D F4, F2, F0 1 7-16 17(2pts) 1 S.D F4, 0(R1) 2 3 18- 1 LW R5, 0(R4) 2 3 4-6 7(2pts) 1 ADD R5, R5, R2 3 8 9(2pts) 1 ST R5, 0(R4) 3 4 10- 1 SUBI R4, R4, #44 4 5 8 1 ADDI R1, R1, #8 4 5 10(2pts) 1 BNE R1, R2, LOOP 5 11 2 L.D F0, 0(R1) 6 12 13-15 16(2pts) 2 DIV.D F4, F2, F0 6 17-26 27 2 S.D F4, 0(R1) 7 12 28- 2 LW R5, 0(R4) 7 13 14-16 18(2pts) 2 ADD R5, R5, R2 8 19 20(2pts) 2 ST R5, 0(R4) 8 13 21- 2 SUBI R4, R4, #44 9 14 15 2 ADDI R1, R1, #8 9 14 19(2pts) 2 BNE R1, R2, LOOP 10 20
Assume the instruction finishes Memory stage earlier has higher priority to get CDB Iter .
Instruction Issue Execute Memory Write-CDB
1 L.D F0, 0(R1) 1 2 3-5 6 (2pts) 1 DIV.D F4, F2, F0 1 7-16 17(2pts) 1 S.D F4, 0(R1) 2 3 18- 1 LW R5, 0(R4) 2 3 4-6 9(2pts) 1 ADD R5, R5, R2 3 8 10(2pts) 1 ST R5, 0(R4) 3 4 11- 1 SUBI R4, R4, #44 4 5 7 1 ADDI R1, R1, #8 4 5 8(2pts) 1 BNE R1, R2, LOOP 5 9 2 L.D F0, 0(R1) 6 10 11-13 15(2pts) 2 DIV.D F4, F2, F0 6 17-26 27 2 S.D F4, 0(R1) 7 10 28- 2 LW R5, 0(R4) 7 11 14-16 18(2pts) 2 ADD R5, R5, R2 8 19 20(2pts) 2 ST R5, 0(R4) 8 11 21- 2 SUBI R4, R4, #44 9 12 13 2 ADDI R1, R1, #8 9 12 14(2pts) 2 BNE R1, R2, LOOP 10 15
Table 2 With speculation. Assume the instruction issued earlier has higher priority to get CDB Iter. Instruction Issue Execute Memor y
Write-CDB Commit
1 L.D F0, 0(R1) 1 2 3-5 6 7 1 DIV.D F4, F2, F0 1 7-16 17 18 1 S.D F4, 0(R1) 2 3 18-20(2pts) 1 LW R5, 0(R4) 2 3 4-6 7 19 1 ADD R5, R5, R2 3 8(2pts) 9 20 1 ST R5, 0(R4) 3 4 21- 1 SUBI R4, R4, #44 4 5 8 21 1 ADDI R1, R1, #8 4 5 10 (2pts) 22 1 BNE R1, R2, LOOP 5 11 23 2 L.D F0, 0(R1) 6 11 12-14 15 24 2 DIV.D F4, F2, F0 6 17-26 (2pts) 27 28 2 S.D F4, 0(R1) 7 12 28-30(2pts) 2 LW R5, 0(R4) 7 9 10-12 13 29 2 ADD R5, R5, R2 8 14 16 30 2 ST R5, 0(R4) 8 9 31-33(2pts) 2 SUBI R4, R4, #44 9 10 11 31 2 ADDI R1, R1, #8 9 12(2pts) 14(2pts) 32 2 BNE R1, R2, LOOP 10 15(2pts) 33