- Asked 3/22
- 2075 Chaitra · 6 marks
Direct mapping with 64-block memory, 10 blocks used
Short answer
With 64 memory blocks and 8 cache lines, direct mapping uses line = block 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: line 0 holds block 8 (tag 001), line 1 holds block 9 (tag 001), lines 2-7 hold blocks 2-7 (tag 000). No replacement algorithm needed as each block has a fixed line.
Suppose main memory has 64 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 64 blocks, so a block address has 6 bits; the cache has 8 lines, so the line field has 3 bits and the tag has 6-3 = 3 bits.
Block address = Tag (3) | Line (3)
Assumption: the 10 blocks used are blocks 0 to 9, accessed in order.
| Block | Block address (6 bits) | Tag (3) | Line (3) | Cache line | Action |
|---|---|---|---|---|---|
| 0 | 000000 | 000 | 000 | 0 | loaded into empty line |
| 1 | 000001 | 000 | 001 | 1 | loaded into empty line |
| 2 | 000010 | 000 | 010 | 2 | loaded into empty line |
| 3 | 000011 | 000 | 011 | 3 | loaded into empty line |
| 4 | 000100 | 000 | 100 | 4 | loaded into empty line |
| 5 | 000101 | 000 | 101 | 5 | loaded into empty line |
| 6 | 000110 | 000 | 110 | 6 | loaded into empty line |
| 7 | 000111 | 000 | 111 | 7 | loaded into empty line |
| 8 | 001000 | 001 | 000 | 0 | replaces block 0 |
| 9 | 001001 | 001 | 001 | 1 | replaces block 1 |
Final cache contents:
| Cache line | Block held | Tag |
|---|---|---|
| 0 | B8 | 001 |
| 1 | B9 | 001 |
| 2 | B2 | 000 |
| 3 | B3 | 000 |
| 4 | B4 | 000 |
| 5 | B5 | 000 |
| 6 | B6 | 000 |
| 7 | B7 | 000 |
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 32-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 →