Transcript Slide 1

D75P 34R - HNC Computer
Architecture
Week 8
More Boolean Logic
© C Nyssen/Aberdeen College 2004
All images © Focus Clipart, used with permission except
Racecar, burglar, wedding © Microsoft
Prepared 24/11/04
We looked already at Boolean Logic,
which is of great importance to how
computers manipulate data.
Boolean logic is essentially very
simple. You may have already used
Boolean Search Expressions when
using Internet Search Engines.
When used in constructing a search
expression, it can be very useful in
specifying exactly what information
you want.
Boolean 'AND'
This is expressed as
‘dogs AND cats'
in a search.
When using AND in this search expression, results
retrieved will contain both dog and cat information. The
results will not include those documents containing only
dog or cat information. In the diagram the documents
retrieved by using this search expression are contained
within the green area.
A scientist wishes to test the
old adage “fighting like cat
and dog”. To do this, he
needs to find some people
to interview who keep both
cats and dogs.
People who don’t have a pet
at all, or have only a cat or
only a dog, are useless for
the purposes of his
experiments.
We can show the logic in a diagram like this…
Cat owner?
Possible
experimental
subject?
Dog owner?
Remember the Truth Table
for an AND gate works like
this…
Cat?
Dog?
Suitable
subject?
0
0
0
0
1
0
1
0
0
1
1
1
Boolean ‘OR'
This is expressed as ‘dogs OR cats' in a search. All the
results retrieved will contain either dog information, or cat
information, or dog-and-cat information together.
Such a search will not
merely retrieve documents
containing only dog
information or only cat
information. In the diagram
the documents retrieved by
using this search
expression are contained
within all the coloured
areas.
An insurance company have
introduced a new policy for Pet
Owners. They have
purchased a mailing list with
information about peoples
households; now they want to
send a mail shot to potential
customers.
The insurance company needs
to target those people who
have a cat, or a dog, or both,
but there is no point sending a
mailshot to people who don’t
keep a pet at all.
We can show the logic in a diagram like this…
Cat owner?
Try and sell a
policy?
Dog owner?
Remember the Truth Table
for an OR gate works like
this…
Cat?
Dog?
Hard Sell?
0
0
0
0
1
1
1
0
1
1
1
1
Boolean ‘NOT’
This is expressed as ‘dogs
NOT cats' in a search.
When using NOT in this search expression, results will
contain only dogs. The NOT operator will exclude cats
completely and thus any dog-and-cat information will be
excluded also. In this diagram the dog related information
is contained within the blue area.
Pat is a Postman
delivering mail to
peoples houses...
...but unfortunately he
just does not get along
with dogs!
So he only visits homes
that have no dogs in
residence…
We can show the logic in a diagram like this…
Dog in residence?
Remember the Truth Table
for a NOT gate works like
this…
Deliver mail?
Dog
present?
Deliver
mail?
0
1
1
0
Boolean ‘XOR’
This is expressed as ‘dogs
XOR cats' in a search. It
must include one, or the
other, but not both, and not
none!
A Vet’s surgery have to send
out annual reminders for all
cats and dogs to come in for
their booster shots.
They need to go through all
their patient’s files and send
out letters to all the dog
owners and all the cat
owners…
…but not the owners of
canaries, goldfish or
hamsters….
… and owners with dogs AND cats would already have
been counted!
We can show the logic in a diagram like this…
Cat owner?
Send reminder?
Dog owner?
Remember the Truth Table
for an XOR gate works like
this…
Cat?
Dog?
Reminder?
0
0
0
0
1
1
1
0
1
1
1
0
Try to draw the Logic Circuit for the following scenario.
To ride the go-karts at the fairground, you have to be
16 or over, OR be 12 or over AND accompanied by a
responsible adult.
12-15?
Adult present?
=> 16?
Allowed
on the
gokarts?
12-15?
Adult present?
Allowed
on the
gokarts?
=> 16?
Complete
the Truth
Table.
12-15?
With
adult?
=>16?
0
1
1
1
0
0
0
0
1
1
1
0
0
0
0
1
1
1
Ride
karts?
A burglar alarm will go off if it has been
set, AND the door is opened without the
correct code number, OR someone
breaks the infra-red beam by climbing in
the window.
Break beam?
Open door
without code?
Alarm set?
Alarm
goes
off?
Break beam?
Open door
without code?
Alarm
goes
off?
Alarm set?
Complete the
Truth Table.
Break
beam?
Open
door?
Alarm
set?
0
1
1
1
0
0
0
0
1
1
1
0
0
0
0
1
1
1
Alarm,
goes off?
To be legally married in Scotland, both parties must be
16 or over, not already married, and of different sexes.
Person #1 is a man?
Person #2 is a man?
Person #1 => 16?
Person #2 => 16?
Person #1 married?
Person #2 married?
Marriage
is legal?
There are many
different ways to
depict the circuit for
this scenario. This is
just one of them!
Complete the Truth
Table.
Person 1
man?
Person 2
man?
Person 1
=>16?
Person 2
=>16?
Person 1
married?
Person 2
Married?
1
1
0
0
1
1
1
0
1
0
0
0
1
1
1
1
0
0
0
1
1
1
0
0
1
0
1
0
1
0
Outcome?
Your exam question will typically consist of a pair of binary
numbers, and you will be asked to perform logical
operations with them.
1010 0000 1111 0101
1111 1111 0000 0000
AND
OR
XOR
NAND
NOR
XNOR
1010 0000 0000 0000
1111 1111 1111 0101
0101 1111 1111 0101
0101 1111 1111 1111
0000 0000 0000 1010
1010 0000 0000 1010
Another one?
1100 0011 0101 1101
1001 1001 0000 0010
AND
OR
XOR
NAND
NOR
XNOR
1000 0001 0000 0000
1101 1011 0101 1111
0101 1010 0101 1111
0111 1110 1111 1111
0010 0100 1010 0000
1010 0101 1010 0000
Summary
NOT (inverter) reverses any input.
 AND requires ALL inputs to be TRUE for a TRUE
output.
 OR requires only ONE input to be TRUE for a TRUE
output.
 XOR requires differences in the inputs for a TRUE
output.
 NAND is equivalent to an AND immediately followed by
a NOT.
 NOR is equivalent to an OR immediately followed by a
NOT.
 XNOR is equivalent to an XOR immediately followed by
a NOT.
