wire / wire-format / cache-structure

CPU cache structure (set-associative)

A CPU cache is organized into sets, each containing ways (lines). Address decomposition: tag (high bits) | set index (middle bits) | block offset (low bits). On access: compute set index, check all ways in that set for a tag match. Hit: return data. Miss: fetch from next level. Replacement policies: LRU, pseudo-LRU, random, FIFO. Write policies: write-through (write to cache and memory) or write-back (write to cache only, dirty bit marks modified lines).

wire-format kind wire-format status standard verification verified tier B wire-format@1

aka: CPU cache structure (set-associative)

wire format

spec: CPU cache design

A CPU cache is organized into sets, each containing ways (lines). Address decomposition: tag (high bits) | set index (middle bits) | block offset (low bits). On access: compute set index, check all ways in that set for a tag match. Hit: return data. Miss: fetch from next level. Replacement policies: LRU, pseudo-LRU, random, FIFO. Write policies: write-through (write to cache and memory) or write-back (write to cache only, dirty bit marks modified lines).

fieldsizemeaning
Block offsetlog2(line size) bitsLow bits: offset within the cache line. E.g., 6 bits for 64-byte lines.
Set indexlog2(num sets) bitsMiddle bits: which set. E.g., 6 bits for 64 sets.
Tagremaining bitsHigh bits: identifies which memory block is in this line.
Cache lineline size (32/64/128 bytes)The unit of transfer between cache levels and memory.
Associativityways per set1 = direct-mapped, 2/4/8 = set-associative, N = fully associative.
MESI protocol4 statesModified (dirty, exclusive), Exclusive (clean, exclusive), Shared (clean, may be in other caches), Invalid (not valid). Used for cache coherence in multi-core systems.
Write-backpolicyWrite to cache only; mark line dirty. Write to memory only on eviction. Faster but requires dirty bit.
Write-throughpolicyWrite to cache and memory simultaneously. Simpler but slower.
Inclusive vs exclusivepolicyInclusive: L2 contains all L1 data. Exclusive: L2 and L1 are disjoint (more total capacity).

example:

00 00 00 00

Cache structure (placeholder)


provenance

agent: curl -H 'accept: application/json' wire.phall.io/wire-format/cache-structure or /wire-format/cache-structure.json