Year 10 · Computer Science · Autumn 2

Data transmission and Boolean logic · Lesson 5 of 5

Logic gates, truth tables and circuits

Exam practice10.1 The six logic gates10.2 Truth tables10.3 Expressions and circuits

Year 10 · Computer Science · Data transmission and Boolean logic · Lesson 5 of 5

You will learn to

  • State the rule, symbol and truth table for NOT, AND, OR, NAND, NOR and XOR.
  • Calculate the number of rows a truth table needs: 2 to the power of the number of inputs.
  • Write a logic expression from a circuit, and draw a circuit from an expression.
  • Complete a truth table for a three-input circuit, using working columns.

Year 10 · Computer Science · Data transmission and Boolean logic · Lesson 5 of 5

Success criteria

You have got it when you can say:

  • I can draw all six gates and fill in their truth tables from memory.
  • I can list the 8 input rows for three inputs in order, from 000 to 111.
  • I can turn a past-paper circuit into an expression and a truth table.

Year 10 · Computer Science · Data transmission and Boolean logic · Lesson 5 of 5

Retrieval starter

Questions from before. Write your answers, then show them.

  1. Last lesson

    Parity can…

    A Detect and fix any errorB Detect one flipped bit but not fix itC Detect two flipped bits

    B. Detect one flipped bit but not fix it

  2. Last unit

    Which of these is lossy?

    A JPEGB PNGC ZIP

    A. JPEG

  3. Earlier this unit

    ARQ stands for…

    A Average rate queryB Automatic repeat requestC Address resolution question

    B. Automatic repeat request

Year 10 · Computer Science · Data transmission and Boolean logic · Lesson 5 of 5

Key words (1 of 4)

Boolean logic
Logic that uses only two values, 1 (true, on) and 0 (false, off).
Logic gate
An electronic component that takes one or two inputs and gives one output by a fixed rule.
Truth table
A table that lists every possible input combination and the output for each one.
Logic circuit
Two or more logic gates joined together to give one output.

Year 10 · Computer Science · Data transmission and Boolean logic · Lesson 5 of 5

Key words (2 of 4)

Logic expression
A written description of a circuit using gate names, such as X = A AND NOT B.
NOT
A one-input gate whose output is the opposite of its input; also called an inverter.
AND
A gate whose output is 1 only when both inputs are 1.
OR
A gate whose output is 1 when at least one input is 1.

Year 10 · Computer Science · Data transmission and Boolean logic · Lesson 5 of 5

Key words (3 of 4)

NAND
NOT AND: the output is 0 only when both inputs are 1.
NOR
NOT OR: the output is 1 only when both inputs are 0.
XOR (EOR)
Exclusive OR: the output is 1 when the two inputs are different.
Input
A signal going into a gate or circuit, such as a sensor reading of 1 or 0.

Year 10 · Computer Science · Data transmission and Boolean logic · Lesson 5 of 5

Key words (4 of 4)

Output
The single result signal that comes out of a gate or circuit.
Working column
An extra truth-table column holding the output of one gate inside a circuit.
Sum of products
An expression made by AND-ing the inputs of each row with output 1, then OR-ing those groups together.

10.1 The six logic gates · The explanation · step 1 of 13 · part 1 of 2

1 and 0: the language of logic

Boolean logic works with only two values: 1 and 0. 1 means on, true or yes. 0 means off, false or no.

A logic gate is a tiny electronic switch inside a chip. It takes one or two inputs and gives one output.

A truth table lists every possible input combination and the output for each one. It is the full description of what a gate or circuit does.

10.1 The six logic gates · The explanation · step 1 of 13 · part 2 of 2

1 and 0: the language of logic (continued)

e.g.Example
A door sensor: door open = 1, door closed = 0. A light: on = 1, off = 0. A gate decides whether the light goes on, using the sensor values.
?Why?

Computers use 1 and 0 because an electric signal is easy to read as two states, high voltage or low voltage. Two states leave little room for error.

10.1 The six logic gates · The explanation · step 2 of 13 · part 1 of 2

NOT gate: flips the input

NOT has one input. The output is the opposite of the input.

Input 1 gives output 0. Input 0 gives output 1. It is also called an inverter.

Symbol: a triangle with a small circle at the tip. The small circle always means "flip it".

AQ = NOT A
01
10

10.1 The six logic gates · The explanation · step 2 of 13 · part 2 of 2

NOT gate: flips the input (continued)

e.g.Example
A night light: X = NOT L, where L = 1 when it is light outside. Daytime: L = 1, so X = 0 (light off). Night: L = 0, so X = 1 (light on).

10.1 The six logic gates · The explanation · step 3 of 13 · part 1 of 2

AND and OR

AND: the output is 1 only when input A and input B are both 1. Think of two switches in a row: both must be closed for the bulb to light.

OR: the output is 1 when A or B is 1, or both are. Think of two switches side by side: either one lights the bulb.

