The Flip-Flop
Every circuit we have met so far suffers from total amnesia: it forgets everything in the fraction of a second in which the input signals vanish. To build a circuit that remembers we need no magical substances, only a simple turning back: a wire from the output ties back to the input. Out of that modest loop are born memory, the rhythm of the clock and, with them, the ordered time of the computing machine.
Terms: combinational circuit sequential circuit NOR latch enable flip-flop edge clock register
Circuits with a past and without
The output of an adder is like a faithful mirror: it reflects strictly what you set before it at the present instant. Change the signals at the input and the output adapts instantly; unplug the wires and the result vanishes without a trace. Such circuits are called combinational. They have no memory: they are prisoners of the present, and their behaviour is described down to the last detail by the truth table — the same inputs will religiously produce the same outputs, today, tomorrow or in ten years.
But a machine that merely reacts mechanically to the stimulus of the instant cannot carry a long line of reasoning. A computer must be able to save an intermediate result, do another operation and come back to what it worked out earlier. It needs circuits whose state depends not only on what they receive now but also on what happened a moment before. These are sequentialcircuits. And their secret lies not in new components or exotic materials but in a simple idea of architecture: the feedback loop, the road by which the output of a circuit turns round and becomes its own input. Memory is not a new substance but a shape: the same logic gates, wired in a ring, suddenly acquire a history and a past.
The loop that holds on to itself
Imagine two inverting NOT gates connected head to tail in a closed ring: the output of the first enters the second, and the output of the second ties back to the input of the first. It is like two people facing each other who decide always to say the opposite of what they hear from the other. If the first says “0”, the second necessarily says “1”. Hearing “1”, the first holds unshaken to its answer “0”. Each gate finds at its input exactly the justification it needs to keep its state.
This simple ring has two perfectly stable states and no reason in the world ever to leave them: top 1 and bottom 0, or top 0 and bottom 1. It remembers a bit without asking anything more from outside, so long as it is fed with current. Yet the loop lacks something essential: a civilised door of access. The only way we can change its state in the experiment above is to force an electrical node brutally from outside, fighting the voltage the gate is holding. Clearly we need an elegant way to write a new value without coming into conflict with the circuit.
The latch
The brilliant solution is to replace the NOT gates with gates that have two inputs: one stays in the loop to sustain the memory, and the second becomes a command input from outside. The ideal gate for that role is NOR (NOR). As long as the command input rests quietly at 0, the NOR gate behaves exactly like an ordinary NOT inverter, and the ring keeps its state undisturbed. But the moment we raise the command to 1, the output is forced to 0 for purely logical reasons, opening the latch with no electrical struggle at all.
Two such gates cross-connected make up a latch (latch). The circuit has two friendly inputs: one called set (Set), which puts the output at 1, and another called reset (Reset), which brings it to 0. When both commands return to 0, the latch locks and keeps the value unchanged indefinitely. Here is the first true cell of static memory: a bit that can be written with a short pulse and stays put after the pulse has ceased.
But what happens if we press both buttons at once? Both outputs are forced to 0, breaking the natural rule that they must be complementary. And if we release both commands in the same microsecond, the two gates collapse into a life-and-death race against the clock: whichever reacts even a nanosecond sooner will lock the other out. The final result becomes unpredictable, depending on the minute imperfections of the silicon atoms. This is a forbidden state — the fascinating place where material physics, with its delays and roughnesses, pierces the elegant façade of ideal logic.
The clock and the edge
To master the latch we can add a guard gate at its input, controlled by a signal called enable. While the enable is 1, the door stands wide open and the output follows the input instant by instant — we say the latch is transparent. The moment the enable falls to 0, the door slams and the last value left inside is frozen.
Transparency hides a great danger, though. If the output of a circuit is connected, through a chain of other gates, back to its own input, keeping the door open even for a short time lets the new signal go round the loop several times over, throwing the circuit into a chaotic oscillation. We need a mechanism that does not leave the gate open over an interval of time but captures the value in a single infinitesimal instant.
Think of a lock chamber on a canal, or of two successive doors on a submarine: the first door opens to admit the passenger only when the second is sealed tight. Then the first door closes and the second opens to let him through. There is never a free path from one end to the other. Chaining two latches, driven in opposite phase, gives us a flip-flop (flip-flop). It updates its output solely at the precise moment when the command signal passes from 0 to 1. That lightning transition is called the rising edge (or clock edge).
The rhythmic signal that rises and falls tirelessly, offering every flip-flop on the chip the same common reference in time, is the clock. With it the computer acquires a heart that beats regularly: a synchronised “now” in clear steps, in which the continuous chaos of nature is disciplined into an ordered succession of faultless steps.
Follow the two traces in the drawing above: the latch on top copies the data faithfully for the whole time the signal is high, trembling at every fluctuation of the input. The flip-flop below, by contrast, is impassive: it “photographs” the input only at the exact instant of the rising edge and ignores completely any later agitation until the next beat of the clock.
The register
If we line up eight flip-flops and connect them all to the same common clock line, we obtain a device that can immortalise a whole byte at every heartbeat. That compact group is called a register. We can change the signals at the input as we please; the byte held inside will not stir until the clock edge arrives.
This memory is volatile: if we cut the supply of energy, the feedback loops die out and the contents are lost instantly. The registers in the heart of the processor are built from exactly such ultra-fast flip-flops. The computer’s large working memory (RAM), on the other hand, uses a denser and more economical solution: every bit is held as a minute charge in a microscopic capacitor, which must be refreshed hundreds of times a second before it drains away.
See how far we have come: we now have circuits able to do arithmetic (the adder) and circuits able to remember values (the registers), all coordinated by a clock that synchronises their steps perfectly. Between two successive beats of the clock, the data leave a register, cross the arithmetic gates, change their values and settle quietly at the input of the next register, waiting for the next pulse to be recorded. In the next lesson we assemble all these pieces together: the clock, the registers, the adder and a control unit that decides what happens at each step. The moment has come to build the processor.