Uploaded by rula mohammad

Chapter 2 Boolean Algebra simplifiaction

advertisement
Jouf University
College of Computer and Information Sciences
Chapter 2 : Boolean Algebra
30/09/2019
1
Logic gates :
AND gate
A
B
Y
Y = AB
OR gate
A
B
Y
Y = A+B
(also Y=AB)
Both of these gates have 2 inputs and 1 output. A larger number of
inputs are possible (see later).
The NOT gate or inverter consists of a single input and the output
is the opposite or complement of the input
truth table
NOT gate
A
Y
0
1
1
0
30/09/2019
A
Y
Y= A or A’
For example 0 = 1 and 1 = 0
2
Example 1. Consider a 2 input AND gate (A,B) and a pulse train
Take A = 1 (always) and let the input of B be represented by this
pulse train
1
h g
1
1
1
f e d c b
a
A
B
Y
Since A is always 1 the output of the AND gate will depend on the
input of B - in this case it will reproduce the pulse train.
If A = 0, the Y = 0 for all times (a-h)
Exercise 1.1: If the gate were replaced by an OR gate what
would Y look like if (i) A=0 for all times and (ii) A= 1 for all
times.
30/09/2019
3
Some simple rules using logic gates
AND gates
OR gates
A
0
A
1
A0 = 0
(1)
A1 = A
(2)
A
AA = A
(3)
AA = 0
(4)
A
A
0
A
1
A+0=A
(5)
A+1=1
(6)
A
A+A=A
(7)
A+A=1
(8)
A
These rules are very easy to work out so don’t try
to learn them off - try to understand them
There are some other rules worth noting
30/09/2019
4
Here are some extra laws from Boolean algebra
A + B = B + A (9) - this is known as the commutative law (OR)
AB=BA
(10) - this is known as the commutative law (AND)
A + (B + C) = (A + B) + C = A + B + C (11)
- this is known as the associative law (OR)
A(BC) = (AB)C = ABC (12)
- this is known as the associative law (AND)
Laws (11) and (12) show that
A(B + C) = AB + AC
Exercise 1.2 : Prove A + AB = A use this result to
show that A + AB = A + B
30/09/2019
5
You may have noticed that there is a certain symmetry
present in which rules of Boolean algebra appear in pairs.
In a binary logic system it makes sense that there is a type
of symmetry between the two operations and this symmetry
is called Duality.
Every equation has its dual which one can generate it by
replacing the AND operators by ORs and vice-versa and the
values 0 by 1s (and vice-versa).
For example 1+A=1 is the dual of 0.A=0
A+A=1 is the dual of AA=0
30/09/2019
6
Laws (11) and (12) deal with 3 - input logic gates. It is possible to
create multiple inputs of both AND and OR gates (and other gates
we shall study later). Note that the NOT gate has only 1 input.
The symbol for a 3 input AND gate is
and a 3 input OR gate
The truth tables for both logic operations are given below
A
B
C
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
30/09/2019
AND gate
A B C
0
0
0
0
0
0
0
1
OR gate
A + B + C
0
1
1
1
1
1
1
1
A truth table with n inputs
will have 2n rows.
Note the ordering of the
inputs - they follow the
binary numbers - it is easier
this way
7
• Operator precedence for evaluating Boolean
expressions:
•
•
•
•
1: parentheses
2:NOT
3:AND
4:OR
• Ex:
(x + y)’
– Evaluate what inside the parentheses first , then take NOT.
30/09/2019
8
To prove that two expressions are equal you need to
prove that each element in the truth table is the same
for both expressions.
Example. Using a truth table determine of the two
expressions for F and G are equal.
F = A B + AC + B C
A
0
0
0
0
1
1
1
1
30/09/2019
B
0
0
1
1
0
0
1
1
C
0
1
0
1
0
1
0
1
F
and G = B + ABC ( Boolean Functions)
G
9
So far we have dealt with individual logic gates. We shall now look
at simple forms of combinational logic gates. Consider the following
circuit - what is the Boolean expression for the output Y?
A
B
Y
C
Answer: Y =
This is an example of a ‘sum-of-products’ expression and is comes
from AND-OR logic
30/09/2019
10
Constructing the truth table
A
0
0
0
0
1
1
1
1
B
0
0
1
1
0
0
1
1
C
0
1
0
1
0
1
0
1
AB
BC
AB + BC
Take the circuit --> Boolean Expression --> Truth table
It is also possible to go from the truth table to produce the
Boolean expression and then produce the ( most simple) circuit
30/09/2019
11
When do we get a logic 1. It occurs 3 times.
The first case is when A is 0, B is 1 and C is 1. We can write this as
ABC
The second case is A is 1, B is 1 and C is 0, A B C
Finally when A is 1, B is 1 and C is 1, which is A B C
So we get a logic 1 output when and one of the 3 conditions is satisfied.
So Y can be written as
Y=ABC +ABC +ABC
Question: Is this the same expression as we got before B(A + C)
30/09/2019
12
Lecture 2
In addition to the three gates already studied, there are other
logic gates which perform different tasks.
They are called NAND, NOR and XOR.
30/09/2019
13
The first is called NAND, and consists of
an AND function followed by a NOT function
For a 2 input NAND gate the Boolean expression is
Y=AB
The circle at the output of the NAND gate denotes the
logical inversion, (c.f. the inverter).
A
0
0
1
1
30/09/2019
B
0
1
0
1
Y=AB
1
1
1
0
Y=AB
0
0
0
1
Note that the over bar is a solid
bar over both input values at once
showing that AND function itself
that is inverted, rather than each
separate input.
14
Inherent in the operation of a 2 input NAND gate is the fact that one
or more LOW inputs produces a HIGH output.
There is a similarity here with a 2 input OR gate - in which one or more
HIGH inputs produces a HIGH output – see table below.
A
0
0
1
1
B
0
1
0
1
Y=AB
1
1
1
0
Y=A+B
0
1
1
1
From this viewpoint a NAND gate
can be used for an OR operation
that requires one or more LOW
inputs to produce a HIGH output.
This is referred to as having active
LOW inputs. (Assertion level logic)
In this way the NAND gate can be viewed as a negative OR gate.
30/09/2019
15
How do we make the inputs go negative i.e active LOW inputs.
The inputs go ‘negative’ by using 2 inverters. Therefore we can
represent a NAND gate as either
1.
An AND gate followed by an INVERTER
2. An OR gate preceded by 2 INVERTERS
AB
NAND gate
AB = A + B
A + B
- DeMorgan’s theorem
Question: What is the dual of this expression??
30/09/2019
16
The NOR function consists of the OR function
followed by a NOT function
For a 2 input NOR gate the Boolean expression is
Y=A+B
Again the bar is over both input values at once showing that
OR function itself that is inverted, rather than each separate input.
A NOR gate produces a LOW output when any of its inputs is HIGH.
Only when all of its inputs are LOW is the o/p HIGH.
A
0
0
1
1
30/09/2019
B
0
1
0
1
Y=A+B
0
1
1
1
Y=A+B
1
0
0
0
17
With a NOR gate a HIGH o/p is produced only if all the inputs are LOW.
From this viewpoint a NOR gate can be used for an AND operation with
active LOW inputs.
Therefore we can represent a NOR gate as either
1.
An OR gate followed by an INVERTER
2. An AND gate preceded by 2 INVERTERS
A + B
A + B
30/09/2019
NOR gate
= AB
AB
- DeMorgan’s theorem
18
Combining gates when
using inverters. There
are times when it is
necessary to convert from
one logic function to
another.
Connecting an inverter
to the output of a gate
reverses the function of
the initial gate
30/09/2019
19
Placing inverters at all the
inputs
changes AND to a NOR gate,
also converts an OR gate to
NAND.
This leads to an alternative
representation for the NAND
and NOR gates below.
Y=A + B
Y= A B
30/09/2019
20
The effects of inverting
both the inputs and the
outputs.
This is not used that often
but does allow for a NAND
gate to be converted to a
NOR gate and
vice versa.
30/09/2019
21
Summary of active HIGH and active LOW 2 input gates.
AND gate
NAND gate
OR gate
NOR gate
30/09/2019
22
AB = A + B
A + B
= AB
- DeMorgan’s theorem
- DeMorgan’s theorem
We can see that each of the these two laws are
duals of each other.
30/09/2019
23
AB = A + B
A + B
= AB
- DeMorgan’s theorem
- DeMorgan’s theorem
There is a certain symmetry between these relationships.
‘ANDing’ or ‘ORing’ two variables together is the same as
‘ORing’ and ‘ANDing’ their complements.
This means providing we have NOT gates available we can
convert and circuit made from AND and OR gates to one
constructed from OR and AND gates.
30/09/2019
24
The final function is the XOR - Exclusive OR.
Verbally it can be stated as ‘Either A or B, but not both’.
For the 2 input XOR gate, a HIGH o/p will occur when one and
only one i/p is logic HIGH.
A
0
0
1
1
B
0
1
0
1
Y=AB
0
1
1
0
Y= A  B
Note how this differs from an OR gate
30/09/2019
25
The XOR function can be made made using AND, OR and NOT gates.
A
Y=AB + AB
B
This is an example of AND-OR logic. We will discuss the importance
of this later!!
Exercise 3.1 Construct using AND, OR and NOT logic
30/09/2019
Y=AB + AB
26
In addition to 2 input NAND, NOR and XOR, multi input gates are
possible. Here are the truth tables 3 input gates.
A
0
0
0
0
1
1
1
1
B
0
0
1
1
0
0
1
1
30/09/2019
C
0
1
0
1
0
1
0
1
NAND
NOR
XOR
A B C
A+B+C
ABC
1
1
1
1
1
1
1
0
1
0
0
0
0
0
0
0
0
1
1
0
1
0
0
1
The XOR gate is
sometimes referred to
as the
‘anything but not all’.
The XOR gate is only
enabled when there
are an odd number of
digital 1s
 Therefore the XOR
