Skip to content
Home > Components > Logic Components > D Flip-Flop (with Reset)

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

D Flip-Flop (Reset)D Flip-Flop (R)

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

PinTypeDescription
DinputData Input. The logic value to be stored on a clock edge.
CLKinputClock Input. Triggers data capture on the rising edge.
RinputAsynchronous Reset. When HIGH, immediately forces Q to LOW.
QdigitalThe current stored state.
Q'digitalThe inverted stored state (NOT Q).

Configurable Attributes

This component currently has no configurable attributes.

Working Principle

State Transition Table

R (Reset)CLK (Edge)DQ (Next State)Q' (Next State)
1 (HIGH)XX01
0 (LOW) (Rising)001
0 (LOW) (Rising)110
0 (LOW)0, 1, XNo 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

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.

Released under the MIT License.