Skip to main content

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.

BlockBlock address (6 bits)Tag (3)Line (3)Cache lineAction
00000000000000loaded into empty line
10000010000011loaded into empty line
20000100000102loaded into empty line
30000110000113loaded into empty line
40001000001004loaded into empty line
50001010001015loaded into empty line
60001100001106loaded into empty line
70001110001117loaded into empty line
80010000010000replaces block 0
90010010010011replaces block 1

Final cache contents:

Cache lineBlock heldTag
0B8001
1B9001
2B2000
3B3000
4B4000
5B5000
6B6000
7B7000

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)

All Computer Organization and Architecture chapter 6 questions →