Chris Low-level systems developer

First principles

From switches to tensor cores.

Six levels. Each one is assembled only from the level below: gates become adders, adders become a processor, processors become an operating system, and so on up to the accelerators that run modern AI. Links under each level are real work; unfinished levels are marked as potential future evidence, not faked.

Companion: The Operating Envelope, the perf, power, and thermal constraints every level lives inside.


Hover a level to light everything it stands on. Click to jump to its section. Each arrow reads upward: the lower level assembles the upper.

L1

Switching logic

A network of switches computes any Boolean function; with feedback and a clock, it remembers.

transistor NAND NOTAND · OR fulladder 8-bitripple adder Dflip-flop register combinational: output is a pure function of the inputs sequential: NANDs with feedback + clock give state
NAND is functionally complete: the combinational chain reduces to one gate type, and NANDs with feedback plus a clock give state.
ASSEMBLED FROM
Device physics: the transistor as a voltage-controlled switch (boundary, below).
ENABLES
L2: arithmetic needs adders, muxes, and registers; all of them live here.
  • NAND (equivalently NOR) is functionally complete: NOT, AND, OR, and therefore every Boolean function, reduce to networks of NAND gates.
  • Full adder: S = A xor B xor Cin, Cout = (A·B) + (Cin·(A xor B)). Chaining n of them gives an n-bit ripple-carry adder with delay linear in n.
  • A D flip-flop latches one bit on the clock edge; n of them form an n-bit register. Setup and hold times bound how fast the clock may run.
POTENTIAL FUTURE EVIDENCE8-bit ALU from gates in a logic simulator, verified exhaustively: all 65,536 input pairs per operation.

L2

Numbers and arithmetic

Bits mean numbers by convention; two's complement turns subtraction into addition, so one adder plus three flags handles every integer add, subtract, and bitwise operation.

000 · 0 001 · 1 010 · 2 011 · 3 100 · -4 101 · -3 110 · -2 111 · -1 +1 +1 wraps 3 to -4 3-bit two's complement 3 - 1, as the adder sees it: sub = 1 flips B, carry in adds the one back 1 1 1 A = 3 0 1 1 -B via ~B+1 + 1 1 0 Y = 2 1 0 1 0 Z = NOR(Y) = 0 · C = carry out = 1 · V = 0, no signed overflow dashed 1 is discarded: the circle's +1 wrap, made the correct answer
Left: the 3-bit code; counting past 3 wraps to -4. Right: subtraction as addition, worked: flip B, carry in the one, add; the flags read straight off the result.
ASSEMBLED FROM
L1 gates, adders, muxes, and registers.
ENABLES
L3: the datapath computes on encoded numbers instead of raw bits.
  • Two's complement: -x = ~x + 1. One representation of zero, and a single adder performs both addition and subtraction.
  • Flags: Z is the NOR of all result bits; C is the carry out of the most significant bit (unsigned overflow); V is carry-into-sign-bit xor carry-out (signed overflow). RISC-V exposes no condition-code register; software compares with slt/sltu and branches.
  • Right shift comes in two forms: logical (srl) zero-fills, arithmetic (sra) sign-extends. The distinction is the representation, not the shifter.
  • IEEE 754 binary32: 1 sign bit, 8 exponent bits with bias 127, 23 stored fraction bits (24 bits of significand precision on normals). Finite precision is a contract, not a bug.
POTENTIAL FUTURE EVIDENCEArrives with the L1 build: the ALU implements two's complement subtraction and raises Z, C, V for real.

L3

The stored-program processor

One fixed machine runs any program: instructions live in memory and steer a datapath through fetch, decode, execute.

