2026-06-28
We've talked about D flip-flops as if they were primitive — but inside, almost every edge-triggered flip-flop is actually two latches stitched back-to-back. Understanding the master-slave structure explains setup time, hold time, transparency hazards, and why pulse latches even exist as an alternative.
The level-sensitive latch problem. A D latch is transparent when its enable is high: whatever wiggles on D propagates straight through to Q. That's useless for pipelines — you can't have stage N's output racing into stage N+1's input while the clock is still high. You need a circuit that samples D at one instant and holds it for the rest of the cycle.
The master-slave trick. Wire two latches in series with opposite clock polarities:
On the rising edge, the master snaps shut (capturing whatever D was just before the edge) and the slave opens (passing that captured value to Q). At no point are both latches transparent simultaneously — so D can never sneak straight through to Q. The flip-flop appears edge-triggered, even though it's built entirely from level-sensitive parts.
Where setup and hold come from. Setup time is the master latch's own requirement: D must be stable long enough before CLK rises for the master's storage node to settle. Hold time is the brief window after the edge during which the master is closing — if D changes too soon, the closing latch can capture the new value instead of the old. The transparency overlap during the switching transient is exactly where hold violations happen.
Real-world example. Standard cell libraries from TSMC, Samsung, and Intel ship dozens of master-slave D flip-flop variants: DFFQX1 (basic), DFFRX2 (with reset, 2x drive), DFFSX1 (with set), DFFSRX1 (set and reset). Each is internally a master-slave pair with maybe 20–24 transistors. The "scan flip-flop" variant (SDFFQX1) adds a mux on the master input for scan-chain insertion — the same one we covered in scan testing.
Rule of thumb. A master-slave DFF costs ~20–26 transistors versus ~12 for a single latch. That's why pulse latches (one latch + a narrow clock pulse) win at the bleeding edge: half the area, half the clock power, and time-borrowing for free — at the cost of harder timing closure.
