Hardware

Hardware

Logic circuits, expressions and truth tables

Logic Gates and Logic Circuits AS Level 19 min read

On this page
  1. What you need to be able to do
  2. Expression → truth table
  3. Circuit → expression
  4. Expression → circuit
  5. Truth table → expression
  6. Problem statement → expression → circuit
  7. Mark-scheme focus
  8. Worked examples
  9. Summary
  10. Can I do this?
  11. Quiz

What you need to be able to do

Syllabus 3.2 Logic gates and logic circuits
  • 3.2Construct a truth table from a logic expression, a logic circuit or a problem statement.
  • 3.2Construct a logic expression from a logic circuit, a truth table or a problem statement.
  • 3.2Construct a logic circuit from a logic expression, a truth table or a problem statement.

You need: Logic gates and truth tables.

There are three ways of writing the same logic: an expression (words: X = (A AND B) OR NOT C), a circuit (gate symbols wired together) and a truth table (every input combination with its output). Each question gives you one and asks for another. Write expressions with the gate names (AND, OR, NOT…), not Boolean algebra symbols, and bracket every gate's inputs.

Expression → truth table

  1. List the inputs in binary counting order: 000, 001, 010 … 111 (the paper prints them for you).
  2. Find the innermost brackets and make a working column for each one, then for the next layer out, and so on.
  3. Fill each working column row by row using only the columns before it; the last column is the output.
  4. Don't forget a NOT outside the brackets: it inverts the whole bracket's column (a common slip, November 2022).

Example (computed): X = (A NOR B) NAND (C XOR B)

ABCA NOR BC XOR BX
000101
001110
010011
011001
100001
101011
110011
111001

Try it yourself. Fill every working cell, then the output: a wrong cell is explained from the columns it depends on. “Next expression” gives more.

Truth table dry run

ABCA NOR BC XOR BX
000101
001110
010011
011001
100001
101011
110011
111001
Use the working space. With the intermediate columns written down, a slip costs one cell, not the whole column; without them you can't find it. Write 0s and 1s clearly: overwritten digits that look like φ are not marked (November 2022).

Circuit → expression

  1. Start at the inputs (left). Label the output of each first-level gate with its little expression, e.g. A AND B.
  2. Move right: each gate's output = its gate name between its two input labels, in brackets: (A AND B) XOR C.
  3. A NOT gate (triangle + circle) on a wire puts NOT in front: NOT B.
  4. The final gate gives the whole expression. Don't simplify unless asked.
ABCBX
Working left to right: A AND B → (A AND B) XOR C → … OR NOT B.

Expression → circuit

  1. Find the innermost brackets: each one is a gate near the inputs.
  2. Draw one gate for each operator, all with two inputs (only NOT has one): A AND B AND C needs two AND gates.
  3. Wire each gate's output into the gate that uses it, working towards the single output.
  4. Draw NOT gates as a triangle with a circle; use the exact syllabus shapes so AND / OR and XOR / NOR can't be confused.
ABCDT
T = (NOT A OR B) XOR (C NAND D): a NOT gate on A only, then OR, NAND, and the XOR.
(NOT A) OR B is not A NOR B, and NOT A AND NOT B is not A NAND B. Moving a NOT changes the logic: NOT A AND NOT B is actually A NOR B. Draw exactly what the expression says. Both replacements were reported mistakes (June 2023, November 2022).
ABNOT A AND NOT BA NAND BA NOR B
00111
01010
10010
11000

Truth table → expression

  1. Find every row where the output is 1.
  2. For each one, write an AND term of all the inputs, with NOT in front of any input that is 0 in that row: row A=1, B=1, C=0 → (A AND B AND NOT C).
  3. Join the terms with OR (“sum of products”). That expression is always correct.
  4. Look for a simpler pattern before you write it all out: if the output simply copies (or inverts) one input, the answer is that input (or NOT it).
RSTQ
0000
0011
0100
0110
1000
1010
1101
1110

