
1. Assume a cache with the following characteristics:
Word size: 4 bytes
Block size: 16 words
Associativity: 4-way
Replacement policy: least-recently-used (LRU)
Total cache data capacity: 8192 bytes
a. Assume the CPU uses a 32-bit address. Show how the address is split into tag,
index, word address, and byte address.
byte address -- bits 1 down to 0
word address -- lg 16 => 4 bits, so bits 5 down to 2
8192 bytes / (4 bytes/word * 16 words/block * 4 sets) = 32 blocks/set
therefore, lg 32 = 5 index bits, so bits 10 down to 6
tag is the rest of the bits, so bits 31 down to 11
21-bit tag 5-bit index 4-bit word address 2-bit byte address
31:11 10:6 5:2 1:0
b. Show the final contents of the cache after the following series of accesses. The
addresses shown correspond to the index fields of each access. Assume the
cache is initially empty.
Note that when I said “index fields” I meant bits 31 down to 6.
2, 3, 11, 16, 21, 13, 64, 48, 19, 11, 3, 22, 4, 27, 6, 11
block set 0 set 1 set 2 set 3
0 64
1
2 2
3 3
4 4
5
6 6
7
8
9
10
11 11
12
13 13
14
15
16 16 48
17
18
19 19
20
21 21
22 22
23
24
25
26
27 27
28
29
30
31