Logic gates and truth table practice
AND is 1 only when all inputs are 1; OR when any is 1; XOR when they differ; NAND and NOR are AND and OR inverted.
Name the gate; one gate with NAND, NOR, XOR.
Which gate has this truth table?
How to solve these
Gates. AND 0001, OR 0111, NAND 1110, NOR 1000, XOR 0110 (outputs for inputs 00, 01, 10, 11). NOT flips one input.
Truth tables. List every input combination in binary order (2 inputs: 4 rows; 3 inputs: 8 rows) and push each row through the gates from left to right.
Expressions. Read the circuit from the inputs to the output, wrapping each gate around what feeds it. Two expressions are equivalent exactly when their truth tables match.
Worked example
With the inputs shown at the top, what is the output?
Answer: 1. OR gives 1 when at least one input is 1. XOR gives 1 when the inputs are different. Step by step: the OR gate takes B = 0 and A = 1 and gives 1; then the XOR gate takes the OR output (1) and B = 0 and gives 1; then the XOR gate takes B = 0 and the XOR output (1) and gives 1.
Show the working
- Write down what is given: A = 1, B = 0.
- The OR gate takes B = 0 and A = 1. OR gives 1 when at least one input is 1, so it gives 1.
- The XOR gate takes the OR output (1) and B = 0. XOR gives 1 when the inputs are different, so it gives 1.
- The XOR gate takes B = 0 and the XOR output (1). XOR gives 1 when the inputs are different, so it gives 1.
- The XOR gate drives the output. Answer: 1.
Questions
How many rows does a truth table have?
2 to the power of the number of inputs: 4 rows for two inputs, 8 for three.
Why are NAND and NOR called universal gates?
Any other gate, and so any logic circuit, can be built from NAND gates alone (or NOR gates alone).
How are these questions checked?
Each circuit is generated fresh; a separate test simulates it with its own gate tables and parses every expression option, and exactly one option must match.