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
| Formula | What it gives | Symbols |
|---|---|---|
A AND B; AND: 0001 | An AND gate | 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 |
A OR B; OR: 0111 | An OR gate | 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 |
A XOR B; XOR: 0110 | An XOR gate | 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 |
NOT A | A NOT gate | NOT 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: 1110 | A NAND gate | AND 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: 1000 | A NOR gate | OR 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.
Answer: 01110000. Work out each gate for every row. The output is 01110000 (NOT (NOT (B OR C) OR A)).
Show the working
- 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.
- B OR C gives 01110111.
- NOT (B OR C) gives 10001000.
- NOT (NOT (B OR C) OR A) gives 01110000.
- 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.
- Forgetting the final NOT, or adding one, flips every bit of the output column (NAND read as AND).
- Using the wrong gate at the last step, such as OR where the circuit has NOR or XOR, changes the output column.
- In a 3-input table, counting the 0s instead of the 1s gives 8 minus the right count.
- Swapping two inputs, such as A and C, in an expression changes its truth table even though it looks almost the same.
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.