EngineerPlay

Logic gate truth tables and rules

A logic gate turns input bits into one output bit. For the input rows 00, 01, 10, 11, AND gives 0001 (1 only when both inputs are 1), OR gives 0111, XOR gives 0110 (1 when the inputs differ), NAND gives 1110 and NOR gives 1000. NOT flips a bit, and a circuit is written by wrapping each gate around what feeds it.

The formulas

FormulaWhat it givesSymbols
A AND B; AND: 0001An AND gateA, B = input bits (0 or 1). The output is 1 only when A = 1 and B = 1. 0001 is the output column for the input rows 00, 01, 10, 11
A OR B; OR: 0111An OR gateA, B = input bits. The output is 1 when at least one input is 1. 0111 is the output column for the input rows 00, 01, 10, 11
A XOR B; XOR: 0110An XOR gateA, B = input bits. The output is 1 when the inputs are different, so its output column for the rows 00, 01, 10, 11 is 0110
NOT AA NOT gateNOT flips one input: 1 becomes 0 and 0 becomes 1. NOT B written under an expression flips every bit of B's column
NOT (A AND B); NAND: 1110A NAND gateAND followed by NOT, so it is written NOT (A AND B): 0 only when both inputs are 1. 1110 is the output column for the input rows 00, 01, 10, 11
NOT (A OR B); NOR: 1000A NOR gateOR followed by NOT, so it is written NOT (A OR B): 1 only when both inputs are 0. 1000 is the output column for the input rows 00, 01, 10, 11

Worked example

This example is made by the same code as the practice questions. Open the working to see every step.

Which is the output column of this circuit's truth table? Rows in order 000, 001, 010, 011, 100, 101, 110, 111.

Logic circuitLabels shown, in drawing order: A, B, C, OR, NOT, NOR, ?.ABCORNOTNOR?
Show the working
  1. The circuit is NOT (NOT (B OR C) OR A). Work out every gate for each row, from 000 to 111, one bit per row.
  2. B OR C gives 01110111.
  3. NOT (B OR C) gives 10001000.
  4. NOT (NOT (B OR C) OR A) gives 01110000.
  5. The last gate gives the output column. Answer: 01110000.

Common mistakes

These are the wrong answers the practice questions offer, and the slip that leads to each.

Questions

What is the formula for an AND gate?

A AND B; AND: 0001. Symbols: A, B = input bits (0 or 1). The output is 1 only when A = 1 and B = 1. 0001 is the output column for the input rows 00, 01, 10, 11.

What is the formula for an OR gate?

A OR B; OR: 0111. Symbols: A, B = input bits. The output is 1 when at least one input is 1. 0111 is the output column for the input rows 00, 01, 10, 11.

What is the formula for an XOR gate?

A XOR B; XOR: 0110. Symbols: A, B = input bits. The output is 1 when the inputs are different, so its output column for the rows 00, 01, 10, 11 is 0110.