Digital logic
OR gate
Also called: OR · disjunction · A + B · either input
Definition
An OR gate outputs 1 when at least one of its inputs is 1.
Picture it
Two switches in parallel: either one lights the lamp. Emergency stops from several places are OR logic: any one of them stops the machine. Bitwise OR sets chosen bits without touching the others.
The maths
Y = A + B A B | Y: 00|0 01|1 10|1 11|1
| Quantity | Unit | Symbol |
|---|---|---|
| ratio | dimensionless | 1 |
Worked example
A register holds 0b0001 0010. Firmware ORs it with 0b1000 0000 to set the top bit. What is the new value in decimal?
- 0001 0010 OR 1000 0000 = 1001 0010
- 128 + 16 + 2 = 146
Answer1001 0010 = 146.
✓ The number in this answer is recomputed from scratch by an automated test.
logic tester
Logic gate tester
Y = 1
Y = A ⊕ B
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 ◀ now |
| 1 | 1 | 0 |
XOR with A = 1, B = 0 gives Y = 1.
Ideal gates: no propagation delay. 1 = true = high, 0 = false = low.
Common misconceptions
- Misconception: The + in Boolean algebra means OR, so 1 + 1 = 1, not 2.
- Misconception: Everyday 'or' often means exclusive or; the OR gate is inclusive.