Logic Gate Basics: Understanding AND, OR, NOT, and XOR
A practical guide to AND, OR, NOT, XOR, NAND, NOR, and XNOR using truth tables and simple examples.
What is a logic gate?
Digital systems commonly represent low and high voltage states as 0 and 1. A logic gate receives one or more inputs and produces an output according to a fixed rule. Even complex processors are built from enormous combinations of these simple elements.
OR: true when at least one input is true
OR outputs 1 when either or both inputs are 1. It outputs 0 only when both inputs are 0. A light controlled by either a motion sensor or a manual switch is a useful analogy. The classic 7432 is a familiar TTL OR-gate IC.
AND: true only when every input is true
AND outputs 1 only when both inputs are 1. A machine that starts only when its safety cover is closed and its start button is pressed is an AND-like condition. The 7408 is a common educational example.
NOT: invert the input
NOT accepts one input and returns the opposite value: 0 becomes 1 and 1 becomes 0. It is therefore also called an inverter. The classic 7404 contains NOT gates.
XOR: true when the inputs differ
Exclusive OR outputs 1 when its two inputs are different and 0 when they are the same. XOR is useful for comparing bits and calculating the sum bit in a binary adder. The 7486 is a traditional XOR IC.
NAND, NOR, and XNOR
NAND inverts AND, NOR inverts OR, and XNOR inverts XOR. NAND and NOR are called universal gates because either type can be combined to implement every other Boolean function. XNOR outputs 1 when two inputs match, making it useful in equality comparisons.
What do numbers such as 7432 and 7408 mean?
They are part numbers in the 7400 logic-IC family, not calculation results or pin counts. The 74 identifies the commercial 7400-series family, while the final digits identify the logic function: 32 is assigned to OR and 08 to AND. The digits are not interpreted individually.
Common function numbers
• 7400: four 2-input NAND gates
• 7402: four 2-input NOR gates
• 7404: six NOT inverters
• 7408: four 2-input AND gates
• 7432: four 2-input OR gates
• 7486: four 2-input XOR gates
Letters may appear in the middle, as in 74LS08 or 74HC08. They describe circuit technology and electrical characteristics rather than logical function. LS means Low-power Schottky TTL, HC means High-speed CMOS, and HCT is CMOS with TTL-compatible input thresholds. They perform the same logic but can differ in supply voltage, speed, power, input thresholds, and output current.
A 7408 is not a single AND gate: a typical 14-pin package contains four independent 2-input AND gates. Always check the exact manufacturer's datasheet before substituting one family for another.
Reading Boolean expressions
AND is commonly written A·B or AB, OR as A+B, NOT as a bar or prime, and XOR as A⊕B. Rather than memorizing symbols alone, list every possible input combination in a truth table and calculate the output.
Summary
OR means at least one, AND means all, NOT means inversion, and XOR means different. Adding inversion gives NAND, NOR, and XNOR. These rules provide the foundation for understanding adders, comparators, registers, and more advanced digital circuits.