Showing posts with label cache. Show all posts
Showing posts with label cache. Show all posts

Thursday, 14 May 2020

Homework on Textbook Sections 4.7 to 4.11, 5.1 to 5.3

For Questions 1 to 5: In the following code sequence, we need to stall the RISC-V pipeline to resolve the load-use data hazard:

i1: ld   x8, 0(x$5)
i2: add  x9, x8, x10
i3: addi x9, x9, -1
i4: sd   x9, 0(x5)

Consider the cycle when i1 is in the EX stage, i2 is in the ID stage, and i3 is in the IF stage.

Question 1: What is the value of ID/EX.MemRead in this cycle?

Solution:


1

Question 2: What is the value of ID/EX.RegisterRd in this cycle?

Solution:


8

Question 3: What is the value of IF/ID.RegisterRs1 in this cycle?

Solution:


8

Question 4: What is the value of IF/ID.RegisterRs2 in this cycle?

Solution:


10

Question 5: Which instruction (i1, i2, i3, or i4) will be fetch by the IF stage in the next cycle?

Solution:


i3

Question 8: For the 2-bit branch predictor shown in Figure 4.61, label the states anti-clockwise from the bottom left as 0, 1, 2 and 3, as shown below.

Assume the initial state for a branch is state 0. A given branch has the following history (T = taken, N = not taken):

N, N, T, T, T, N, N

What is the state of the predictor after this history?

Solution:


1

For Questions 11 to 15: Consider a system using 28-bit addresses, with a direct-mapped cache of 32Kbytes and a block size of 64 bytes. The cache uses a write-through/no-allocate strategy without a write buffer.

Question 11: How many bits are required for the offset field of an address?

Solution:


6

Question 12: How many bits are required for the index field of an address?

Solution:


9

Question 13:

How many bits are required for the tag field of an address?

Solution:


13

Question 14: How many bits of storage are required for the cache, in addition to those for data storage?

Solution:

7,168