0% found this document useful (0 votes)
17 views24 pages

Logic Gates and Truth tables

The document covers foundational concepts of computational thinking and programming, focusing on logic gates and truth tables. It introduces various types of logic gates including AND, NOT, OR, XOR, and NAND, explaining their functions, Boolean expressions, and how they can be combined to form logic circuits. Learning outcomes include understanding Boolean logic, binary logic's connection to computing, and the ability to create truth tables and logic circuits.

Uploaded by

Alistair Frame
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views24 pages

Logic Gates and Truth tables

The document covers foundational concepts of computational thinking and programming, focusing on logic gates and truth tables. It introduces various types of logic gates including AND, NOT, OR, XOR, and NAND, explaining their functions, Boolean expressions, and how they can be combined to form logic circuits. Learning outcomes include understanding Boolean logic, binary logic's connection to computing, and the ability to create truth tables and logic circuits.

Uploaded by

Alistair Frame
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

FOUNDATIONS

OF
COMPUTATIONAL
THINKING AND PROGRAMMING

Logic Gates & Truth tables


Revising ideas from the previous lesson

1. To refresh your knowledge on A B Q


the first logic gate we
studied, fill out the truth 0

table for AND logic gate that 0


will result in the following
0
outputs on the right
1
2. Draw a diagram of how the
AND Logic Gate is AND Truth Table
represented in Computer
Architecture
Revising ideas from the previous lesson

Answers are on the right


A B Q
Check carefully, you might have a
1 0 0
different order of bits in your
truth table for the first three lines 0 1 0

0 0 0
A
Q 1 1 1
B
AND Truth Table

AND Logic Gate


Learning outcomes
1. To review the idea of ‘Boolean logic’
2. To connect the idea of Binary logic to binary
number system and decision-making in computing
systems
3. To explore more types of logic gates,
their functions, representations and truth tables
4. To review how two or more logic gates could be
connected to form a logic circuit
Boolean logic

• In the previous session, we covered


AND logic gate
• Today we are going to review more
types of logic gates
• Keep in mind that logic gates will
function on Boolean logic
What is Boolean logic?
Introducing other logic gates

In today’s session we will cover more logic


gates. The most common are:
• AND (conjunction)
• NOT (negation)
• OR (disjunction)
• XOR (exclusive disjunction)
• NAND (alternative denial)
AND Gate (conjunction) A B Q

0 0 0

• Every logic gates takes a Boolean 0 1 0


expression. The Boolean expression of the
AND gate is written as follows: 1 0 0

Q=A∧B 1 1 1
where ∧ represents AND AND Truth Table

A
Q
B

AND Logic Gate


NOT Gate (negation)

• The NOT Gate takes one input and A Q


inverts it to output the opposite value.
0 1
• The circle represents the inverted 1 0
output
NOT gate truth
• The Boolean expression is written as table
Q = ¬A
where ¬ represents NOT
A Q

NOT gate
representation
NOT Gate (negation)

1. If the input to the NOT gate is


1, what is the output?
2. If the input to the NOT gate is
0, what is the output?
A Q

NOT gate representation


OR Gate (disjunction) A B Q
• The OR gate will display output as
True if either the A or B input is True 0 0 0

• The Boolean expression for the OR 0 1 1


Gate is
1 0 1
Q=A∨B
1 1 1
Where ∨ represents OR
OR gate truth table

A
B Q
OR gate representation
OR Gate (disjunction)
1. For the OR gate, if A is 0 and B is 1,
what is Q?
2. For the OR gate, if A is 1 and B is 1,
what is Q? A
B Q
3. For the OR gate, if A is 1 and B is 0,
what is Q?
OR gate representation
XOR Gate (exclusive
disjunction)
• The XOR gate will display output as A B Q
True if either the A or B input but not
0 0 0
when both are True. (Compare to OR
gate) 0 1 1
• The Boolean expression for the XOR
1 0 1
Gate is
Q=A⊻B 1 1 0

Where ⊻ represents XOR XOR gate truth table

