Hardware

Hardware

Logic gates and truth tables

Logic Gates and Logic Circuits AS Level 11 min read

On this page
  1. What you need to be able to do
  2. The six gates
  3. Describing a gate in words
  4. Mark-scheme focus
  5. Worked examples
  6. Summary
  7. Can I do this?
  8. Quiz

What you need to be able to do

Syllabus 3.2 Logic gates and logic circuits
  • 3.2Use and draw the symbols for NOT, AND, OR, NAND, NOR and XOR gates (all two-input except NOT).
  • 3.2Describe the function of each gate and construct its truth table.

Next: Logic circuits, expressions and truth tables, where gates are combined.

Inside a processor every decision is made by logic gates: tiny electronic switches whose inputs and output are each 0 or 1 (low or high voltage). A truth table lists the output for every possible combination of inputs: 2 rows for one input, 4 for two, 8 for three.

The six gates

AX
NOT gate

NOT

One input; the output is the opposite (inverse) of the input.

AOutput
01
10
ABX
AND gate

AND

Output is 1 only when both inputs are 1.

ABOutput
000
010
100
111
ABX
OR gate

OR

Output is 1 when either or both inputs are 1; 0 only when both are 0.

ABOutput
000
011
101
111
ABX
NAND gate

NAND

NOT AND: output is 0 only when both inputs are 1, otherwise 1.

ABOutput
001
011
101
110
ABX
NOR gate

NOR

NOT OR: output is 1 only when both inputs are 0, otherwise 0.

ABOutput
001
010
100
110
ABX
XOR gate

XOR

Exclusive OR: output is 1 when the inputs are different; 0 when they are the same.

ABOutput
000
011
101
110
Draw the shapes carefully. The reports (November 2022, June 2023) saw OR and AND gates that couldn't be told apart, NOT gates without the small circle, and XOR drawn like NOR. The circle means “NOT” (inverted output); the extra curved line at the inputs marks XOR.
GateSame asHow to remember it
NANDNOT (A AND B)AND's output column, flipped: 0 0 0 1 → 1 1 1 0
NORNOT (A OR B)OR's output column, flipped: 0 1 1 1 → 1 0 0 0
XOR(A OR B) AND NOT (A AND B)“one or the other, but not both”: 0 1 1 0

Describing a gate in words

A description must cover every combination of inputs: say when the output is 1 (or 0) and that it is the other value otherwise.

1 NAND

Describe the operation of a NAND gate.

AskeddescriptionKnowAND flippedRoutewhen is it 0?

  1. The output is 0 only when both inputs are 1; otherwise the output is 1

“A NAND gate is the opposite of an AND gate” was not enough (June 2023): describe the outputs.

2 NOR

Describe the operation of a NOR gate.

AskeddescriptionKnowOR flippedRoutewhen is it 1?

  1. The output is 1 only when both inputs are 0; otherwise 0

3 XOR

Describe the operation of a 2-input XOR gate.

AskeddescriptionKnowexclusiveRoutedifferent inputs

  1. The output is 1 only if one input is 1 and the other is 0 (the inputs are different); 0 if they are the same

4 Which input gives 1?

Give one pair of inputs that makes a NOR gate output 1, and one that makes a NAND gate output 1.

Askedinput pairsKnowNOR: 1 only for 0,0; NAND: 1 unless 1,1Routeread the tables

  1. NOR: A = 0, B = 0 (the only pair)
  2. NAND: any pair except 1, 1, e.g. A = 0, B = 1

Mark-scheme focus

Describe the function of the NAND and NOR gates (2 marks)

9618/11/M/J/23 Q5Paper 1 · Theory fundamentalsPart (b)2 marksFull size
(b) Describe the function of the NAND and NOR logic gates. NAND … NOR … [2]
Credited
  • NAND: 0 is only output when both inputs are 1 // 1 is output when none or one of the inputs is 1 B1
  • NOR: 1 is only output when both inputs are 0 // 0 is output when one or both inputs are 1 B1
Not credited
  • “NAND is the opposite of AND” / “NOR is NOT OR” with no outputs
  • Describing AND and OR instead
Why

The function of a gate is its output for each input combination; “opposite of AND” leaves the examiner to work it out.

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

Describe the operation of NAND, NOR, XOR and OR (4 marks)

9618/12/M/J/24 Q1Paper 1 · Theory fundamentalsPart (a)4 marksFull size
(a) Describe the operation of each of the following logic gates: NAND, NOR, XOR, OR. [4]
Credited
  • NAND: the output is 0 when both inputs are 1, otherwise the output is 1 B1
  • NOR: the output is 1 when both inputs are 0, otherwise 0 B1
  • XOR: the output is 1 when one input is 1 and the other is 0, otherwise 0 B1
  • OR: the output is 0 when both inputs are 0, otherwise 1 B1
Not credited
  • “OR: the output is 1 if one input is 1” (what if both are 1?)
  • XOR described as OR

