The gated D latch
A gated D latch stores one bit. It has a data input D, an enable input E and an output Q, the bit it remembers. D stands for data. One wire carries the bit, so set and reset can never clash.
While enable is 1, the latch is transparent: Q copies D straight through, like looking through a window. Each time D changes, Q changes right after it.
When enable is 0, the latch is closed. Q keeps the value D had when enable fell and ignores every later change on D. That is how the latch remembers.
Signals often flicker before they settle. While enable stays 1, every flicker on D goes straight through to Q. Here Q changes three times during one pulse, so other circuits could read a wrong value.
The edge-triggered flip-flop
A clock is a signal that flips between 0 and 1 at a steady rate, often millions of times a second. The instant it jumps from 0 to 1 is called the rising edge; the arrows mark each one.
An edge-triggered D flip-flop joins two latches. The leader takes D; the follower copies the leader and drives Q. A NOT gate gives the leader the flipped clock, so the two are never open together.
While the clock is 0, the leader is open and follows D. The follower is closed, so Q keeps its old value however much D moves.
At the rising edge the two latches swap. The leader closes and freezes the bit D had at that instant. The follower opens and passes that bit on to Q.
Same flickering D, two circuits. The latch's Q jumps with every flicker while the clock is 1. The flip-flop's Q changes only at a rising edge, then holds that bit for the whole clock cycle.
Timing rules
D must stay steady for a short setup time before the edge and a hold time after it. A real SN74LVC74A chip at 3.3 V needs 3 ns before and 1 ns after. A nanosecond (ns) is a billionth of a second.
Moment by moment
;; step 1/10 · d-latch ;; about: D input, Enable / clock, D latch, Latch Q inputs: D (data), E (enable) output: Q (the stored bit) E = 1 → Q = D E = 0 → Q keeps its value Here the enable comes from the clock lamp.
In the figure each column of the timing card is one moment. Real clocks tick far faster; the frames are slowed down so you can watch them.