Question
What are the basic logic gates and their truth tables? Why are NAND and NOR called universal gates, and how do we construct other gates from them?
Solution — Step by Step
NOT gate (inverter): Single input. Output is the complement.
- (if A = 0, Y = 1; if A = 1, Y = 0)
AND gate: Output is 1 only when ALL inputs are 1.
- (both A and B must be 1)
OR gate: Output is 1 when ANY input is 1.
- (at least one must be 1)
NAND gate: AND followed by NOT. Output is 0 only when all inputs are 1.
NOR gate: OR followed by NOT. Output is 1 only when all inputs are 0.
XOR gate: Output is 1 when inputs are different.
A gate is universal if any other gate can be built using only that gate. Both NAND and NOR satisfy this.
Building from NAND gates only:
- NOT: Connect both inputs of NAND together:
- AND: NAND followed by NOT (another NAND used as inverter):
- OR: NOT each input, then NAND: (by De Morgan’s law)
Since we can build AND, OR, and NOT from NAND alone, we can build ANY Boolean function using only NAND gates.
graph TD
A[NAND Gate: Universal] --> B["NOT: tie inputs together"]
A --> C["AND: NAND + NOT"]
A --> D["OR: NOT inputs, then NAND"]
E[NOR Gate: Universal] --> F["NOT: tie inputs together"]
E --> G["OR: NOR + NOT"]
E --> H["AND: NOT inputs, then NOR"]
B --> I[All gates from NAND]
C --> I
D --> I
Why This Works
The universality comes from De Morgan’s theorems:
These theorems let us convert between AND/OR operations by adding inversions. Since NAND and NOR inherently include an inversion (the NOT bar), they can bridge between AND and OR operations.
| Gate | Boolean Expression | Output is 1 when… |
|---|---|---|
| AND | Both inputs are 1 | |
| OR | At least one input is 1 | |
| NOT | Input is 0 | |
| NAND | NOT both inputs are 1 | |
| NOR | Both inputs are 0 | |
| XOR | Inputs are different |
Alternative Method
For truth table questions, remember the patterns:
- AND: only one row with output 1 (both inputs 1)
- OR: only one row with output 0 (both inputs 0)
- NAND: only one row with output 0 (both inputs 1)
- NOR: only one row with output 1 (both inputs 0)
- XOR: output 1 when inputs differ
NAND and NOR are simply AND and OR with inverted outputs — their truth tables are the complement of AND and OR respectively.
Common Mistake
Students confuse NAND with NOR when constructing other gates. Remember: NAND builds OR by inverting inputs (De Morgan: ), while NOR builds AND by inverting inputs (). Getting this backward means every derived gate is wrong. In CBSE boards, a 3-mark question on universal gate construction is almost guaranteed.