- Asked 3/22
- 2070 Asar · 2 marks
Direct mapping with 32-block memory, 10 blocks used
Short answer
Direct mapping: block j placed in line j mod 8. For blocks 0–9 accessed sequentially, blocks 0–7 fill lines 0–7; block 8 replaces block 0 in line 0, block 9 replaces block 1 in line 1. Final cache: line0 holds B8 (tag 01), line1 B9 (tag 01), lines2–7 hold B2–B7 (tag 00).
Suppose main memory has 32 blocks and cache memory has 8 blocks. When 10 blocks of main memory are used, show how mapping is performed in the direct mapping technique.
In direct mapping a main-memory block j goes to cache line (j mod 8). Main memory has 32 blocks, so a block address has 5 bits; the cache has 8 lines, so the line field has 3 bits and the tag has 5-3 = 2 bits.
Block address = Tag (2) | Line (3)
Assumption: the 10 blocks used are blocks 0 to 9, accessed in order.
| Block | Block address (5 bits) | Tag (2) | Line (3) | Cache line | Action |
|---|---|---|---|---|---|
| 0 | 00000 | 00 | 000 | 0 | loaded into empty line |
| 1 | 00001 | 00 | 001 | 1 | loaded into empty line |
| 2 | 00010 | 00 | 010 | 2 | loaded into empty line |
| 3 | 00011 | 00 | 011 | 3 | loaded into empty line |
| 4 | 00100 | 00 | 100 | 4 | loaded into empty line |
| 5 | 00101 | 00 | 101 | 5 | loaded into empty line |
| 6 | 00110 | 00 | 110 | 6 | loaded into empty line |
| 7 | 00111 | 00 | 111 | 7 | loaded into empty line |
| 8 | 01000 | 01 | 000 | 0 | replaces block 0 |
| 9 | 01001 | 01 | 001 | 1 | replaces block 1 |
Final cache contents:
| Cache line | Block held | Tag |
|---|---|---|
| 0 | B8 | 01 |
| 1 | B9 | 01 |
| 2 | B2 | 00 |
| 3 | B3 | 00 |
| 4 | B4 | 00 |
| 5 | B5 | 00 |
| 6 | B6 | 00 |
| 7 | B7 | 00 |
Blocks that differ by a multiple of 8 compete for the same line (for example block 0 and block 8). The tag stored with each line tells which of these blocks is present. A block is a hit if the line's tag equals the tag of the address; no replacement algorithm is needed because each block has only one possible line.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Direct mapping with 64-block memory, 10 blocks used · Computer Organization and Architecture, chapter 6 · asked 3×
- Direct mapping with 32-block memory, 8-block cache · Computer Organization and Architecture, chapter 6 · asked 3×
- Cache read and direct-mapping demerits · Computer Organization and Architecture, chapter 6
- Direct cache mapping · Computer Organization and Architecture, chapter 6 · asked 3×
- Cache memory mapping techniques · Embedded System, chapter 4 · asked 3×
All Computer Organization and Architecture chapter 6 questions →