4.1.14 · D1Computer Architecture (Deep)

Foundations — Virtual memory — concept, page table, virtual-to-physical translation

2,602 words12 min readBack to topic

This page assumes nothing. Before you read the parent virtual-memory note, you must be fluent in every symbol it throws at you. We build each one from the ground up, in an order where each rung of the ladder rests on the one below it.


0. The absolute starting point: what is an address?

Look at Figure s01 below: RAM is drawn as a straight row of lockers, and the coral one is byte number . Notice the address is nothing more than the label under a locker — hold this picture, because virtual memory's whole job is to secretly swap which real locker a label points to.

Figure — Virtual memory — concept, page table, virtual-to-physical translation

Why the topic needs it. Virtual memory is entirely about rewriting these house-numbers. If you don't picture memory as a numbered row of lockers, nothing else lands. "Byte-addressable" (a phrase the parent uses) simply means every locker holds one byte and has its own number — we count in bytes, not in bigger chunks.


1. Powers of two: and why computers love them

Figure s02 plots this explosion: each extra bit doubles the number of nameable things (note the log scale — the bars climb by a constant factor, which is what "doubling" looks like on a log axis). Read off : twelve wires already name distinct things.

Figure — Virtual memory — concept, page table, virtual-to-physical translation

The sizes you will meet (memorize the shape, not the digits):

Why the topic needs it
Page sizes, address widths, and page-table sizes are all counts of "how many patterns can bits make" — which is always .

2. Bits and binary: reading a number as a row of switches

For example the binary string means

Why the topic needs it. The parent's key move — "slicing the bits" of an address into a page number and an offset — only makes sense if you see an address as a physical row of bits you can cut with scissors.


3. Hexadecimal: shorthand for four bits at a time

Why hex and not decimal
Because 1 hex digit = 4 bits exactly, so grouping / slicing bits by page boundaries is clean; decimal has no such alignment.

Why the topic needs it. Every address in the worked examples (0x5A3C, 0x12A3C, 0x9004) is hex. If you can flip between hex and 4-bit groups in your head, you can read the offset straight off the low digits.


4. Integer division: quotient and remainder — the heart of the split

Together they satisfy the identity that the parent leans on:

Figure s03 makes this concrete: the number is laid out as three full blocks of (the quotient ) plus a partial butter-coloured stub of length (the remainder). The quotient answers "which block?" and the remainder answers "how far inside?" — the exact two questions virtual memory asks.

Figure — Virtual memory — concept, page table, virtual-to-physical translation
Why the topic needs it
Splitting a virtual address into VPN (quotient) + offset (remainder) is integer division by the page size.

5. The symbols and , and the power-of-two shortcut

Before the next formula, we must name two things the parent uses constantly.

Now the shortcut. When you divide by (a power of two), quotient and remainder become pure bit-slicing — no arithmetic needed:

Figure s04 shows the cut in action: the same bits of 0x5A3C are drawn as a row, with red scissors sitting at bit . Everything to the right of the scissors (lavender→butter) is the offset (remainder); everything to the left is the page number (quotient).

Figure — Virtual memory — concept, page table, virtual-to-physical translation

Why the topic needs it. This is the reason page sizes are powers of two: it turns the (slow) divide-and-remainder into a (free) "cut the bit-row here" operation the hardware does for nothing.


6. Two symbols hardware uses: (shift) and (bitwise OR)

Once we have translated the page number, the hardware must rebuild a full address by gluing the new page part back onto the untouched offset. It does this with two operations — let's define them on their own first, using a plain number , and only then apply them to addresses.

We now have every ingredient. §7 names the address labels (, VPN, PFN, …) and only there do we write the parent's final formula — because it needs those labels to make sense.


7. The named boxes: VA, VPN, offset, PFN, PA, valid bit

Now every earlier tool combines into the topic's actual vocabulary. Read this table after the sections above, not before.


How the foundations feed the topic

Address = numbered byte locker

Binary = row of bits

Powers of two 2 to the n

Hex = 4 bits per digit

Integer division: quotient and remainder

Divide by 2 to the p = slice bits

Split VA into VPN and offset

Shift and OR

Rebuild PA = PFN shifted OR offset

Page table: VPN to PFN lookup + valid bit

Virtual to Physical Translation

Each foundation is a prerequisite for the box it points into. Follow the arrows: powers of two and binary make bit-slicing possible, which makes the VA split possible, which the page table consumes, which shift+OR reassembles into the final translated address.


Where to go next

  • Ready for the full mechanism? → Virtual memory — concept, page table, translation
  • Curious how the slow RAM lookup gets cached? → TLB — Translation Lookaside Buffer
  • Worried about the 4 MiB per-process table? → Multi-level Page Tables
  • What happens on a context switch? → Context Switching and CR3 / Page-Table Base Register
  • Bigger picture of fast-vs-slow storage → Memory Hierarchy and Cache Memory and Locality

Equipment checklist

Cover the right side and test yourself — if any answer is fuzzy, reread that section before the parent note.

means
multiply 2 by itself times; the count of patterns bits can make.
in KiB
bytes.
One hex digit equals how many bits
exactly 4 bits ( values).
Read 0xA3C as binary groups
1010 0011 1100.
means
whole number of times fits into (round down).
means
the leftover remainder after removing whole copies of .
What does the symbol stand for
— the number of offset bits / where the scissors cut.
What does stand for
virtual address — the fake whole-number address a program uses.
Dividing a binary number by does what to its bits
chops off the low bits (those become the remainder / offset).
does what
shifts bits left by , filling low bits with 0 — multiplies by .
Why "concatenate not add" for PA
the shift leaves empty low bits; the -bit offset drops in with no overlap, so OR just glues them.
Which part of a VA is NEVER translated
the offset (low bits).
VPN corresponds to which division result
the quotient ; offset is the remainder.
valid bit = 0 means
page not in RAM → page fault → OS fetches from disk.