Logo
All chapters
Volume II: Digital Logic  ›  Boolean Algebra & Logic Gates

Digital Logic Gates

The basic building blocks: each gate computes one Boolean operation on its inputs.

PrevOther Logic Operations
NextIntegrated Circuits

Description

Physical circuits that each implement one Boolean function of their inputs. They are the atomic primitives every larger digital circuit is assembled from. Transistors switch to pull the output high or low according to the gate's truth table.

  • AND: output 1 only if all inputs are 1.
  • OR: output 1 if any input is 1.
  • NOT: inverts a single input.
  • NAND / NOR: AND/OR followed by inversion — each is universal on its own.
  • XOR: 1 when inputs differ (odd parity); XNOR is its inverse.
  • Any Boolean function can be built from NAND gates alone (or NOR alone).
  • This is why standard-cell libraries lean heavily on NAND/NOR.
  • What: Physical circuits that each implement one Boolean function of their inputs.
  • Why: They are the atomic primitives every larger digital circuit is assembled from.
  • How: Transistors switch to pull the output high or low according to the gate's truth table.

At a glance

What

Physical circuits that each implement one Boolean function of their inputs.

Why

They are the atomic primitives every larger digital circuit is assembled from.

How

Transistors switch to pull the output high or low according to the gate's truth table.

Where

Standard-cell libraries, FPGAs, and every combinational and sequential block.

When

At the lowest design level — gate-level netlists and schematic capture.

Think of it like…

Gates are the LEGO bricks of logic. AND/OR/NOT are special-shaped bricks, but NAND is the one brick you can clip together to rebuild every other shape.

The seven gates

  • AND: output 1 only if all inputs are 1.
  • OR: output 1 if any input is 1.
  • NOT: inverts a single input.
  • NAND / NOR: AND/OR followed by inversion — each is universal on its own.
  • XOR: 1 when inputs differ (odd parity); XNOR is its inverse.

Universality

  • Any Boolean function can be built from NAND gates alone (or NOR alone).
  • This is why standard-cell libraries lean heavily on NAND/NOR.

Gate reference

GateBoolean2-input output = 1 whenUniversal?
ANDA · Bboth inputs 1no
ORA + Bany input 1no
NOTA′input is 0no
NAND(A · B)′not both 1yes
NOR(A + B)′both 0yes
XORA ⊕ Binputs differno
XNOR(A ⊕ B)′inputs equalno

Black-box view

ABLogic gateblack boxY

Inputs on the left → outputs on the right · particles show signal direction

Logic diagram

1YA0B0C0ANDNOTOR

Click inputs to toggle · glowing wires carry 1 · particles show signal direction

gate · truth table

▶ live simulator
A0B00YAND

Click a terminal (A/B) to toggle it · glowing wires carry a logic 1 · the lamp is output Y

ABY
000
010
100
111

HDL — Verilog · VHDL · SystemVerilog

module gates(input a, b,
            output y_and, y_or, y_xor, y_nand);
  assign y_and  = a & b;
  assign y_or   = a | b;
  assign y_xor  = a ^ b;
  assign y_nand = ~(a & b);
endmodule

The basic gates as continuous-assignment dataflow in all three HDLs.

Real-world applications

CPU control & ALU logicAddress decodersParity / error detection (XOR)FPGA look-up tablesMultiplexed buses (tri-state)

The 5 Whys

  1. 1

    Why do we need logic gates? To physically realize Boolean functions.

  2. 2

    Why realize them physically? So computation runs in hardware, not just on paper.

  3. 3

    Why standardize on a few gate types? Reusable cells simplify design and fabrication.

  4. 4

    Why favor NAND/NOR? Each alone is universal, so libraries optimize them heavily.

  5. 5

    Root cause: a small universal gate set lets any logic be built, verified, and mass-produced.

Cheat sheet

Working principle

  • Transistors switch to pull the output high or low according to the gate's truth table.
  • Physical circuits that each implement one Boolean function of their inputs.

Formulas & Boolean expressions

  • AND: Y = A·B
  • OR: Y = A + B
  • NOT: Y = A′
  • NAND: Y = (A·B)′
  • NOR: Y = (A + B)′
  • XOR: Y = A⊕B = A′B + AB′
  • XNOR: Y = (A⊕B)′

Key facts

  • AND: output 1 only if all inputs are 1.
  • Any Boolean function can be built from NAND gates alone (or NOR alone).

Why it exists

  • Root cause: a small universal gate set lets any logic be built, verified, and mass-produced.
PrevOther Logic Operations
NextIntegrated Circuits