Basic Logic Gates

Basic logic gates — AND, OR, NOT, NAND, NOR, XOR — are the complete set of standard building blocks from which every digital circuit is constructed, each with defined truth tables and transistor implementations.

Why This Matters

Logic gates are the atomic units of digital hardware. A complete understanding of all basic gate types — their truth tables, Boolean expressions, transistor implementations, and common applications — provides the vocabulary needed to read any digital circuit schematic and design any combinational function.

Each gate has specific properties that make it valuable for particular applications: NAND and NOR are universal (any function from one type); XOR enables parity and addition; NOT enables inversion and De Morgan transformations. Knowing which gate to use in a given situation is the core skill of combinational logic design.

This survey of all basic gates serves as the reference that designers return to repeatedly throughout any circuit project.

AND Gate

Output is 1 only when ALL inputs are 1. Boolean: F = A·B.

Truth table (2 inputs):

  • 00 → 0, 01 → 0, 10 → 0, 11 → 1

Applications: gating signals, address decoding, carry generation in adders.

IC: 74HC08 (quad 2-input AND), 74HC11 (triple 3-input AND).

OR Gate

Output is 1 when ANY input is 1. Boolean: F = A+B.

Truth table (2 inputs):

  • 00 → 0, 01 → 1, 10 → 1, 11 → 1

Applications: combining interrupt signals, carry merge in adders, encoding “any of several conditions.”

IC: 74HC32 (quad 2-input OR), 74HC4075 (triple 3-input OR).

NOT Gate (Inverter)

Output is the complement of input. Boolean: F = NOT A = Ā.

Truth table:

  • 0 → 1, 1 → 0

Applications: signal inversion, enabling De Morgan transformations, buffering with inversion.

IC: 74HC04 (hex inverter), 74HC14 (hex Schmitt trigger inverter — for noisy signals).

The Schmitt trigger variant adds hysteresis (different threshold for rising vs. falling edges), providing noise immunity. Use 74HC14 when input signals have slow edges or noise.

NAND Gate

Output is 0 only when ALL inputs are 1 (NOT-AND). Boolean: F = NOT(A·B) = Ā+B̄.

Truth table (2 inputs):

  • 00 → 1, 01 → 1, 10 → 1, 11 → 0

NAND is the most important gate in practice: it is universal (all other gates derivable from NAND alone), and CMOS NAND implementation is more efficient than AND. Most logic design starts from NAND.

Derived functions from NAND:

  • NOT: connect both inputs together → NAND(A,A) = NOT A
  • AND: NAND followed by NOT = NAND(NAND(A,B), NAND(A,B))
  • OR: NOT both inputs, then NAND = NAND(NOT A, NOT B) = A OR B (De Morgan)

IC: 74HC00 (quad 2-input NAND), 74HC10 (triple 3-input NAND), 74HC20 (dual 4-input NAND).

NOR Gate

Output is 1 only when ALL inputs are 0 (NOT-OR). Boolean: F = NOT(A+B) = Ā·B̄.

Truth table (2 inputs):

  • 00 → 1, 01 → 0, 10 → 0, 11 → 0

NOR is also universal. Historical note: the Apollo Guidance Computer (1960s) used only NOR gates to simplify manufacturing by requiring a single gate type.

Derived functions from NOR:

  • NOT: NOR(A,A) = NOT A
  • OR: NOR followed by NOT
  • AND: NOT both inputs, then NOR = NOR(NOT A, NOT B) = A AND B (De Morgan)

IC: 74HC02 (quad 2-input NOR), 74HC27 (triple 3-input NOR).

XOR Gate (Exclusive OR)

Output is 1 when inputs DIFFER. Boolean: F = A⊕B = A·B̄ + Ā·B.

Truth table (2 inputs):

  • 00 → 0, 01 → 1, 10 → 1, 11 → 0

XOR is the “odd parity” function for two inputs: output is 1 when an odd number of inputs are 1. For N inputs, XOR output is 1 when the total count of 1-inputs is odd.

Critical applications:

  • Sum bit in binary adder: Sum = A XOR B XOR Cin
  • Parity generation and checking: XOR all data bits for parity; re-XOR received bits and compare to received parity bit
  • Controlled inverter: A XOR 0 = A (pass through); A XOR 1 = NOT A (invert). Used for building adder-subtractors where the B input is selectively inverted by the subtract control signal
  • Equality testing: A XNOR B = NOT(A XOR B) = 1 when A = B

IC: 74HC86 (quad 2-input XOR), 74HC4030 (quad 2-input XOR, alternative pinout).

XNOR Gate (Exclusive NOR)

Output is 1 when inputs are THE SAME. Boolean: F = NOT(A⊕B) = A·B + Ā·B̄.

Truth table (2 inputs):

  • 00 → 1, 01 → 0, 10 → 0, 11 → 1

Applications: equality detection. For N-bit equality: XNOR each pair of corresponding bits, then AND all results. If all XNOR outputs are 1, the values are equal.

IC: 74HC266 (quad 2-input XNOR, open-drain outputs), or build from XOR + NOT.

Selecting Gates for a Project

For a gate-based digital project, stock these five IC types to handle any combinational function:

  1. 74HC00 (NAND) — universal gate, most versatile
  2. 74HC02 (NOR) — alternative universal gate, useful for SR latches
  3. 74HC04 (NOT) — inverter/buffer
  4. 74HC86 (XOR) — parity and addition
  5. 74HC245 (tri-state buffer) — bus interface

With these five types, any combinational function can be implemented. Add flip-flop ICs (74HC74, 74HC273) for sequential logic.