Logic gates are the fundamental building blocks of digital circuits. They perform basic Boolean operations on one or more binary inputs to produce a single binary output. All digital computers, from simple microcontrollers to complex CPUs, are constructed from billions of these tiny electronic switches implemented in silicon.
The NOT gate has one input and one output. It simply inverts the input: 0 becomes 1, and 1 becomes 0.
| A | Output |
|---|---|
| 0 | 1 |
| 1 | 0 |
The AND gate produces a 1 output only when all inputs are 1.
| A | B | A AND B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
The OR gate produces a 1 output if at least one input is 1.
| A | B | A OR B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
The NAND gate is an AND gate followed by a NOT. It produces 0 only when all inputs are 1. NAND is universal—any other gate can be built using only NAND gates.
| A | B | A NAND B |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
The NOR gate is an OR gate followed by a NOT. It produces 1 only when all inputs are 0. NOR is also universal.
| A | B | A NOR B |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
The XOR gate produces 1 when the inputs are different (exactly one input is 1).
| A | B | A XOR B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
The XNOR gate produces 1 when the inputs are the same (both 0 or both 1). It is also called an equivalence gate.
| A | B | A XNOR B |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Logic gates are combined to form combinational circuits (adders, multiplexers, decoders) and sequential circuits (flip-flops, registers, counters). Every arithmetic operation, memory access, and decision in a computer ultimately reduces to the action of these simple gates operating billions of times per second.