Skip to main content

X-OR gate using NAND gates only

Short answer

Use four 2-input NAND gates. N1 = NAND(A,B); N2 = NAND(A, N1); N3 = NAND(B, N1); N4 = NAND(N2,N3) yields A XOR B.

Draw the circuit of X-OR gate using NAND gates only.

The XOR function is Y = A⊕B = A'B + AB' and is built from four 2-input NAND gates.

 A ---+------------------[N2]---+
      |        +--------/       |
      +--[N1]--+                [N4]--- Y
      |        +--------\       |
 B ---+------------------[N3]---+

(N1 takes A and B; its output goes to both N2 and N3. N2 also takes A, and N3 also takes B.)

  • N1 = NAND(A, B) = (AB)'
  • N2 = NAND(A, N1) = (A·(AB)')' = (A·(A' + B'))' = (AB')'
  • N3 = NAND(B, N1) = (B·(AB)')' = (A'B)'
  • N4 = NAND(N2, N3) = ((AB')' · (A'B)')' = AB' + A'B = A⊕B

Check by truth table: for A = 1, B = 0: N1 = 1, N2 = (1·1)' = 0, N3 = (0·1)' = 1, Y = (0·1)' = 1. For A = B = 1: N1 = 0, N2 = N3 = 1, Y = (1·1)' = 0.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Basic Electronics Engineering chapter 6 questions →