4.1.15 · D1Computer Architecture (Deep)

Foundations — TLB — structure, TLB miss handling

1,981 words9 min readBack to topic

Before you can read the parent note TLB — structure & miss handling, you need to own every symbol it throws at you. This page builds each one from nothing — plain words, then a picture, then the reason the topic can't live without it.


0. The very first picture: two kinds of address

Imagine every byte of memory has a name. There are two naming systems for the same byte.


1. Bits, and reading them as a binary number

Everything below is built from bits. A bit is one switch: 0 or 1. A group of bits is read as a number in base 2.


2. The page: memory sold in fixed blocks

The mapping doesn't work byte-by-byte (too many bytes!). Memory is chopped into equal blocks called pages.


3. Splitting an address: VPN and offset

Because memory moves in whole pages, a virtual address naturally splits into which page and where inside it.


4. The translation itself: VPN → PFN

The whole game is a lookup: given a VPN, find its PFN, then glue the untouched offset back on.


5. Cache, hit, and miss — the words the TLB borrows

The TLB is a cache, so you must own three cache words first. (Full treatment: Cache Memory & Associativity.)


6. Who owns which address: ASID

Two programs can both use VA but need different frames. The TLB must not confuse them.


Prerequisite map

bits and 2 to the n

log base 2 gives bit count

page size P equals 2 to the p

split address into VPN and offset

virtual vs physical address

mapping VPN to PFN

form PA by shift and OR

cache hit miss and ratio h

TLB is a cache of mappings

ASID tags an owner

TLB miss handling and EMAT

Read it bottom-up: bit arithmetic feeds the address split, the split feeds the mapping, the mapping plus cache-thinking plus ASIDs give you the TLB, and the TLB plus its miss-cost give you the parent topic.


Equipment checklist

Cover the right side and answer out loud.

How many distinct things can bits name?
— each extra bit doubles the count.
What does compute, and why base 2?
The number of bits needed to name things; base 2 because each bit doubles the choices.
For a page, how many offset bits, and why?
, because .
Given -bit virtual addresses and page size , how many VPN bits?
.
Why is the page offset never translated?
Moving a whole page doesn't change where a byte sits inside it; only the page's location (VPN→PFN) changes.
What does do and why?
Shifts the frame number into the high bits (multiply by ), leaving empty low bits for the offset.
Why can we use (OR) to combine PFN and offset?
Their 1 bits never overlap, so OR just merges the two non-overlapping bit-groups.
Difference between a TLB miss and a page fault?
Miss = mapping not cached but still in the page table (ns); fault = page not in RAM, fetch from disk (ms).
What is , and what is ?
= fraction of accesses that hit the TLB; = fraction that miss.
What does an ASID let you avoid on a context switch?
A full TLB flush — entries from different programs coexist by owner tag.