Direct Mapped Cache

A direct-mapped cache is the simplest form of cache mapping, where each memory block is mapped to exactly one cache line. 

Key Concepts of Direct-Mapped Cache

  • Indexing: A portion of the memory address selects the cache line.
  • Tag Comparison: The tag is stored alongside the data and compared to the incoming address.
  • Eviction Policy: If a new block is mapped to an occupied cache line, the old block is evicted (replaced).

Address Breakdown (Typical Structure)

Assuming a 32-bit address and a cache with lines:

  • Offset: Identifies bytes within a block.
  • Index: Selects a cache line.
  • Tag: Identifies which memory block is stored.

Example (Cache with 64 Lines, Block Size = 16B)

A 32-bit address layout:

  • Offset (log₂(16) = 4 bits)
  • Index (log₂(64) = 6 bits)
  • Tag (32 - 6 - 4 = 22 bits)

Comments

Popular posts from this blog

Cache Basics

Cache Sizes

Cache Memory for RISC V