Memory: a circuit that refuses to forget
Every gate so far answers instantly and forgets. Feed a gate its own output and it starts to remember.
Everything built so far has a problem: it has no past. An AND gate does not know what it output a second ago, only what its inputs are right now. Take the inputs away and the output means nothing. To store a bit you need a circuit whose output depends on what it did before, and ordinary gates never do that.
The trick is feedback: connect a gate output back to its own input. Now the circuit has a state, because the value on the wire is both the cause and the effect. Push it into 1 and it stays 1; push it into 0 and it stays 0. Nothing outside needs to keep holding the input — the loop holds itself.
stored = NOT(NOT(stored))
stored = 1 -> NOT(1) = 0 -> NOT(0) = 1 -> stays 1
stored = 0 -> NOT(0) = 1 -> NOT(1) = 0 -> stays 0A loop made of two NOT gates holds whatever it is givenIn practice the loop is built from two gates pointing at each other, so that each one holds the other in place. Add a way to override the loop for a moment — a write line — and you can push in the bit you want. Release the write line and the loop keeps that bit. This circuit is called a latch, and two latches working together on a clock make a flip-flop, which changes state only at the moment the clock ticks.
Chain 64 latches and you have a register: 64 bits the processor can read and write as one number, sitting right next to the arithmetic unit so it is available in a single tick. A handful of registers is all a processor needs to do its work. RAM is the same idea repeated billions of times, with an address decoder in front so that the processor can say "give me the byte at this address" — slower and much bigger, but built from exactly the same feedback loop.
Practice
A latch holds the value 1. The input signal is then removed entirely. What does the latch output?
Hints
- Ask what the output is connected to, not what the input is doing right now.
- A gate whose output comes back to its own input does not need anything from outside to keep its value.
15 XP
Order the steps of writing one bit into a latch and keeping it.
Hints
- Nothing survives the power going away, so start with the bit going in while the power is still on.
- The loop is what holds the value; everything after it is just reading the result back out.
15 XP
Match each kind of storage with what it actually is.
Hints
- A register sits inside the processor and is counted in tens; RAM is counted in billions.
- Speed and distance from the processor go together: the closer the storage, the faster and the smaller it is.
15 XP