CRYSTALSIM

initializing lattice

Logic Gates — From Switches to Computing

Lesson 4 of 6·15 min read·+50 XP
Back to Track

From one switch to a thinking machine

A single transistor switches a current. Wire two together properly and you get a logic gate — a device that takes one or more 1/0 inputs and produces a 1/0 output according to a simple rule. Wire enough gates together and you get arithmetic, memory, and eventually an entire processor. This is the bridge between physics and computing.

Key Concept
Logic Gate
A small circuit (usually 2–6 transistors) that implements a Boolean function: output is HIGH (1) or LOW (0) based on the combination of inputs. The basic primitive of every digital chip.
Key Concept
Truth Table
A complete enumeration of input combinations and their resulting outputs. For a 2-input gate, that's just 4 rows — yet from these tiny tables, every program you've ever run is built.
Key Concept
Boolean Logic
The algebra of true/false (1/0) values, formalized by George Boole in 1854. Claude Shannon showed in 1937 that switching circuits implement Boolean algebra exactly — the conceptual foundation of digital electronics.
Key Concept
NOT Gate (Inverter)
One input, one output. Output is the logical inverse of input: NOT 0 = 1, NOT 1 = 0. Built from one pMOS + one nMOS transistor. The simplest possible logic gate.
Key Concept
AND Gate
Output is 1 only when ALL inputs are 1. Like two doors in series — both must be open. In CMOS we usually build AND as NAND followed by NOT.
Key Concept
OR Gate
Output is 1 if ANY input is 1. Like two doors in parallel — either path lets you through.
Key Concept
NAND Gate
AND followed by NOT — output is 0 only when all inputs are 1. The cornerstone of CMOS design because it's the simplest universal gate.
Diagram · Logic gate playground
interactive
CMOS Schematic — NAND
VDDGNDY = 1ApBpAnBnpull-up active → output HIGH
Truth Table
ABY
001
011
101
110
NAND is universal — every other gate can be built from NANDs alone.
Pick a gate, toggle inputs A and B, watch the truth table row light up and the underlying CMOS transistors flip ON/OFF.
Light switches
**NOT** is a switch wired backwards — flip ON, the lamp goes OFF. **AND** is two switches in series feeding one lamp — both must be on. **OR** is two switches in parallel — either one lights it up. **NAND** is AND with the bulb wired backwards — it lights up unless both switches are flipped.
Checkpoint · +5 XP
NAND inputs (1, 1) produce output:

Why NAND is special. Mathematically, NAND is functionally complete: any Boolean function — AND, OR, XOR, an entire CPU — can be built from nothing but NAND gates. Combine that with the fact that NAND is dirt-cheap in CMOS (4 transistors, fast, low power) and you have the reason almost every chip is, deep down, an enormous sea of NANDs.

Lesson Summary
  • Combine a few transistors and you get a logic gate — the atom of digital computing.
  • The five core gates: NOT, AND, OR, NAND, NOR.
  • Every gate has a truth table: a tiny lookup of outputs for every possible input combination.
  • NAND is universal — give an engineer enough NAND gates and they can build any digital circuit, including a CPU.
Test Your Knowledge · +50 XP
1
An AND gate outputs 1 when:
2
A NOT gate of input 1 produces:
3
Why is NAND called 'universal'?
4
An OR gate is most like:
5
A truth table for a 2-input gate has how many rows?