Tiny decision makers
02Logic gates
- Stage 1
- Stage 2 (this one)
- Stage 3
- Stage 4
- Stage 5
- Stage 6
- Stage 7
- Stage 8
- Stage 9
- Stage 10
- Stage 11
- Stage 12
- Stage 13
- Stage 14
- Stage 15
Explanation
A logic gate takes one or two bits in and gives one bit out by a fixed rule. AND gives 1 only if both inputs are 1. OR gives 1 if either is. NOT flips its input. XOR gives 1 when the inputs differ.
In a real chip each gate is a handful of transistors acting as switches. Here gates are ideal: they switch instantly and every wire is exactly 0 or 1. NAND (NOT-AND) is special: any other gate, and so any computer, can be built from NAND gates alone.
Pick a gate, flip its inputs
AB
Y0
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Check yourself
Marked instantly in your browser. Use the interactive above to work it out.