Logic Gates

Every smartphone, laptop, and digital watch is built from billions of tiny switches called transistors, but the real magic happens one level up: logic gates. A logic gate is a circuit that takes one or more binary inputs — voltages that are either HIGH (logic 1, typically ~5 V or 3.3 V) and LOW (logic 0, ~0 V) — and produces a single binary output according to a fixed logical rule. Because every number, every letter, and every instruction a computer processes is ultimately represented as patterns of 1s and 0s, logic gates are the true atoms of digital computation. The three fundamental gates are OR, AND, and NOT. Every other digital circuit — from a simple alarm to a modern CPU performing billions of operations per second — can be constructed entirely from combinations of these three. In practice, engineers often prefer two universal gates, NAND and NOR, because any logical function whatsoever can be built using only one type of universal gate, making chip fabrication simpler and cheaper. Understanding how these gates work, and how to read their truth tables, is the essential first step in digital electronics. Logic gates sit at the boundary between physics and mathematics. Physically, each gate is implemented using transistors acting as voltage-controlled switches; mathematically, they obey Boolean algebra, a branch of mathematics developed by George Boole in the 1850s — nearly a century before the first electronic computer was built. When you write A AND B, you are simultaneously describing a physical circuit and a mathematical operation, which is why digital electronics is one of the most elegant topics in all of modern physics.

Key takeaways
  • NOT Gate (Inverter)
  • AND Gate
  • OR Gate
  • NAND Gate (Universal)
  • NOR Gate (Universal)

NOT Gate (Inverter)

The NOT gate has one input A and one output Q. Its rule is brutally simple: it flips the bit. If A = 0, then Q = 1; if A = 1, then Q = 0. In Boolean notation, Q = Ā (read 'A bar' or 'NOT A'). Think of it like a light switch connected to a warning light: the light is ON only when the switch is OFF. A NOT gate is built from a single transistor wired so that a HIGH input drives the transistor into saturation (pulling output LOW), while a LOW input keeps the transistor cut off (allowing output to go HIGH through a pull-up resistor).

AND Gate

The AND gate has two (or more) inputs and one output. The output Q is HIGH only when ALL inputs are simultaneously HIGH. Q = A · B (the dot denotes logical AND). Truth table: (0,0)→0, (0,1)→0, (1,0)→0, (1,1)→1. Analogy: two switches in series controlling a lamp — the lamp lights only when both switches are closed. In transistor circuits, AND is often built as a NAND followed by a NOT, because a direct AND is harder to implement efficiently in CMOS technology.

OR Gate

The OR gate output Q is HIGH when ANY input is HIGH — equivalently, Q is LOW only when ALL inputs are LOW. Q = A + B (the plus sign denotes logical OR, not arithmetic addition). Truth table: (0,0)→0, (0,1)→1, (1,0)→1, (1,1)→1. Analogy: two switches in parallel — the lamp lights if either or both switches are closed. Note that the OR gate includes the case where both inputs are 1 (unlike everyday language where 'or' sometimes means 'one or the other but not both').

NAND Gate (Universal)

