COMPUTER ORGANIZATION & ARCHITECTURE / 1. TRANSISTORS & LOGIC GATES
Transistors & Logic Gates
From silicon physics to AND, OR, NOT — the atoms of computation
EXPLANATION
Everything your computer does — every calculation, every pixel, every bit of memory — is ultimately the result of transistors switching on and off billions of times per second. The Transistor — a voltage-controlled switch: A transistor (specifically MOSFET — Metal Oxide Semiconductor Field Effect Transistor) has three terminals: - Gate — the control input. Apply voltage → transistor turns ON (conducts) - Source — where current flows from - Drain — where current flows to NMOS (N-type): Gate HIGH → switch ON (conducts). Gate LOW → switch OFF. PMOS (P-type): Gate LOW → switch ON. Gate HIGH → switch OFF. CMOS (Complementary MOS): uses both NMOS and PMOS together. This is what ALL modern chips use. Extremely low power — only draws current during switching, not when idle. Process node (nm): the "7nm", "3nm" numbers refer to the approximate size of transistor features. Smaller = more transistors per mm² = more power + less energy. Apple M3 at 3nm has ~300 million transistors per mm². From transistors to logic gates: A logic gate implements a Boolean function using transistors. The key insight: you never need to design with transistors directly — gates are the abstraction layer. NAND gate (2 NMOS + 2 PMOS transistors): - Output is LOW only when BOTH inputs are HIGH - NAND is a UNIVERSAL GATE — you can build ANY circuit using only NAND gates - NOR is also universal The 7 fundamental gates: NOT, AND, OR, NAND, NOR, XOR, XNOR NOT (inverter): simplest gate, 1 PMOS + 1 NMOS. Output = opposite of input. AND: NOT(NAND). Output HIGH only when all inputs HIGH. OR: NOT(NOR). Output HIGH when any input HIGH. XOR: Output HIGH when inputs DIFFER. Critical for arithmetic (used in adders). XNOR: Output HIGH when inputs are SAME. Used in comparators. Why NAND is preferred in real chips: NAND gates are faster and smaller than AND gates (AND = NAND + NOT = 6 transistors vs NAND's 4). Chip designers build everything from NAND/NOR. Propagation delay: gates aren't instantaneous. Each gate introduces a small delay (~10-100 picoseconds). The longest path of gates from input to output is the critical path — it determines the maximum clock speed.
DIAGRAM
CMOS NAND GATE (4 transistors):
VDD (power)
│
┌───┤P├───┬───┤P├───┐
│ └─A─┘ │ └─B─┘ │
│ Output │
│ │ │
│ ┌───┤N├───┐ │
│ │ └─A─┘ │ │
│ │ │ │
│ │ ┌───┤N├───┘
│ │ │ └─B─┘
└────┘ GND (ground)
TRUTH TABLES:
NOT AND OR XOR NAND
A out A B out A B out A B out A B out
0 1 0 0 0 0 0 0 0 0 0 0 0 1
1 0 0 1 0 0 1 1 0 1 1 0 1 1
1 0 0 1 0 1 1 0 1 1 0 1
1 1 1 1 1 1 1 1 0 1 1 0
↑ universal!
GATE SYMBOL RECAP:
NOT: A ──▷○── out
AND: A,B ──D── out
OR: A,B ──)── out
XOR: A,B ──⊕── outCODE