A logic gate is the smallest building block of digital hardware. It watches its input wires, each carrying a 0 or a 1, and drives its output wire to 0 or 1 according to one fixed rule. Change the inputs and the output follows almost instantly.
There are seven gates you meet in every course:
- NOT: flips its single input.
- AND: 1 only when every input is 1.
- OR: 1 when at least one input is 1.
- NAND and NOR: AND and OR with the output inverted.
- XOR: 1 when the inputs differ.
- XNOR: 1 when the inputs match.
Each gate can be described three equivalent ways: a symbol for drawing circuits, a boolean expression for writing it down, and a truth table that lists the output for every input combination. A gate with n inputs has 2ⁿ rows in its table.
Why do gates matter? Every digital system, from a calculator to a processor, is gates wired together. Adders, multiplexers, memory cells and control logic are all gate networks. Inside a chip each gate is a handful of transistors acting as switches, but for logic design you can treat a gate as a black box that obeys its truth table.
Two of the seven, NAND and NOR, are universal: either one alone can build every other gate.
| 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 |