100% found this document useful (1 vote)
181 views

T1 Boolean Logic GCSE Computer Science

Uploaded by

HazzaYT Hicks
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
181 views

T1 Boolean Logic GCSE Computer Science

Uploaded by

HazzaYT Hicks
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 45

Objectives

• Construct truth tables for the following logic gates:


• NOT
• AND
• OR
• XOR

• Construct truth tables for simple logic circuits


• Interpret the results of truth tables
• Create, modify and interpret simple circuit diagrams
• Create Boolean expressions for a simple logic circuit
and vice versa
Boolean logic
Unit 4 Computer systems

Starter
• Consider a safe with two keys
• If both keys are used,
the safe will open
IF key1 AND key2 THEN
safeOpen ← True
ELSE
safeOpen ← False
• What are the only possible
values that key1 and key2
can be?
• What values must they be to open the safe?
Boolean logic
Unit 4 Computer systems

Starter
IF key1 AND key2 THEN
safeOpen ← True
ELSE
safeOpen ← False
• What are the only possible values that key1 and
key2 can be?
• Key1 and key2 can only be True or False (lock or unlock)

• What values must they be to open the safe?


• They must both be True to open the safe
Boolean logic
Unit 4 Computer systems

Binary situations
• Binary situations are common in
daily life and can refer to things
that can be in only one of two
states:
• Stop or Go
• Pass or Fail
• On or Off

• In computing terms
• A binary 1 can represent True
• A binary 0 can represent False
Boolean logic
Unit 4 Computer systems

Booleans in loops
• Booleans used in IF
statements and loops
WHILE doorOpen
turnOnLight()
ENDWHILE
Boolean logic
Unit 4 Computer systems

True or False?
Unlocking a smartphone:
• using a known fingerprint or
• using a correct PIN code?
IF fingerprint OR correctPIN THEN
unlock ← True
ELSE
unlock ← False
ENDIF
Boolean logic
Unit 4 Computer systems

Boolean functions
• AND, OR and NOT are Boolean operators
• A computer can calculate the results of A AND B,
A OR B, or NOT A
• What do these two circuit diagrams represent?

Input Output
A B

A
Input Output
B
Boolean logic
Unit 4 Computer systems

Boolean functions
• What do these two circuit diagrams represent?
AND
Input Output Both switches must be down
A B to complete the circuit

OR
A Either switch needs to be
Input Output
down to complete the circuit
B
Boolean logic
Unit 4 Computer systems

Truth tables
• A truth table shows the output from all possible
combinations of inputs from a Boolean expression
• If there are two inputs A AND B, there are four possible
combinations of TRUE and FALSE
• Both A and B must be True for the output to be True

Input A Input B A AND B


False False False
False True False
True False False
True True True
Boolean logic
Unit 4 Computer systems

Boolean function – AND


• It is also possible to use 1 and 0 to represent True
and False
• The below truth tables represent: IF a lift is on the correct floor
AND the call button has been pressed THEN open the lift door
• What are the values for Open Life Door and P below
Lift on
Button Open Lift
correct
Pressed Door
floor A B P
False False ? 0 0 ?
False True ? 0 1 ?
True False ? 1 0 ?
True True ?
1 1 ?
Boolean logic
Unit 4 Computer systems

Truth table – AND


• IF both inputs are TRUE then the output
is TRUE

Lift on Open
Button
correct Lift A B P
Pressed
floor Door
0 0 0 0 0 0
0 1 0 0 1 0
1 0 0 1 0 0
1 1 1
1 1 1
Boolean logic
Unit 4 Computer systems

Boolean function – OR
• IF lane1Open OR lane2Open
• If lane one is open OR lane 2 is open then you can drive
down the road
• What is P?

lane1 lane2
P A B P
Open Open

False False ? 0 0 ?
False True ? 0 1 ?
True False ? 1 0 ?
True True ? 1 1 ?
Boolean logic
Unit 4 Computer systems

Boolean function – OR
• IF lane1Open OR lane2Open
• If lane one is open OR lane 2 is open then you can drive
down the road
• What is P?

lane1 lane2
P A B P
Open Open

False False False 0 0 0


False True True 0 1 1
True False True 1 0 1
True True True 1 1 1
Boolean logic
Unit 4 Computer systems

Boolean function – NOT


• IF the input is True then the output is False
• IF the input is False then the output is True

Input A Output P = NOT A


False True
True False
Boolean logic
Unit 4 Computer systems

More logic
Which of the following statements are True?
• (4 > 3) AND (5 > 7)
• (2 < 8) OR (8 > 10)
• NOT (5 * 7 > 30)
• ((7 DIV 3) >= 2) OR ((7 DIV 3) < 2)
• ((12 MOD 5) < 2) AND ((12 MOD 5) == 2)
• DIV gives the integer division (the result of division without any
fractional component)
• MOD gives the remainder after a division
Boolean logic
Unit 4 Computer systems

