A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Cache Associativity and Address Mapping Strategies

College Depth 96 in the knowledge graph ☐ I know this ☆ Set as goal
3topics build on this
356prerequisites beneath it
See this on the map →
Cache Memory DesignCache Replacement Policies→→Multilevel Cache Design and CoordinationTranslation Lookaside Buffer (TLB) Design
cache-associativity cache-mapping address-mapping

Core Idea

Cache mapping strategy determines where a memory address can reside in the cache. Direct-mapped: each address maps to one cache location (fast but prone to conflicts). Fully associative: any address can be stored in any location (flexible but slow to search). N-way set-associative: intermediate approach, dividing the cache into sets and allowing N locations per set. Associativity increases hit rate but complexity.

Explainer

From your study of cache design principles, you know that a cache stores recently accessed data closer to the processor to exploit temporal and spatial locality. The question cache associativity answers is: when a new block arrives from main memory, *where* in the cache can it be placed? This placement rule has profound implications for both hit rate and hardware complexity.

A direct-mapped cache is the simplest design. Each memory address maps to exactly one cache line, determined by the formula `cache_line = (block_address) mod (number_of_lines)`. Think of it like an apartment building where your unit number is determined entirely by the last two digits of your social security number — you have no choice of where to live. The hardware only needs to check one location, making lookups extremely fast. But the fatal flaw is conflict misses: if two frequently accessed addresses happen to map to the same cache line, they evict each other repeatedly, regardless of how much empty space exists elsewhere in the cache. Two arrays whose base addresses differ by exactly the cache size will thrash on every access.

A fully associative cache goes to the opposite extreme: any memory block can be stored in any cache line. This eliminates conflict misses entirely — a block is only evicted when the entire cache is full. But the hardware cost is severe: on every access, the cache must compare the requested address tag against *every* stored tag simultaneously, requiring a comparator for each cache line. This is feasible only for very small caches (like TLBs with 32–64 entries), not for the thousands of lines in a typical L1 data cache.

Set-associative caches split the difference. The cache is divided into sets, and each memory address maps to exactly one set (like direct-mapped), but within that set, the block can occupy any of N lines (like fully associative). A 4-way set-associative cache, for instance, has 4 lines per set — the hardware needs only 4 comparators per lookup instead of thousands, yet conflict misses drop dramatically compared to direct-mapped. The address is split into three fields: the offset (which byte within a block), the index (which set), and the tag (which block within that set's mapping). Increasing associativity from 1-way (direct-mapped) to 2-way typically cuts conflict misses by roughly half; going from 2-way to 4-way helps further but with diminishing returns. Most modern L1 caches use 4-way or 8-way associativity, and the replacement policy you studied earlier (LRU, random, etc.) determines which line within a set gets evicted when a new block arrives.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Boolean Algebra and Fundamental Laws → Logic Gates Fundamentals → Implementing Boolean Functions with Gates → Karnaugh Map Simplification → Combinational Circuit Design → Flip-Flops and Latches → Binary Counters: Design and Analysis → Binary Arithmetic → Fixed-Point Number Representation → Two's Complement Representation → Overflow and Underflow Detection → Binary Adders: Half-Adders and Full-Adders → Full Adder and Carry Propagation → Carry Lookahead Adder Design → Half Adder Circuit Design → Multiplication Circuit Design → Sequential Circuit Design → Registers and Register Files → Instruction Set Architecture (ISA) → Assembly Language Basics → Memory Organization and Addressing → Memory Hierarchy → Cache Memory Design → Cache Replacement Policies → Cache Associativity and Address Mapping Strategies

Longest path: 97 steps · 356 total prerequisite topics

Prerequisites (2)

Leads To (2)