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.
Switching logic
A network of switches computes any Boolean function; with feedback and a clock, it remembers.
- 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.
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.
- 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/sltuand 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.
The stored-program processor
One fixed machine runs any program: instructions live in memory and steer a datapath through fetch, decode, execute.
- 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;
x0is 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;
satppoints at the root table.
- Bare-metal RISC-V: trap gates, CSR contracts, QEMU-verified
- Proving Ground, Bench 08: RISC-V playground
- The Register That Is Always Zero
- The Bell and the Switch
- The Bit That Reroutes a Trap
The operating system
One machine, many programs: traps cross privilege levels, the scheduler shares time, the memory manager shares space.
- 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.
ecalltraps upward;sret/mretreturn 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.
Data-parallel machines
One instruction stream drives many datapaths; throughput scales with lane count on regular data.
- 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.
Specialized accelerators
Fix the workload to dense matrix math and the machine can be rewired around dataflow instead of control.
- 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.
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.