Home / Learn Verilog / The Flip-Flop: One Bit of Memory

The Flip-Flop: One Bit of Memory

A D flip-flop copies its input to its output on a clock edge and holds it until the next edge.

Quick summaryA D flip-flop copies its input to its output on a clock edge and holds it until the next edge.

How to think about this

D flip-flopDCLKRSTQD flip-flop
D flip-flop

What it is

A D flip-flop has data input D, clock input and output Q. At each rising clock edge it samples D and stores it in Q. Between edges Q does not change.

Why it matters

Flip-flops are the memory elements of all synchronous designs: registers, counters, FSM state and pipeline stages are built from them.

Mechanically speaking

In Verilog: always @(posedge clk) q <= d; Synthesis maps this to a flip-flop cell.

Shows up in

  • Registers
  • Counters and FSMs
  • Pipelines

See the sampling

D flip-flop samples D only at the clock edgeVerilog: edit and run

q follows d only at rising edges (t=5, 15, 25...). Changes of d between edges are ignored until the next edge.

Check yourself

1. A flip-flop updates Q...

2. Registers are made of...