Memory from Logic
A flip-flop is the smallest possible memory — a circuit that stores exactly one bit. Unlike combinational logic where outputs depend only on current inputs, a flip-flop's output depends on its history. This feedback loop, where two cross-coupled gates reinforce each other, creates two stable states that persist until explicitly changed. Every register in your CPU, every bit of SRAM cache, uses flip-flops.
SR: Set and Reset
The SR (Set-Reset) flip-flop is the simplest type. Setting S=1, R=0 forces Q to 1. Setting S=0, R=1 forces Q to 0. With both inputs low, Q holds its previous value — this is the memory property. The forbidden state S=R=1 makes both outputs equal, breaking the expected Q̄=NOT(Q) relationship. This limitation led to the development of the JK flip-flop.
JK: The Universal Flip-Flop
The JK flip-flop resolves the SR forbidden state elegantly: when J=K=1, instead of producing undefined output, it toggles Q to its complement. Combined with the set, reset, and hold behaviors inherited from the SR design, the JK flip-flop is functionally complete for sequential logic. D and T flip-flops are simplified versions — D captures input directly, T toggles on command.
Clock Synchronization
Real flip-flops are edge-triggered: they only sample inputs at the rising or falling edge of a clock signal. Between clock edges, inputs can change freely without affecting the stored state. This synchronization ensures that all flip-flops in a circuit update simultaneously, preventing race conditions and enabling predictable sequential behavior at gigahertz speeds.