← Back to Roadmap

🚪Logic Gates & Truth Tables

The fundamental building blocks of all digital systems — from simple gates to billion-transistor processors.

Logic Levels & Noise Margins

Digital circuits use voltage thresholds: for 5V CMOS, V_IL(max) = 1.5V (max voltage considered LOW), V_IH(min) = 3.5V (min voltage considered HIGH). Between is the forbidden zone. Noise margin: how much noise can be tolerated. NM_L = V_IL - V_OL, NM_H = V_OH - V_IH. Higher noise margin = more robust. 3.3V and 1.8V logic use lower thresholds for power saving.

Gate Implementation

CMOS (Complementary MOS): two MOSFETs per gate (pull-up PMOS + pull-down NMOS). Zero static power consumption (ideally). TTL (Transistor-Transistor Logic): bipolar transistors, faster but higher power. Modern CPUs use FinFET/GAAFET at ∼1V. A single NAND gate in CMOS requires just 4 transistors (2 PMOS + 2 NMOS). A modern CPU has billions of them.

Universal Gates

NAND and NOR are universal — any logic function can be built using only NAND gates (or only NOR). This is why NAND flash memory is named after the gate. To build NOT from NAND: tie both inputs together. To build AND: NAND + NOT. To build OR: NOT both inputs, then NAND. Every digital system can theoretically be built from one gate type.

🎮 Logic Gate Simulator

🎮 Logic Gate Simulator
Toggle A and B inputs — see AND, OR, NAND, NOR, XOR, XNOR outputs simultaneously.
AND
0
OR
0
NAND
1
NOR
1
XOR
0
XNOR
1

7 Fundamental Gates (Truth Table)

  • NOT: output = ¬input | 1→0, 0→1
  • AND: output = A∧B | 1 only if ALL inputs are 1
  • OR: output = A∨B | 0 only if ALL inputs are 0
  • NAND: output = ¬(A∧B) | Universal gate
  • NOR: output = ¬(A∨B) | Universal gate
  • XOR: output = A⊕B | 1 if inputs DIFFER
  • XNOR: output = ¬(A⊕B) | 1 if inputs SAME (equality comparator)

🔌 Real-World: Building an Adder

🔌 Real-World: Building an Adder
Half Adder: Sum = A⊕B, Carry = A∧B. Adds two bits, outputs sum + carry.
Full Adder: Sum = A⊕B⊕C_in, Carry_out = (A∧B)∨(C_in∧(A⊕B)). Adds three bits.
Chain 8 full adders = 8-bit adder. This is how your CPU adds numbers. A modern CPU has thousands of these chained in parallel for 64-bit math.