NAND means NOT-AND: Q = ̄(A · B). The output is LOW only when ALL inputs are HIGH; in all other cases the output is HIGH. Truth table: (0,0)→1, (0,1)→1, (1,0)→1, (1,1)→0. NAND is called a universal gate because you can build NOT (connect both inputs together), AND (NAND followed by NOT), and OR (by De Morgan's law: ̄Ā · B̄ = A + B) entirely from NAND gates. The entire early TTL logic family (74xx series) was dominated by NAND-based designs because NAND requires fewer transistors per gate in bipolar technology.

NOR Gate (Universal)

NOR means NOT-OR: Q = ̄(A + B). The output is HIGH only when ALL inputs are LOW. Truth table: (0,0)→1, (0,1)→0, (1,0)→0, (1,1)→0. NOR is also universal: NOT (tie inputs together), OR (NOR then NOT), AND (by De Morgan's law: ̄Ā + B̄ = A · B). CMOS (complementary metal-oxide-semiconductor) technology — used in virtually all modern chips — implements NOR gates efficiently because a NOR's transistor network mirrors the natural CMOS topology. The Apollo Guidance Computer famously used only NOR gates, containing about 4,100 of them.

The Key Equation

QNAND=A⋅B‾QNOR=A+B‾Q_{\text{NAND}} = \overline{A \cdot B} \qquad Q_{\text{NOR}} = \overline{A + B}
  • A, B — Binary inputs (dimensionless (0 or 1)): Logic levels representing LOW (0 V) or HIGH (~3.3–5 V) voltages applied to the gate inputs.
  • Q — Binary output (dimensionless (0 or 1)): The logic level produced at the gate's output terminal, determined solely by the Boolean rule of the gate.
  • \overline{X} — Logical complement (NOT) (dimensionless): The bar notation means 'invert': if X = 0 then X̄ = 1, and if X = 1 then X̄ = 0.
  • \cdot — Logical AND operator (dimensionless): Boolean multiplication: output is 1 only if both operands are 1.
  • + — Logical OR operator (dimensionless): Boolean addition: output is 1 if at least one operand is 1.

Worked Example

Problem. A security system uses two sensors: sensor A detects motion, sensor B detects a door opening. The alarm should sound only if BOTH sensors are triggered simultaneously. However, the only available chip contains NAND gates. Design a circuit using only NAND gates that activates the alarm (output HIGH) when both A = 1 AND B = 1, and derive its Boolean expression.

Q=A⋅B‾‾=A⋅BQ = \overline{\overline{A \cdot B}} = A \cdot B

Answer. Two NAND gates in series (second gate with inputs tied together) implement AND: the alarm activates only when A = 1 AND B = 1.

Figure
Diagram
Logic Gate Symbols and Truth TablesNOTAQA Q0 11 0ANDABQA B Q0 0 00 1 01 0 01 1 1ORABQA B Q0 0 00 1 11 0 11 1 1NAND = AND + bubbleQ = overline(A·B)NOR = OR + bubbleQ = overline(A+B)Both are UNIVERSAL gates:any circuit can be builtfrom NAND (or NOR) alone.
Origins · 1 minGeorge Boole and how this was discovered
GB
George Boole
1815–1864 · British

George Boole invented Boolean algebra in his 1854 work 'An Investigation of the Laws of Thought', creating a mathematical system where variables take only two values (true/false) and are combined with operations like AND, OR, and NOT. Claude Shannon's 1937 master's thesis showed that Boolean algebra perfectly describes circuits of electrical switches, directly founding digital electronics. Without Boole's abstract mathematics — developed 85 years before Shannon's insight — the design of all modern digital computers would lack a rigorous foundation. Boole was entirely self-taught and never attended university as a student, yet he became the first professor of mathematics at University College Cork at age 34. He died at 49 after reportedly walking two miles in heavy rain to deliver a lecture, then developing a fatal fever — a tragically ironic end for someone whose logical thinking now underpins technology keeping millions of people alive in hospitals worldwide.

  • Boolean Algebra — Logic gates are the physical implementation of Boolean algebra operations; understanding De Morgan's laws and algebraic simplification is essential for designing efficient gate circuits.
  • Transistors as Switches — Each logic gate is physically constructed from transistors operating in cutoff and saturation modes; understanding the transistor switch is the layer beneath the gate abstraction.
  • Binary Number System — Logic gates process binary (base-2) signals; understanding how numbers and data are represented in binary explains why the two-state (0 and 1) logic of gates is sufficient to perform all computation.
  • Combinational Circuits — Gates are combined into combinational circuits such as half-adders, full-adders, and multiplexers — the next step up from individual gates toward complete arithmetic and data-routing units.