Ground Embedded KO Subscribe

Notes / Digital Logic

Flip-flops and registers

A flip-flop captures a value at a clock edge and remembers it. Put several together and you have an MCU register.

GROUND EMBEDDED · NOTEDigital Logic 04Flip-flops and registersANDABY

A combinational circuit cannot remember. Remembering a value needs a structure where the output feeds back to the input, and the basic unit of that is the flip-flop.

D flip-flop

CLKDQ
D flip-flop. Q captures the value of D at the rising clock edge and holds it until the next clock.

At the instant the clock goes from 0 to 1 (the rising edge) it copies the value on the D input to the Q output and holds it until the next edge. However much D wobbles in between, Q does not change.

Clock D Q
Rising edge 0 Becomes 0
Rising edge 1 Becomes 1
Otherwise Any Held

Register

Tie 32 D flip-flops to the same clock and you have a 32-bit register. Writing a value to a GPIO output register stores it in flip-flops, and it keeps going out as the pin voltage.

Difference from a latch

A latch passes its input through for as long as the clock is 1; a flip-flop accepts it only at the edge. Synchronous digital circuits are designed almost entirely with flip-flops, so every value changes together in step with the clock.

FREE PDFGet the 3 free ebooksIf you want to keep reading this topic as one book: BLDC motor control, serial communication and sensors at book length. PDFs are in Korean.Get them free →