Logic gates
- AND: the output is 1 only if both inputs are 1.
- OR: the output is 1 if at least one input is 1.
- NOT: the output is the opposite of the input.
- XOR: the output is 1 if the two inputs are different.
Truth tables
- A truth table shows the output for every combination of inputs. 2 inputs give 4 rows; 3 inputs give 8 rows (2ⁿ rows for n inputs).
- AND: 0 0 → 0, 0 1 → 0, 1 0 → 0, 1 1 → 1. OR: 0 0 → 0, 0 1 → 1, 1 0 → 1, 1 1 → 1. NOT: 0 → 1, 1 → 0.
Logic circuits and expressions
- Gates can be joined into circuits. P = NOT (A AND B) is 0 only when A and B are both 1.
- Work through a circuit one gate at a time, adding a column to the truth table for each gate's output.
- Expressions may use symbols. OCR writes AND as ∧, OR as ∨ and NOT as ¬. AQA writes A AND B as A·B, A OR B as A + B, and NOT A as A with a bar over it.
Using logic
- Logic is used in program conditions and in real systems. An alarm might sound if (a door is open OR a window is open) AND the alarm is set.
Key terms
- Logic gate
- An electronic component that carries out a Boolean operation on its inputs.
- AND gate
- Outputs 1 only when both inputs are 1.
- OR gate
- Outputs 1 when at least one input is 1.
- NOT gate
- Outputs the opposite of its single input.
- XOR gate
- Outputs 1 when the two inputs are different.
- Truth table
- A table showing the output for every possible combination of inputs.
- Boolean expression
- A statement using AND, OR and NOT that is either true or false.
Quick questions on Boolean logic and logic gates
- What does an AND gate output when both inputs are 1?
- 1: Both inputs are 1, so the output is 1.
- What does an OR gate output when the inputs are 0 and 1?
- 1: At least one input is 1.
- What does a NOT gate do?
- Outputs the opposite of its input: 1 becomes 0, and 0 becomes 1.
- How many rows does a truth table for 3 inputs have?
- 8: 2³ = 8.
- Which gate outputs 1 only when both inputs are 1?
- AND: Both conditions must be true.
- What is NOT (1 AND 1)?
- 0: 1 AND 1 = 1, and NOT 1 = 0.
- What is (1 OR 0) AND 0?
- 0: 1 OR 0 = 1, and 1 AND 0 = 0.
- An XOR gate has the inputs 1 and 1. What is the output?
- 0: The inputs are the same, so XOR gives 0.
Boolean logic and logic gates: questions and answers
- An alarm sounds when it is set AND a door is open. The alarm is set, but no door is open. Does it sound?
- No. 1 AND 0 = 0.
- How many rows does a truth table with 2 inputs have?
- 4. 00, 01, 10 and 11.
- What does an OR gate output when both inputs are 0?
- 0. Neither input is 1.