Q is 1 in two rows: R=0, S=0, T=1 and R=1, S=1, T=0, so Q = (NOT R AND NOT S AND T) OR (R AND S AND NOT T).

Problem statement → expression → circuit

  1. Give each condition its letter and note what 1 means (e.g. T = 1 means “too high”).
  2. Turn the words into gates: “and” → AND, “or” → OR, “not / off / acceptable / closed” when 1 means the opposite → NOT.
  3. Group with brackets exactly as the sentence groups the conditions (bullet points are usually separate brackets).
  4. Write the expression, then draw the circuit from it.

1 Greenhouse window

The window opens (X = 1) if the temperature is too high (T = 1) and the wind speed is acceptable (W = 0), and rain is not detected (R = 0) or the manual override is off (M = 0).

AskedXKnowacceptable / not / off = 0Routetwo bracketed groups ANDed

  1. First group: too hot AND wind acceptable → T AND NOT W
  2. Second group: no rain OR override off → NOT R OR NOT M
  3. X = (T AND NOT W) AND (NOT R OR NOT M)

NOT R OR NOT M must stay as two NOT gates into an OR: replacing it with a single NOR was a reported error (it means NOT (R OR M), a different thing).

2 Security floodlight

X = 1 if the system is on (E = 1) and it is dark (A = 1) and a person is detected (C = 1).

AskedXKnowall three conditionsRouteAND them

  1. X = E AND A AND C (two AND gates in a circuit)

3 Alarm

Y = 1 if the system is on (E = 1) and one or more doors (B, D) are open or a person is detected (C).

AskedYKnowon AND (any of three)RouteOR the three, then AND with E

  1. Y = E AND (B OR C OR D)
TWRMX
The greenhouse window circuit.

Mark-scheme focus

Draw the circuit for T = (NOT A OR B) XOR (C NAND D) (2 marks)

9618/11/M/J/23 Q5Paper 1 · Theory fundamentalsPart (a)2 marksFull size
(a) Draw the logic circuit for this logic expression: T = (NOT A OR B) XOR (C NAND D). [2]
Credited
  • 1 mark for 2 correct gates, 2 marks for all 4 gates (NOT on A, OR, NAND, XOR) with correct inputs
Not credited
  • NOT A OR B drawn as a NOR gate
  • Gate shapes that can't be told apart; NOT without its circle
Why

The report: “A common incorrect circuit was where the NOT A OR B had been incorrectly replaced with A NOR B.”

From: 9618/11/M/J/23 Q5(a)

Write the logic expressions for the security system (2 marks)

9618/11/O/N/24 Q5Paper 1 · Theory fundamentalsPart (b)2 marksFull size
(b) The floodlight (X) and audio alarm (Y): parameters A daylight low, B front door open, C person within 2 m, D back door open, E system on. X turns on if the system is on and the daylight is low and a person is detected. Y turns on if the system is on and one or more doors are open, or a person is detected. Write logic expressions for X and Y. [2]
Credited
  • X = E AND A AND C B1
  • Y = E AND (B OR C OR D) B1
Not credited
  • Y = E AND B OR C OR D (no brackets: the AND then binds only to B)
Why

The brackets carry the meaning: the system must be on for ANY of the three triggers.

From: 9618/11/O/N/24 Q5(b)

  • Logic is in every paper, usually Q1-Q5: complete a truth table (2), write an expression for a circuit (2-3), draw a circuit (2-4).
  • Marks for truth tables: 1 for the first four rows, 1 for the last four.
  • Lost marks: missing final NOT, XOR applied wrongly (whole column inverted), brackets in the wrong place, gate replacements.

Worked examples

Example 1 · A truth table from an expression (Paper 1, 2 marks) ★ Easy
9618/12/M/J/22 Q7Paper 1 · Theory fundamentals2 marksFull size
Complete the truth table for the following logic expression: X = (A XOR B) AND NOT C. [2]
1 Read it with me what is actually happening?