Q = A ⊻ B is the same as
A
Q = (A ∧ ¬B) ∨ (¬A ∧ B) Q
B
XOR gate representation
XOR Gate (exclusive disjunction)

1. For the XOR gate, if A is 0 and B is


0, what is Q?
2. For the XOR gate, if A is 1 and B is A
Q
1, what is Q? B
3. For the XOR gate, if A is 1 and B is XOR gate representation

0, what is Q?
NAND Gate (alternative denial)

• The NAND gate will display output as A B Q


False if both the A or B input is True
only. (Compare to AND gate) 0 0 1

• The Boolean expression for the NAND 0 1 1


Gate is
1 0 1
Q = ¬(A ∧ B)
1 1 0

NAND gate truth


table
A
Q
B
NAND gate
representation
NAND Gate (alternative denial)

1. For the NAND gate, if A is 1 and B


is 1, what is Q?
2. For the NAND gate, if B is 1 and A A
is 0, what is Q?
B Q
3. For the NAND gate, if A is 0 and B
is 0, what is Q?
Logic Circuits
• In CPU circuitry, multiple logic gates
are connected to produce an output
based on multiple inputs
• On the right you can see the
combination of the AND gate with a
NOT gate
Applying what you have learned in this A Q
session, answer the following questions: B
1. If the input for A is 0 and the input
for B is 1, what is Q?
2. If the input for A is 1 and the input
for B is 1, what is Q?
Logic Circuits

• For a further example, let’s combine


AND and OR for a more complex If it is sunny
logical statement AND if it is
• Consider the following set of warm,
conditions on the right OR if it is my
birthday,
I am going to
go to the
beach
Logic Circuits: Task

Consider the following set of conditions If it is sunny AND


on the right and do the following 2
tasks: if it is warm,
OR if it is my
1. Visualise these conditions in a logic
gate circuit (you need to connect 2 birthday,
gates together) I am going to go
2. Produce a truth table to represent to the beach
this
You have 15 minutes to complete the
task
Logic Gates: Answers

A B C Q
A 0 0 0 0
B Q 0 0 1 1
C 0 1 0 0
1. We need to combine 1 0 0 0
the AND gate with the 1 0 1 1
OR gate to represent
the condition below 1 1 0 1
1 1 1 1
If it is sunny AND if it is warm, 2. Just like any algebraic equation, the A
OR if it is my birthday, and B condition needs to be evaluated
I am going to go to the beach first, then we evaluate the C
The expression for this logic table will
look like this: Q = (A ∧ B) ∨ C
Learning outcomes
1. We reviewed the idea of ‘Boolean logic’
2. We connected the idea of Binary logic to binary
number system and decision-making in computing
systems
3. We explored more types of logic gates,
their functions, representations and truth tables
4. We reviewed how two or more logic gates could be
connected to form a logic circuit
Revising ideas from today’s session

Correct the mistakes in the following summary


(2 errors):
One electronic logic gates can take one or
more inputs and produce many possible
outputs. This output can become the input
to another gate. Logic gates use Boolean
expressions AND, OR, XOR and NOT and
work on logic.
Revising ideas from today’s session

Correct the mistakes in the following summary


(2 errors):
One electronic logic gates can take one or
more inputs and produce many possible
outputs one possible output. This output can
become the input to another gate. Logic gates
use Boolean expressions AND, OR, XOR (XOR
is not a Boolean expression, it is the name of
a logic gate) and NOT and work on logic.
Revising ideas from today

1. Explain the properties of the


following logic gates: AND,
OR, NOT, XOR and NAND
2. What is a logic gate circuit? D
A
3. What is a truth table?
Q
4. Look at the logic circuit on the E
B
right and write a Boolean C
expression that represents it
5. Produce the truth table for the
circuit on the right
Topics and key vocabulary from
today:
• Logic Gates
• Truth tables What questions do
• Boolean expressions you have at the
• NOT gate end of this lesson?
• OR gate
• NOR gate
• XOR gate
• NAND gate
• Logic circuit

You might also like