Electronics & control · Higher

Digital logic

11 cards · 9 quiz · 0 exam
What you're learning in this topic

Learning intention WALT

We are learning about digital logic, specifically to be able to:

  • complete truth tables for AND, OR and NOT and combinations of gates
  • turn a written problem into a logic circuit
  • write a Boolean expression from a circuit or truth table
  • use NAND and NOR equivalents to reduce the number of chips

Success criteria WILF

  • I can complete truth tables for AND, OR and NOT and combinations of gates
  • I can turn a written problem into a logic circuit
  • I can write a Boolean expression from a circuit or truth table
  • I can use NAND and NOR equivalents to reduce the number of chips

Logic gates

  • AND: output 1 only when all inputs are 1. Boolean A·B.
  • OR: output 1 when any input is 1. A+B.
  • NOT (inverter): output is the opposite of the input. Ā.
AND (A·B)A B Z0 0 00 1 01 0 01 1 1OR (A+B)A B Z0 0 00 1 11 0 11 1 1NOT (Ā)A Z0 11 0
The three N5 gates. Higher adds NAND, NOR and EOR, and building any circuit from NAND gates.

Truth tables list every combination of inputs: 2 inputs = 4 rows, 3 inputs = 8 rows. Work through a logic diagram column by column, labelling the intermediate points (D, E, F) as SQA does.

Interactive simulation: try this on the revision site, where you can change the values and see the result.

From a written problem to a logic circuit

Pick out the conditions: "the alarm sounds when the door is open AND the system is armed, OR the panic button is pressed" gives Z = (A·B) + C. Draw each gate with all its input connections, and wire the final gate to the output. NOT gates come first on the input they invert.

Boolean expressions and truth tables

Write the expression one gate at a time, from the inputs to the output. A NOT gate on A gives Ā; Ā into an OR gate with B gives (Ā + B); that into an AND gate with C gives Z = (Ā + B)·C. Use brackets to show which gate comes first.

For a truth table, add a column for each point in the middle of the circuit, and work out that column before the output. Example: Z = (A·B) + C, with M = A·B.

ABCM = A·BZ = M + C
00000
00101
01000
01101
10000
10101
11011
11111

Number of rows = 2inputs: 2 inputs = 4, 3 inputs = 8. Count up in binary so no combination is missed.

Design challenge: safe guillotine

The brief. A workshop guillotine must only operate when the guard is closed (A) and both hands are on the buttons (B and C). A key switch (D) lets a technician test it with the guard open.

  1. Write the conditions as a sentence using AND and OR.
  2. Draw the logic circuit.
  3. Write the Boolean expression.
  4. Complete the truth table for A, B and C with D = 0.
What a good answer includes
  • The blade operates when A AND B AND C, OR when D.
  • Three-input AND gate (or two AND gates) feeding an OR gate with D.
  • Z = (A·B·C) + D.
  • Only the row A = B = C = 1 gives Z = 1 when D = 0.

NAND, NOR and EOR HIGHER

  • NAND: NOT AND: output 0 only when all inputs are 1.
  • NOR: NOT OR: output 1 only when all inputs are 0.
  • EOR (exclusive OR): output 1 when the inputs are different.

NAND equivalents: any gate can be built from NANDs: NOT = NAND with inputs joined; AND = NAND followed by a NAND-NOT; OR = NAND-NOTs on each input then a NAND. Convert the whole circuit, then cancel any two NOTs in a row (double inversion) to use the fewest gates. The 2025 Higher assignment report: many didn't reduce to the fewest gates.

Derive Boolean expressions from truth tables, diagrams or specifications with up to four inputs, using brackets: e.g. Z = NOT(A + B) + B·C.

Boolean from a truth table HIGHER

  1. Find every row where the output is 1.
  2. For each one, write an AND term using every input: write the input if it is 1 and NOT the input if it is 0. E.g. A = 0, B = 1, C = 1 gives Ā·B·C.
  3. OR the terms together: e.g. Z = Ā·B·C + A·B·C̄.
  4. Draw the circuit straight from the expression, then convert to NAND gates if asked.

With 4 inputs a truth table has 24 = 16 rows. Circuits are often built from NAND gates because one type of IC (for example a chip with four 2-input NANDs) can make any function, so fewer types of chip are needed and costs fall.

Key terms

Writing a Boolean expressionGate by gate from the inputs, with brackets for the order.
Boolean from a truth tableAND term for each row where Z = 1; OR the terms together.
AND gateOutput 1 only when all inputs are 1.
OR gateOutput 1 when any input is 1.
NOT gateOutput is the opposite of the input.
Rows in a 3-input truth table8
NANDOutput 0 only when all inputs are 1.
NOROutput 1 only when all inputs are 0.
EOROutput 1 when the inputs are different.
NOT from NANDA NAND gate with its inputs joined.
Double inversionTwo NOTs in a row cancel, so they can be removed.

Quick check

1. NOT A into an OR gate with B, then AND with C gives…

  1. Z = Ā + B·C
  2. Z = Ā·B + C
  3. Z = (Ā + B)·C
  4. Z = (A + B)·C
Show answer
C: Z = (Ā + B)·C. Work gate by gate, using brackets.

2. Z = (A·B) + C. When A = 1, B = 0, C = 0, Z is…

  1. 2
  2. 1
  3. Undefined
  4. 0
Show answer
D: 0. A·B = 0 and C = 0.

3. Z = 1 only when A = 0 and B = 1. The Boolean expression is…

  1. Ā·B
  2. A·B
  3. A + B̄
  4. Ā + B
Show answer
A: Ā·B. Invert the input that is 0.

4. How many rows does a 4-input truth table have?

  1. 8
  2. 16
  3. 12
  4. 4
Show answer
B: 16. 2⁴.

5. A=1, B=0 into an AND gate gives…

  1. Both
  2. 1
  3. 0
  4. Neither
Show answer
C: 0. All inputs must be 1.

6. A=1, B=0 into an OR gate gives…

  1. 0
  2. 2
  3. Undefined
  4. 1
Show answer
D: 1. Any input 1.

7. How many rows does a 3-input truth table have?

  1. 8
  2. 6
  3. 3
  4. 9
Show answer
A: 8. 2³.

8. Which gate gives 1 only when its inputs differ?

  1. NAND
  2. EOR
  3. NOR
  4. AND
Show answer
B: EOR. Exclusive OR.

Printable worksheet

An I do, we do, you do worksheet for this topic, with a separate answer sheet.

Worksheet (PDF)Answers (PDF)