How Computers Work from the transistor up · chapter 07
07Remembering a Bit
Chapter 6 ended on a confession, and this is the chapter that pays it off. Everything we've built so far shares one trait we never said out loud — every gate, every adder, the whole ALU. It has no past. Its output is a pure function of the inputs sitting on its wires right now. Set the operands and the answer appears. Change them and the old answer is gone without a trace. That property has a name: combinational logic, logic that only ever reacts. It's exactly why a calculator can't remember the number you just computed. So here is the strange question this chapter turns on: how can a machine made entirely of parts with no memory ever remember anything? The answer is almost insultingly small. It's a single wire bent back into a loop. When a gate's output feeds its own input, the machine stops being a function and starts having a history. The same inputs can now give two different outputs, depending on what happened before. That broken determinism isn't a bug. It is memory — the first thing in this whole course that can hold a value on its own. We'll watch an OR gate latch itself to 1 and refuse to let go. We'll build the cross-coupled SR latch that rests in either of two stable states, then gate it so it stores only on command. And we'll finish on the one flaw it can't shake: it listens too much. That flaw is the exact door the clock walks through next chapter. No magic in any of it — just a wire, doing something we've carefully never let a wire do until now.
01When a wire feeds itself
Before we break it, let's be precise about the thing we're breaking, because the whole chapter is a contrast against it. Take any gate we've built — say an AND. Notice its defining virtue: it is a function. Give it the same two inputs a billion times and it hands back the same one bit a billion times. No drift, no history, no "it depends." Its output is decided entirely by the inputs present this instant. That's determinism, and every truth table quietly assumes it — one row per input combination, one fixed answer each. Run a whole tape of chips through the same gate below and watch them all drop the identical colour. There is no yesterday in here.
A gate has no dice inside and no memory. Set A and B, predict Y, then hit Run again and again. Watch the disagreement count.
0 runs — predict Y, then Run
Fig 1. A logic gate is a function on {0,1} — it maps a pair of bits to one bit, and that map is fixed. Pick a gate, set A and B, then hammer Run: every chip on the tape drops the same colour, the run count climbs into the dozens, and the disagreement tally stays nailed to 0. No dice, no drift, no memory of the last run — the hundredth press answers exactly like the first. That perfect repeatability is the whole reason a billion of these can stack into a computer: change an input and you ask a new question, but ask the same question and a gate can never change its mind.
Now pick the one gate we're about to abuse, and remind yourself exactly how it behaves, because its stubbornness is the whole trick. The OR gate lights its output the instant either input is 1. It goes dark only in the single case where both are 0. Hold that in your head: an OR with even one 1 anywhere on its inputs outputs 1. Flip the two inputs below and confirm it. One lit input is all it takes.
The OR gate is the mirror of AND: it outputs 1 when either input is 1 — it only stays 0 when both are 0. Toggle the two inputs and watch the lamp.
0 OR 0 → 0 · both off, so the light stays dark
Fig. The OR gate — “either.” Flip the two inputs (click the pads or pick a row): the lamp lights the instant either A or B is 1, and goes dark only in the single case where both are 0. That one fact wears three costumes at once — it's logical-or (either one), it's max(a, b) (the larger of the two bits), and it's set union (an element is in A ∪ B if it's in either set). It is the exact mirror of AND: where AND demanded both, OR is satisfied by one.
Here's the move we've spent six chapters never making. Take that OR gate and do something that should feel slightly illegal. Run its output wire back around and connect it to one of its own inputs. Now the gate is reading a signal it is itself producing. The same physical wire is both the answer and part of the question. Every circuit until now flowed strictly left-to-right, inputs to outputs — a clean one-way street. This one has a feedback loop, a cycle, and that single cycle is enough to change what a wire fundamentally is. Trace the loop below. Follow the output around and watch it arrive back at the input it feeds.
click a pad to flip its bit
One-way street — Q = A OR B. The signal crosses the gate, lights the lamp, and stops there. Nothing comes back.
Fig 3. The move every earlier chapter refused to make. In one-way mode this is an ordinary OR gate: Q = A OR B. The signal starts at the pads, crosses the gate, lights the lamp, and stops — one direction, no way back, exactly like every circuit you have built so far. Now press bend it back. The output wire loops down, around, and into input B. Nothing has been added and nothing has been taken away: it is the same single wire, only now it is both the answer and part of the question, and the gate is reading what it just said. Hit trace the signal to send a pulse around and watch where it arrives. Flip the pads and follow the loop. What a cycle does to a circuit is the next figure's business.
Watch what that loop actually does, because it's the birth of memory and it happens fast. Leave the free input — call it Set — at 0. The output sits at 0, quietly feeding 0 back to itself: stable. Now pulse Set to 1 for even an instant. The output snaps to 1. And here's the thing: that 1 now travels around the loop and lands back on the gate's own input. So the OR keeps seeing a 1 coming in, even after you let Set drop back to 0. And an OR with a 1 on any input outputs 1. It holds itself up by its own bootstraps. Pulse it and let go — the 1 stays.
predict first: once you let go, is Q 0 or 1?
empty — output is 0
Fig. The output wire loops back into the gate's own second input. Both inputs start at 0, so the OR puts out 0 — nothing. Now press & hold Set: one input goes high, OR fires, the output snaps to 1 — and that 1 races around the feedback loop into the gate. Here is the question. Answer it before you let go: the moment Set drops back to 0, where does Q land — back at 0, or still 1? Say it out loud, then release the button and watch. Then read on: Set is at 0, but the gate is still seeing a 1 on the loop, so it keeps outputting 1, which keeps the loop at 1, which keeps the output at 1… forever. Nothing is holding the input; the bit is holding itself. That circling 1 is the memory.
So we've built the simplest memory there is — and immediately hit its fatal flaw. It's worth feeling now, because the next section's whole design exists to fix it. This latch can remember a 1, beautifully, forever. But try to put it back. Drive Set to 0 and nothing happens. The loop is still feeding itself a 1, and the OR keeps outputting 1 no matter what you do to the free input. There is no wire you can wiggle to bring it home to 0. It's a write-once memory cell with no eraser: you can set it but you can never reset it. Try every input below and watch it refuse to come down.
Q = 0. Flip SET to 1 to write a bit.
rule: Q = SET OR fb · fb = 0 the two fb = 1 rows are out of reach — Q just follows SET.
the plug is the only way back — and pulling it is not a logic input.
An OR only ever pushes up. Its forcing value is 1: a single 1 anywhere on its inputs forces the output to 1 — so no value on any input can force a 0 out. To erase a bit with logic instead of a plug, we need the opposite: a gate whose 1 forces the output DOWN.
Fig. An OR gate wired back into itself — the simplest thing that remembers. It has one free input, SET, and one input fed straight from its own output. Flip SET to 1 and Q jumps to 1; the feedback wire carries that 1 back in, so the fb column is now pinned at 1 — and of OR's four rows, only two of them have fb = 1. Both output 1. Drop SET back to 0 and Q doesn't budge, not because we failed to find the right combination but because there is no such row left to find: an OR only ever pushes up, never down. It's a write-once cell with no eraser; the only way back is to pull the plug. To erase with logic instead of a plug, we need a gate whose 1 forces the output down.
Now step back and notice the deep thing that just happened. It's the conceptual heart of the entire chapter, bigger than any one circuit. Look at the latch when Set is 0. What is its output? The honest answer is: I can't tell you from the inputs alone. It might be 0 (if you never pulsed it) or 1 (if you did). Same input, two possible outputs. That is a flat-out contradiction of everything determinism promised. A truth table has one row for "Set = 0" and demands one answer; this device has two. The circuit has stopped being a function of its inputs. It's now a function of its inputs plus its own history. That's the line we just crossed, and it has a name: sequential logic, logic with a past. Set the same input and watch the output disagree with itself, depending on the road you took to get there.
now · S 0 R 0 — idle
…or poke it yourself (hold):
Q is unwritten — run a history to give it a value.
the truth‑table row for “S 0 · R 0”
S 0 · R 0→Q = ·after History A
S 0 · R 0→Q = ·after History B
Fig. 6 — Determinism, shattered. A truth table promises one output for one input. Here the input is the same both times — S 0, R 0, perfectly idle — yet Q comes out 1 after you set it and 0 after you reset it. Nothing on the input lines changed; what changed is the past. The output feeds back into itself through those two crossed wires, so the circuit is now a function of its inputs and its history. That is the whole idea of sequential logic — and the first thing in this book that can remember.
If a truth table can't describe this thing, then the truth table is the wrong tool. Swapping tools is how you know you've genuinely entered new territory. A truth table has no axis for "when." But this circuit's whole behaviour is about when: its output depends on the order of things that happened over time. So we reach for the instrument that has time built in — the timing diagram. It draws each wire as a horizontal track, with time running left to right. You can literally see a 1 arrive on Set, watch the output rise in response, then see it stay high long after the input has dropped away. That persistence — a line staying up with no input holding it there — is memory made visible. Read the two tracks below left to right.
Set 1Rst 0Q 1
Set is high — it is forcing Q up to 1
Slide the now line across.
A truth table lists Set, Reset → Q and stops — but here Set=0, Reset=0 gives Q=0 early and Q=1 later. Same inputs, different output. Only when tells them apart, so we draw when.
Fig 7. A truth table has a column for every input and none for when — so it can't describe a wire whose output depends on its own past. Switch tools: draw each wire as a track with time running left → right. Read the story: a short Set pulse snaps Q up — and Q stays high across the long stretch where Set has dropped back to 0, right until Reset knocks it down. Drag the now line (or click the tracks) and compare two instants where Set=0 and Reset=0: early, Q=0; late, Q=1. Identical inputs, opposite output. That gap is memory — and it only shows up once you give the picture an axis for time.
02Two stable homes — the SR latch
Our OR-latch works, but it's lopsided: one-way, no eraser. To fix it we need a mental picture of what "good" memory even looks like, and physics hands us the perfect one. Picture a ball in a landscape with two valleys and a hill between them. Leave the ball in the left valley and it stays there — nudge it a little and it rolls right back. Leave it in the right valley? Same story. The system has two resting places. Each one actively holds itself, and it takes a real shove to cross from one to the other. That's called bistability, two stable states, and it is the honest shape of a memory bit. 0 is one valley, 1 is the other, and small disturbances can't tip it between them. Push the ball around below and feel the two valleys hold.
So we want two valleys. Before we wire anything, though, ask a harder question: why did the OR-latch only ever have one? The honest answer isn't our wiring. It's OR itself. An OR input can do exactly one thing to the output: a 1 on it forces the output to 1. A 0 on it forces nothing at all — it just steps aside and lets the other input decide. So there is no value you can put on any OR input that drags a 0 out of it. OR only ever pushes up. That's why the eraser was missing: not because we weren't clever enough to find it, but because with OR it cannot exist. And that hands us the shopping list. We need a gate with an input that forces the output down. Now check NOR against that list, on the table you built in Chapter 2. Put a single 1 anywhere on a NOR's inputs and the output is 0. Every time. Whatever the other input is doing. That is OR's rule held up to a mirror — OR's 1 forces high, NOR's 1 forces low. Hold that in your head, because the next five paragraphs lean on it. We didn't pick NOR. We deduced it.
stored bit: 0
resting in valley 0 — a stored 0
Drag the ball up a slope and let go — it rolls back. Only a shove big enough to clear the hill flips the stored bit.
Fig 8. A ball in a landscape with two valleys and a hill between them — the honest physical shape of a memory bit. Valley 0 and valley 1 are the two stable resting states; each one actively holds the ball, so a small disturbance just rolls back. Grab the ball and drag it partway up a slope, or hit gentle nudge — the energy bar stays under the dashed barrier line and the valley pulls it home every time. Only a hard shove with enough energy to clear the hill flips the stored bit to the other valley, where it settles and holds just as stubbornly. That "two homes, a hill between, each holding itself" is bistability, and the next figure builds exactly this out of two cross-coupled gates.
Now let's build that ball-and-two-valleys out of gates. The trick is the same feedback we just discovered, done symmetrically so it works both ways. Take two of the gate we just deduced: two NOR gates. Keep both halves of its rule in your hand. A NOR is an OR with the output flipped, so it outputs 1 only when both inputs are 0 — and a single 1 anywhere on it forces the output to 0. Now cross-couple them: wire the output of the first into an input of the second, and the output of the second back into an input of the first. Each gate is now watching the other's answer. That mutual staring is the whole mechanism. The two outputs, which we'll call Q and its opposite Q̄, lock into being each other's opposite and stay that way. This is the SR latch, the canonical one-bit memory, with two control inputs left over: S (set) and R (reset). Trace the cross-coupling below.
HOLD — the loop is remembering Q = 0
Two pulses ride the feedback: Q leaves gate 1 and drops into gate 2 · Q̄ leaves gate 2 and climbs into gate 1. Each output holds the other in place.
press SET then let go — Q stays 1. That "staying" is memory. Hover a gate to light the wire it drives.
Fig 9. Two NOR gates, each with its output wired straight back into the other's input — that mutual feedback is the whole trick. Watch the two pulses ride the loop: Q leaves gate 1 and drops into gate 2, while Q̄ leaves gate 2 and climbs into gate 1, and the two feedback wires cross (the little hop shows they pass without touching). A 1 on any NOR input forces that gate's output to 0 — so whichever output is high is pinning the other one down, and the loop, once it settles, stays settled. Tap SET and let go: Q snaps to 1 and stays, even with your finger off. Tap RESET: it flips to 0 and stays. That refusal to forget is a single bit of memory. Raising S and R together is forbidden — it drives both outputs to 0, breaking the "always opposite" rule and, on release, leaving the winner to a coin-flip race.
Here's the payoff over the crippled OR-latch: this one erases. Pulse S to 1 and Q snaps to 1 and stays — set. Now pulse R to 1 and Q drops to 0 and stays — reset, the very move the OR-latch couldn't make. And when both S and R are back at 0, the latch simply holds whatever it last became. That's the full behaviour of a memory bit, in three modes: set it, reset it, or leave it alone and it remembers. Drive S and R below and store, erase, and hold a single bit with your own hands.
One thing before we open the hood, and it's the thing that makes the argument easy. Look at the latch in hold mode, with S and R both at 0. Each NOR now has one dead input — an input pinned at 0, which we just said forces nothing and steps aside. So what is a NOR with a dead input actually doing? Check it on the table you already have. NOR(0, 0) = 1, and NOR(0, 1) = 0. Feed a NOR a 0 on one input and it hands back the opposite of the other. That's an inverter. A two-input NOR with a dead input is quietly a one-input gate. Say that out loud, because it changes the picture completely: while the latch is holding, the SR latch simply is two inverters wired in a ring, each one's output feeding the other's input. Not a picture of it. The same device, with the dead inputs doing nothing. And two inverters in a ring is about the simplest object we could ever argue about.
both low — the bit holds its last value (0)
Tap a button for a quick pulse, or press and hold to drive the line yourself. Notice: the drive is momentary, but the bit stays put — that's memory. Set with S, reset with R, and with both low it simply remembers.
Fig. A single stored bit, built from two NOR gates wired mouth-to-tail so each one's output feeds the other's input. Pulse S and the bottom gate is forced low, so the top gate rises — Q lights and reads 1. Pulse R and it's forced low — Q goes dark, 0. Now let both lines fall to 0 and watch the loop hold itself lit through the feedback: the bit stays. That third mode — hold — is the thing a bare OR-latch never had. (Drive both high at once and both outputs collapse to 0: not a valid bit, which is why a real memory cell forbids it.)
I don't want "it just holds" to feel like hand-waving, because the why is the most beautiful part. So let's watch the loop actually settle. Say Q is currently 1 and both inputs are 0. That 1 feeds into the second NOR, whose inputs are now (1, 0). A NOR with any 1 outputs 0, so Q̄ is 0. That 0 feeds back into the first NOR, whose inputs are now (0, 0). Both low, so it outputs 1, which is Q. And that's the 1 we started with. The state proves itself: each gate's output is exactly the input the other gate needs to keep producing it. The loop isn't just sitting still. It's a tiny argument that keeps reaching the same conclusion, faster than you can perturb it. That self-reinforcement is the ball settling into its valley. Step the signal around the ring below and watch it close on itself.
Predict first — of the four candidates, how many survive a lap?
With S = R = 0 both gates are left alone with each other. Four assignments of (Q, Q̄) are conceivable. Commit to a number first.
checked: 0 of 4
Fig 11. The hold ring with S = R = 0: two NOR gates, cross‑coupled, each with its dead input pinned to 0 — and since a NOR with a 0 on one input just inverts the other, NOR(0, x) = NOT x. Gate 1 drives Q; gate 2 drives Q̄. Nothing outside is touching this loop, so the only thing holding the wires up is the wires themselves. Four assignments of (Q, Q̄) are conceivable — (0, 0), (0, 1), (1, 0), (1, 1). Predict how many of them the ring can actually hold, then load each one and Step it round: ask each gate what it really drives, and see whether the loop still agrees with what you assumed. What you find is the whole reason this circuit can store a bit.
Every honest engineer owes you the failure modes too, and this latch has one that textbooks love to skip past. We've used S, R, and both-low. What about both high — S = R = 1? Ask the latch to set and reset at the same instant and you get nonsense. Both NOR gates are forced to output 0, so Q and Q̄ are both0 — no longer opposites, which was the one promise the latch made. Worse, when you release both inputs together, the loop has no defined state to fall into. It can hang for a moment, balanced on the hilltop between the valleys. That's a real, physical condition called metastability: the ball teetering on the peak before it topples one way or the other. This is the forbidden input. It's not a bug in our drawing, but a genuine hole in the naive latch that better designs have to engineer around. Drive both inputs high below and watch the contradiction.
Click the R and S pads to drive them 0/1. Now set both to 1 — the forbidden input — then press Release both.
coin-flips so far — Q=1: 0 · Q=0: 0
Hold → Q = 0, remembered from before.
Predict first: if you drop one input at a time it's clean — so why is dropping both at once a coin‑flip?
Fig 12. Two NOR gates wired mouth-to-tail — each output feeds back into the other — make a one-bit memory: S sets Q to 1, R resets it to 0, and with both low the loop simply holds whatever it last had. But drive both high and the contradiction shows: a NOR outputs 1 only when both its inputs are 0, so with a 1 on each gate both outputs are forced to 0 — Q and Q̄ are no longer opposites, and the whole idea of “the bit” falls apart. Worse is what happens on the way out. Drop one input and the latch lands cleanly. Drop both at the same instant and each gate sees 0, 0, each tries to rise to 1, each shoves the other back down — the loop teeters on the hilltop between the two valleys, and which way it finally topples is decided by noise too small to name. That is metastability: the naive latch has a real hole in it, and taming it is the first job of every clocked flip-flop that follows.
One more question the OR-latch let us dodge, and this one can't: what does the latch read the instant you switch the power on, before anyone has touched S or R? The unsettling truth is that nobody can say. Both gates power up at once, each racing to answer before the other has. Which valley the ball tumbles into is decided by microscopic differences between the two gates: a hair more delay here, a whisper of thermal noise there. It might come up 0, it might come up 1, and it can differ from one power-on to the next. That's why real memory is garbage until initialized — the very reason your programs must set a variable before reading it. The bit is real from the first microsecond; its value is meaningless until you write one. Power-cycle the latch below and watch it land on an unpredictable state.
landed 0power-upslanded 1
00 cycles0
Flip the switch — which valley will the bit fall into?
Same latch, same untouched inputs, every time. Yet the answer changes — because nothing wrote it. That’s why memory is garbage until you initialise it.
Fig 13. The same cross-coupled latch, switched on again and again — with S and R both left at 0, untouched. At power-up both NOR gates start from zero and race to pull high first, and which one wins is settled by things you can’t see: a hair more delay in one gate, a whisper of thermal noise. So the ball tumbles off the hilltop into whichever valley it happens to fall — 0 one time, 1 the next. Nudge the gate mismatch and you tilt the odds, but never to a certainty. The bit is real from the first microsecond; its value is meaningless until something writes it. That is precisely why memory is garbage until initialised, and why your programs must set a variable before they dare read it.
03Storing on command
We can now store a bit — but look at how twitchy the storing is. The SR latch reacts to S and R the moment they move. Any glitch, any stray pulse on those lines, and the stored bit changes whether you meant it or not. That's no way to run a computer, where a hundred wires are settling and rippling at once. What we really want is control over timing: a way to say "ignore your inputs entirely, except during the exact window when I tell you to listen." So we add one more wire, an enable — call it C for control. It gates whether S and R can reach the latch at all. When C is 0 the latch is sealed and holds. When C is 1 it accepts input. Toggle the enable below and watch the same inputs get through or get blocked.
The enable tames when the cell listens. But we're still carrying that hole from earlier, and it's worth going back for. Look at where the forbidden input actually lived: one row. S = R = 1. That's all of it — every other combination behaves perfectly. So here's a question worth sitting with. What if we made that row unwireable? Not guarded against. Not written up in a footnote nobody reads. Physically impossible to ask for. Look at what it would take. S and R only break the latch when they agree. So don't let them agree. Run a single wire in, send it straight to S, and send it through an inverter on its way to R. Now R is always the opposite of S, by construction — the two can never both be 1, because there's no longer a wire to say it on. The forbidden row is off the map. Now look at what that did to the controls. Drive the new wire to 1 and the cell sets, so it stores a 1. Drive it to 0 and R goes high and the cell resets, so it stores a 0. It isn't giving an order any more. It is the bit. That's not a control line, that's data — so call it D. Two commands collapsed into one value, and the flaw didn't get engineered around. It got deleted.
Try it: set S = 1 with the enable SHUT — nothing moves. Now flip the enable OPEN and watch the bit store on command.
S — the set line
R — the reset line
S · R (what you asked for)1 · 0
reaching the latch (S·C , R·C)0 · 0
stored bit Q0
enable SHUT · inputs blocked · holding Q = 0
With C low, both AND gates output 0 no matter what S and R do — the latch sees hold and keeps its bit. Raise C and the gates pass S and R straight through. That's store on command.
Fig 14. The raw latch was too twitchy — every wobble on S or R rewrote the bit. So we add one more wire, the enable C, and stand an AND gate in front of each input: the latch now sees S·C and R·C, not S and R. While C is low, both gates output 0 no matter how you jiggle the inputs — the latch reads that as hold and guards its bit. Raise C and the gates swing open, letting S and R through to set or clear the cell. Set S = 1 with the enable shut and nothing happens; flip the enable and the bit snaps into place. That is the whole trick of memory-on-purpose: it ignores its inputs except during the window you choose.
Now step back and read what we just built, because its behaviour has a shape you'll recognise. Forget the gates for a second and write down only what the cell does. When C is 1, Q takes the value sitting on D. When C is 0, Q keeps the value it already has. Two lines, and look at what they have in common. Each one hands you a value from one of two sources, and a control wire decides which source wins. A wire carrying a new value, a wire carrying the old value, and a line that picks which one comes out — that is a multiplexer, the 2-to-1 selector from Chapter 3, letter for letter. When the select is one way it passes input A; the other way, input B. We didn't import that. We derived the behaviour with our own hands and then found out it already had a name. Here's that MUX again so the shape is fresh in your hands. Flip its select and watch it choose between two inputs.
A
B
C
picks
Y
C = 0 → Y follows A = 0
Set A and B to anything you like. Now flip C back and forth: the whole lit path swings across, and Y snaps onto whichever input C names — ignoring the other completely. The gold row is where you are; the table proves it holds for all eight cases.
Fig. The finished 2-to-1 selector, in your hands. Two data inputs A and B each feed an AND gate; the single select wire C arms the bottom gate directly and the top gate through a NOT (so exactly one is ever open), and an OR merges the survivor into Y. Set A and B however you like, then flip C: the entire lit path swings from one input to the other and Y locks onto the chosen one, deaf to the input C ignored. This is the circuit from Chapter 3 that makes a decision — and the live truth table confirms it holds across all eight A/B/C cases, no exceptions.
So the same cell can be drawn a second way, and this drawing is the cleanest memory cell in the book. Take a MUX. Wire one of its data inputs to a fresh value we'll call D (for data). Wire the other data input — the feedback input — to the MUX's own output, looped back. The select line is our enable C. Read what that does. When C = 1, the MUX passes D through, and the cell takes the new value. When C = 0, the MUX passes the other data input instead — the one wired back to its own output. So it feeds itself its current value and holds. Be careful here, because the wording traps people. With the enable low the cell does not put out a 0. It puts out whatever Q already was. That feedback path is the memory. One data wire, one enable, and the feedback we've been circling all chapter. This is the gated D latch. It has no forbidden input — not by luck, but because we deleted that row ourselves: R is wired to be the opposite of S, so the two can never both sit at 1. There's no separate set/reset dance left either, because those two commands became one value. You just present a bit and say when. Wire it below.
The loop is open — input 0 dangles, so with C=0 the MUX picks up nothing. Click the dashed wire to feed Q back into itself.
the new data bit — D
the enable C — which input the MUX takes
select C0
picks input0 · the loop
stored Q?
loop open · C=0 selects a floating wire
One MUX, fed its own tail. C=1 lets a fresh D wash straight through; drop C=0 and the output picks the loop — itself — so it just keeps re-choosing the bit it already holds. No illegal combo exists.
Fig 16. A gated D latch is nothing but a 2:1 multiplexer wired to its own output. One input is fresh data D; the other is the latch’s own Q, looped straight back; the select line is the enable C. When C=1 the MUX passes D — the latch is transparent, Q simply follows the data. When C=0 it passes input 0 instead, which is Q feeding itself, so the output endlessly re-selects the bit it already carries — that circulating loop is the memory. Cut the loop and C=0 has nothing to hold, which is why the figure starts open and asks you to wire it. Unlike the raw SR latch, every combination of C and D is legal: there is no forbidden input.
Let's make storing a bit into a concrete, repeatable ritual, because this exact four-beat sequence is how every register you'll ever meet writes a value. To store a bit in the gated D latch: one — put the value you want onto D. Two — raise the enable C to 1, opening the door, and the latch takes D. Three — drop C back to 0, closing the door and locking the value in. Four — now you can change D to anything you like and the stored bit doesn't budge, sealed behind the closed enable. Present, enable, latch, release. Step through the store procedure below one beat at a time.
Beat 1 — PRESENT: pick the bit on D. The door is shut, so Q is untouched.
Fig 17. Every register writes with the same four-beat ritual. Present the bit on D; the door is shut, so Q ignores it. Raise C (enable) and the door swings open — now Q copies D live, so toggle D and watch it follow. Drop C (latch) and the door shuts, freezing Q on whatever D was at that instant. Now release: flip D as much as you like — the door is sealed, and the stored bit doesn't move. That one locked door is how a wire remembers.
04The catch: transparency
We have a proper one-bit memory — and now I have to show you the crack in it, because being honest about this flaw is the entire reason the next chapter exists. Go back to step two of that ritual, the moment the enable C is high. During that whole window, what is the latch doing? It isn't taking a single snapshot of D. It's passing D straight through, live, continuously. Wiggle D while C is still 1 and the output Q wiggles right along with it, tracking every change like a plain wire. The latch is transparent: you can see clean through it to D for as long as the enable is held. It only truly "remembers" the value that happened to be on D at the instantC fell. Hold the enable high below and watch the output helplessly follow its input.
transparent — Q is just D, live
Hold the enable HIGH and wiggle D. Watch Q chase it with no will of its own. Only when you drop C to LOW does Q stop and keep the last value.
Fig 18. A D-latch with its enable C held HIGH is transparent — the shutter is open, so D pours straight through to Q like a bare wire. Wiggle D (or hit auto-wiggle) and the scope shows Q tracing every move of D with a helpless, one-for-one copy — it isn't remembering anything, it's just passing it through live. Drop C to LOW and the shutter slams: D is walled off and Q freezes flat, keeping exactly the value that happened to be present the instant C fell. That falling edge — not the whole time C was high — is the only moment a latch actually decides what to remember.
Now feel why that transparency is a real problem and not a curiosity. Put it on a timing diagram, where the danger is obvious. Picture the output of our ALU wired to the D input of a latch, and imagine we hold the enable high for a stretch to "capture" the answer. But during that stretch the ALU's own output is still settling — carries rippling, bits flickering toward their final values. And because the latch is transparent, all of that churn passes straight to Q. We didn't store a value. We stored a live feed of a circuit mid-thought. The enable is high for a duration, but the thing we want to capture is a single trustworthy instant. That mismatch is the whole flaw. Watch the output smear across the transparent window below, when what we wanted was one clean sample.
how do we grab the bit?
window open 0.80 of the cycle → Q smeared through 7 glitches
while it's open, Q is transparent — it just copies D, churn and all.
A level-high enable is a duration. Everything D does during it leaks onto Q. We wanted one instant.
Fig 19. Three waveforms in one compute cycle. D is the ALU's output: at the top of the cycle it churns — racing through half-formed intermediate values — before it finally settles and holds steady. EN is the enable, and the gold band is it held high — a window that stays open for a stretch of time. While that window is open the latch is transparent: Q simply copies D, so every glitch in the churn smears straight through onto the stored bit. Drag the window narrower and the smear shrinks; but the real fix is the toggle — switch to an instant and Q stops watching the whole duration and takes one sample at the closing edge, on the settled value, immune to the churn. That single active instant is exactly what a clock gives us — and it's where the next section begins.
And that's Chapter 7 — the chapter where a wire learned to remember. The whole climb was one idea turned over and over: a feedback loop gives a circuit a past, and a past is memory. We watched an OR gate latch itself to 1 and shatter determinism — same input, two outputs, depending on history. That is precisely the definition of sequential logic. We drew it on a timing diagram, because a truth table has no room for "when." We built the SR latch from two cross-coupled NOR gates and watched it hold a bit in either of two bistable states. We were honest about its forbidden input, its metastability, and its garbage power-on value. Then we tamed it. An enable wire and a fed-back multiplexer gave us the gated D latch — a bit you store on command with one clean ritual: present, enable, latch, release. But we end exactly where every good chapter should: on a flaw we can't paper over. The gated latch is transparent the entire time its enable is high. It echoes its input live, so it can only faithfully capture a value at the single instant the enable falls. A memory that listens for a whole window, when we need it to listen for an instant, is a memory you can't trust to hold a computer together. So the question that opens the next chapter writes itself. What if the latch could only ever change at one razor-thin moment — the edge of a signal that ticks like a metronome — and stayed frozen the rest of the time? That signal is the clock. That device is the edge-triggered flip-flop, and eight of them side by side is a register — a machine word that holds still. That's where we go next.