Prerequisites
Before studying this topic, make sure you understand:
- Transistor - Transistor as digital switch
- Diode - Diode switching behavior
- Basic binary number system (0 and 1)
The Hook: How Does Your Computer Make Decisions?
Every time you tap your smartphone screen, billions of logic gates spring into action:
- Is touch detected AND screen unlocked? → Open app
- Is battery low OR overheating? → Alert user
- NOT connected to WiFi? → Use mobile data
Mind-blowing scale:
- Modern processor: Billions of logic gates
- Each gate: Made from 2-4 transistors
- All working together at GHz speeds (billion operations/second)
Your calculator solving 2+3:
- Binary addition using AND/XOR gates
- Carry propagation through chain of gates
- Display output via decoder gates
- All in nanoseconds!
How do simple transistor switches combine to create the digital brain that runs AI, games, and the internet? Let’s decode the building blocks of computing!
Interactive Demo
Build logic circuits and see truth tables in action:
The Core Concept: Binary Logic
Digital vs Analog
Analog: Continuous values (like volume knob)
Digital: Only two states (like light switch)
- 0 = LOW = False = ~0V
- 1 = HIGH = True = ~5V
Why digital won:
- Noise immunity: Easier to distinguish 0 from 1
- Reliable storage: Bits don’t drift
- Perfect copying: No degradation
- Easy processing: Boolean algebra!
Boolean Algebra Basics
Three fundamental operations:
- NOT (complement): $\overline{A}$ or $A'$
- AND (product): $A \cdot B$ or $AB$
- OR (sum): $A + B$
All digital circuits built from these three!
George Boole (1854) invented Boolean algebra for logic
- Worked with True/False, not numbers
- Showed logic can be mathematical!
Claude Shannon (1938) - Master’s thesis (most important ever!)
- Connected Boolean algebra to electrical circuits
- Showed switches can perform logic
- Foundation of all digital computers!
Result: Your smartphone uses 170-year-old math and 85-year-old circuit ideas - timeless fundamentals!
The Seven Basic Gates
1. NOT Gate (Inverter)
Symbol:
——|▷○|—— Output
A NOT
Truth Table:
| A | Y |
|---|---|
| 0 | 1 |
| 1 | 0 |
Boolean: $Y = \overline{A}$ or $Y = A'$
Transistor circuit:
VCC
|
RC
|
├── Y
A ───┤ (npn)
│
GND
Operation:
- A = 0 → Transistor OFF → Y = HIGH (1)
- A = 1 → Transistor ON → Y = LOW (0)
Uses: Signal inversion, creating complements
2. AND Gate
Symbol:
A ——| \
| & |—— Y
B ——| /
Truth Table:
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Boolean: $Y = A \cdot B$ or $Y = AB$
In words: Output is 1 only if A AND B both are 1
Real-world analogy:
- A = Key inserted
- B = Door unlocked
- Y = Door opens
- Need BOTH conditions!
Uses: Conditional execution, masking, multiplication (binary)
3. OR Gate
Symbol:
A ——| \
|≥1 |—— Y
B ——| /
Truth Table:
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
Boolean: $Y = A + B$
In words: Output is 1 if A OR B or both are 1
Real-world analogy:
- A = Front door sensor
- B = Back door sensor
- Y = Alarm triggers
- Either door opening triggers alarm!
Uses: Signal combination, decision trees
4. NAND Gate (Universal Gate)
Symbol:
A ——| \
| & |○—— Y
B ——| /
(AND + NOT bubble)
Truth Table:
| A | B | Y |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Boolean: $Y = \overline{A \cdot B}$ or $Y = (AB)'$
In words: Output is 0 only if both A AND B are 1
Special property: UNIVERSAL GATE!
- Can create any logic gate using only NAND
- Preferred in IC manufacturing (simpler)
Create other gates from NAND:
NOT: Connect inputs together: $\overline{A} = \overline{A \cdot A}$
AND: NAND + NOT: $AB = \overline{\overline{AB}}$
OR: $A + B = \overline{\overline{A} \cdot \overline{B}}$ (De Morgan’s law)
5. NOR Gate (Universal Gate)
Symbol:
A ——| \
|≥1 |○—— Y
B ——| /
(OR + NOT bubble)
Truth Table:
| A | B | Y |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
Boolean: $Y = \overline{A + B}$ or $Y = (A+B)'$
In words: Output is 1 only if both A AND B are 0
Also UNIVERSAL GATE!
- Can create any gate using only NOR
- Alternative to NAND for IC design
Create NOT from NOR: $\overline{A} = \overline{A + A}$
6. XOR Gate (Exclusive OR)
Symbol:
A ——| \
| =1 |—— Y
B ——| /
Truth Table:
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Boolean: $Y = A \oplus B = A\overline{B} + \overline{A}B$
In words: Output is 1 if inputs are different
Real-world: Two-way light switch!
- Either switch flips → Light state changes
- Both flip → Back to original state
Uses:
- Binary addition (1+1 = 0, carry 1)
- Parity checking (error detection)
- Comparators (detecting differences)
7. XNOR Gate (Exclusive NOR)
Symbol:
A ——| \
| =1 |○—— Y
B ——| /
(XOR + NOT bubble)
Truth Table:
| A | B | Y |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Boolean: $Y = \overline{A \oplus B} = AB + \overline{A}\,\overline{B}$
In words: Output is 1 if inputs are same
Use: Equality checker
- Password match? (all bits same → output 1)
- Data verification
Truth Table Summary
| A | B | AND | OR | NAND | NOR | XOR | XNOR |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 |
Pattern recognition:
- NAND = NOT(AND)
- NOR = NOT(OR)
- XNOR = NOT(XOR)
- XOR = 1 when inputs different
- XNOR = 1 when inputs same
Boolean Algebra Laws
Basic Laws
1. Identity Laws:
$$A + 0 = A \quad ; \quad A \cdot 1 = A$$2. Null Laws:
$$A + 1 = 1 \quad ; \quad A \cdot 0 = 0$$3. Idempotent Laws:
$$A + A = A \quad ; \quad A \cdot A = A$$4. Complement Laws:
$$A + \overline{A} = 1 \quad ; \quad A \cdot \overline{A} = 0$$5. Double Negation:
$$\overline{\overline{A}} = A$$Important Theorems
De Morgan’s Theorems (Most important for JEE!)
$$\boxed{\overline{A + B} = \overline{A} \cdot \overline{B}}$$ $$\boxed{\overline{A \cdot B} = \overline{A} + \overline{B}}$$In words:
- NOT(OR) = (NOT A) AND (NOT B)
- NOT(AND) = (NOT A) OR (NOT B)
This converts NAND ↔ NOR!
Distributive Law:
$$A(B + C) = AB + AC$$Absorption Law:
$$A + AB = A$$ $$A(A + B) = A$$NAND to NOR conversion:
$$\overline{AB} = \overline{A} + \overline{B}$$Practical use: If you have only NAND gates, but need NOR:
- Invert both inputs (use NAND as NOT)
- Feed to NAND gate
- Result = NOR operation!
This is how real chips optimize gate count:
- Design with AND/OR (easy to understand)
- Convert all to NAND or NOR (cheaper to manufacture)
- De Morgan’s laws enable the conversion!
Your processor: Billions of NAND gates pretending to be AND/OR/NOT!
Combinational Logic
Half Adder
Adds two 1-bit numbers.
Inputs: A, B Outputs: Sum (S), Carry (C)
Truth Table:
| A | B | S (Sum) | C (Carry) |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
Boolean:
$$S = A \oplus B \quad \text{(XOR)}$$ $$C = A \cdot B \quad \text{(AND)}$$Circuit: 1 XOR + 1 AND gate
Full Adder
Adds three 1-bit numbers (includes carry-in).
Inputs: A, B, $C_{in}$ Outputs: Sum (S), Carry ($C_{out}$)
Boolean:
$$S = A \oplus B \oplus C_{in}$$ $$C_{out} = AB + BC_{in} + AC_{in}$$Uses: Building multi-bit adders in calculators, processors!
8-bit adder: Chain 8 full adders → Add two 8-bit numbers!
Memory Tricks & Patterns
Gate Memory Mnemonics
AND: “All Need to be Done”
- All inputs must be 1 for output 1
OR: “One is Ready”
- Any one input being 1 makes output 1
NAND: “Not All Need to be Done”
- Output 0 only when all are 1
XOR: “Exactly One Ready”
- Output 1 when exactly one input is 1 (for 2 inputs)
XNOR: “Same gives 1”
- Inputs same → output 1
De Morgan’s Quick Memory
“Break the bar, Change the operator”
$$\overline{A + B} → \overline{A} \cdot \overline{B}$$- Break bar over (A+B)
- Add bars over A and B
- Change + to ·
Truth Table Patterns
NAND = Opposite of AND
- Just flip AND’s output column!
NOR = Opposite of OR
- Just flip OR’s output column!
XOR pattern: Outputs alternate in groups
- 0, 1, 1, 0 (one each, then swap)
Universal Gates Memory
"Naughty And Naughty Or Rule"
NAND and NOR are universal!
When to Use This
For circuit simplification:
- Write Boolean expression
- Apply De Morgan’s and Boolean laws
- Minimize gates
For truth table → circuit:
- Write Sum of Products (SOP) or Product of Sums (POS)
- Simplify using Boolean algebra or K-map
- Implement with gates
For gate conversion:
- Need NOT? → Use NAND/NOR with inputs tied together
- Have only NAND? → Use De Morgan’s to convert everything
- Have only NOR? → Use De Morgan’s to convert everything
For JEE problems:
- Given truth table → Find Boolean expression
- Given Boolean expression → Draw circuit
- Simplify expression → Count minimum gates
Common Mistakes to Avoid
Wrong: “AND gives 1 if any input is 1”
Correct:
- AND: Output 1 only if all inputs are 1
- OR: Output 1 if any input is 1
Memory aid:
- AND is strict (needs all)
- OR is lenient (needs any)
JEE trap: Truth table with 3 inputs - carefully check all combinations!
Wrong: $\overline{A + B} = \overline{A} + \overline{B}$
Correct: $\overline{A + B} = \overline{A} \cdot \overline{B}$
Remember: Break bar + Change operator!
Common mistake: Forgetting to change + to · (or vice versa)
Check yourself: NAND ≠ OR with inverted inputs!
Wrong: “XOR gives 1 if both inputs are 1”
Correct:
- OR: 1 if at least one is 1 (inclusive OR)
- XOR: 1 if exactly one is 1 (exclusive OR)
- XOR(1,1) = 0 ← Key difference!
Think: XOR = “one or the other, but not both”
JEE loves asking: “Difference between OR and XOR?” → The (1,1) case!
Wrong: Forgetting the bubble means NOT
Correct:
- Small circle (○) on gate output = NOT operation
- NAND = AND + bubble
- NOR = OR + bubble
- Bubble on input = that input is inverted
Symbol reading:
- Identify base gate (AND/OR shape)
- Check for bubble(s)
- Bubble = inversion
Practice Problems
Level 1: Foundation (NCERT/Basic)
Write the truth table for a 2-input NAND gate.
Solution:
| A | B | AB | Y = $\overline{AB}$ |
|---|---|---|---|
| 0 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 0 |
Pattern: Output 0 only when both inputs 1
Answer: See table above
How can you create a NOT gate using a 2-input NAND gate?
Solution:
Connect both inputs together:
$$Y = \overline{A \cdot A} = \overline{A}$$Circuit:
——| \
A —| & |○—— Y = Ā
——| /
Truth table check:
- A = 0 → Y = $\overline{0 \cdot 0}$ = $\overline{0}$ = 1 ✓
- A = 1 → Y = $\overline{1 \cdot 1}$ = $\overline{1}$ = 0 ✓
Answer: Tie both NAND inputs to same signal
Insight: This is how NOT gates are made in real ICs!
Level 2: JEE Main
Simplify: $Y = A\overline{B} + AB$
Solution:
Method 1 - Factoring:
$$Y = A\overline{B} + AB$$ $$Y = A(\overline{B} + B)$$ $$Y = A \cdot 1$$(since $\overline{B} + B = 1$)
$$Y = A$$Method 2 - Absorption law:
$$Y = A(\overline{B} + B) = A$$Answer: $Y = A$
Insight: The B term completely disappears! Output depends only on A.
Circuit: Just a wire (or buffer)!
Apply De Morgan’s theorem to: $Y = \overline{A + BC}$
Solution:
Step 1: Apply De Morgan’s:
$$Y = \overline{A + BC} = \overline{A} \cdot \overline{BC}$$Step 2: Apply De Morgan’s again to $\overline{BC}$:
$$\overline{BC} = \overline{B} + \overline{C}$$Final result:
$$\boxed{Y = \overline{A}(\overline{B} + \overline{C})}$$Or expanded:
$$Y = \overline{A}\,\overline{B} + \overline{A}\,\overline{C}$$Answer: $Y = \overline{A}(\overline{B} + \overline{C})$
Gate count:
- Original: 1 AND + 1 OR + 1 NOT = 3 gates
- Simplified: 3 NOT + 1 OR + 1 AND = 5 gates
- (But sometimes NAND/NOR form is preferred in IC design!)
Design a 2-input XOR gate using only NAND gates.
Solution:
XOR Boolean expression:
$$Y = A \oplus B = A\overline{B} + \overline{A}B$$Using NAND:
Step 1: Create $\overline{AB}$ (direct NAND)
Step 2: Create $A\overline{AB}$ and $B\overline{AB}$
Step 3: NAND the results
Simplified circuit: 4 NAND gates needed
A ——NAND₁—┐
B —— |—NAND₃—┐
↓ |
A —— NAND₁—NAND₄—— Y
B ——NAND₂—┘
Truth table verification:
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Answer: 4 NAND gates in specific configuration
Insight: XOR is more complex than AND/OR - needs multiple gates!
Level 3: JEE Advanced
Prove that NAND is a universal gate by creating AND, OR, and NOT gates from NAND.
Solution:
(1) NOT from NAND:
Inputs tied together:
$$Y = \overline{A \cdot A} = \overline{A}$$✓
(2) AND from NAND:
NAND + NOT:
$$Y = \overline{\overline{A \cdot B}} = AB$$✓
Circuit: NAND gate followed by NOT (made from NAND with tied inputs)
(3) OR from NAND:
Using De Morgan’s: $A + B = \overline{\overline{A} \cdot \overline{B}}$
Step 1: Create $\overline{A}$ and $\overline{B}$ (NAND with tied inputs)
Step 2: NAND them: $\overline{\overline{A} \cdot \overline{B}} = A + B$ ✓
Proved! All three basic gates can be made from NAND.
Since AND, OR, NOT are complete set → NAND is universal!
Why it matters: Real IC chips often use only NAND gates for entire design!
A full adder has inputs A=1, B=1, $C_{in}$=1. Find Sum and Carry outputs.
Solution:
Full adder equations:
$$S = A \oplus B \oplus C_{in}$$ $$C_{out} = AB + BC_{in} + AC_{in}$$Given: A=1, B=1, $C_{in}$=1
Sum:
$$S = 1 \oplus 1 \oplus 1$$ $$= 0 \oplus 1$$(since $1 \oplus 1 = 0$)
$$= 1$$Carry:
$$C_{out} = (1)(1) + (1)(1) + (1)(1)$$ $$= 1 + 1 + 1 = 1$$(in Boolean, $1+1 = 1$)
Binary interpretation:
$$1 + 1 + 1 = 11_2$$- Sum bit = 1 (LSB)
- Carry bit = 1 (MSB)
Answer: S = 1, $C_{out}$ = 1
This represents: 1+1+1 = 3 (decimal) = 11 (binary)
Quick Revision Box
| Gate | Symbol | Boolean | Output = 1 when |
|---|---|---|---|
| NOT | $\overline{A}$ | $\overline{A}$ | Input is 0 |
| AND | $AB$ | $A \cdot B$ | All inputs are 1 |
| OR | $A+B$ | $A + B$ | Any input is 1 |
| NAND | $\overline{AB}$ | $\overline{A \cdot B}$ | Not all inputs are 1 |
| NOR | $\overline{A+B}$ | $\overline{A + B}$ | All inputs are 0 |
| XOR | $A \oplus B$ | $A\overline{B}+\overline{A}B$ | Inputs are different |
| XNOR | $\overline{A \oplus B}$ | $AB+\overline{A}\,\overline{B}$ | Inputs are same |
De Morgan’s: $\overline{A+B} = \overline{A} \cdot \overline{B}$, $\overline{AB} = \overline{A} + \overline{B}$
JEE Strategy: High-Yield Points
Truth tables - Given gate, write truth table (or vice versa)
- Know all 7 gates by heart!
- Especially AND, OR, NAND, NOR, XOR
Boolean simplification - Reduce expressions
- Identity, null, complement laws
- Absorption: $A + AB = A$
- De Morgan’s - appears every year!
De Morgan’s theorem - Most important!
- $\overline{A+B} = \overline{A} \cdot \overline{B}$
- $\overline{AB} = \overline{A} + \overline{B}$
- Can convert NAND ↔ NOR
Universal gates - NAND and NOR
- Creating other gates from NAND
- Creating other gates from NOR
- Why universal? (Can create NOT, AND, OR)
XOR properties:
- $A \oplus 0 = A$
- $A \oplus 1 = \overline{A}$
- $A \oplus A = 0$
- $A \oplus \overline{A} = 1$
- Commutative, associative
Combinational circuits:
- Half adder (1 XOR + 1 AND)
- Full adder (2 XOR + 2 AND + 1 OR)
- Gate count minimization
Time-saving tricks:
- NAND = NOT(AND) - flip AND’s outputs
- NOR = NOT(OR) - flip OR’s outputs
- For XOR: Count 1s in inputs - if odd → output 1
- De Morgan’s: “Break bar, change operator”
Related Topics
Within Electronic Devices
- Transistor - Building blocks of gates
- Diode - Diode logic gates (older tech)
Connected Chapters
- Current Electricity - Circuit analysis
- Electrostatics - Voltage concepts
Real-world Applications
- Processors - Billions of logic gates (ALU, control unit)
- Memory - NAND/NOR flash, RAM
- Calculators - Adders, comparators
- Digital watches - Counters, decoders
- Smartphones - Everything digital!
- Internet routers - Packet processing logic
Teacher’s Summary
Three fundamental operations: NOT, AND, OR
- All digital logic built from these
- Combined to create seven basic gates
Truth tables define gate behavior:
- AND: Output 1 only if all inputs 1
- OR: Output 1 if any input 1
- XOR: Output 1 if inputs different
- NAND/NOR: Inverses of AND/OR
- XNOR: Inverse of XOR (equality check)
NAND and NOR are universal gates
- Can create any other gate from them
- Entire processors built using just NAND gates!
- Cheaper to manufacture (one type of gate)
De Morgan’s theorems are crucial:
- $\overline{A+B} = \overline{A} \cdot \overline{B}$
- $\overline{AB} = \overline{A} + \overline{B}$
- Enables gate conversion and circuit simplification
Boolean algebra simplifies circuits
- Fewer gates = faster, cheaper, less power
- Modern chips: billions of optimized gates
From gates to intelligence:
- Gates → Adders → ALU → Processor
- Billions working together → AI, internet, smartphones
- All from simple ON/OFF switches!
“Seven simple gates combining in billions - creating the digital revolution that runs our world, from calculators to AI!”