1-Bit Memory: The Atom of RAM — and the Finale of Building a Computer from Relays
In the previous post, we built the D latch: a circuit that accepts a Data input and a Write-enable line, and faithfully stores whatever it sees on Data at the moment Write is asserted. It was the relay world’s version of a controlled memory slot — and it was almost a complete, reusable memory cell. Almost. One small piece of packaging remained.
This is Post 18 of Building a Computer from Relays — the last stop. We are going to finish that memory cell, name it for what it is, and then do something this series has been building toward for seventeen posts: trace every rung of the ladder we have climbed, together, all the way from a single clicking switch to the stored bit.
Welcome to the atom of RAM.
Packaging the 1-bit memory cell
The D latch already does the hard work. It has a Write-enable line (often called EN or WE) and a Data line (D), and it holds the last value of D that it saw while Write was high. But as a raw latch, it exposes its internal topology — cross-coupled relay feedback, the direct output pins — and invites the user to wire things in ways that cause problems.
A 1-bit memory cell is the D latch, packaged with a clean interface contract:
- Write — a single control line. Assert it high (1) to write; hold it low (0) to read or just hold.
- Data — the bit you want to store: 0 or 1.
- Q — the stored output. Reflects Data while Write is 1; holds its last value when Write drops back to 0.
Everything else — the cross-coupled feedback, the inverter that prevents the forbidden state — is sealed inside. The user never needs to see it. The state table for this cell is refreshingly small:
| Write | Data | Q (next) |
|---|---|---|
| 0 | — | Q (held) |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
That dash in the Data column when Write is 0 is the whole point. When Write is low, Data is irrelevant. The cell is not listening. It holds what it last heard — and it will keep holding it for as long as power is supplied.
Notice what the state table cannot say: it cannot tell you what Q is right now, without knowing what was written last. Memory has state. It is not a pure function of its current inputs — it is a function of its inputs and its history. That’s the profound difference between combinational circuits (AND, OR, XOR, the adder) and sequential circuits (latches, flip-flops, registers, RAM). Combinational circuits are stateless; you apply inputs, you read outputs, done. Sequential circuits carry the past forward into the present. Your latch remembers.
Scaling up: from one bit to one computer
Here is where the abstraction earns its weight.
Eight of these cells, written together, store one byte — a number from 0 to 255 that your processor can load, modify, and store in a single operation. One thousand bytes make a kilobyte. One million bytes make a megabyte. One billion bytes make a gigabyte. Modern computers carry tens of billions of these cells on a chip the size of a postage stamp, cycling through Write and Hold millions of times per second.
Every cell obeys the same two-row state table above. Nothing about that table changes when you shrink the relay down to a transistor and pack four billion of them onto a square centimeter of silicon. The switch got smaller. The logic did not move.
Try it yourself
Below is the memory-bit cell — the D latch packaged as a clean 1-bit memory cell, running as a genuine relay simulation in your browser. Not an animation: the relay contacts are physically switching, the current is flowing, and Q is holding actual state.
Work through this sequence deliberately:
-
Store a 1. Set Data = 1, then assert Write = 1. The cell latches; Q goes to 1. Now release Write back to 0. Data doesn’t matter anymore — wiggle it, flip it to 0, disconnect it in your imagination. Q stays at 1. You just stored a bit.
-
Overwrite with a 0. Set Data = 0, then pulse Write high again briefly. Q falls to 0. Release Write. Q holds 0. You just overwrote the bit.
-
Confirm it holds under silence. Leave both Write and Data at 0. Q remains 0. The cell is not reacting to inputs; it is simply remembering the last thing you told it.
You just stored a bit by hand. Now imagine a million of them — each one identical, each one holding its own patient 0 or 1, each one deaf to the outside world until its Write line is asserted. That image is RAM.
The ladder you climbed
This series had a plan from the first click of Post 1. Before we look at the relay computers that ran on circuits like these, let’s retrace every rung together — because seen all at once, the arc is remarkable.
Post 1 — The relay itself. A switch that electricity controls. A coil pulls an armature; the armature moves a contact; one circuit throws a switch in another circuit. Wired normally-open it’s a buffer; wired normally-closed it’s an inverter. That click was not just a pleasant sound. It was the seed of everything.
Posts 2–3 — Series and parallel. Two switches in series, and current only flows when both are closed: AND. Two switches in parallel, and current flows when either closes: OR. No gate symbols yet — just wire and the observable behavior of current. Logic was already there, written in copper.
Posts 4–7 — The named gates. AND, OR, and NOT got names and symbols, courtesy of George Boole’s algebra and Claude Shannon’s 1937 proof that relay networks and Boolean algebra are the same thing. The buffer, the inverter, the gate trio — all first-principles builds in relay hardware.
Posts 8–9 — The universal gates. NAND and NOR: each one capable of implementing any logic function in existence. The simplicity is disorienting — one gate type, wired creatively, yields all the others. Followed by the Apollo Guidance Computer’s famous dependence on NOR gates: the Moon mission flew on a circuit you could now build yourself.
Posts 10–11 — XOR and XNOR. The difference detector. XOR produces 1 when its inputs disagree — a surprisingly powerful idea that shows up in error detection, encryption, and, crucially, arithmetic.
Posts 12–13 — The adder. XOR produces the sum bit; AND produces the carry. Two switches, two outputs, binary addition. Then the half adder was promoted to a full adder with a carry-in — composable, chainable, the ripple-carry architecture that every processor still uses at its core. George Stibitz proved this worked in 1937 on his kitchen table, using relays and a tobacco tin for contacts.
Posts 14–16 — Feedback and the clock. The first purely sequential idea in the series: wire an inverter so its output feeds its own input, and the circuit oscillates. Tame that oscillation into a regular square wave and you have a clock — the heartbeat that lets sequential circuits update in lockstep. Without the clock, a computer is a combinational network that computes once and stops. With the clock, it computes repeatedly, step by step, following a program.
Post 17 — The D latch. Feedback turned constructive: cross-coupled relays that hold a state until instructed to change it. The Write-enable line that prevents the forbidden (both-relays-on) state. Controlled memory in a relay circuit.
Post 18 — The 1-bit memory cell. Package the D latch behind a clean interface. Write high to store; Write low to hold. Stack eight for a byte. Stack millions for a megabyte.
And now the payoff.
A computer is, at bottom, four things:
- A clock — a regular oscillator that beats time and tells every other circuit when to act.
- An ALU — an arithmetic and logic unit: adders, comparators, boolean operations.
- Memory — storage that holds its state between clock ticks, through programs, across power cycles.
- Control and selection — multiplexers, decoders, and instruction logic that route the right data to the right place at the right time.
You have now built every one of those pieces from relays, by hand, from first principles. The clock: Posts 14–16. The ALU: Posts 12–14. The memory: Posts 16–18. Control and selection: Posts 7 and 12 (the multiplexer, the decoder). The only remaining step is scale and organization — wiring thousands of these building blocks together under a program’s direction. But the physics is all here. You are not missing any fundamental idea. You are just missing more wire.
The machines that did exactly this
The real relay computers of the 1940s were doing exactly what you have been doing — they just did it at a scale that filled rooms and cost millions of dollars.
Konrad Zuse’s Z3 (1941) is widely recognized as the first fully programmable, automatically controlled computing machine. Zuse — a German civil engineer who built his first computers in his parents’ Berlin living room — assembled roughly 2,000 relays into a machine that could execute a program stored on a punched film strip. The Z3 used floating-point arithmetic and could be reprogrammed without rewiring. It was destroyed in a 1943 Allied bombing raid. Zuse had been introduced briefly in this series when we discussed arithmetic, but the Z3 deserves its full moment here: it was the first machine that matched the architecture we have been building. Clock, ALU, memory, control — assembled from the same clicking switches.
In the United States, Howard Aiken at Harvard, working with IBM, built the Mark I — formally the IBM Automatic Sequence Controlled Calculator — which was unveiled in 1944. Fifty-one feet long, eight feet tall, and weighing about five tons, the Mark I contained approximately 3,300 relays alongside a forest of mechanical counters, clutches, and cam shafts. It took 3 to 5 seconds to multiply two numbers. It was fed instructions on a punched paper tape and ran continuously for years, computing ballistic tables, logarithm tables, and, later, mathematical work for the Manhattan Project. Visitors to Harvard could hear it from outside the building — the rhythmic clatter of a 3,300-relay computer at work was not subtle.
The Mark I was followed by the Mark II in 1947 — a similar electromechanical machine, also at Harvard. And it is the Mark II that gave us one of computing’s most enduring stories.
On 9 September 1947, a team of operators including a young Navy officer and mathematician named Grace Hopper found the Mark II behaving erratically. They traced the fault to Relay #70 in Panel F. When they pulled the relay, they found a moth — a real, biological moth — wedged between the contacts, preventing them from closing properly. The moth was carefully removed with tweezers, taped into the operations logbook with a note: “First actual case of bug being found.”
The logbook page survives. It is on display at the Smithsonian’s National Museum of American History. The moth is still there, under its piece of tape.
The word “bug” for a technical fault had existed informally for decades before — Thomas Edison used it as early as 1878 to describe glitches in his apparatus — but that taped moth is the incident everyone remembers, because it is so perfectly literal. An actual insect, in an actual relay, in an actual computer. The metaphor made flesh. And it happened in a relay computer, because relay computers were large enough and open enough for moths to get inside. A transistor is sealed. A moth has no chance.
The lineage: relay → vacuum tube → transistor → chip
The relay computers ran from the late 1930s into the early 1950s. They were then displaced — rapidly and completely — by vacuum tube computers. Tubes had no moving parts: instead of a mechanical armature, a grid electrode inside an evacuated glass envelope controlled the flow of electrons, performing the same switching function in microseconds rather than milliseconds. The logic was identical. The architecture was identical. Only the switch changed.
Vacuum tubes were displaced in turn by transistors, demonstrated at Bell Labs in 1947 and commercialized through the 1950s. A transistor is a semiconductor switch: a small voltage applied to a base terminal controls a much larger current between collector and emitter. No moving parts, no glass envelope, no filament to burn out. Millions of operations per second. The logic was identical. The architecture was identical. Only the switch changed.
Transistors were then integrated by the billions onto silicon wafers — the integrated circuit, born in 1958 and still the foundational technology of every computing device you own. The logic is identical. The architecture is identical. Only the switch is microscopic.
The relay you met in Post 1, clicking audibly under its spring-loaded armature, and the transistor switching silently in your phone 500 trillion times per second are doing the same thing. They are both controlled switches — electricity using one circuit to govern another. Shannon’s 1937 algebra describes both of them, using the same symbols, deriving the same truth tables.
The history of computing hardware is, in one reading, the history of the relay. Everything that came after is a faster, quieter, smaller version of the same idea.
Where to go from here
Three honest recommendations for the reader who has made it to the end of this series.
First: build something bigger. The circuits in this series were sized for a blog post. What happens when you chain eight full adders, wire up a register to hold the result, add a clock, and watch 8-bit arithmetic actually execute? The DigiSim Relay Lab contains exactly that progression — an 8-bit adding machine you can watch carry ripple across all eight stages, a 3-bit ripple counter clicking through binary in sequence, an edge-triggered D flip-flop that only captures data on the rising clock edge, and a frequency divider that halves a clock signal with a single flip-flop. These are the “wow” builds: real programs running on relay logic, every click visible and audible. They are not embedded in a blog post because a blog post is too small for them. They deserve the full canvas.
Second: read Charles Petzold’s CODE. This series was deeply inspired by it. Petzold’s book starts with Morse code and flashlights and ends at a working CPU, built step by step from first principles in a way that is simultaneously rigorous and humane. He covers the same ground we have covered here — and then he keeps going, into machine language, assembly, operating systems. If you want a book that does for reading what DigiSim does for simulation, CODE is it.
Third: build your own. Open the DigiSim canvas, drop a relay, and wire something that came to you while reading this series. The jump from “following someone else’s circuit” to “designing my own” is the real graduation. It does not require any new knowledge. You have everything you need. Go make the relays click on your terms.
Seventeen posts ago, you met a switch thrown by electricity. Today you built a memory cell that holds a bit through silence, and you traced the line from that click all the way to every computer ever built. That line is unbroken.
Go watch a computer made of relays actually run: DigiSim Relay Lab.