Mastering Logic Gates and Truth Tables WHAT IS B O O L E A N? LO G I C G AT E S.

Download Report

Transcript Mastering Logic Gates and Truth Tables WHAT IS B O O L E A N? LO G I C G AT E S.

Mastering Logic Gates and Truth
Tables
WHAT IS B O O L E A N?
LO G I C G AT E S – T YPE S
CO R R E S PO NDING T R U T H TA B L E S
DR AWI NG CIR CUIT DI AG R A MS
VID E O S INCL UDED (D E MO S O F LO G IC G AT E ) U S I NG
 LO GI C.LY/DE MO
* A L S O S E E PR E SE NTATI ONS O N B O O L E A N LO G I C
Purchase the full teaching package (KS3, GCSE and A Level topics from www.teachingcomputing.com
Did you know?
Have you ever looked inside your
computer? The internal circuitry of
computers is a bit of a mystery.
Have a look at the mother board
on the right.
Logic Gates play a big role in
understanding the circuitry of
computers. Digital systems are
basically constructed using logic
gates that operate using Boolean
logic
Source: Wires N Code
An Electronics Project Website
What is Boolean?!
In computer science, the Boolean data type is
a data type, having two values (usually
denoted true (1) and false (0), intended to
represent the truth values of logic and
Boolean algebra.
It is named after George Boole, who first
defined an algebraic system of logic in the
mid 19th century.
Example: Data type: Seat booked? Options
are True (1) or False (1)
… and what is a logic gate?
In electronics, a logic gate is an idealized or physical device implementing
a Boolean function; that is, it performs a logical operation on one or
more logical inputs, and produces a single logical output.
Logic gates are primarily implemented using diodes or
transistors acting as electronic switches, but – and this is
interesting - can also be constructed using vacuum tubes,
electromagnetic relays (relay logic), fluidic logic,
pneumatic logic, optics, molecules, or even mechanical
elements.
Logic circuits include such devices as ALUs*, computer memory, and
complete CPU** chips, which may contain more than 100 million gates
Logic Gates and Circuitry
Learning about logic gates will give you
an insight into the circuitry of computers
and how they work.
You’ll remember that computers don’t
understand English – all they can make
sense of is: Binary (0) and (1) as
computers are basically comprised of
millions of on and off switches.
In modern practice, most gates are made from field-effect transistors
(FETs), particularly MOSFETs (metal–oxide–semiconductor field-effect
transistors).
Hardware Design – how would you illustrate
a circuit with its components?
If you tried to draw the circuit on the right on paper
(as it is) it probably wouldn’t make much sense.
You may understand what it means because it’s your
circuit, but other people would struggle!
Common convention uses a series of symbols to
stand for the various types of logic gates. The
diagram on the right is a circuit diagram showing 3
inputs and 2 outputs. You can combine logic gates
to do clever things with inputs and outputs.
But …what do the funny shapes mean?
Types of Gates
If you are a beginner to all this, you probably would start with knowing the three main gates: the AND
gate, the OR gate and the very clever NOT gate. The symbolic representations for each of these
gates is shown below.
And
Or
Not
Yes, it would be helpful if the AND and OR gates didn’t look quite so similar, but that’s just the way it
is now. You would do well to find an interesting way of remembering what the AND and OR gates look
like, and test yourself to make sure you don’t get confused.
The And Gate – remembering the shape!
Memory by association really works. The wackier and more creative the association the more likely
you are to remember what the gates stand for! Here’s one (completely ridiculous way but it worked for
me) Try and think of your own!
And
This gate is ROUNDED
and looks a little like the
door of a cave (if
rotated). A year ago I was
in a desert – there was
loads of SAND, and
there were caves nearby
in which the (biblical)
dead sea scrolls were
found. AND!
The Or Gate– remembering the shape!
Memory by association really works. The wackier and more creative the association the more likely
you are to remember what the gates stand for! Here’s one (completely ridiculous way but it worked for
me) Try and think of your own!
Or
Thor was a chap that was from space. The gate above looks a little like a space
ship. THOR ….from outer space, and so when I see a spaceship shaped gate, I
think: THOR……….and remember it’s the OR gate.
Other types of gates
There are other types of gates which make use of the AND or OR symbolic representations within them
NAND
NOR
XOR
XNOR
AND GATE
What do these gates do?
Watch the video below, or create the diagram for yourself in logic.ly/demo and see what happens. Note
that the gate below is the AND gate.
Input A
If InputA AND InputB are
on, then the bulb will be
on (Boolean value = 1)
Connect the toggle switches (on the left)
to the AND gate (centre) and then the
AND gate to the bulb (output)
You’ll notice something quite interesting:
The bulb only lights when both Input 1
AND Input 2 are on.
Input B
The AND logic gate performs this function
and produces an output depending on the
inputs.
If Input B is ON (this
represents a 1)
If INPUT A = 1 (on) and INPUT B = 1 (on),
Only then with the output also be on (1)
OR GATE
What do these gates do?
Watch the video below, or create the diagram for yourself in logic.ly/demo and see what happens. Note
that the gate below is the OR gate.
Input A
If InputA OR InputB are
on, then the bulb will be
on (Boolean value = 1)
Connect the toggle switches (on the left)
to the OR gate (centre) and then the OR
gate to the bulb (output)
You’ll notice something quite interesting:
The bulb lights up when either Input 1 OR
Input 2 are on.
Input B
The OR logic gate performs this function
and produces an output depending on the
inputs.
If Input B is ON (this
represents a 1)
If INPUT A = 1 (on) OR INPUT B = 1 (on),
the output also be on (1)
NOT GATE
The NOT gate acts as an inverter
Watch the video below, or create the diagram for yourself in logic.ly/demo and see what happens. Note
that the gate below is the NOT gate.
Input A
Input A
If InputA OR InputB are
on, then the bulb will be
on (Boolean value = 1)
NOT GATE
Connect the single input (toggle switch on
the left) to the NOT gate, and then
connect the NOT gate to the bulb.
You’ll notice a pattern. If the switch is on
(1) then the bulb is off (0). And if the
switch is off (0), then the bulb goes on (1)
Input B
If Input B is ON (this
represents a 1)
If Input A = 0
(off) then the
bulb is on!
The NOT gate tends to invert the signal
that is coming through to produce the
opposite signal.
If INPUT A = 1 then NOT A = 0
If INPUT A = 0 then NOT A = 1
Use of a truth table – weird examples
Each of the gates have a corresponding TRUTH TABLE. The truth table is an effective way of
displaying the inputs and outputs of a gate using binary (Boolean values)
Suppose the desired outcome was to PUT YOUR FAITH in Person x. You may come up with two
factors that are crucial in determining whether or not you should put your faith in this person.
Variable A = X must be Good AND
Variable B = X must be Divine
Variable A
X is good
X is not good
X is good
Variable B
X is divine
X is divine
X is not divine
Final Output
Believe!
Don’t believe!
Don’t believe!
You’ll note that you have made use of an AND gate - both conditions must be true for the output to be favourable.
Another example – this time for the OR
Your computing teacher is planning a trip to Bletchley Park. It is only, unfortunately, for the students
that managed to achieve an A OR a B in their A Level Exams.
What would the truth table look like?
Achieved an A
No
Yes
No
Yes
Achieved a B
No
Yes
Yes
No
Going on Trip?
Nope
Yes!
Yes!
Yes!
You’ll note that you have made use of an OR gate - EITHER CONDITION can be true for a favourable response.
Using truth tables
Each of the gates have a corresponding TRUTH TABLE. The truth table is an effective way of
displaying the inputs and outputs of a gate using binary (Boolean values)
And
A
?
A*B
B
Note: The And gate is associated
with multiplication
?
?
?
Using truth tables
Each of the gates have a corresponding TRUTH TABLE. The truth table is an effective way of
displaying the inputs and outputs of a gate using binary (Boolean values)
Or
A
?
A+B
B
Note: The OR gate is associated
with addition
?
?
?
Using truth tables
Each of the gates have a corresponding TRUTH TABLE. The truth table is an effective way of
displaying the inputs and outputs of a gate using binary (Boolean values)
Not
A
Not A
?
?
Using truth tables
This is a NOT-AND gate which is equal to an AND gate followed by a NOT gate. The outputs of all
NAND gates are high if any of the inputs are low. The symbol is an AND gate with a small circle on
the output. The small circle represents inversion.
NAND
A
B
__
AB
?
?
?
?
Using truth tables
This is a NOT-OR gate which is equal to an OR gate followed by a NOT gate. The outputs of all NOR
gates are low if any of the inputs are high.
The symbol is an OR gate with a small circle on the output. The small circle represents inversion
NOR
A
B
____
A+B
?
?
?
?
Using truth tables
The 'Exclusive-OR' gate is a circuit which will give a high output if either, but not both, of its two inputs
are high. An encircled plus sign () is used to show the EOR operation.
XOR
A
?
?
B
?
?
Using truth tables
The 'Exclusive-NOR' gate circuit does the opposite to the EOR gate. It will give a low output if either,
but not both, of its two inputs are high. The symbol is an EXOR gate with a small circle on the output.
The small circle represents inversion.
XNOR
A
?
?
B
?
?
Sample Questions
Sample Questions
Sample Questions
Answers