Assignment 1 — Solved
Four cache questions (10 marks): locality, a direct-mapped cache diagram, the total-bits calculation with an address split, and why set associativity lowers the miss rate. Every answer here is Module 7 material — the linked sections have the full derivations.
Q1 — Principle of locality 2 marks
Q1smallState the principle of locality for memory access. [2]
Q2 — Direct-mapped cache diagram 2 marks
Q2bigDiagram a direct-mapped cache with 256 blocks and 8-word (32-byte) block size. Assume a 32-bit memory address. [2]
Q3 — Total bits and address split 3 marks
Q3abig(a) How many total bits (tag + valid + data) are required for a direct-mapped cache with 512 KB of data capacity and 4-word (16-byte) block size? Assume a 32-bit memory address. [2]
Q3bsmall(b) For the same cache, what are the index and tag of the address 0000 1111 0000 1111 0011 1100 0000 1100? [1]
Q4 — Set associativity and miss rate 3 marks
Q4bigBriefly explain how a set-associative cache can reduce the cache miss rate. [3]
Assignment checklist
- Locality = temporal + spatial, each with an example, and why the hierarchy works.
- 256 lines, 8-word blocks ⇒ tag 19 / index 8 / block offset 3 / byte offset 2; diagram needs comparator + valid AND + word MUX.
- 512 KB, 16 B blocks ⇒ 2¹⁵ lines, tag 13, 142 bits/line, total 4,653,056 bits.
- Tag
0000111100001, index111001111000000for the given address. - Set associativity removes conflict misses — at the cost of comparators and hit time.