Two working columns: A XOR B, then NOT C; the output ANDs them.

  • AND NOT CC must be 0
2 What is it asking for? the target, part by part
  • Whole8 outputs2
3 What do we know? everything the question gives us
    4 Plan the route work backwards from what we want
    FindKey ideaAlready have itWork out firstTrap
    • X
      • Col 1A XOR B
      • Col 2NOT C
      • Xcol 1 AND col 2
    5 Now solve it have a go on paper first, then open the worked solution
    1. A XOR B: 0 0 1 1 1 1 0 0
    2. NOT C: 1 0 1 0 1 0 1 0
    3. X = 0 0 1 0 1 0 0 0 B2
    ABCA XOR BNOT CX
    000010
    001000
    010111
    011100
    100111
    101100
    110010
    111000
    6 Check it does the answer make sense?

    X is 1 only where A ≠ B and C = 0: rows 010 and 100 ✓.

    Example 2 · Expression, truth table and a missing gate (Paper 1, 8 marks) ★★ Medium
    9618/11/O/N/21 Q3Paper 1 · Theory fundamentals8 marksFull size
    A logic circuit is shown: A AND B feeds an XOR gate with C; B also feeds a NOT gate; the XOR output and NOT B feed an OR gate giving X. (a) Write the logic expression for the logic circuit. [3] (b) Complete the truth table. [2] (c) Identify one logic gate not used in the circuit, draw its symbol and complete its truth table. [3]
    1 Read it with me what is actually happening?

    Read the circuit left to right, label each gate's output, then use those labels as the working columns.

    • not usedgates in it: AND, XOR, NOT, OR → NAND or NOR are left
    2 What is it asking for? the target, part by part
    • (a)expression3
    • (b)table2
    • (c)gate + symbol + table3
    3 What do we know? everything the question gives us
      4 Plan the route work backwards from what we want
      FindKey ideaAlready have itWork out firstTrap
      • (a)
        • 1A AND B
        • 2… XOR C
        • 3… OR NOT B
      5 Now solve it have a go on paper first, then open the worked solution
      1. (a) A AND B B1 … XOR C B1 … OR NOT B B1: X = ((A AND B) XOR C) OR NOT B
      2. (b) X = 1 1 0 1 1 1 1 0 B2
      3. (c) e.g. NOR: OR shape with a circle; outputs 1 0 0 0 B3 (or NAND: 1 1 1 0)
      ABCA AND B(A AND B) XOR CNOT BX
      0000011
      0010111
      0100000
      0110101
      1000011
      1010111
      1101101
      1111000
      6 Check it does the answer make sense?

      Row 010: A AND B = 0, XOR C = 0, NOT B = 0, so X = 0 ✓.

      Example 3 · Draw the circuit, then the truth table (Paper 1, 6 marks) ★★ Medium
      9618/12/M/J/21 Q3Paper 1 · Theory fundamentals6 marksFull size
      A logic expression is given: S = (A AND B AND C) OR (B XOR C). (a) Draw the logic circuit for the given expression. [4] (b) Complete the truth table. [2]
      1 Read it with me what is actually happening?

      A AND B AND C needs two 2-input AND gates (a 3-input AND was also accepted).

        2 What is it asking for? the target, part by part
        • (a)circuit4
        • (b)table2
        3 What do we know? everything the question gives us
          4 Plan the route work backwards from what we want
          FindKey ideaAlready have itWork out firstTrap
          • (a)
            • GatesAND, AND, XOR, OR
          5 Now solve it have a go on paper first, then open the worked solution
          1. (a) one mark per correct gate with correct inputs: two ANDs, XOR, OR B4
          2. (b) S = 0 1 1 0 0 1 1 1 B2
          ABCBCS
          S = (A AND B AND C) OR (B XOR C), with 2-input gates.
          ABCA AND B(A AND B) AND CB XOR CS
          0000000
          0010011
          0100011
          0110000
          1000000
          1010011
          1101011
          1111101
          6 Check it does the answer make sense?

          Row 111: AND part 1, so S = 1 regardless of the XOR ✓.

          Example 4 · From a problem statement to a circuit (Paper 1, 3 marks) ★★★ Hard
          9618/12/O/N/22 Q3Paper 1 · Theory fundamentalsPart (a)3 marksFull size
          (a) A greenhouse window X: T temperature 1 too high, W wind speed 1 too high, R rain 1 detected, M manual override 1 on. The window opens if the temperature is too high and the wind speed is acceptable, and rain is not detected or the manual override is off. Draw a logic circuit to represent the operation of the window. [3]

          Why it is hard: three of the four inputs must be inverted, and only careful reading of the condition table shows which.

          1 Read it with me what is actually happening?

          Translate each phrase using the table: “acceptable” wind = W is 0 → NOT W; “not detected” → NOT R; “off” → NOT M.

          • acceptablethe 0 value → NOT
          • and / or between the bulletsthe grouping
          2 What is it asking for? the target, part by part
          • (a)circuit3
          3 What do we know? everything the question gives us
            4 Plan the route work backwards from what we want
            FindKey ideaAlready have itWork out firstTrap
            • X
              • Part 1T AND NOT W
              • Part 2NOT R OR NOT M
              • JoinAND
            Why not R NOR M for part 2?

            R NOR M is NOT (R OR M) = 1 only if both are 0; the statement says either one is enough.

            5 Now solve it have a go on paper first, then open the worked solution
            1. T AND NOT W B1
            2. NOT R OR NOT M B1
            3. final AND joining them B1
            TWRMX
            X = (T AND NOT W) AND (NOT R OR NOT M)
            6 Check it does the answer make sense?

            The report: missing NOT gates and replacing NOT R OR NOT M with a NOR gate were common ✓.

            Example 5 · An expression from a truth table (Paper 1, 2 marks) ★★ Medium
            9618/11/O/N/25 Q3Paper 1 · Theory fundamentalsPart (b)2 marksFull size
            (b) Write the logic expression for the following truth table: R S T Q: 000 0, 001 1, 010 0, 011 0, 100 0, 101 0, 110 1, 111 0. [2]
            1 Read it with me what is actually happening?

            Two rows give Q = 1: write an AND term for each and OR them.

              2 What is it asking for? the target, part by part
              • (b)expression2
              3 What do we know? everything the question gives us
                4 Plan the route work backwards from what we want
                FindKey ideaAlready have itWork out firstTrap
                  5 Now solve it have a go on paper first, then open the worked solution
                  1. Row 001: NOT R AND NOT S AND T B1
                  2. Row 110: R AND S AND NOT T, joined with OR B1
                  3. Q = (R AND S AND NOT T) OR (NOT R AND NOT S AND T)
                  6 Check it does the answer make sense?

                  Each term is 1 in exactly its own row ✓.

                  Summary

                  • Expression → table: working columns, innermost first; last column is the output.
                  • Circuit → expression: label gate outputs left to right, bracket each gate.
                  • Expression → circuit: one 2-input gate per operator, innermost first; NOT = triangle + circle.
                  • Table → expression: one AND term per 1-row (NOT for 0 inputs), OR the terms.
                  • Statement → expression: “acceptable / off / not” usually means NOT; brackets follow the sentence.
                  If you see…do this
                  NOT outside bracketsinvert the whole bracket's column last
                  A AND B AND Ctwo AND gates (2 inputs each)
                  a sentence with “or” inside an “and”brackets round the OR group
                  (NOT A) OR Ba NOT gate then OR - never NOR

                  Can I do this?

                  Anything unticked: revise that section first. All ticked: take the quiz.

                  Quiz

                  The multiple-choice and guided questions need JavaScript. The concept checks and exam practice below work without it.

                  Concept checks

                  Answer each one in your head first, then open it.

                  1Why are the truth table's input rows always in binary counting order?Show answer

                  So no combination is missed and every candidate's table lines up with the mark scheme's.

                  2Is there only one correct circuit for an expression?Show answer

                  No: equivalent circuits score if they give the same truth table and use the allowed gates (e.g. a NOR in place of OR then NOT), but the safest is to draw exactly what the expression says.

                  Exam-style practice

                  New questions, not used above. Do them on paper, then mark your work against the official mark scheme.

                  Q19618/12/M/J/23 Q6Paper 1 · Theory fundamentals4 marksFull size
                  (a) Draw the logic circuit for Z = (R XOR S) AND (NOT T NOR P). [2] (b) Complete the truth table for Z = (NOT P OR Q) XOR (R NOR Q). [2]
                  Show the mark scheme
                  PartAnswer / workingMarksGuidance
                  (a)Correct XOR and AND gates with correct inputsB1
                  Correct NOT and NOR gates with correct inputsB1
                  (b)First four rows: 0 1 1 1B1
                  Last four rows: 1 0 1 1B1
                  Total: 4 marks
                  Q29618/13/O/N/23 Q4Paper 1 · Theory fundamentals4 marksFull size
                  (a) Complete the truth table for Y = ((P AND Q) XOR ((NOT Q) OR R)) AND NOT P. [2] (b) Draw a logic circuit for the same expression. [2]
                  Show the mark scheme
                  PartAnswer / workingMarksGuidance
                  (a)First four rows: 1 1 0 1B1
                  Last four rows: 0 0 0 0B1NOT P makes every row with P = 1 output 0
                  (b)P AND Q and NOT Q OR RB1
                  NOT gate on P, the XOR and the final ANDB1
                  Total: 4 marks
                  Q39618/11/M/J/24 Q1Paper 1 · Theory fundamentals3 marksFull size
                  (a) Tick one box to identify the correct logic statement for the given truth table (outputs 1 0 0 0 0 0 1 0): NOT (A AND B AND C); (A XOR B) NOR C; (A OR B OR C) NOR C; NOT A AND NOT B AND NOT C. [1] (b) Draw a logic circuit for X = NOT (NOT A AND (NOT B XOR C)). [2]
                  Show the mark scheme
                  PartAnswer / workingMarksGuidance
                  (a)(A XOR B) NOR CB1
                  (b)NOT B XOR CB1
                  NOT A, the AND and the final NOTB1
                  Total: 3 marks
                  Q49618/13/M/J/24 Q6Paper 1 · Theory fundamentals3 marksFull size
                  Each of three truth tables has inputs A, B, C and output X. Draw one line to match each truth table with its logic expression: NOT (A XOR B) AND C; (A OR C) AND NOT B; A NAND B NAND C; (A NAND B) OR C; NOT (A AND B AND C). [3]
                  Show the mark scheme
                  PartAnswer / workingMarksGuidance
                  Table 1 (0 1 0 0 1 1 0 0) → (A OR C) AND NOT BB1
                  Table 2 (0 1 0 0 0 0 0 1) → NOT (A XOR B) AND CB1
                  Table 3 (1 1 1 1 1 1 0 1) → (A NAND B) OR CB1
                  Total: 3 marks
                  Q59618/12/O/N/25 Q9Paper 1 · Theory fundamentals4 marksFull size
                  (a) Write the logic expression for the given logic circuit. Do not simplify. [2] (b) For X = NOT ((A NAND B) XOR (NOT A OR NOT C)), the given truth table (outputs 1 0 1 0 1 0 1 1) has three errors. Identify the three row numbers with an incorrect output. [2]
                  Show the mark scheme
                  PartAnswer / workingMarksGuidance
                  (a)NOT (A XOR B)B1
                  NAND ((B AND C) OR A): X = (NOT (A XOR B)) NAND ((B AND C) OR A)B1
                  (b)Rows 2, 4 and 7B21 mark for one or two correct
                  correct outputs: 1 1 1 1 1 0 0 1
                  Total: 4 marks

                  Your progress on this note is saved when JavaScript is on.