Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following memory addresses are used consecutively by a running program (from

ID: 3571884 • Letter: T

Question

The following memory addresses are used consecutively by a running program (from left to right, shown in decimal). Note that the followings are memory address not block number:

520, 400, 380, 540, 816, 204, 1348, 200, 440, 140, 1064, 44, 196, 404, 180

In each of the following cache structures, compute the number of hits, misses and the final values stored in each cache location (show finally which block of memory is in each cache block). Each word is 4-bytes and the memory size is 8Kbyte

(a) Direct-mapped cache with 32-word blocks and a total size of cache is 128 words of data (b) 2-way set associative cache with 32-word blocks and a total size of cache is 128 words of

Explanation / Answer

a) Here in Direct mapped cache we have 32 words block and total cache size is 128 hence number of cache blocks would be 128/32 = 4 blocks which means

Cache 0 – 0,..,31 128,…,159 257,..,288 385,…,416 513,.., 544 641,…, 672 769,..,800 897,..,928 1025,..,1056 1153,…,1184 1281,…1312

Cache 1 - 32,..,63 160,…,191 289,…,320 417,…,448 545,.., 576 673,…,704 801,..,832 929,..,960 1057,..,1088 1185,…,1216 1313,…1344

Cache 2 – 64,..,95 192,..,223 321,..,352 449,..,480 577,…,608 705,…, 736 833,…,864 961,..,992 1089,…,1120 1217,…,1248 1345,…,1376

Cache 3 - 96,..,127 224,…,256 353,…,384 481,…,512 609,…,640 737,…,768 865,….,896 993,..,1024 1121,….,1152 1249,…,1280

Address

Hit/Miss

Cache description

520

Miss

Fetches 520 from cache 0 513,…544

400

Miss

Fetches 400 from cache 0 385,…416

380

Miss

Fetches 380 from cache 3 , 353,..384

540

Miss

Fetched 540 from cache 0 , 513,…544

826

Miss

Fetches from cache 1 801,…832

204

Miss

Fetches 204 from cache 2 192,223

1348

Miss

Fetches 1348 from cache 2 1345,..1376

200

Miss

Fetches 200 from cache 2, 192,…223

440

Miss

Fetches 440 from cache 1, 417,…448

140

Miss

Fetches 140 from cache 0, 128,…159

1064

Miss

Fetches 1064 from Cache 1 1057,…,1088

44

Miss

Fetches 44 from cache 1 32,…63

196

Hit

Already in cache 2

404

Miss

Fetches 404 from cache 0 385,…416

180

Miss

Fetches 180 from cache 1 160,..191

Address

Hit/Miss

Cache description

520

Miss

Fetches 520 from cache 0 513,…544

400

Miss

Fetches 400 from cache 0 385,…416

380

Miss

Fetches 380 from cache 3 , 353,..384

540

Miss

Fetched 540 from cache 0 , 513,…544

826

Miss

Fetches from cache 1 801,…832

204

Miss

Fetches 204 from cache 2 192,223

1348

Miss

Fetches 1348 from cache 2 1345,..1376

200

Miss

Fetches 200 from cache 2, 192,…223

440

Miss

Fetches 440 from cache 1, 417,…448

140

Miss

Fetches 140 from cache 0, 128,…159

1064

Miss

Fetches 1064 from Cache 1 1057,…,1088

44

Miss

Fetches 44 from cache 1 32,…63

196

Hit

Already in cache 2

404

Miss

Fetches 404 from cache 0 385,…416

180

Miss

Fetches 180 from cache 1 160,..191