Flip-Flop Basics & Memory
A flip-flop is a one-bit memory element that changes state only on a clock edge (the instant the clock transitions from 0 to 1). This edge-triggering ensures predictable, once-per-tick updates, unlike a level-sensitive latch.
The D flip-flop ("data" flip-flop) is the most common type: on each clock edge, its output takes the value of its input . In short, it remembers whatever was at the tick.
| Feature | Latch | Flip-Flop |
|---|---|---|
| Sensitivity | Level-sensitive | Edge-triggered |
| Transparency | Transparent when enabled | Samples only at clock edge |
| Timing Risk | High risk of timing bugs | Stable, predictable updates |
Common pitfall: Confusing an edge-triggered flip-flop with a level-sensitive latch. A latch lets outputs follow inputs continuously while active, causing subtle timing bugs if used where strict edge-sampling is required.
Registers and Sequential Circuits
Wiring D flip-flops side by side, driven by the same clock, creates an -bit register. This unit stores an -bit value and updates all bits simultaneously on each clock edge.
Registers form the fast working storage inside a CPU. Feed a register's output back through combinational logic to build stateful machines:
- Counter: A register whose next value is current + 1, incrementing each tick.
- Shift Register: Moves its stored bits one position per tick.
All sequential circuits follow this core pattern: flip-flops hold the state, combinational logic computes the next state, and the clock advances it.