Building a 16-Bit Computer from 277,248 Identical NAND Gates: When Even Memory Is Built from Scratch

Building a 16-Bit Computer from 277,248 Identical NAND Gates: When Even Memory Is Built from Scratch

Computer ScienceHardwareLogic Gates

Sources:HN + web research

A total of 277,248 two-input NAND gates run an entire 16-bit computer directly inside the browser. Free from any other kind of logic unit, it smoothly runs a Tetris variant at a 16.4 kHz clock rate. In an era dominated by high-level languages and layers of software abstraction, NAND-16 chooses to reinvent the wheel in the most fundamental way possible. We often assume that building a complex computing machine demands purpose-built components—specialized ALUs working in tandem with dedicated memory chips. NAND-16 demonstrates the opposite reality: the threshold for universal computation is as simple as a single elementary switch.

Complexity Without Specialized Components

NAND gate chip Figure: A 7400-series quad 2-input NAND gate chip. The entire computer is built using 277,248 of these basic logic units. Source: Wikimedia Commons

The NAND-16 project uses exclusively one type of logic element: the NAND gate. It is the architectural equivalent of handing someone a single shape of Lego brick and asking them to assemble a skyscraper complete with a working elevator. Within this architecture, adders, registers, and instruction decoding logic are all formed by interlocking patterns of the same identical brick. Constraining the entire design to a single gate type makes the genesis of computing power unmistakably transparent.

The project tour (Genesis) spans 15 guided chapters under the theme of “reinventing this computer from a single gate.” It demonstrates how two NAND gates form an RS flip-flop, and how those latches are progressively stacked into complex registers and arithmetic units. Following this conceptual pipeline strips away the mystique of hardware engineering: every high-level computing feature eventually reduces to the coordinated toggling of millions of switches.

Why 277K Gates? The Cost of Gate-Level Memory

When the figure 277,248 hit Hacker News, the initial reaction was disbelief. The historic ARM1 processor operated on fewer than 25,000 transistors. The reason NAND-16 requires more than ten times that scale is that its ROM and RAM are assembled entirely from NAND gate arrays. The machine relies on zero off-the-shelf memory components.

In conventional architectures, processing and memory belong to distinct silicon topologies, with dedicated transistors heavily optimized for dense storage. In NAND-16, however, every storage cell is pieced together from raw logic gates. Providing storage for code and data within logic gates inevitably triggers an exponential explosion in gate count.

Real-time telemetry in the browser shows the machine crossing 160,208 clock cycles and roughly 58,402 instructions executed, with the program counter resting at 046C. This is a live physical simulation churning through machine code instruction by instruction. The browser engine clocks gate evaluation speeds around 23.0 M/s and an instruction execution rate of roughly 4.0 k/s. Behind these performance metrics lies an illuminating truth: the overwhelming majority of those 277,000 gates are not performing arithmetic; they are simply acting as memory cells. Universal computation can indeed be achieved with a single switch type—the catch is that you need an ocean of switches just to store a handful of bytes.

Breaking Gates to Watch the Machine Crumble

NAND-16 Screenshot Figure: NAND-16 running live in the browser, complete with a top-bar auditor continuously validating circuit evaluations. Source: somethingbig.ai

Because the entire architecture is uniform, debugging and stress testing turn into tangible physical experiments. The project features an integrated Fault Lab, allowing users to permanently pin any arbitrary gate to 0 or 1 and observe the system unravel in real time. Sever phase 2 of the clock, and the display locks up instantly; corrupt a gate inside video memory, and a permanent phantom block appears on the game screen.

Pre-packaged failure scenarios include severed carry chains, a branch instruction that never jumps, and a degraded pseudo-random number generator. When a keypress hangs during gameplay, the root cause is often traced to a single underlying logic gate being forcibly pinned.

All operational state is rendered in real time. At the top of the interface sits an independent auditor that re-evaluates sampled cycles with an alternate simulation engine, turning the interface bright red if netlist states diverge. The built-in logic analyzer supports both single-step execution and cycle recordings with gate-delay bullet-time replay. Double-clicking any pixel on screen instantly traces backward to the latch circuit holding that pixel’s state. When every gate in the computer is laid bare in the browser window, the hardware black box ceases to exist.

Community Reactions and the AI Era Lens

Community response split cleanly into two camps. One group marveled at the engineering persistence required to synthesize memory out of raw NAND arrays, praising the purist ethos of building a digital universe from first principles. Another camp reacted with detachment, arguing that while such an undertaking would have been awe-inspiring years ago, today a netlist of this scale was likely generated by AI and warranted less excitement. The debate on Hacker News illustrates the default skepticism the modern tech community brings to large-scale hobbyist projects.

The filter of the current era may reshape our perception of engineering difficulty, but it does not alter the underlying physics of computation. Whether or not automated synthesis assisted the netlist construction, NAND-16 strips away the illusion of complexity and leaves a living computer open to inspection in a browser tab. Computing does not rely on arcane magic: given enough identical switches wired to fixed rules, an entire digital world comes to life. A transparent computer remains the finest textbook on computing fundamentals.

Reference Links:

  • NAND-16 Project
  • HN Discussion
  • Wikimedia Commons