asked 38.9k views
5 votes
show the hits and misses and final cache contents for a fully associative cache with four-word blocks and a total size of 16 words. Assume LRU replacement. Below is a list of 32-bit memory address references, given as word addresses. 2,3,11,16,21,13,64,48,19,11,3,22,4,27,6, and 11 a. Show the hits and misses and final cache contents for a two-way set-associative cache with one-word blocks and a total size of 16 words.

1 Answer

4 votes

In a two-way set-associative cache, the cache is divided into sets, and each set can hold two blocks (also known as lines). This means that each set has two possible locations where data can be stored. The cache size is still 16 words, but it is organized differently.

Let's go through the list of memory address references and determine hits, misses, and the final cache contents for this two-way set-associative cache:

Initially, all cache lines are empty.

1. Reference to word 2:

- Block 0: Empty (Miss)

- Block 1: Empty (Miss)

2. Reference to word 3:

- Block 0: Store word 3 (Miss)

- Block 1: Empty (Miss)

3. Reference to word 11:

- Block 0: Store word 11 (Miss)

- Block 1: Empty (Miss)

4. Reference to word 16:

- Block 0: Store word 16 (Miss)

- Block 1: Empty (Miss)

5. Reference to word 21:

- Block 0: Store word 21 (Miss)

- Block 1: Empty (Miss)

6. Reference to word 13:

- Block 0: Store word 13 (Miss)

- Block 1: Empty (Miss)

7. Reference to word 64:

- Block 0: Store word 64 (Miss)

- Block 1: Evict Block 0, store word 64 (Miss)

8. Reference to word 48:

- Block 0: Store word 48 (Miss)

- Block 1: Store word 16 (Miss)

9. Reference to word 19:

- Block 0: Store word 19 (Miss)

- Block 1: Store word 48 (Miss)

10. Reference to word 11 (Again):

- Block 0: Hit

- Block 1: Store word 21 (Miss)

11. Reference to word 3 (Again):

- Block 0: Hit

- Block 1: Store word 11 (Miss)

12. Reference to word 22:

- Block 0: Store word 22 (Miss)

- Block 1: Evict Block 1, store word 22 (Miss)

13. Reference to word 4:

- Block 0: Store word 4 (Miss)

- Block 1: Evict Block 0, store word 4 (Miss)

14. Reference to word 27:

- Block 0: Store word 27 (Miss)

- Block 1: Evict Block 1, store word 27 (Miss)

15. Reference to word 6:

- Block 0: Store word 6 (Miss)

- Block 1: Evict Block 0, store word 6 (Miss)

16. Reference to word 11 (Yet again):

- Block 0: Hit

- Block 1: Store word 11 (Miss)

Final cache contents:

Block 0: 11, 6, 27, 4

Block 1: 11, 27, 22, 21

Hits: 5 (word 11, word 3, word 11, word 11, word 11)

Misses: 11

This is how the two-way set-associative cache with one-word blocks and a total size of 16 words would behave for the given memory address references using the LRU (Least Recently Used) replacement policy.

answered
User Rapt
by
8.5k points