Lesson 2 of 116 minBeginner

Logic Gates & Boolean Algebra

The seven fundamental logic gates with truth tables and equations, how they map to CMOS transistors, and the Boolean algebra that simplifies them.

The Physical Reality

Logic gates are built from transistors - CMOS technology uses PMOS and NMOS transistors as complementary switches. A NAND gate in 28nm CMOS has 4 transistors; a NOT gate has 2. Every Boolean function you write maps directly to physical transistors on silicon.

The 7 Fundamental Gates - Truth Tables & Equations

AND Gate

AND Gate (click to enlarge)

Y is 1 only when all inputs are 1.

ABY=A·B
000
010
100
111

OR Gate

OR Gate (click to enlarge)

at least one

ABY=A+B
000
011
101
111

NOT Gate (Inverter)

NOT Gate (Inverter) (click to enlarge)
AY=A'
01
10

NAND Gate Universal

NAND Gate Universal (click to enlarge)
ABY=(AB)'
001
011
101
110

NOR Gate Universal

NOR Gate Universal (click to enlarge)
ABY=(A+B)'
001
010
100
110

XOR Gate (Exclusive OR)

XOR Gate (Exclusive OR) (click to enlarge)

different

ABY=A⊕B
000
011
101
110

XNOR Gate (Exclusive NOR)

XNOR Gate (Exclusive NOR) (click to enlarge)

equal

ABY=(A⊕B)'
001
010
100
111

Universal Gates - NAND & NOR Can Build Everything

A gate is called universal if you can construct any other logic function using only that gate. Both NAND and NOR are universal - this is critical in IC design because using fewer gate types reduces fabrication complexity.

Building with NAND only

NOT: Connect both inputs of NAND together → Y = (A·A)' = A'

AND: NAND followed by NOT → Y = ((A·B)')' = A·B

OR: NOT each input, then NAND → Y = (A'·B')' = A+B (De Morgan)

Any Boolean expression can be built with NAND gates alone.

Building with NOR only

NOT: Connect both inputs of NOR together → Y = (A+A)' = A'

OR: NOR followed by NOT → Y = ((A+B)')' = A+B

AND: NOT each input, then NOR → Y = (A'+B')' = A·B (De Morgan)

Any Boolean expression can be built with NOR gates alone.

Boolean Algebra Laws

LawAND FormOR Form
IdentityA · 1 = AA + 0 = A
Null (Annulment)A · 0 = 0A + 1 = 1
IdempotentA · A = AA + A = A
ComplementA · A' = 0A + A' = 1
Double Negation(A')' = A,
CommutativeA · B = B · AA + B = B + A
AssociativeA(BC) = (AB)CA+(B+C) = (A+B)+C
DistributiveA(B+C) = AB+ACA+BC = (A+B)(A+C)
AbsorptionA(A+B) = AA + AB = A
De Morgan's(A·B)' = A' + B'(A+B)' = A' · B'
De Morgan's Theorem

The Most Used Rule in Digital Design, In words: To complement a function, invert each variable AND swap AND↔OR (or equivalently, break the bar and change the sign). Example 1: (A·B·C)' = A' + B' + C' (NAND = bubbled OR) Example 2: (A+B+C)' = A'·B'·C' (NOR = bubbled AND) This is the mathematical basis for why NAND and NOR are universal gates.

XOR Properties - Especially Important

A ⊕ 0 = A

XOR with 0 leaves the value unchanged - identity property.

A ⊕ 1 = A'

XOR with 1 inverts the value - controllable inverter. Used in encryption and data masking.

A ⊕ A = 0

XOR with itself is always 0. Used to clear registers and detect errors.

A ⊕ B ⊕ B = A

XOR is self-inverse - applying it twice restores the original. Foundation of XOR-based encryption.

Finished reading?

Mark it complete to track your progress through the path.

Get new lessons by email

New lessons, interview prep and real EDA tool workflows. No spam.

PrevNext