Lesson 6 of 13
Memory: holding a bit still
Explain how a loop of gates can hold a value instead of just reacting to it, and why being able to remember is what separates a computer from a calculator.
01 · Learn · the idea
Type a sentence and walk away to make a cup of tea. Come back five minutes later and it is still there on the screen, every letter exactly where you left it. Nothing was holding the keys down. No input was arriving. Yet the machine kept the sentence whole. That stubborn keeping is the thing this lesson is about — and it is the single trick that separates a computer from a calculator.
So far in this course, every part we have built has been a reflex. A gate (lesson 4) does nothing on its own; it just reacts. Feed an AND gate two 1s and its output is 1. Take one input away and the output drops to 0 in an instant. The adder (lesson 5) is the same: it computes a sum the moment you present the digits, and forgets it the moment you stop. Pure reaction, nothing held. So here is the puzzle. If a computer is built from nothing but gates, and a gate forgets the instant its input leaves — how can the machine remember anything at all?
The problem: a gate has no past
Picture a single NOT gate, which flips its input: a 1 in gives a 0 out, a 0 in gives a 1 out. Useful, but it has no memory. Its output depends only on what is being fed to it right now. The instant the input changes, the output changes. There is no yesterday inside it. Whatever you set, it lets go the moment you let go.
A calculator is exactly this, scaled up. You press 7 + 3, it shows 10, and the answer hangs there only because the circuit is still being told what to compute. The numbers do not live anywhere. They are a wave passing through, gone the second the wave stops. A calculator can compute, but it cannot keep.
To keep a bit, we need a part that does something no single gate can do: respond not only to its input, but to its own past.
The trick: feed the output back in
Here is the move. Take a gate and wire its output back into its own input. The gate now sees what it is itself producing. It reacts to its own state.
Think of two NOT gates in a ring. The first flips its input and feeds the result to the second. The second flips that and feeds it back to the first. Suppose the first is currently putting out a 1. The second flips it to 0 and hands it back. The first flips that 0 to a 1 — which is exactly what it was already putting out. The loop agrees with itself. It is stable. It will sit at 1 forever, with no input arriving at all, because each gate is being held in place by the other.
That self-agreeing loop is called a latch, or a flip-flop. It is the first part in this whole course with a memory. The bit it holds is not a wave passing through; it is a standing pattern, propped up by feedback, that stays put until something deliberately knocks it over.
Set and Reset: a worked example in time
A bare loop holds a value but gives you no way to change it. So a real latch adds two control wires: Set (force it to 1) and Reset (force it to 0). The trick is that a brief pulse is enough — you tap the wire, and the loop takes over from there. Let us walk one latch through time and watch.
Start: the latch holds 0. No wires are touched. The feedback loop is quietly agreeing with itself at 0.
Press Set, then release. The Set pulse forces the loop to 1. Now — here is the whole point — you let go, and it stays 1. The pulse is gone, but the loop is now agreeing with itself at 1, each gate holding the other up. It remembers.
Wait. A second, an hour. No input. Still 1.
Press Reset, then release. The Reset pulse forces the loop to 0. Let go, and it holds 0. It remembers the new value just as stubbornly.
Compare that to a plain gate. If you “set” a gate by holding its input high, it reads 1 — but the instant you release, it drops straight back. It cannot hold. The latch can, because its output is wired to keep feeding itself. That difference — holds after you let go versus drops the moment you let go — is the entire difference between a circuit that remembers and one that merely reacts. You will feel it directly in the lab: two indicators, one that holds and one that doesn’t, side by side.
A field of stubborn loops
One latch holds one bit. Lay millions of them side by side and you have the machine’s working memory — what is usually called RAM. Each tiny loop holds its own 1 or 0. An address is just a way of pointing at one particular latch: “the bit at position 4,051,992 — read it, or write a new value into it.” Reading checks which way the loop is leaning; writing sends a Set or Reset pulse and walks away, leaving the loop to hold the new bit.
This is what makes the machine in front of you a computer and not a calculator. A calculator reacts. A computer holds state — it keeps numbers, keeps your half-typed sentence, and, crucially, keeps the program it is running. In the next lesson the processor will step through instructions one at a time; it can only do that because memory holds the instructions still while it works through them. Without latches there is no program to step through, no document to edit, no past at all. Just an endless present of reactions, forgotten as fast as they happen.
It is worth sitting with what memory really is down there. When the machine “remembers” your sentence, there is no mind keeping it in view, no inner picture of the words. There is a vast field of tiny gate-loops, each doing the only thing it can — feeding its own output back to itself, agreeing with itself, holding one plain yes-or-no still against the passing of time. The remembering you feel is millions of those loops, holding, all at once. The cleverness is not in any one of them. It is in how many there are, and in the simple idea that a thing wired to feed itself can keep itself.
02 · Try · the lab
03 · Check · quick quiz
1. A plain gate is fed a 1, then the input is taken away. What does its output do?
- It drops back, because a gate's output follows only what is fed to it right now
- It stays at 1, because gates remember their last input
- It slowly fades from 1 to 0 over a few seconds
- It flips to 0 and then back to 1 on its own
Answer
It drops back, because a gate's output follows only what is fed to it right now — A plain gate is a reflex — its output depends only on its inputs at this instant. Remove the input and the output drops at once. It has no past. That is exactly the limitation a latch is built to overcome.
2. What lets a latch keep holding a bit after the Set pulse has ended and no input is arriving?
- Its output is wired back into its own input, so the loop keeps reinforcing its own state
- A tiny battery inside the latch keeps the bit charged
- It stores the bit on the chip's surface like writing on paper
- The Set wire stays slightly powered even after you release it
Answer
Its output is wired back into its own input, so the loop keeps reinforcing its own state — The trick is feedback: the gate's output feeds back into its input, so the loop agrees with itself and props its own value up. No battery, no held wire — just a loop holding itself still after a brief pulse.
3. You press Set on a latch and release. Then you press Reset and release. With nothing now pressed, what is the latch holding?
- 1 — it keeps the most recent value it was forced to, which was Set
- 0 — Reset was the last pulse, and it holds that until something changes it
- Both at once, since Set and Reset were both used
- Nothing — releasing the buttons clears it to empty
Answer
0 — Reset was the last pulse, and it holds that until something changes it — A latch holds whichever value it was last forced to and keeps it until the next pulse. Reset came last, so it holds 0 — and will hold 0 indefinitely with no input. Releasing a button never clears a latch; that is the whole point of memory.
4. Why is the ability to hold a bit still what separates a computer from a calculator?
- A calculator reacts and forgets, while a computer holds state — including the program it is stepping through
- A computer's gates are faster than a calculator's gates
- A calculator has fewer buttons than a computer keyboard
- A computer uses ten voltage levels while a calculator uses two
Answer
A calculator reacts and forgets, while a computer holds state — including the program it is stepping through — Both are built from gates, but a calculator only reacts — the answer vanishes the moment the input stops. A computer's latches keep numbers, your text, and the program still, so a processor has something to step through. Holding state is the difference.