Docsity

4 Problems on Computer Architecture Principles - Assignment 2 | CDA 5155, Assignments of Electrical and Electronics Engineering

Toggle sidebar
bg1
Homework 2
CDA 5155: Fall 2008
Due Date: 10/16/2008 11:59 PM (UF EDGE Students: 10/23/2008 11:59 PM)
Primary TA: Xiaoke (Scott) Qin
You are not allowed to take or give help in completing this assignment. Submit the PDF version of
the submission in e-Learning website before the deadline. Please include the sentence in bold on
top of your submission: “I have neither given nor received any unauthorized aid on this
assignment”.
1. [10 points] Identify all possible hazards in the following instructions and show clearly which
instructions are involved in what type of hazard (structural, WAW, WAR, RAW and control)
and why? Is it possible to avoid such hazard using data forwarding? If possible, what
forwarding should be used? Consider a simple 5-stage MIPS pipeline as shown in Figure A.3
for this exercise. I1 is the first instruction and I13 is the last instruction in the program.
Possible hazards Possible solution
I 1 LD R1,1024(R4)
I 2 SUBI R5,R5,#4
I 3 ADD R1,R2,R1 RAW: R1 is the result of I1 Forwarding from MEM/WB to ID/EX
I 4 LD R2,1000(R5)
I 5 SUB R1,R2,R1
I 6 BGTZ R1, #16
I 7 SUB R1,R0,R1
I 8 SD R1, 1024(R4)
I 9 SUBI R4,R4,#4
I 10 BNE R4, R0, #64
I 11 NOP
I 12 J #800
I 13 BREAK
pf3
pf4

Partial preview of the text

Download 4 Problems on Computer Architecture Principles - Assignment 2 | CDA 5155 and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

Homework 2

CDA 5155: Fall 2008

Due Date: 10/16/2008 11:59 PM (UF EDGE Students: 10/23/2008 11:59 PM)

Primary TA: Xiaoke (Scott) Qin

You are not allowed to take or give help in completing this assignment. Submit the PDF version of the submission in e-Learning website before the deadline. Please include the sentence in bold on top of your submission: “ I have neither given nor received any unauthorized aid on this assignment ”.

  1. [10 points] Identify all possible hazards in the following instructions and show clearly which instructions are involved in what type of hazard (structural, WAW, WAR, RAW and control) and why? Is it possible to avoid such hazard using data forwarding? If possible, what forwarding should be used? Consider a simple 5-stage MIPS pipeline as shown in Figure A. for this exercise. I1 is the first instruction and I13 is the last instruction in the program.

Possible hazards Possible solution I 1 LD R1,1024(R4)

I 2 SUBI R5,R5,#

I 3 ADD R1,R2,R1 RAW: R1 is the result of I1 Forwarding from MEM/WB to ID/EX

I 4 LD R2,1000(R5)

I 5 SUB R1,R2,R

I 6 BGTZ R1, #

I 7 SUB R1,R0,R

I 8 SD R1, 1024(R4)

I 9 SUBI R4,R4,#

I 10 BNE R4, R0, #

I 11 NOP

I 12 J #

I 13 BREAK

  1. [20 points] For the following instructions:

Loop: L.D F0, 1024(R1) MUL.D F4, F2, F S.D F4, 1024(R2) DIV.D F5, F3, F ADD.D F5, F5, F S.D F5, 1024(R1) DSUBIU R2, R2, # DSUBIU R1, R1, # BNEZ R1, Loop

The second column in the following table indicates the number of cycles spent by the instruction (first column) in their respective functional units. Only exception is the load-store instructions where it spends one clock cycle in “Integer ALU” and three clock cycles in load/store (Memory) unit. The third column indicates the number of functional units for different types of instructions.

Instruction Cycle Number of unit Integer ALU 1 2 Load/Store 3 2 ADD.D 3 1 MUL.D 3 1 DIV.D 10 1

Assume that the reservation station and the reorder buffer both have infinite size. The integer ALUs are used for effective address calculation, ALU operations and branch condition evaluation. Assume that you can make at most two writes to CDB in one clock cycle. Complete the following two tables showing when each instruction issues, begins execution, accesses memory and writes its result to the CDB for the first two iterations for the following two scenarios using Tomasulo’s algorithm.

a) Use a MIPS pipeline with two-issue and without speculation. Assume that branches are issued alone (single-issue for that time step) and branch prediction is perfect. To answer this question, use the MIPS pipeline structure in Figure 2.9 in page 94 of the book with modified information based on the abovementioned table.

b) Use a MIPS pipeline with two-issue and with speculation. You also need to specify when each instruction commits. Moreover, assume that up to two instructions of any type can commit per cycle. Furthermore, assume that branches are issued alone (single-issue for that time step) and branch prediction is perfect. Note that stores will spend 3 cycles in the commit stage, because its memory access occurs during commit. To answer this question, use the MIPS pipeline structure in Figure 2.14 in page 107 of the book with modified information based on the abovementioned table.

c) In part b, stores access the memory only during the commit stage. Why is this important for Tomasulo’s algorithm with speculation?

  1. [10 points]

a) Draw the state transition diagram of a 2-bit predictor that can “E-perfectly” predict the following branch sequence:

<NT, NT, NT, T>, <NT, NT, NT, T>, ….. (repeat the 4-element sequence indefinitely).

Recall that you have four possible states for any 2-bit predictor. The initial state of your predictor can be anyone of the four states. By “E-perfectly”, we mean that your predictor must be always correct after a finite number of wrong predictions, regardless of its initial state. (The correct solution is not unique.)

b) Is it possible to build a 2-bit predictor that can “E-perfectly” predict the following branch sequence?

<NT, NT, NT, NT, T>, <NT, NT, NT, NT, T>, ….. (repeat the 5-element sequence).

If possible, draw its state transition diagram. If not, why?

  1. [10 points] In this problem, you are going to investigate the impact of the reorder buffer size on the performance of a processor implementing Tomasulo’s algorithm. Assume that we have infinite number of functional units and reservation stations. The branch predictor works perfectly. Infinite number of instructions can be issued and committed per cycle. There are no data dependences in the flow of instruction. a) If our fetch unit can fetch up to 8 instructions per cycle. Every instruction takes 1 cycle to execute. What is the average IPC for such a processor? b) Suppose that now every 100th^ instruction is a floating-point division instruction which takes 200 cycles to complete. What is the average IPC? c) Consider the system in part b) except that we only have 30 entries in ROB. What is the average IPC for this processor? If we still want to keep an IPC of 8, what is the minimum size of the ROB?