EngineerPlay

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?

Truth table with outputs 0111Labels shown, in drawing order: A, B, Out, 0, 1, 0, 1.ABOut000011101111

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?

Logic circuit with 3 gatesLabels shown, in drawing order: A, 1, B, 0, OR, XOR, ?.A1B0ORXORXOR?
Show the working
  1. Write down what is given: A = 1, B = 0.
  2. The OR gate takes B = 0 and A = 1. OR gives 1 when at least one input is 1, so it gives 1.
  3. The XOR gate takes the OR output (1) and B = 0. XOR gives 1 when the inputs are different, so it gives 1.
  4. The XOR gate takes B = 0 and the XOR output (1). XOR gives 1 when the inputs are different, so it gives 1.
  5. 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.