Skip to main content

De Morgan's laws; XOR using 3-input NAND

Short answer

De Morgan's laws: ¬(A+B)=¬A·¬B, ¬(A·B)=¬A+¬B; extended, ¬(A+B+C)=¬A¬B¬C. XOR using four 3-input NAND gates: tie one unused input of each gate to logic 1, then use the standard 4-gate XOR configuration to produce A⊕B.

Describe De' Morgan's laws with examples. Construct XOR gate using only 3-inputs NAND gates.

De Morgan's laws

First theorem: the complement of a sum (OR) of variables equals the product (AND) of their complements.

A+B‾=Aˉ⋅Bˉ\overline{A + B} = \bar{A} \cdot \bar{B}

Second theorem: the complement of a product (AND) of variables equals the sum (OR) of their complements.

A⋅B‾=Aˉ+Bˉ\overline{A \cdot B} = \bar{A} + \bar{B}

In words: "break the bar and change the sign".

Examples

  • A+B+C‾=AˉBˉCˉ\overline{A + B + C} = \bar A \bar B \bar C and ABC‾=Aˉ+Bˉ+Cˉ\overline{ABC} = \bar A + \bar B + \bar C (extended to 3 variables).
  • (A+Bˉ)C‾=A+Bˉ‾+Cˉ=AˉB+Cˉ\overline{(A + \bar B)C} = \overline{A + \bar B} + \bar C = \bar A B + \bar C.
  • Check with A = 1, B = 0: 1+0‾=0\overline{1 + 0} = 0 and 1ˉ⋅0ˉ=0⋅1=0\bar 1 \cdot \bar 0 = 0 \cdot 1 = 0.

XOR gate using only 3-input NAND gates

A 3-input NAND gives XYZ‾\overline{XYZ}. If one input is tied to logic 1 (HIGH, e.g. +5 V through a resistor), it behaves as a 2-input NAND: X⋅Y⋅1‾=XY‾\overline{X \cdot Y \cdot 1} = \overline{XY}. (Tying the unused input to one of the used inputs also works, since XX=XXX = X.) So the 4-NAND XOR circuit is built with four 3-input NAND gates:

G1=A⋅B⋅1‾=AB‾G2=A⋅G1⋅1‾G3=B⋅G1⋅1‾Y=G2⋅G3⋅1‾=ABˉ+AˉB=A⊕B\begin{aligned} G_1 &= \overline{A \cdot B \cdot 1} = \overline{AB} \\ G_2 &= \overline{A \cdot G_1 \cdot 1} \\ G_3 &= \overline{B \cdot G_1 \cdot 1} \\ Y &= \overline{G_2 \cdot G_3 \cdot 1} = A\bar B + \bar A B = A \oplus B \end{aligned}
 A --+-------------[NAND3 G2]--+
     |               |    1 -->|
     +--[NAND3 G1]---+         +--[NAND3 G4]-- Y
     |   1 -->|      |         |    1 -->|
 B --+-------------[NAND3 G3]--+
                          1 -->|
 (1 --> : third input tied to logic HIGH)
ABG1G_1G2G_2G3G_3Y
001110
011101
101011
110110

✓ Answer checked by Claude Opus 5.5 (high effort)

All Digital Logic chapter 2 questions →