a flip-flop
A flip-flop is a one-bit memory cell with discipline: it captures its input only at a precise moment — the clock edge — and then holds that value rock-steady until the next edge. Where a plain latch is transparent for a whole stretch of time, a flip-flop is like a camera shutter that snaps exactly once per clock tick, freezing the input as it was at that instant and ignoring whatever the input does in between. This 'sample once per tick' behaviour is what makes large synchronous systems predictable.
The most common type is the D flip-flop. It has a data input D, a clock input, and an output Q. On each rising clock edge (the moment the clock goes from 0 to 1), it copies whatever is on D into Q; for the rest of the cycle Q does not change no matter what D does. A standard way to build one is two latches in series (a primary and a secondary) controlled by opposite clock phases, so the pair is transparent for only the brief edge rather than a whole level — this is the master-slave construction. For the capture to be reliable, D must be stable for a short setup time before the edge and a short hold time after it.
Why it matters: the edge-triggered flip-flop is the workhorse storage element of nearly all digital design. A row of them is a register; arrays of them with shifting connections are shift registers; with feedback through combinational logic they become counters and state machines. Crucially, because every flip-flop in a synchronous system samples on the same clock edge, the whole machine advances in lockstep one well-defined step at a time. That shared timing is the foundation that lets engineers build chips with billions of these cells that nonetheless behave predictably.
A turnstile that lets exactly one person through per green flash is like a D flip-flop: it acts only at the instant of the flash (the clock edge), not continuously. Even if someone leans on it between flashes (D wobbling mid-cycle), nothing happens until the next flash samples the state. One capture per tick, no matter the noise in between.
Sample on the edge, hold for the cycle: the flip-flop is the clocked one-bit memory the whole machine is built from.
Edge-triggered does not mean instantaneous and forgiving. The data must already be stable across the setup-and-hold window around the edge; violate that window and the flip-flop can land in a half-valued, metastable state instead of a clean 0 or 1.