More logic
Which of the following statements are True?
• (4 > 3) AND (5 > 7) False
• (2 < 8) OR (8 > 10) True
• NOT (5 * 7 > 30) False
• ((7 DIV 3) >= 2) OR ((7 DIV 3) < 2) True
• ((12 MOD 5) < 2) AND ((12 MOD 5) == 2) False
Boolean logic
Unit 4 Computer systems

Worksheet 1
• Now complete Task 1 on Worksheet 1
Boolean logic
Unit 4 Computer systems

From truth tables to logic gates


• Physical circuits are built using logic gates
• Four key gates and the logic symbols that represent
them are:

Example with
Logic gate Logic symbol Meaning
logic symbols
AND . A.B A AND B
OR + A+B A OR B
NOT A NOT A
XOR Ꚛ AꚚB A XOR B
Boolean logic
Unit 4 Computer systems

Binary logic – AND gate


• If both inputs are 1 (True) then the output is 1 (True)
• Otherwise the output is 0 (False)

A B P
INPUT
A 0 0 ?
OUTPUT
P 0 1 ?
INPUT
B 1 0 ?

Logic statement: P = A AND B 1 1 ?


Or: P = A.B

Logic Diagram Truth Table


Boolean logic
Unit 4 Computer systems

Binary logic – AND gate


• If both inputs are 1 (True) then the output is 1 (True)
• Otherwise the output is 0 (False)

A B P
INPUT
A 0 0 0
OUTPUT
P 0 1 0
INPUT
B 1 0 0

Logic statement: P = A AND B 1 1 1


Or: P = A.B

Logic Diagram Truth Table


Boolean logic
Unit 4 Computer systems

Binary logic – OR gate


• If either input is 1 (True) then the output is 1 (True)
• Otherwise the output is 0 (False)

A B P
INPUT
A 0 0 ?
OUTPUT
P 0 1 ?
INPUT
B 1 0 ?

Logic statement: P = A OR B 1 1 ?
Or: P = A+B

Logic Diagram Truth Table


Boolean logic
Unit 4 Computer systems

Binary logic – OR gate


• If either input is 1 (True) then the output is 1 (True)
• Otherwise the output is 0 (False)

A B P
INPUT
A 0 0 0
OUTPUT
P 0 1 1
INPUT
B 1 0 1

Logic statement: P = A OR B 1 1 1
Or: P = A+B

Logic Diagram Truth Table


Boolean logic
Unit 4 Computer systems

Binary logic – XOR gate


• If just one input is 1 (True) then the output is 1 (True)
• Otherwise the output is 0 (False)

A B P
INPUT
A 0 0 ?
OUTPUT
P 0 1 ?
INPUT
B 1 0 ?

Logic statement: P = A XOR B 1 1 ?


Or: P = AꚚB

Logic Diagram Truth Table


Boolean logic
Unit 4 Computer systems

Binary logic – XOR gate


• If just one input is 1 (True) then the output is 1 (True)
• Otherwise the output is 0 (False)

A B P
INPUT
A 0 0 0
OUTPUT
P 0 1 1
INPUT
B 1 0 1

Logic statement: P = A XOR B 1 1 0


Or: P = AꚚB

Logic Diagram Truth Table


Boolean logic
Unit 4 Computer systems

Binary logic – NOT gate


• If 0 is input it outputs 1 (True)
• If 1 is input it outputs 0 (False)

A P
INPUT OUTPUT 0 ?
A P
1 ?

Logic statement: P = NOT A


Or: A

Logic Diagram Truth Table


Boolean logic
Unit 4 Computer systems

Binary logic – NOT gate


• If 0 is input it outputs 1 (True)
• If 1 is input it outputs 0 (False)

A P
INPUT OUTPUT
0 1
A P
1 0

Logic statement: P = NOT A


Or: A

Logic Diagram Truth Table


Boolean logic
Unit 4 Computer systems

Worksheet 1
• Now complete Task 2 on Worksheet 1
Boolean logic
Unit 4 Computer systems

Combining logic gates


• We can combine logic gates together to make more
complex circuits

INPUT
A R OUTPUT
P
INPUT
B

A B R = A.B P=R
0 0
Logic statement:
0 1
P = A.B
1 0
1 1
Boolean logic
Unit 4 Computer systems

Combining logic gates


• We can combine logic gates together to make more
complex circuits

INPUT
A R OUTPUT
P
INPUT
B

A B R = A.B P=R
0 0 0
Logic statement:
0 1 0
P = A.B
1 0 0
1 1 1
Boolean logic
Unit 4 Computer systems

Combining logic gates


• We can combine logic gates together to make more
complex circuits

INPUT
A R OUTPUT
P
INPUT
B

A B R = A.B P=R
0 0 0 1
Logic statement:
0 1 0 1
P = A.B
1 0 0 1
1 1 1 0
Boolean logic
Unit 4 Computer systems