PC instrmemory registerfile ALU datamemory writeback control: opcode to mux selects and enables PC + 4 fetch: PC indexes instruction memory · decode: control reads the opcode · execute: registers feed the ALU, memory optionally
Single-cycle schematic. Real cores pipeline these stages and pay for it in hazards; the contract the software sees is unchanged.
ASSEMBLED FROM
L2 ALUs and L1 registers and memories, wired into a datapath under a control unit.
ENABLES
L4: traps, timers, and the memory-management unit are the hardware interface the OS is written against.
  • The ISA is the contract. RISC-V names 32 integer registers; x0 is hardwired to zero, so it can be a source but never a destination.
  • Pipelining overlaps fetch, decode, and execute across instructions. The cost is hazards: data (read-after-write), control (branches), structural (one memory, two accesses).
  • The memory hierarchy works because programs exhibit locality: registers, then caches, then main memory, each larger and slower. The TLB caches page-table translations; satp points at the root table.

L4

The operating system

One machine, many programs: traps cross privilege levels, the scheduler shares time, the memory manager shares space.

U-mode S-mode ecall save x1-x31, sepc = pc stvec = handler handler runs restore sret trap taken resume the trap frame: the general-purpose registers, saved by the entry code and restored before sret
A system call is a controlled fall down the privilege ladder and a climb back up. The hardware records the trap (sepc, scause, privilege level, handler PC); the entry code saves the general-purpose registers.
ASSEMBLED FROM
L3 mechanisms: trap delivery, privilege modes, timers, and the MMU.
ENABLES
L5: processes and threads are the units the parallel machine is programmed through.
  • Privilege is a ladder: machine mode, supervisor mode, user mode. ecall traps upward; sret/mret return downward. Nothing in user mode can touch the ladder itself.
  • A context switch saves one thread's registers and resumes the next; switching between processes additionally swaps the page-table root. The trap frame holds a thread's saved state.
  • Virtual memory gives each process its own address space: per-process page tables, enforced by hardware on every access, isolate programs that share one machine.

L5

Data-parallel machines

One instruction stream drives many datapaths; throughput scales with lane count on regular data.

one instruction 32 threads, one program counter: SIMT (32 is NVIDIA's warp width). When lanes disagree on a branch, the paths serialize.
Vector units and GPU warps are the same idea at different widths: replicate the datapath, share the control.
ASSEMBLED FROM
L3 datapaths, replicated under one control unit; L4 threads as the programming unit.
ENABLES
L6: a parallel fabric is the raw material the accelerator specializes.
  • SIMD applies one operation to many elements. RISC-V's V extension is vector-length agnostic: the same code runs on 128-bit and 512-bit implementations.
  • SIMT (GPU): on NVIDIA GPUs, threads group into warps of 32 that execute in lockstep. Divergent branches serialize the taken and not-taken paths; a fully divergent warp runs at scalar speed.
  • Memory is the real bottleneck: coalesced global accesses and programmer-managed per-block shared memory exist because bandwidth, not arithmetic, usually limits.
POTENTIAL FUTURE EVIDENCEVector extension on RISC-V: one kernel, measured against scalar, on real hardware.

L6

Specialized accelerators

Fix the workload to dense matrix math and the machine can be rewired around dataflow instead of control.

C = A x B: each cell holds one multiply-accumulate; data pulses through instead of being fetched. Output-stationary flow shown.
The general-purpose control of L3 is traded away. What remains is arithmetic with the memory movement designed out.
ASSEMBLED FROM
L5 parallel fabric, with control logic traded away for multiply-accumulate density.
ENABLES
Modern AI training and inference (boundary, above).
  • CUDA is the programming model for the L5 machine: kernels launch as grids of thread blocks; the hardware schedules the warps.
  • Tensor cores collapse a small matrix-multiply-accumulate (for example 4x4 FP16 into FP32) into one instruction: the operation AI actually performs, in silicon.
  • This array is output-stationary: each cell holds its running sum while A and B pulse through, so each fetched element is reused by many cells instead of refetched for every multiply.
  • Roofline: attainable performance is the minimum of peak compute and bandwidth times arithmetic intensity. Every accelerator argument is this curve.
POTENTIAL FUTURE EVIDENCEA measured matmul: naive, tiled, then tensor-core, with the roofline drawn from real numbers.

BELOW L1

Semiconductor device physics: doping, threshold voltage, why a transistor switches. Out of scope; L1 starts at the switch.

ABOVE L6

Distributed training, interconnects, datacenter scale. Out of scope; L6 ends at the single accelerator.