LearnGates

Make an OR gate from NAND gates

Building an OR gate from NAND gates needs one of the most useful rules in digital logic: De Morgan’s law.

Truth table

Truth table of OR from NAND
ABY
000
011
101
111

Try it Click the inputs to change them.

Y0

De Morgan’s law

De Morgan says that A OR B is the same as NOT( NOT A AND NOT B ). In words: “A or B is true” means the same as “it is not the case that both A and B are false”. Check it with the truth table: the only row where OR gives 0 is the one where A and B are both 0.

Now look at the formula again: NOT( … AND … ) is a NAND. So OR is a NAND whose inputs are first inverted, and each inversion is one more NAND. Three gates in total.

Hints and solution

Try on your own first. Each hint gives away a little more.

  1. De Morgan: A OR B = NOT( NOT A AND NOT B ).
  2. NAND of two inverted inputs is exactly that.
  3. Invert A and B with one NAND each, then NAND the results.