Courses / Computer Science I
Basic Digital Design

Flip-Flops and Registers

Computer Science I 305 words Free to read

The Building Block of Memory

A flip-flop is a one-bit memory element that changes state only on a clock edge — the instant the clock transitions (typically rising, 0 to 1). This edge-triggering is the key refinement over a plain latch (which is level-sensitive and can change whenever its inputs do): a flip-flop samples its input at the exact clock edge and holds that value steady until the next edge. Predictable, once-per-tick updates are what flip-flops provide.

The most common is the D flip-flop ("data" flip-flop): on each clock edge, its output QQ takes the value of its input DD. In words, "remember whatever DD was at the tick." That simple behavior is the foundation of almost all storage in a processor. Other types exist (JK, T for toggling), but D flip-flops dominate modern design.

Wiring nn D flip-flops side by side, all driven by the same clock, makes an nn-bit register — a unit that stores an nn-bit value and updates it all at once on each edge. Registers are the fast working storage inside a CPU (Unit 1's registers are exactly these).

Feed a register's output back through combinational logic and you build stateful machines: a counter (a register whose next value is current + 1) increments each tick; a shift register moves its bits one position per tick. All follow the same pattern: flip-flops hold the state, combinational logic computes the next state, the clock advances it — the finite-state-machine shape made concrete.

Common pitfall: confusing an edge-triggered flip-flop with a level-sensitive latch. A latch is "transparent" while its enable is active — its output can follow the input continuously during that window. A flip-flop captures the input only at the clock edge and then holds it. Using a latch where an edge-triggered flip-flop is needed causes subtle timing bugs.

Practise this lesson

The explanation above is free to read. The graded practice for this lesson lives in the Tryals app.

10practice questions
2interactive scenes
Start Computer Science I free

Basic Digital Design