Skip to main content

3-input XOR using NAND gates only

Short answer

A 3-input XOR is built with eight NAND gates. Two 4-NAND XOR blocks are cascaded: first block computes P = A⊕B using four NANDs (G1= (AB)′, G2= (A G1)′, G3= (B G1)′, G4= (G2 G3)′). Second block similarly computes Y = P⊕C with another four NANDs.

Realize 3 inputs XOR gates using NAND gates only.

A 3-input XOR gives Y=A⊕B⊕C=(A⊕B)⊕CY = A \oplus B \oplus C = (A \oplus B) \oplus C. Each 2-input XOR needs 4 NAND gates, so cascade two 4-NAND XOR blocks: 8 NAND gates.

Block 1: P=A⊕BP = A \oplus B G1=AB‾G_1 = \overline{AB}, G2=AG1‾G_2 = \overline{A G_1}, G3=BG1‾G_3 = \overline{B G_1}, P=G2G3‾P = \overline{G_2 G_3}

Block 2: Y=P⊕CY = P \oplus C G5=PC‾G_5 = \overline{PC}, G6=PG5‾G_6 = \overline{P G_5}, G7=CG5‾G_7 = \overline{C G_5}, Y=G6G7‾Y = \overline{G_6 G_7}

 A --+-------[G2]--+
     +--[G1]--+    +--[G4]--P--+-------[G6]--+
 B --+-------[G3]--+           +--[G5]--+    +--[G8]-- Y
                           C --+-------[G7]--+
 (all gates are 2-input NAND)
ABCP = A⊕BY
00000
00101
01011
01110
10011
10110
11000
11101

Y = 1 when an odd number of inputs are 1.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Digital Logic chapter 2 questions →