Flip-Flop
A flip-flop is a one-bit memory circuit built from logic gates, able to hold either a 0 or a 1 indefinitely and change that stored value only at a specific moment dictated by a clock signal, rather than reacting continuously to its inputs the way an ordinary logic gate does. That clock-synchronized behavior is the entire point: a processor needs billions of these one-bit memories to hold intermediate results steady while the surrounding combinational logic computes the next value, and the flip-flop is what lets that computation happen in discrete, orderly steps instead of as an uncontrolled, continuously shifting cascade of signals. How a flip-flop actually captures and holds a bit, cycle by cycle, looks like this:
A few things are worth knowing about why a flip-flop's clock-edge discipline is what separates orderly digital computation from chaos:
A flip-flop only changes its stored value at a clock edge, and that single property is what turns a pile of logic gates into a machine that computes in discrete, predictable steps. Combinational logic — plain gates with no memory — reacts continuously: the instant an input changes, the output starts changing too, rippling through however many gates sit downstream. If nothing captured and held a stable value at some point, a chip's internal signals would never settle into a clean, usable state; they'd just keep shifting as each change triggered the next. A flip-flop breaks that chain deliberately: it ignores its input except at the instant of a clock edge, at which point it captures whatever value is present and holds it rock steady until the next edge, giving the combinational logic downstream from it an entire clock cycle to work with a stable value rather than a constantly shifting one.
A flip-flop is internally built from two latches wired master-slave, and understanding why two are needed, not one, explains why "flip-flop" and "latch" aren't interchangeable terms even though people often use them loosely. A single latch is level-sensitive — transparent the whole time its enable signal is active, meaning its output tracks its input continuously during that window, which makes it unsuitable as a reliable pipeline boundary because a signal could race straight through it while it's open. Chaining two latches together, with the first passing data through on one clock phase and the second capturing and holding it on the opposite phase, produces a circuit whose output changes only at the single instant the clock transitions — that composite two-latch structure is what a flip-flop actually is, and it's why a flip-flop behaves as a clean, edge-triggered snapshot rather than a transparent window.
Setup time and hold time are the two timing constraints that determine whether a flip-flop captures the correct value or fails unpredictably, and violating either one is a leading cause of real chip bugs. Setup time is how long before the clock edge the data input must already be stable; hold time is how long after the clock edge it must remain stable. If data changes too close to the edge in either direction, the flip-flop can enter a metastable state — an unresolved, lingering condition where its output hovers at neither a clean 0 nor a clean 1 for an unpredictable duration before settling, which is far more disruptive to downstream logic than simply capturing the wrong value cleanly. Chip designers run dedicated static timing analysis across an entire design specifically to guarantee every flip-flop's setup and hold requirements are met at every corner of voltage and temperature the chip might operate in.
Wiring many flip-flops together with a common clock and simple feedback logic is how a processor builds every higher-level memory structure it needs, from a single register to an entire pipeline. A register is just a group of flip-flops wide enough to hold one data word, all clocked together so the whole word updates atomically. A pipeline stage boundary is a row of flip-flops separating one block of combinational logic from the next, letting each stage work on a different instruction simultaneously while flip-flops hold the stable intermediate results between them. A finite-state machine's "state" is nothing more than the current contents of a small group of flip-flops, with combinational logic computing the next state from the current one and the next clock edge committing it — nearly everything a processor does sequentially traces back to this same building block.
Read a flip-flop as the device that converts continuous logic into discrete time steps, not just "memory": it's the clock-edge discipline — captured once, held until the next edge — that lets a chip's billions of gates compute in orderly, predictable cycles instead of an uncontrolled cascade, and nearly every higher-level sequential structure on a chip, from a register to a full pipeline, is ultimately just many flip-flops sharing a clock.