can be viewed as an
odd-bits check circuit.
27
Exercise 3.2. What is the output pulse train if (a) B = 1 and (b) B=0
0
1
h g
0
1
1
0
0
f e d c b
30/09/2019
1
a
A
B
28
Using NAND logic
An obvious question is why do we use NAND or NOR gates
rather than AND, OR and NOT since their implementation is
easier?
Answer:
Many electronic gates naturally invert signals thus NAND is
more natural than AND.
Secondly, NAND and NOR are universal gates (also called
Functionally Complete) since all the basic logical operations can
be done with NAND or NOR gates.
30/09/2019
29
All digital systems can be constructed from the
fundamental AND, OR and NOT gates.
It is also possible to construct them from NAND gates.
The NAND gate is referred to as the universal gate for
AND-OR logic.
A
A
A NAND gate acting
as an inverter
The best way to analyse the next few circuits is by doing each
logic operation in stages.
30/09/2019
30
A
A
A B
B
= A + B
B
Three NAND gates acting as an OR gate
30/09/2019
31
A
A
B
B
30/09/2019
AB
A + B
Four NAND gates
acting as an NOR gate
32
NAND gates is a Universal gate
30/09/2019
33
The AND-OR logic circuit for Y = A B + C + D E is
A
B
C
D
E
The same circuit using NAND logic is
A
B
C
D
30/09/2019E
34
30/09/2019
35
Exercise 3.3. Using only NAND gates construct circuits
which perform the following representations.
(i) A B C
and
ABC
(ii) A B + C D
30/09/2019
36
(ii)
30/09/2019
37
Simplifying logic circuits
As circuits get more complicated it is necessary to try to simplify
the circuit as much as possible. This will depend on what information
is provided e.g. a truth table.
A
0
0
0
0
1
1
1
1
30/09/2019
B
0
0
1
1
0
0
1
1
C
0
1
0
1
0
1
0
1
Y
0
0
0
0
1
0
0
1
We want to construct the
Boolean minterm from looking
at the those parts of the truth
table that give 1s
(I) count up the number of
terms that give a 1
Y=ABC+ABC
This can be read as ‘an A AND a
NOT B AND a NOT C give a 1’
38
To construct the circuit we need to know how to produce the individual
logic elements. We shall do one example in detail. For example in
Y=ABC+ABC
we need
(i) need three elements A, B and C
(ii) to OR the logic functions
A B C with A B C
(ii) to AND the elements A with NOT B with NOT C as well as A
with B with C
(iii) to produce NOT B as well as NOT C
This is an example of a sum-of-products (SOP) expression.
We will meet product-of-sums (POS) expressions later and how to
convert between the two.
30/09/2019
39
A
B
C
30/09/2019
40
We discussed the use of the minterm when there are a few 1’s and more
zeros in the truth table. There is an alternative way to simplify the
results if there are more 1’s than 0’s.
Consider the usual 2 input OR truth table
A
0
0
1
1
B
0
1
0
1
Y
0
1
1
1
The Boolean minterm is A B + A B + A B
The remaining term is
AB
We know that since this is an OR
gate that the simplified Boolean
expression is Y = A + B
How do we get this from the minterm
or maxterm?
30/09/2019
41
Lecture 4
Given that the maxterm is A B we can find the simplified
Boolean expression with NOT elements using DeMorgan’s theorem
AB = A+B
(1)
A+B = A B
(2)
To simplify a complicated expression using DeMorgan’s theorems
Step
Step
Step
Step
1: change all ORs to ANDs as well as all ANDs to ORs
2: complement each individual variable (bar over each variable)
3: complement the entire function
4: eliminate any double groups
This procedure will be demonstrated by the following example
Example: Simplify Y= (A + B + C) . (A + B + C)
30/09/2019
42
Y = (A + B + C) . (A + B + C)
Step 1: change all ORs to ANDs
ANDs to ORs
Y = (A . B . C) + (A . B . C)
Step 2: complement each individual
variable
Y = (A . B . C) + (A . B . C)
Step 3: complement the entire
function
Y = (A . B . C) + (A . B . C)
Step 4: eliminate any double groups
30/09/2019
Y = (A . B . C) + (A . B . C)
43
To finish off the example of the 2 input OR gate. The maxterm
was A B
Step 1: change all ORs to ANDs
ANDs to ORs
Step 2: complement each individual
variable
Step 3: complement the entire
function
Step 4: eliminate any double groups
A+ B
A+ B
A+ B
A+ B
This is the simplified maxterm (i.e. The one based on 0’s). To get the
simplifier minterm invert this and get A + B
30/09/2019
44
Exercise 4.1 : simplify
Y = (A + B + C+ D) . (A + B + C + D)
Step 1: change all ORs to ANDs
ANDs to ORs
Step 2: complement each individual
variable
Step 3: complement the entire
function
Step 4: eliminate any double groups
30/09/2019
45
Download