Lesson 5 of 15
Universal Gates
Universal Gates
NAND is called a universal gate because you can build any logic function using only NAND gates:
NOT(A) = NAND(A, A)
AND(A, B) = NAND(NAND(A, B), NAND(A, B)) = NOT(NAND(A,B))
OR(A, B) = NAND(NAND(A, A), NAND(B, B)) = NAND(NOT(A), NOT(B))
This matters for chip manufacturing: a factory that can make NAND gates can make any digital circuit.
Let's verify De Morgan's law for NAND:
NAND(A, B) = NOT(A) OR NOT(B)
| A | B | NAND | NOT(A) OR NOT(B) |
|---|---|---|---|
| 0 | 0 | 1 | 1 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 |
Your Task
Using only nand(a, b), implement:
notFromNand(a)— NOT using only NANDandFromNand(a, b)— AND using only NANDorFromNand(a, b)— OR using only NAND
Then print the full truth table for orFromNand.
JavaScript loading...
Loading...
Click "Run" to execute your code.