Realize XNOR Logic Function Using NAND Gates Only

Realize XNOR Logic Function Using NAND Gates Only

Verified Sources
Sep 14, 2026

The XNOR gate implements the Boolean function:
Y=AB=(AB)+(AB)Y = A \odot B = (A\cdot B) + (A' \cdot B')
Equivalently using XOR and NOT:
Y=¬(AB)Y = \neg(A \oplus B)
where AB=(AB)+(AB)A \oplus B = (A' \cdot B) + (A \cdot B').

To “realize using NAND only,” we use the NAND gate as the only primitive. The key identities are:

  • Inverter via NAND: ¬A=NAND(A,A)\neg A = \text{NAND}(A,A)
  • NAND is functionally complete: any AND/OR/NOT expression can be rewritten using only NAND with De Morgan’s laws.

We will construct XNOR structurally from NANDs by (1) building XOR using NANDs, then (2) inverting it to get XNOR using one more NAND.


XNOR and XOR using NAND (Logic gate realization)

Core NAND-only rewrite rules

Using De Morgan’s laws:

  • De Morgan’s law: (AB)=A+B(AB)' = A' + B'

  • Thus AND from NAND: AB=((AB))A\cdot B = \big((A\cdot B)'\big)' Implementing ((AB))((A\cdot B)') with NAND and then inverting using a NAND-as-inverter.

  • OR from NAND: A+B=((A+B))A + B = \big((A + B)'\big)'
    And (A+B)=AB(A + B)' = A'\cdot B', so: A+B=(AB)A + B = \big(A'\cdot B'\big)'
    Again: generate complements with NAND-inverters, then use NAND(s) to form the complemented AND, then invert.

In practice, to build a gate-level circuit, we minimize inversions and reuse intermediate signals.

Step-by-step NAND-only realization of XNOR

  1. 1
    Step 1

    Use Y=eg(AB)Y = eg(A \oplus B), where XOR can be implemented from NANDs and then inverted using NAND.

  2. 2
    Step 2

    Create A=NAND(A,A)A' = \text{NAND}(A,A) and then compute T1=ABT_1 = A'\cdot B using NAND with a final inversion if needed.

  3. 3
    Step 3

    Create B=NAND(B,B)B' = \text{NAND}(B,B) and compute T2=ABT_2 = A\cdot B' using NAND-only structure.

  4. 4
    Step 4

    Implement the OR of T1T_1 and T2T_2 using NAND-only OR construction via De Morgan.

  5. 5
    Step 5

    Finally, compute Y= eg(AB)Y = \ eg(A \oplus B) using a single NAND configured as an inverter: Y=NAND(XOR,XOR)Y = \text{NAND}(XOR, XOR).

A concrete NAND-only XNOR gate-level construction (reusable netlist)

Define:

  • An=¬A=NAND(A,A)A_ n = \neg A = \text{NAND}(A,A)
  • Bn=¬B=NAND(B,B)B_ n = \neg B = \text{NAND}(B,B)

XOR structure:

  • T1=AnBT_1 = A_n \cdot B
    Implement AND from NAND: T1=NAND(NAND(An,B), NAND(An,B))T_1 = \text{NAND}(\text{NAND}(A_n,B),\ \text{NAND}(A_n,B))
  • T2=ABnT_2 = A \cdot B_n
    T2=NAND(NAND(A,Bn), NAND(A,Bn))T_2 = \text{NAND}(\text{NAND}(A,B_n),\ \text{NAND}(A,B_n))
  • X=T1+T2X = T_1 + T_2 (OR from NAND): X=NAND(NAND(T1,T1), NAND(T2,T2))X = \text{NAND}(\text{NAND}(T_1,T_1),\ \text{NAND}(T_2,T_2))
    because NAND(T1,T1)=¬T1\text{NAND}(T_1,T_1)=\neg T_1 and NAND of complements gives ¬(¬T1¬T2)=T1+T2\neg(\neg T_1\cdot \neg T_2) = T_1+T_2.

XNOR:

  • Y=¬X=NAND(X,X)Y = \neg X = \text{NAND}(X,X)

This is guaranteed correct by the functional equivalences of NAND + De Morgan’s transformations.

Verification via truth table (XNOR)

XNOR outputs 1 when A and B are equal.

Common pitfalls and optimizations

Pro Tip

When converting to NAND-only, treat each AND/OR as “complemented form” first, then apply De Morgan. This prevents losing track of where inversions are actually created.

Warning

Be careful: NAND networks often produce complemented intermediate signals. If you accidentally invert one too many times, the final output becomes XOR instead of XNOR.

XNOR with NAND-only (Self-check)

1 / 5
Question · Term

Boolean form of XNOR?

Click to reveal
Answer · Definition

Y = (A·B) + (A'·B') = ¬(A ⊕ B)

Knowledge Check

Question 1 of 4
Q1Single choice

Which identity is commonly used to realize XNOR with a NAND-only design?