D flip-flop capture

Flip the lever, press the button, and the lamp locks in the lever's value. A ready-made memory circuit you can open in the TorchAnvil simulator.

Capture a value with a button press

Set the lever. Press Latch. The lamp snaps to match the lever and stays there, even if you flip the lever afterward. Press Latch again and it re-samples whatever the lever is doing right now.

That's a D flip-flop — arguably the memory cell of the modern world. Most RAM, most registers, most "hold this signal until I say otherwise" circuits you've heard of are built from these.

How it works

The D flip-flop has two inputs:

On every rising edge of CLK (the moment it goes from low to high), Q samples whatever D is at that instant and holds it until the next rising edge. In between edges, D can wiggle all it wants — Q doesn't care.

D (at CLK rise) Q (next)
0 0
1 1

(No more complicated than that. The magic is when it samples.)

Why it matters

Compare this to the SR flip-flop. SR needs you to drive Set or Reset explicitly — two wires, two buttons, careful not to press both. D gives you one data line and one clock. Line up a bunch of D flip-flops sharing a clock and you get a register: a synchronized snapshot of multiple bits, all captured on the same edge. Every CPU is full of them.

Try this