Cache Mapping Techniques

Cache mapping determines where each memory block may reside and how conflicts occur.

Key formulas & points

Skim these first — then read the full notes below.

  • Block size trades spatial locality versus conflict misses
  • LRU/FIFO/LFU replacement in associative sets
  • Write allocate vs no-write-allocate on miss

Topic details

Introduction

Patterson and Hennessy compare mapping policies through miss behavior and hardware complexity. Indian exam questions commonly ask tag/index/offset breakup from address size.

Key relations & formulas

Formulas (Indian textbook notation)

  • directmapped:index=(addressblocksize)modnumsetsdirect mapped: index = (\frac{address}{block_{size}}) mod num_{sets}

Formulas (Indian textbook notation)

  • setassociative:indexthentagcomparewithinsetset associative: index then tag compare within set

Formulas (Indian textbook notation)

  • fullyassociative:comparetagonalllinesfully associative: compare tag on all lines

Notation and sign conventions

Relation 1 —
directmapped:index=direct mapped: index =

Formulas (Indian textbook notation)

  • directmapped:index=(addressblocksize)modnumsetsdirect mapped: index = (\frac{address}{block_{size}}) mod num_{sets}
Write this relation with symbols exactly as in Computer System Architecture — Morris Mano before substituting numbers. Examiners award partial marks for a correct setup even when arithmetic slips.
Relation 2 —
setassociative:indexthentagcomparewithinsetset associative: index then tag compare within set

Formulas (Indian textbook notation)

  • setassociative:indexthentagcomparewithinsetset associative: index then tag compare within set
Write this relation with symbols exactly as in Computer System Architecture — Morris Mano before substituting numbers. Examiners award partial marks for a correct setup even when arithmetic slips.
Relation 3 —
fullyassociative:comparetagonalllinesfully associative: compare tag on all lines

Formulas (Indian textbook notation)

  • fullyassociative:comparetagonalllinesfully associative: compare tag on all lines
Write this relation with symbols exactly as in Computer System Architecture — Morris Mano before substituting numbers. Examiners award partial marks for a correct setup even when arithmetic slips.

Concept in depth

Direct mapping is simple and fast but suffers conflict misses. Set-associative caches reduce conflicts by allowing multiple candidate lines per set, at extra comparator cost. Fully associative design minimizes conflicts but is expensive for large caches. Replacement and write policy selection strongly affects effective miss penalty.

Assumptions and validity limits

State assumptions explicitly before using any relation for cache mapping techniques — steady state, uniform properties, linear elastic material, ideal gas, incompressible flow, etc., as applicable.
Wrong assumptions invalidate the entire solution even when the formula is correct. In Computer Architecture viva and GATE descriptive questions, listing valid assumptions often earns separate marks.

Step-by-step problem approach

1. Read the question and list given data with SI units (common in Computer Architecture papers).
2. Draw a neat labelled diagram where applicable — examiners in Indian universities award diagram marks even when arithmetic slips.
3. Identify which relation from this topic applies to cache mapping techniques.
4. Use equation 1:
directmapped:index=direct mapped: index =
.
5. Use equation 2:
setassociative:indexthentagcomparewithinsetset associative: index then tag compare within set
.
6. Substitute values, compute, and verify units and sign (direction).
7. State conclusion in one line — e.g. safe/unsafe, stable/unstable, feasible/infeasible.

Applications & exam relevance

Cache Mapping Techniques appears in processor and system design. In Indian computer hardware curricula this topic is tested because it connects theory to CPU, memory hierarchy, and I/O.
GATE and semester exams often combine cache mapping techniques with earlier units — revise prerequisites before attempting mixed problems.
Industry interview panels sometimes ask: "Where did you use cache mapping techniques?" — answer with a lab, mini-project, or plant visit example if possible.

Common mistakes in exams

A typical mistake is incorrect bit partitioning for tag/index/offset, which makes all later answers wrong. Always compute number of sets first, then index bits via log2.

Quick revision checklist

Before attempting cache mapping techniques problems, confirm you can:
1. Block size trades spatial locality versus conflict misses
2. LRU/FIFO/LFU replacement in associative sets
3. Write allocate vs no-write-allocate on miss
Revise the solved examples in Computer System Architecture — Morris Mano and one previous-year GATE or university paper for this unit.

Worked examples

Try the problem first — open the solution when you are ready to check.

Direct-mapped index calculation

Problem

32-bit address, cache size 16 KB, block size 64 B, direct mapped. Find index bits.

Solution

Number of lines = 16KB/64B = 256, so index bits = log2(256) = 8. Offset bits = log2(64) = 6, tag bits = 32-8-6 = 18.

Conceptual check — Cache Mapping Techniques

Problem

In a Computer Architecture semester or GATE paper you are asked: "State the main assumption, the governing relation, and one practical consequence of cache mapping techniques." What should a complete answer include?

📖 Standard books (India)

  • Computer System ArchitectureMorris Mano

    Read: Syllabus unit

    CPU, memory hierarchy, and I/O