Boolean Algebra and Digital Circuits Part 1: Boolean Algebra

advertisement
Boolean Algebra and Digital
Circuits
Part 1: Boolean Algebra
Binary Logic and Digital Circuits
•
we saw in the previous set of lectures how
computers represent information
•
and in particular how they perform arithmetical
operations upon numbers
•
in the following set of lectures we’ll see how binary
logic is used to design and implement digital circuits
which can perform such operations
•
and how simple circuits combine to perform
more complex operations
A Potted History
•
1854: George Boole’s The Laws of Thought is published, thus creating
Symbolic Logic, or Boolean Algebra
•
1938: John Atanasoff determines 4 principles for his ABC digital
computer:
•
•
•
it will use electricity instead of mechanical movements
•
computations will be performed by direct logical action - which
Claude Shannon proved is essentially Boolean Algebra - rather
than by enumeration as had been done before
it will use base 2 because switches are either on or off
it will use capacitors for memory because they store charge
with a regenerative process, avoiding power leakage
Boolean Algebra
•
•
a system for the manipulation of variables, where the
variables can have one of two values:
•
•
true or false
which correspond to on or off, 1 or 0
Boolean Expressions are created by applying Boolean
Operators to one or more variables:
•
•
such as AND, OR and NOT
and also NAND, NOR and XOR
Operators and their Truth Tables
•
each operator can be described using its truth table:
AND
Inputs
x
0
0
1
1
math:
logic:
y
0
1
0
1
OR
Output
x.y
0
0
0
1
x⋀y
x.y
Inputs
x
0
0
1
1
math:
logic:
y
0
1
0
1
NOT
Output
x+y
0
1
1
1
x⋁y
x+y
Input
Output
x
0
1
x̅
1
0
math:
logic:
¬x
x̅
Operators and their Truth Tables
•
each operator can be described using its truth table:
NAND
Inputs
x
0
0
1
1
math:
logic:
y
0
1
0
1
Output
x̅.̅y̅
1
1
1
0
¬(x ⋀ y)
x.y
NOR
Inputs
x
0
0
1
1
math:
logic:
y
0
1
0
1
XOR
Output
x̅+̅y̅
1
0
0
0
¬(x ⋁ y)
x+y
Inputs
Output
x
y
x⊕y
0
0
0
0
1
1
1
0
1
1
1
0
math:
(x ⋁ y) ⋀ ¬(x ⋀ y)
logic:
x⊕y
Boolean Functions
•
•
•
•
A Boolean Function involves:
•
•
•
one or more input variables
one or more operators
a result from the set {0,1}
examples:
•
•
•
F(x, y) = x.y
F(x, y) = x + y
F(x, y, z) = y + x̅.z
if x = 0, y =1 and z = 1 then we can easily evaluate the first two functions:
•
•
x.y = 1 AND 0 = 0
x + y = 1 OR 0 = 1
but in what order to we perform the operations to find the answer to the third function?
Operators: Order of Precedence
•
•
•
•
priority highest to lowest:
•
easiest to evaluate in stages:
•
NOT then AND then OR
F(x,y,z) = y + x̅.z
evaluate F when x = 0, y = 1
and z = 1
•
•
•
x̅ = NOT(0) = 1
x̅.z = 1 AND 1 = 1
y + x̅.z = 1 OR 1 = 1
so we see that it helps to evaluate
the function in pieces
Inputs
x
0
0
0
0
1
1
1
1
y
0
0
1
1
0
0
1
1
Intermediate
z
0
1
0
1
0
1
0
1
x̅
1
1
1
1
0
0
0
0
x̅.z
0
1
0
1
0
0
0
0
Output
F=y+x̅.z
0
1
1
1
0
0
1
1
(can you spot the easy way to generate the set of truth table
input values for x, y and z?)
Boolean Identities
•
•
boolean functions can quickly become complicated
yet the simpler we can make the function, the smaller
circuit we’ll need to build for it
•
cheaper, more economical and faster
•
so there’s an incentive to reduce boolean functions to their
simplest form
•
sometimes this can be tricky, so we’ll look at a clever
technique for simplifying functions later
•
for now, we’ll use the basic identities to perform the task
Boolean Identities
Name
AND Form
OR Form
Identity Law
1.x = x
0 + x = x
Null (or Dominance) Law
0.x = 0
1 + x = 1
Idempotent Law
x.x = x
x + x = x
Inverse Law
x.x̅ = 0
x + x̅ = 1
Commutative Law
x.y = y.x
x + y = y + x
Associative Law
(x.y).z = x.(y.z)
(x+y)+z = x+(y+z)
Distributive Law
x+y.z = (x+y).(x+z) x.(y+z) = x.y + x.z
Absorption Law
x.(x+y) = x
x + x.y = x
DeMorgan’s Law
x̅.̅y̅ = x̅ + y̅
x̅+̅y̅ = x̅.y̅
Double Complement Law
note the double-bar over the x
x̿ = x
Table 3.5 from Computer Organization & Architecture
Using Identities to Simplify Functions
i. simplify F(x, y, z) = x̅.y.z + x̅.y.z̅ + x.z
= x̅.y.z + x̅.y.z̅ + x.z
= x̅.y.(z + z̅) + x.z
distributive
= x̅.y.(1) + x.z
inverse
= x̅.y + x.z
identity
(examples i., ii. & iii. are based upon examples 3.2, 3.3 and the proof on p128 from Computer Organization & Architecture)
Using Identities to Simplify Functions
ii. simplify F(x, y) = y + x̅.̅y̅
= y + x̅.̅y̅
= y + (x̅ + y̅)
DeMorgan’s
= y + (y̅ + x̅)
commutative
= (y + y̅) + x̅
associative
= 1 + x̅
inverse
= 1
null
Using Identities to Simplify Functions
iii.
prove (x + y).(x̅ + y) = y
(x + y).(x̅ + y)
= x.x̅ + x.y + y.x̅ + y.y
distributive
= 0 + x.y + y.x̅ + y.y
inverse
= 0 + x.y + y.x̅ + y
idempotent
= x.y + y.x̅ + y
identity
= y.(x + x̅) + y
distributive (& commutative)
= y.(1) + y
inverse
= y + y
identity
= y
idempotent
DeMorgan’s Law
•
•
recall that:
•
•
x̅.̅y̅ = x̅ + y̅
x̅+̅y̅ = x̅.y̅
important: note that
x̅.y̅ ≠ x̅.̅y̅
this is one of the most useful identities in practical terms
•
why?
•
answer: it tells us how to covert AND and OR operations into NAND
and NOR operations
•
moreover we can determine that all other operations can be
performed using just NAND or just NOR
•
and that makes digital circuits much easier to produce
NAND Alone
•
example: show that OR, NOT and AND can be performed using NAND
operations only:
•
OR:
x+y
= x.x + y.y
idempotent
= (̅x̿.̿x̿)̅ + (̅y̿.̿y̿)̅ double complement
•
•
NOT: x̅
AND: x.y
= x̿.̿x̿.̅y̿.̿y̿
DeMorgan
= (̅x̅)̅
simple re-write
= (̅x̅.̅x̅)̅
idempotent
= x̿.̿y̿
double complement
= (̅x̿.̿y̿)̅
simple re-write
= (̅x̿.̿y̿)̅.̅(̅x̿.̿y̿)̅
idempotent
More DeMorgan
•
because building circuits is often easier just using NAND and NOR gates,
it’s useful to be able to negate a function (using a simple NOT operation)
•
•
this gives the complement of the function
example: if F(x, y, z) = x + y + z then find F̅:
F̅(x, y, z) = x̅ ̅+̅ ̅y̅ ̅+̅ ̅z̅
•
= w̅ ̅+̅ ̅z̅
substituting w = x + y
= w̅.z̅
DeMorgan’s
= x̅ ̅+̅ ̅y̅.z̅
replacing x + y = w
= x̅.y̅.z̅
DeMorgan’s
so we see that DeMorgan’s law extends for 3 variables, and in fact generally
Standardized Form
•
we’ve seen that the same boolean function can be written in many different
ways
•
to avoid confusion designers specify functions in a standardized (or canonical)
form
•
the two most common forms are:
•
•
sum of products
•
•
ANDed variables are ORed together
such as F(x, y, z) = x.y + x.z + y.z
product of sums
•
•
ORed variables are ANDed together
such as F(x, y, z) = (x + y).(x + z).(y + z)
Sum of Products
•
•
the easiest version to determine because we can just use a truth table:
•
•
find and list the values of x, y and z which make the function true
then simply OR each expression in the list together
example: a majority polling function
x
0
0
0
0
1
1
1
1
y
0
0
1
1
0
0
1
1
z
0
1
0
1
0
1
0
1
F
0
0
0
1
0
1
1
1
Table 3.8 from Computer Organization & Architecture
so the function is:
F = x̅yz + xy̅z + xyz̅ + xyz
x̅yz
xy̅z
xyz̅
xyz
To Conclude
•
•
we’ve learned about Boolean variables, operators, expressions and functions
we’ve seen how to form truth tables to help us to determine the
outcome of functions
•
don’t underestimate the value of using these!
•
we’ve seen how to apply the identities to help us to simplify some
functions
•
and to transform others so that they can be expressed just using NAND
or NOR
•
•
making good use of DeMorgan’s law
we’ve seen how to represent functions in a standardized form
References & Further Learning
•
•
•
outline primarily based upon:
•
Chapter 3, Computer Organization & Architecture (3rd Edition), Null & Lobur
other material used for reference:
•
Set 5, CG066 Lecture Notes, Dave Harrison,Northumbria University
suggested learning activities:
•
practice creating truth tables for the basic operators until you are
comfortable with them
•
•
use NAND gates to build the remaining gates from the example
create a function, draw its truth table and then derive its standardized form
as a sum of products
Download