Consider a machine with a byte addressable main memory of 2^20 bytes, block…
2015
Consider a machine with a byte addressable main memory of 2^20 bytes, block size of 16 bytes and a direct mapped cache having 2^12 cache lines. Let the addresses of two consecutive bytes in main memory be (E201F)16 and (E2020)16. What are the tag and cache line address (in hex) for main memory address (E201F)16?
- A.
E, 201
- B.
F, 201
- C.
E, E20
- D.
2, 01F
Attempted by 205 students.
Show answer & explanation
Correct answer: A
Solution:
Step 1 — Determine bit widths:
Total address bits = 20 (since main memory is 2^20 bytes).
Block offset = 4 bits (block size 16 bytes = 2^4).
Index = 12 bits (2^12 cache lines).
Step 2 — Compute tag bits:
Tag bits = 20 - 12 - 4 = 4 bits (one hex digit).
Step 3 — Map the hex address E201F to tag, index, offset:
Write the 20-bit address as 5 hex digits: E 2 0 1 F.
Top hex digit (E) = tag.
Next three hex digits (2 0 1) = index (cache line address) = 201 (hex).
Last hex digit (F) = block offset within the cache line.
Answer: tag = E (hex), cache line address = 201 (hex).
A video solution is available for this question — log in and enroll to watch it.