Modelling real life –


security lighting
• What would the circuit diagram for this situation
look like?
• The security light must come on if it senses
movement AND it is night time, OR if someone
presses a manual override switch
Boolean logic
Unit 4 Computer systems

Modelling real life


Sensor detects Night time Manual override Security
movement = TRUE = TRUE Button = TRUE Light On

AND OR =

Sensor detects
Movement (S)

Night time (N) Security


Light
Manual override
Button (B)
Boolean logic
Unit 4 Computer systems

The truth table


Sensor detects OUTPUT
Movement (S) R
Night time (N) Security
Light (P)
Manual override
Button (B)

S N B R = S.N P = R+B

Logic statement:
P = (S.N) + B
Boolean logic
Unit 4 Computer systems

The truth table


Sensor detects OUTPUT
Movement (S) R
Night time (N) Security
Light (P)
Manual override
Button (B)

S N B R = S.N P = R+B
0 0 0
0 0 1
0 1 0 Logic statement:
0 1 1 P = (S.N) + B
1 0 0
1 0 1
1 1 0
1 1 1
Boolean logic
Unit 4 Computer systems

The truth table


Sensor detects OUTPUT
Movement (S) R

Night time (N) Security


Light (P)
Manual override
Button (B)

S N B R = S.N P = R+B
0 0 0 0
0 0 1 0
0 1 0 0 Logic statement:
0 1 1 0 P = (S.N) + B
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
Boolean logic
Unit 4 Computer systems

The truth table


Sensor detects OUTPUT
Movement (S) R

Night time (N) Security


Light (P)
Manual override
Button (B)

S N B R = S.N P = R+B
0 0 0 0 0
0 0 1 0 1
0 1 0 0 0 Logic statement:
0 1 1 0 1 P = (S.N) + B
1 0 0 0 0
1 0 1 0 1
1 1 0 1 1
1 1 1 1 1
Boolean logic
Unit 4 Computer systems

Boolean expressions
• A Boolean expression can be created for a particular
logic circuit
• What is the Boolean expression for the following circuit?

A
B P

P=?
Boolean logic
Unit 4 Computer systems

Boolean expressions
• A Boolean expression can be created for a particular
logic circuit
• What is the Boolean expression for the following circuit?

A
B P

P = A Ꚛ (B OR C)
Boolean logic
Unit 4 Computer systems

Boolean expressions
• Logic circuits can be created from a simple
Boolean expression
• What is the logic circuit for the following Boolean expression?

P = A . (B.C)
Boolean logic
Unit 4 Computer systems

Boolean expressions
• Logic circuits can be created from a simple
Boolean expression
• What is the logic circuit for the following Boolean expression?

P = A . (B.C)

A
P

C
Boolean logic
Unit 4 Computer systems

Worksheet 1
• Now complete Task 3 on Worksheet 1
Boolean logic
Unit 4 Computer systems

Plenary
• Answer the following questions with a partner:
1. Name four logic gates?
2. What are the symbols for each of these logic gates?
3. Explain what each
logic gate does
4. What is a
truth table?
Boolean logic
Unit 4 Computer systems

Plenary
1. Name four logic gates?
• AND, OR, NOT, XOR

2. What are the symbols for each of these logic gates?


• AND OR NOT XOR

3. Explain what each logic gate does


• AND – Both inputs must be True for output to be True
• OR – At least one input must be True for output to be True
• NOT – The output is opposite to the input
• XOR – The output is True is only one of the inputs is True

4. What is a truth table? It shows all possible combinations of


inputs and the outputs they create
Boolean logic
Unit 4 Computer systems

Copyright

© 2020 PG Online Limited

The contents of this unit are protected by copyright.

This unit and all the worksheets, PowerPoint presentations, teaching guides and other associated files
distributed with it are supplied to you by PG Online Limited under licence and may be used and copied by you
only in accordance with the terms of the licence. Except as expressly permitted by the licence, no part of the
materials distributed with this unit may be used, reproduced, stored in a retrieval system, or transmitted, in any
form or by any means, electronic or otherwise, without the prior written permission of PG Online Limited.

Licence agreement

This is a legal agreement between you, the end user, and PG Online Limited. This unit and all the worksheets,
PowerPoint presentations, teaching guides and other associated files distributed with it is licensed, not sold, to
you by PG Online Limited for use under the terms of the licence.

The materials distributed with this unit may be freely copied and used by members of a single institution on a
single site only. You are not permitted to share in any way any of the materials or part of the materials with any
third party, including users on another site or individuals who are members of a separate institution. You
acknowledge that the materials must remain with you, the licencing institution, and no part of the materials may
be transferred to another institution. You also agree not to procure, authorise, encourage, facilitate or enable any
third party to reproduce these materials in whole or in part without the prior permission of PG Online Limited.

You might also like