Skip to content

XNOR Gate

A digital logic gate that outputs HIGH when its inputs are equal (both HIGH or both LOW).

Component Preview

XNOR Gate

A digital logic gate that implements logical Exclusive-NOR. It acts as an equality detector, producing a HIGH output only when both inputs are identical (either both HIGH or both LOW).

Logic ComponentsDigital Logic

Overview

The XNOR (Exclusive-NOR) gate is commonly used in parity generation, digital comparators, and encryption circuits. It checks for equality between two digital signals.

Pin Reference

PinTypeDescription
IN1inputFirst digital logic input. Expects HIGH (1) or LOW (0).
IN2inputSecond digital logic input. Expects HIGH (1) or LOW (0).
OUTdigitalDigital logic output. Driven HIGH when IN1 equals IN2. Driven LOW otherwise.

Configurable Attributes

This component currently has no configurable attributes.

Working Principle

Truth Table

IN1IN2OUT
0 (LOW)0 (LOW)1 (HIGH)
0 (LOW)1 (HIGH)0 (LOW)
1 (HIGH)0 (LOW)0 (LOW)
1 (HIGH)1 (HIGH)1 (HIGH)

The XNOR function evaluates if two logic inputs are equal.

Wiring Diagram

Example of a logic XNOR gate wired to an Arduino Uno and an LED (with a resistor).

Wiring Diagram

Example Arduino Code

cpp
const int pinIn1 = 2; // Connect to IN1
const int pinIn2 = 3; // Connect to IN2
const int pinOut = 4; // Connect to OUT

void setup() {
  Serial.begin(9600);
  pinMode(pinIn1, OUTPUT);
  pinMode(pinIn2, OUTPUT);
  pinMode(pinOut, INPUT);
  Serial.println("XNOR Gate Truth Table Test:");
}

void loop() {
  for (int state = 0; state < 4; state++) {
    bool val1 = (state & 1);
    bool val2 = (state & 2) >> 1;

    digitalWrite(pinIn1, val1 ? HIGH : LOW);
    digitalWrite(pinIn2, val2 ? HIGH : LOW);
    delay(10);
    
    int result = digitalRead(pinOut);
    
    Serial.print("IN1: ");
    Serial.print(val1);
    Serial.print(" | IN2: ");
    Serial.print(val2);
    Serial.print(" => OUT: ");
    Serial.println(result);
    delay(1000);
  }
}

Simulation Notes

  • Evaluates logic instantaneously.
  • Floating inputs may cause undefined behavior. Tie unused inputs to Ground.

Notes / Warnings

  • Voltage Levels: The simulator treats standard logic signals as valid inputs. Do not apply analog voltages.

Released under the MIT License.