D Flip-Flop (with Reset)
A digital memory element that captures data on a clock edge, featuring an asynchronous reset pin to force the state to LOW.
Component Preview
This variant of the D Flip-Flop includes an asynchronous Reset (R) pin. When the Reset pin is activated, the flip-flop immediately clears its stored data (forcing Q to LOW), regardless of the clock signal.
Logic ComponentsSequential LogicMemory
Overview
The D Flip-Flop with Reset is essential for initializing digital circuits to a known state upon power-up, or for clearing error states without waiting for a clock cycle.
Pin Reference
| Pin | Type | Description |
|---|---|---|
| D | input | Data Input. The logic value to be stored on a clock edge. |
| CLK | input | Clock Input. Triggers data capture on the rising edge. |
| R | input | Asynchronous Reset. When HIGH, immediately forces Q to LOW. |
| Q | digital | The current stored state. |
| Q' | digital | The inverted stored state (NOT Q). |
Configurable Attributes
This component currently has no configurable attributes.
Working Principle
State Transition Table
| R (Reset) | CLK (Edge) | D | Q (Next State) | Q' (Next State) |
|---|---|---|---|---|
| 1 (HIGH) | X | X | 0 | 1 |
| 0 (LOW) | ↑ (Rising) | 0 | 0 | 1 |
| 0 (LOW) | ↑ (Rising) | 1 | 1 | 0 |
| 0 (LOW) | 0, 1, ↓ | X | No Change (Q) | No Change (Q') |
- Asynchronous Priority: The Reset pin overrides the Clock and Data inputs. As long as R is HIGH, the flip-flop cannot store new data.
Wiring Diagram

Example Arduino Code
cpp
const int pinD = 2; // Data Input
const int pinCLK = 3; // Clock Input
const int pinR = 4; // Reset Input
const int pinQ = 5; // State Output
bool lastClkState = LOW;
bool stateQ = LOW;
void setup() {
pinMode(pinD, INPUT);
pinMode(pinCLK, INPUT);
pinMode(pinR, INPUT);
pinMode(pinQ, OUTPUT);
}
void loop() {
bool currentClkState = digitalRead(pinCLK);
bool resetState = digitalRead(pinR);
// Asynchronous Reset has highest priority
if (resetState == HIGH) {
stateQ = LOW;
}
// Detect Rising Edge
else if (currentClkState == HIGH && lastClkState == LOW) {
stateQ = digitalRead(pinD);
}
// Drive Output
digitalWrite(pinQ, stateQ);
lastClkState = currentClkState;
}Simulation Notes
- The Reset pin acts immediately in the simulation without waiting for the next physics tick.
- Floating the Reset pin may lead to unpredictable resets. Always tie it to Ground if not in use.
Notes / Warnings
- Active HIGH Reset: By default, the reset function is triggered when the R pin receives a HIGH signal.