AND has a flat back and a round front. OR has a curved back and a pointed front.

10.1 The six logic gates · The explanation · step 3 of 13 · part 2 of 2

AND and OR (continued)

ABA AND BA OR B
0000
0101
1001
1111
e.g.Example
A metro ticket gate opens (1) only if the card is valid AND the card has credit → AND. A shop bell rings (1) if the front door OR the back door opens → OR.

10.1 The six logic gates · The explanation · step 4 of 13 · part 1 of 3

NAND and NOR: AND and OR, then flipped

NAND means NOT AND. Work out AND, then flip the answer. The output is 0 only when both inputs are 1.

NOR means NOT OR. Work out OR, then flip the answer. The output is 1 only when both inputs are 0.

Their symbols are the AND and OR symbols with the small "flip" circle on the output.

10.1 The six logic gates · The explanation · step 4 of 13 · part 2 of 3

NAND and NOR: AND and OR, then flipped (continued)

ABA NAND BA NOR B
0011
0110
1010
1100
?Why?

Put the NAND column next to the AND column and every value is flipped. The same is true for NOR and OR. This is a quick way to check your table.

10.1 The six logic gates · The explanation · step 4 of 13 · part 3 of 3

NAND and NOR: AND and OR, then flipped (continued)

!Watch out

NAND is not "NOT A AND NOT B". You do the AND first, then flip the single answer.

10.1 The six logic gates · The explanation · step 5 of 13 · part 1 of 3

XOR: one or the other, not both

XOR (exclusive OR, also written EOR) gives 1 when the inputs are different.

If both inputs are the same, both 0 or both 1, the output is 0.

Symbol: the OR symbol with an extra curved line behind it.

10.1 The six logic gates · The explanation · step 5 of 13 · part 2 of 3

XOR: one or the other, not both (continued)

ABA XOR B
000
011
101
110

10.1 The six logic gates · The explanation · step 5 of 13 · part 3 of 3

XOR: one or the other, not both (continued)

e.g.Example
A landing light with a switch at the top and bottom of the stairs. Flip either switch and the light changes. This is XOR. Both down (0, 0) → off. One up (0, 1) → on. Both up (1, 1) → off.
!Watch out

OR and XOR only differ in the last row. When A = 1 and B = 1, OR gives 1 but XOR gives 0.

The explanation · 8 more steps

More on the lesson page

The lesson page has the rest of the explanation, step by step:

  • All six symbols together
  • How many rows?
  • Filling in the inputs: count in binary
  • Working columns for a 3-input circuit
  • From a statement to an expression
  • From an expression to a circuit
  • From a circuit to an expression
  • From a truth table to an expression

Open the lesson page

Year 10 · Computer Science · Data transmission and Boolean logic · Lesson 5 of 5

Try it: Play with logic gates

Year 10 · Computer Science · Data transmission and Boolean logic · Lesson 5 of 5

The maths: Rows in a truth table

Symbols first, then the words, then the equation. Change the numbers.

Year 10 · Computer Science · Data transmission and Boolean logic · Lesson 5 of 5

The maths: Logic gates as arithmetic

Symbols first, then the words, then the equation. Change the numbers.

Year 10 · Computer Science · Data transmission and Boolean logic · Lesson 5 of 5

Quick quiz · 1 of 3

XOR gives 1 when…

  1. A Exactly one input is 1
  2. B Neither input is 1
  3. C Both inputs are 1

A. Exactly one input is 1

Exclusive OR: one or the other, not both.

Year 10 · Computer Science · Data transmission and Boolean logic · Lesson 5 of 5

Quick quiz · 2 of 3

A truth table for 3 inputs has…

  1. A 6 rows
  2. B 8 rows
  3. C 3 rows

B. 8 rows

2 to the power of 3 combinations.

Year 10 · Computer Science · Data transmission and Boolean logic · Lesson 5 of 5

Quick quiz · 3 of 3

NAND is…

  1. A AND followed by NOT
  2. B NOT followed by AND
  3. C OR followed by NOT

A. AND followed by NOT

Not-AND: the opposite output of AND.

Year 10 · Computer Science · Data transmission and Boolean logic · Lesson 5 of 5

Exit ticket

Answer on paper before you go. Then check.

  1. With A = 1 and B = 1, A OR B is…

    A 1B 0C 2

    A. 1 OR is true when at least one input is 1, including both.

  2. X = (A AND B) OR C with A = 0, B = 1, C = 1 gives…

    A 0B 1C Cannot tell

    B. 1 A AND B = 0. Then 0 OR 1 = 1.

Year 10 · Computer Science · Data transmission and Boolean logic · Lesson 5 of 5

Homework and the challenge

Homework

The CS 2 and CS 10 quizzes; the logic gates study page to the quiz.

End-of-unit challenge

End-of-unit test: past-paper questions on topics 2 and 10.