You are on page 1of 4

COMP 452 – Computer Architecture

Assignment 2

Deadline: Tuesday, 23rd May (In class)

Name: ____________________________ Roll No.____________________________

1. Show complete working of your solution.


2. You are supposed to submit the handwritten solution. You can take print out of this document and solve the assignment on that print out.

Q1: (1 point) Execute the following assembly code on a MC FP MIPS pipeline and complete the table with stall detection and with data forwarding. This
version uses ROB, instruction queue, and memory enhancement (i.e., only integer unit goes through memory stage). Observe the following lengths of
execution stage for different FUs.

FP ADD/SUB: 2 CC FP MUL: 10 CC FP DIV: 20 CC LD/SD: 1 CC

IF ID EXE MEM WB Comments (Mention different hazards


stalling the pipeline)
LD F4, 0(R2) 1 2 3 4 5
DIV.D F5, F4, F2 2 3-4 5-24 - 25 RAW(F4)
S.D F2, 20(R2) 3-4 5 6 7 8-26
MUL.D F2, F5, F0 5 6-24 25-34 - 35 RAW(F5)
SUB.D F0, F4, F6 6-24 25 26-27 - 28-36
ADD.D F0, F0, F2 26 27 28-29 - 30-37 WAW/RAW F(0), RAW (F2)
Q2: (1 point) Execute the following assembly code on a MIPS with a scoreboard and complete the table. Observe the following lengths for execution stage.

FP ADD/SUB: 2 CC FP MUL: 10 CC FP DIV: 20 CC INT: 1 CC


There are 2 MUL units, 1 FP DIV unit, 1 FP ADD unit, and 1 INT unit. L.D/S.D will be executed on INT unit.

IS RO EX WR Comments (Mention different hazards


stalling the pipeline)
LD F4, 0(R2) 1 2 3 4
DIV.D F5, F4, F2 2 3-5 6-25 26 RAW(F4)
S.D F2, 20(R2) 3-5 6 7 8 STRUCT(INT)
MUL.D F2, F5, F0 6 7-27 28-37 38 RAW(F5)
SUB.D F0, F4, F6 7 8 9-10 11-28 WAR(F0)
ADD.D F0, F0, F2 8-29 30-39 40-41 42 WAW/RAW(F0), RAW(F2)
Q3 (1.5 points): Complete the following table for two iterations of a loop using Tomasulo’s algorithm. Assume that there is no inter-loop dependence of
instructions but we must wait for the outcome of first loop branch condition (i.e., non speculative execution) before issuing the first instruction of second
loop. Register all stalls in the comments column. Assume we have infinite no. of reservation stations available with us. Observe the following lengths for
execution stage.

3. FP ADD/SUB/L.D/S.D: 2 CC FP MUL: 10 CC FP DIV: 20 CC INT/Branch: 1 CC

Iteration# Instructions IS EX WR Comments (Mention different hazards stalling


the pipeline)
1 DIV.D F5, F2, F4 1 2-21 22
1 L.D F5, 0(R3) 2 3-4 5
1 MUL.D F2, F4, F5 3,4-5 6-15 16 RAW(F5) FROM L.D
1 ADD.D F4, F5, F3 4,5 6-7 8 RAW(F5) FROM L.D
1 DADDI R3, R3, -8 5 6 7
1 BNEZ R3, Loop 6,7 8 9 RAW(R3)

2 DIV.D F5, F2, F4 7,8-9 10-29 30 Waiting for Branch hazard (branch outcome)
2 L.D F5, 0(R3) 8,9 10-11 12 Branch hazard (Waiting for branch outcome)
2 MUL.D F2, F4, F5 9, 10-12 13-22 23 RAW (F5) FROM L.D
2 ADD.D F4, F5, F3 10, 11-12 13-14 15 RAW (F5) FROM L.D
2 DADDI R3, R3, -8 11 12 13
2 BNEZ R3, Loop 12, 13 14 15, 16 RAW(R3), STRUCTU (CDB)
Q4 (1.5 points): Complete the following table for two iterations of a loop using Tomasulo’s algorithm. Assume that there is no inter-loop dependence of
instructions and we can do speculative execution with ROB. Register all stalls in the comments column. Assume we have infinite no. of reservation stations
available with us. Observe the following lengths for execution stage.

1. FP ADD/SUB/L.D/S.D: 2 CC FP MUL: 10 CC FP DIV: 20 CC INT/Branch: 1 CC

Iteration# Instructions IS EX WR Commit Comments (Mention different hazards


stalling the pipeline)
1 DIV.D F5, F2, F4 1 2-21 22 23
1 L.D F5, 0(R3) 2 3-4 5, 6-23 24
1 MUL.D F2, F4, F5 3,4-5 6-15 16, 17-24 25 RAW(F5) FROM L.D
1 ADD.D F4, F5, F3 4,5 6-7 8, 9-25 26 RAW(F5) FROM L.D
1 DADDI R3, R3, -8 5 6 7, 8-26 27
1 BNEZ R3, Loop 6,7 8 9, 10-27 28 RAW(R3)

2 DIV.D F5, F2, F4 7 8-27 28 29 No waiting for branch (speculative


execution)
2 L.D F5, 0(R3) 8 9-10 11, 12-29 30 No waiting for branch (speculative
execution)
2 MUL.D F2, F4, F5 9, 10-11 12-21 22, 23-30 31 RAW (F5) FROM L.D
2 ADD.D F4, F5, F3 10, 11 12-13 14, 15-31 32 RAW (F5) FROM L.D
2 DADDI R3, R3, -8 11 12 13, 14-32 33
2 BNEZ R3, Loop 12, 13 14 15, 16-33 34 RAW(R3), STRUCTU (CDB)

You might also like