You are on page 1of 4

Computer Architecture

End Semester Exam


Set-2
Date: 24-12-2021

Instructions
1. This is a closed book online proctored exam.
1. You should not refer to books, notes or online resources.
2. You should not discuss questions or answers with anyone (including
outsiders)
3. You should have your camera and microphone ON at at all times and no
headphones
2. Write the solutions clearly and legibly in A4 sheets, using pen (NOT pencil) and at
the end of the exam you should submit the scanned copy of your solutions as
explained by the faculty
3. Follow all other instructions given by the faculty during the exam

Descriptive Questions
Note: For problems show step-by-step solution

1a. LW $T1, 0($T0)


ADD $T1, $T2, $T1
BEQ $T1, $T4, IF ; branch if [T1]=[T4]
ADDI $T3, $T3, #8 ; Add a constant to [T3]
IF: ADDI $T3, $T3, #1
END: SW $T3, 0($T0)

Show what happens in the pipeline during each clock cycle for executing the above code
starting from the first instruction to the last instruction. Also find the total number of
clockcycles needed if each stage takes 1 cycle. Assume:
● The pipeline follows static branch prediction and predicts that the branch will be
taken
● In reality the branch is not taken i.e. the branch prediction is wrong.

● Data forwarding is supported.


● Branches are resolved during Execute stage.
● Assume enough functional units are available to avoid structural hazards.

(5)
1b. Identify and list all the data dependencies in the following code. Highlight separately the
data hazards that will result in a stall even with forwarding.

SUB $T4,$T3,$T1
ADD $T5,$T4,$T2
ST $T5,100($T4)
LW $T6,200($T5)
SUB $T6,$T6,$T5 (5)

Answer:
SUB $T4,$T3,$T1
ADD $T5,$T4,$T2 //T4 with Sub
ST $T5,100($T4) //T4 with Sub and T5 with add
LW $T6,200($T5) //T5 with add
SUB $T6,$T6,$T5 //T6 with LW and T5 with add

4 marks for identifying dependencies


1 mark if both source instruction and dependent register are
written
2a. If a direct mapped cache has a hit rate of 95%, a hit time of 5 ns, and a miss penalty of
100 ns.
I. What is the AMAT?

AMAT = Hit time + Miss rate x Miss penalty


AMAT 5 + 0.05 x 100 = 10 ns

II. If replacing the cache with a 2-way set associative increases the hit
rate to 96%, but increases the hit time to 6 ns, what is the new AMAT?
AMAT = Hit time + Miss rate x Miss penalty
AMAT = 5 + 0.04 x 100 = 09 ns
III. List out any two methods to Improve performance of cache
i. Reduce the miss rate,
ii. Reduce the miss penalty,
iii. Reduce the time to hit in the cache.

(2+2+1)

2b. A computer system has the following cache configuration. It uses 4-bit memory
addresses. It has a 16 bytes cache organized in a direct-mapped manner with 2
bytes/blocks. There are 4 sets and one block per set. The no of bit for tag, set, block
given bellow

All the below addresses are shown in decimal/binary values. Assume


that the cache is initially empty. For each of the below addresses, indicate
whether the cache access will result in a hit or a miss with appropriate
justification. (5)

Address trace
(reads, one byte per read):

1[0001]

3[0011]

5 [0101]

6 [0110]

7[0111]
8[1000]

Answer:

Address trace
(reads, one byte per Cache status after miss [ Set-No : address
read): Hit/Miss Justification ]
1[0001] Miss Data miss S-0: [0-1]
3[0011] Miss Data miss S-0: [0-1],S-0: [2-3]
5 [0101] Miss Data miss S-0: [0-1],S-1: [2-3], S-2: [4-5]
6 [0110] Miss Data miss S-0: [0-1],S-1: [2-3], S-2: [4-5], S-3: [6-7]
7[0111] Hit Data is at set 3 S-0: [0-1],S-1: [2-3], S-2: [4-5], S-3: [6-7]
8[1000] Miss Data Miss S-0: [8-9],S-1: [2-3], S-2: [4-5], S-3: [6-7]

3. What are the different optimization blockers? Give an example. (5)

1. Procedure calls
Example - a procedure call that returns the same value every time but called
multiple times
Use of global variables in procedure.
● Procedure may have side effects
○ Alters global state each time called
● Function may not return same value for given arguments
● Depends on other parts of global state
● Procedure lower could interact with strlen

2. Memory aliasing
Example - where two pointers point to the same memory location and how it
affects the result of calculation.
● Two different memory references specify single location
● Easy to have happen in C
○ Since allowed to do address arithmetic
● Direct access to storage structures
● Get in habit of introducing local variables
● Accumulating within loops

You might also like