- Asked 3/22
- 2076 Chaitra · 4 marks
- 2072 Chaitra · 6 marks
- 2071 Shrawan · 6 marks
Direct cache mapping
Short answer
Direct mapping places each main memory block into exactly one cache line: line = block mod number of lines. Address splits into tag, line, and word. It is simple and fast but fixed mapping can cause thrashing when blocks compete for the same line.
Explain direct cache mapping technique with organization diagram, example, merits and demerits.
Cache memory is a small, very fast memory placed between the CPU and main memory. It holds copies of the most recently used blocks of main memory, so that most CPU accesses are served at cache speed. It works because of locality of reference (temporal and spatial).
Example system used below: main memory = 64K words (16-bit address), block size = 4 words, cache = 16 lines (64 words). Main memory has 16384 blocks.
Direct mapping
Each main-memory block can go to exactly one cache line: line number = (block number) mod (number of lines). The address is split into Tag | Line | Word.
Address (16 bits)
+-----------+---------+--------+
| Tag 10b | Line 4b | Word 2b|
+-----+-----+----+----+--------+
| |
| +-----v------+
| | line 0 | tag | data
| | line 1 | tag | data
| | ... |
| | line 15 | tag | data
| +-----+------+
v v
+--------------------+
| compare tag = ? |--> hit / miss
+--------------------+
Working: the line field selects one line, and the tag stored there is compared with the tag of the address. If the tags are equal (and the valid bit is set), it is a hit, and the word field picks the word. Otherwise it is a miss: the block is read from memory into that line, and the line's tag is updated.
Example: blocks 0, 16, 32 of main memory all map to line 0 (block mod 16); block 5 maps to line 5; block 21 also maps to line 5.
- Merits: simple and cheap hardware (only one comparator), fast lookup, no replacement algorithm needed.
- Demerits: fixed location for each block, so two blocks that map to the same line keep replacing each other (thrashing) even when other lines are empty; lower hit ratio.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Cache read and direct-mapping demerits · Computer Organization and Architecture, chapter 6
- Direct mapping with 32-block memory, 8-block cache · Computer Organization and Architecture, chapter 6 · asked 3×
- Direct mapping with 32-block memory, 10 blocks used · Computer Organization and Architecture, chapter 6 · asked 3×
- Direct mapping with 64-block memory, 10 blocks used · Computer Organization and Architecture, chapter 6 · asked 3×
- Cache mapping techniques · Computer Organization and Architecture, chapter 6 · asked 7×
- Cache management; direct vs associative address structure · Computer Organization and Architecture, chapter 6
- Associative cache mapping · Embedded System, chapter 4 · asked 2×
- Cache memory mapping techniques · Embedded System, chapter 4 · asked 3×
- Reactors in stations: merits and demerits · Power Plant Equipment, chapter 4
- Cofferdam types, uses, merits and demerits · Foundation Engineering, chapter 5 · asked 7×
All Computer Organization and Architecture chapter 6 questions →