D Flip-Flop with Controls
D flip-flop with preset, clear, and clock inputs. Learn edge-triggered memory storage with asynchronous controls.
What You'll Learn
- Use asynchronous Set and Reset to override clock-driven behaviour.
- Use synchronous Enable to gate clock edges.
- Recognise the priority order: Reset > Set > Enable > Clock.
- Apply asynchronous reset for power-on initialization.
- Apply Enable for register write-enable in a register file.
How It Works
A D flip-flop with controls adds three common features to the basic edge-triggered DFF:
- Set (asynchronous): When asserted, forces Q = 1 immediately, regardless of clock. Used for power-on initialization or explicit overrides. - Reset (asynchronous): When asserted, forces Q = 0 immediately, regardless of clock. Used for system reset propagation. - Enable (synchronous): When low, the flip-flop ignores the clock edge and holds its current value; when high, it operates normally and captures D on the edge.
Priority typically: Reset > Set > Enable > Clock. So a high reset wins over set or normal operation.
This cell is the standard library element for register design. Almost every register in a real CPU uses DFFs with at least Reset (for power-on initialization) and Enable (for write-control logic). Set is less common but useful for default-1 power-on values.
The Enable input is particularly important: it's how a register's write-enable signal gates the flip-flop. Without Enable, you'd need an extra MUX feeding back Q to itself when not writing — wasteful in area and timing.
Truth Table
Behaviour by control-input state. Async controls override clock; Enable gates clock.
| Inputs | Output | |||||
|---|---|---|---|---|---|---|
| RST | SET | EN | CLK | D | Q (next) | |
| 1 | 0 | 0 | 0 | 0 | 0 | Reset asserted → Q = 0 immediately, async |
| 0 | 1 | 0 | 0 | 0 | 1 | Set asserted → Q = 1 immediately, async |
| 0 | 0 | 0 | 1 | 1 | 0 | Enable low → clock edge ignored, Q holds |
| 0 | 0 | 1 | 1 | 1 | 1 | Enable high, rising clock, D=1 → Q = 1 (captured) |
| 0 | 0 | 1 | 1 | 0 | 0 | Enable high, rising clock, D=0 → Q = 0 |
Boolean Expression
Priority cascade: async controls win over clock-driven behaviour.
Try It Step-by-Step
Set the inputs in the embed above, then read what should happen and confirm.
- 1RST = 1 SET = 0 EN = 1 CLK = anyExpected:
Q = 0What you'll see: Reset asserted — Q goes immediately to 0, regardless of clock or D. Async means right now, not waiting for an edge. - 2RST = 0 SET = 1 EN = 0 CLK = stoppedExpected:
Q = 1What you'll see: Set asserted with clock stopped — Q goes to 1 anyway. Async controls don't need a clock. - 3RST = 0 SET = 0 EN = 0 CLK = runningExpected:
Q frozen at last valueWhat you'll see: Enable low — flip-flop ignores all clock edges. D's changes have no effect. Useful for stalled pipeline stages. - 4RST = 0 SET = 0 EN = 1 CLK = rising edge D = 1Expected:
Q = 1What you'll see: Normal write — Enable high, clock rises with D=1, Q captures 1. The standard register-write pattern.
Components Used
Real-World Applications
CPU register file. Every register has a write-enable that gates whether each clock cycle captures new data. Implemented via the Enable input on each DFF.
System reset distribution. A global async reset signal connects to every flip-flop's Reset input, ensuring all state initializes simultaneously at power-on or external reset.
Configuration-bit storage with default values. Some configuration bits should default to 1 (e.g., interrupt-enable in some architectures); they use Set to initialize at reset.
Pipeline stall flip-flops. When a pipeline stage stalls, downstream flip-flops keep their values via Enable=0; new data isn't captured until the stall clears.
State-machine reset states. FSMs reset to a known initial state via async Reset on the state-encoding flip-flops.