Logic Gates — NOT, AND, OR and Friends
On this page 4 headings
Start here A lift door should open only if the lift has stopped AND someone pressed the button. A fan should run if the switch is on OR the timer is on. A night lamp should glow when it is NOT bright outside. These three words, AND, OR and NOT, are the basic building blocks of every computer.
| Gate | Written as | Read as | Output is 1 when… |
|---|---|---|---|
| NOT | (or A′) | “not A” | A is 0 (it flips the input) |
| AND | (or AB) | “A and B” | both A and B are 1 |
| OR | “A or B” | at least one of A, B is 1 |
Careful: in Boolean algebra, + means OR, not addition. So 1 + 1 = 1 (not 2).
| Gate | Formula | Output is 1 when… | Memory trick |
|---|---|---|---|
| NAND | NOT both are 1 | AND, then flip | |
| NOR | both are 0 | OR, then flip | |
| XOR | the inputs are different | “one or the other, not both” | |
| XNOR | the inputs are the same | an “equality checker” |
Full truth table for 2 inputs:
| A | B | AND | OR | NAND | NOR | XOR | XNOR |
|---|---|---|---|---|---|---|---|
| 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 |
Two useful facts (they come up a lot):
- XOR with many inputs = 1 when an odd number of inputs are 1.
- XNOR of two inputs = 1 when . That’s a 1-bit comparator.
What does mean? Just like × before + in normal maths:
- NOT first (highest)
- then AND
- then OR (lowest)
So (W AND (NOT X)) OR (Y AND Z).
In one line: NOT flips, AND needs all 1s, OR needs at least one 1. NAND and NOR are their flipped versions, XOR checks “different” and XNOR checks “same”. Order: NOT, then AND, then OR. Exam words: logic gate, NOT (inverter), AND, OR, NAND, NOR, XOR, XNOR, complement, precedence, bubble.
