Why Circuits Need Memory
In combinational gates like adders, you would always get the same result for the same input i.e., the output is independent of what happened before. That property where the output depends only on current input, is very useful in computation because it's reliable, but useless when it comes to trying to hold information.
Combinational Logic: A Pure Function of Its Inputs
Half adders, multiplexers, majority voters, all belong to a category called combinational logic. Formally, a combinational circuit computes a function output = f(inputs) with no dependence on time. Most of digital logic is combinational, and for pure computation (adders, comparators, decoders) that's sufficient for the most part. On the other hand, stateful circuits are sequential, which means that the output depends on a chronological sequence of inputs.
But a computer needs more than computation. It needs to count, hold a running total, remember which state a state machine is currently in, and store a byte long after the signal that produced it is gone. None of that is expressible as a pure function of the current inputs, because the whole point is that the output has to depend on something that isn't there anymore, in other words, the history of the inputs.
The Trick: Route a Gate's Output Back Into Itself
Take a gate's output and wire it back into one of its own inputs (directly, or through a neighboring gate that loops back into it), and the gate's output stops being a pure function of its external inputs. It becomes a function of its own recent output too, because that old output is now literally one of the signals feeding it.
Why This Doesn't Blow Up Into an Infinite Loop
A feedback loop in software that recomputes a value from itself is usually a bug. In a digital circuit it isn't, because gates aren't instantaneous. Every gate has a small propagation delay, which is why a signal chasing itself around a loop doesn't recompute forever, it settles. After a handful of gate delays the loop reaches a value that's consistent with itself, every gate's output matches what its inputs demand, and nothing changes further. That converging behavior is what makes the next three tutorials safe to build, and it's why simulating one of these circuits gate-by-gate always converges instead of spinning.
Where This Section Is Going
Three storage elements, built in order, each one fixing a specific problem with the last:
SR latch -> two cross-coupled NOR gates, the smallest circuit that stores a bit
(has one input combination that is genuinely forbidden)
Gated D latch -> fixes the forbidden state by trading two inputs (S, R) for one (D)
(still reacts to a signal LEVEL, which causes race-through when chained)
D flip-flop -> fixes race-through by reacting to a clock EDGE instead of a level
(this is what real registers and counters are built from)By the end you'll know exactly what a register is made of, gate by gate, and why each design decision along the way was forced by a specific limitation of the one before it.