From: 9618/12/M/J/24 Q1(a)

  • A gate question in almost every paper: describe gates (1-4 marks), tick / match the gate, complete gate truth tables, or give inputs for an output.
  • Lost marks: NAND / NOR swapped, XOR confused with OR or NOR, careless symbols.

Worked examples

Example 1 · Which gate does each statement describe? (Paper 1, 3 marks) ★ Easy
9618/11/M/J/21 Q8Paper 1 · Theory fundamentals3 marksFull size
Tick one box in each row to identify the logic gate (AND, NAND, NOR, XOR, OR) that each statement describes: the output is 1 only when both inputs are 1; the output is 1 only when both inputs are different; the output is 1 only when both inputs are 0. [3]
1 Read it with me what is actually happening?

One tick per row - more than one scores nothing for that row (June 2021).

  • only whenthe one case that gives 1
2 What is it asking for? the target, part by part
  • Whole3 rows3
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
    • Rows
      • both 1AND
      • differentXOR
      • both 0NOR
    5 Now solve it have a go on paper first, then open the worked solution
    1. 1 only when both inputs are 1 → AND B1
    2. 1 only when both inputs are different → XOR B1
    3. 1 only when both inputs are 0 → NOR B1
    6 Check it does the answer make sense?

    Each statement picks out exactly one row of a 2-input truth table ✓.

    Example 2 · One set of inputs for an output of 1 (Paper 1, 4 marks) ★★ Medium
    9618/11/M/J/22 Q2Paper 1 · Theory fundamentalsPart (c)(i)4 marksFull size
    (c) Computers consist of logic gates. (i) Complete the table by writing one set of values (input 1 and input 2) for each gate (AND, NAND, XOR, NOR) that will give the output 1. [4]
    1 Read it with me what is actually happening?

    For each gate find a row of its truth table with output 1.

      2 What is it asking for? the target, part by part
      • (c)(i)4 rows4
      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
        • Rows
          • ANDonly 1,1
          • NANDanything but 1,1
          • XORdifferent
          • NORonly 0,0
        5 Now solve it have a go on paper first, then open the worked solution
        1. AND: 1, 1 B1
        2. NAND: 0, 0 or 0, 1 or 1, 0 B1
        3. XOR: 0, 1 or 1, 0 B1
        4. NOR: 0, 0 B1
        6 Check it does the answer make sense?

        Check each in the gate tables above ✓.

        Example 3 · Truth tables for NOR and NAND (Paper 1, 2 marks) ★ Easy
        9618/12/O/N/21 Q2Paper 1 · Theory fundamentalsPart (a)2 marksFull size
        (a) Complete the truth table for each of the following two logic gates (two gate symbols are shown, with inputs A and B). [2]
        1 Read it with me what is actually happening?

        Identify each symbol first: a bubble on an OR shape is NOR; a bubble on an AND shape is NAND.

        • the circleNOT on the output
        2 What is it asking for? the target, part by part
        • (a)two tables2
        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. First gate (OR shape + circle) = NOR: outputs 1, 0, 0, 0 B1
            2. Second gate (AND shape + circle) = NAND: outputs 1, 1, 1, 0 B1
            6 Check it does the answer make sense?

            The report: some candidates swapped the NAND and NOR tables ✓ - always identify the shape first.

            Summary

            ABANDORNANDNORXOR
            0000110
            0101101
            1001101
            1111000
            • NOT inverts. NAND = AND then NOT; NOR = OR then NOT. XOR = 1 when the inputs differ.
            • Describe a gate by its outputs for every input combination.
            • Circle = NOT; extra input curve = XOR.

            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 NAND and NOR called universal gates?Show answer

            Any other gate (and so any circuit) can be built from NAND gates alone, or NOR gates alone: e.g. A NAND A = NOT A. That is why flash memory is built from NAND or NOR cells.

            2How many rows does a truth table with 4 inputs need?Show answer

            2⁴ = 16: each extra input doubles the rows.

            Exam-style practice

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

            Q19618/13/O/N/24 Q1Paper 1 · Theory fundamentalsPart (a)1 markFull size
            (a) Describe the operation of a 2-input XOR gate. [1]
            Show the mark scheme
            PartAnswer / workingMarksGuidance
            (a)Output is only 1 if one input is 1 and the other is 0 // only 1 if both inputs are different // only 0 if both inputs are the sameB1
            Total: 1 mark
            Q2Past-paper style3 marks

            Draw the symbol and complete the truth table for a NAND gate, then state one pair of inputs for which its output is 0.

            1. [3]
            Show the mark scheme
            PartAnswer / workingMarksGuidance
            AND-shaped symbol with a circle on the outputB1
            Outputs 1, 1, 1, 0 (inputs 00, 01, 10, 11)B1
            Output 0 only for A = 1, B = 1B1
            Total: 3 marks

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