OCR H446, section 1.4.3 (d)
A logic gate is an electronic circuit that takes one or more binary inputs and gives one output, following a rule. Computers are built from millions of gates. A logic circuit joins gates together.
The gates
The standard symbols are shown below: AND has a flat back and a rounded front, OR has a curved back and a pointed front, NOT is a triangle, and a small circle (bubble) at the output means the result is inverted. So NAND is AND with a bubble, and NOR is OR with a bubble. XOR is OR with an extra curved line at the back.
| Gate | Expression | Output is 1 when... |
|---|---|---|
| NOT | the input is 0 | |
| AND | both inputs are 1 | |
| OR | at least one input is 1 | |
| XOR | the inputs differ | |
| NAND | not both inputs are 1 | |
| NOR | neither input is 1 |
Truth tables
| A | B | AND | OR | XOR | NAND | NOR |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 |
| A | NOT A |
|---|---|
| 0 | 1 |
| 1 | 0 |
NAND and NOR are called universal gates: any other gate (and so any circuit) can be built from NAND gates alone, or from NOR gates alone.
Reading a circuit
To work out what a circuit does, deal with the gates in order, from the inputs towards the output, writing the result at each gate.
This circuit has an AND gate on and , a NOT gate on , and an OR gate that combines them.
The Boolean expression
Write the expression for each gate in turn:
The truth table
For 3 inputs there are rows. Add a column for each intermediate result.
| A | B | C | Q | ||
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 |
| 0 | 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 0 | 0 | 1 | 1 |
| 0 | 1 | 1 | 0 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 | 1 |
| 1 | 0 | 1 | 0 | 0 | 0 |
| 1 | 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 | 1 |
List the inputs in binary counting order (000, 001, 010, ...), so that you don't miss any.
Drawing a circuit from an expression
Work from the inside out, following the order of operations. For :
- Use a NOT gate on .
- Use an OR gate on and .
- Use an AND gate to combine the two results.
Each operator in the expression becomes one gate, and each bracket is a sub-circuit whose output goes into the next gate.
Building a circuit from a truth table
- Pick out the rows where the output is 1.
- For each such row, write an AND term of all the inputs (use for the inputs that are 0).
- OR the terms together.
- Simplify if possible (using algebra or a K-map, 1.4.3 (b)).
For example, if only for and , then , which is XOR.
Combinations of gates that are equivalent
| Circuit | Same as |
|---|---|
| NOT followed by NOT | the original input (double negation) |
| AND then NOT | NAND |
| OR then NOT | NOR |
| XOR | |
| NAND (De Morgan) |
Worked example
Task: a circuit has an XOR gate on and , whose output goes into an AND gate with . Give the expression and complete the truth table.
Expression: .
| A | B | C | Q | |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 0 | 0 | 0 |
| 1 | 1 | 1 | 0 | 0 |
is 1 only when exactly one of and is 1, and is 1.
Exam tip: list the inputs in counting order, add a column for each gate output, and fill them in one gate at a time. For a circuit, write the expression as you go. When drawing a circuit, give each operator its own gate. Use only the gates you need: extra gates can lose the mark for correct connections.
Check yourself
What is the output of a NOR gate when both inputs are 0?
- NOR is the opposite of OR, and OR of (0, 0) is 0.
What is the difference between OR and XOR?
OR is 1 if either or both inputs are 1. XOR is 1 only when exactly one input is 1, so it gives 0 when both are 1.
Write the expression for a circuit where A and B go into an OR gate, and the output goes through a NOT gate
, which is a NOR gate.
How many rows are in the truth table for a circuit with 3 inputs?
.