02_boolean algebra
02_boolean algebra
Boolean Algebra
جبر بول
:هر دو شرط
وthe lift door is closed
true بايدa button is pressed at a floor
.باشند تا آسانسور حرکت کند
2
Digital Systems: Boolean Algebra
and Logical Operations
• In Boolean algebra:
Values: 0,1
0: if a logic statement is false,
1: if a logic statement is true.
• Operators: AND, OR, NOT
X Y X AND Y X Y X OR Y X NOT X
0 0 0 0 0 0 0 1
0 1 0 0 1 1 1 0
1 0 0 1 0 1
1 1 1 1 1 1
3
مثال
IF
IFthe
thelift
liftdoor
doorisisclosed
closed
AND
ANDaabutton
buttonisispressed
pressedatataafloor
floor
THEN
THENthe thelift
liftmust
mustmove
move
4
سيستم هاي نوعي
System
• ورودي ها:
فشار کليد (ديجيتال)
درجةحرارت محيط (آنالوگ)
تغييرات سطح مايع (آنالوگ)
• خروجي ها:
ولتاژ راه اندازي موتور (آنالوگ)
بازکردن/بستن شير (آنالوگ يا
ديجيتال)
نمايش روي ( LCDديجيتال)
5
سيستم هاي نوعي
Analog
Phenomena
Sensors &
other inputs
Analog
Inputs
Digital
A2D
Inputs
Digital
Inputs
Digital
System . کمربند بسته است:’S = ‘1
Digital Digital . سوييچ داخل است:’K = ‘1
Outputs
. راننده روي صندلي است:’P = ‘1
Outputs
D2A
Open
button
9
عملگرهاي منطقي:سوييچ ها
Open
button
Button Open
at a floor Is off Door
closed
IF ((a button pressed at a floor
AND “Open” button is off) True
Move lift
OR a button inside the lift is pressed)
AND the door lift is closed True
THEN the lift can move Button
inside
10
Binary Logic
Deals with binary variables that take
2 discrete values (0 and 1), and with
logic operations
Basic logic operations:
− AND, OR, NOT
Binary/logic variables: letters: A,B,C,
…,X,Y,Z
11
Binary Logic Function
F(vars) = expression
Operators ( +, •, ‘ )
Variables
set of binary
Constants ( 0, 1 )
variables
Groupings (parenthesis)
Example:
F(a,b) = a’•b + b’
G(x,y,z) = x•(y+z’)
12
Basic Logic Operators
AND (also •, )
Binary
OR (also +, )
NOT (also ’, ) Unary
13
Basic Logic Operators (cont.)
• 1-bit logic AND resembles binary
multiplication:
0 • 0 = 0, 0 • 1 = 0,
1 • 0 = 0, 1 • 1 = 1
• 1-bit logic OR resembles binary
addition, except for one operation:
0 + 0 = 0, 0 + 1 = 1,
1 + 0 = 1, 1 + 1 = 1 (≠ 102)
14
Truth Tables for logic
Truth table:
operators
tabular form that uniquely represents the
relationship between the input variables of a
function and its output
15
Truth Tables (cont.)
• Q:
Let a function F() depend on n
variables. How many rows are there
in the truth table of F() ?
• A:
2n rows, since there are 2n possible
binary patterns/combinations for the n
variables
16
Logic Gates
Logic gates are abstractions of electronic
circuit components that operate on one or
more input signals to produce an output
signal.
F = A•B G = A+B H = A’
17
Timing Diagram
t0 t1 t2 t3 t4 t5 t6
1
Input A 0
1 Transitions
signals B 0
1
F=A•B 0 Basic
Gate
1 Assumption:
Output G=A+B 0 Zero time for
Signals
1 signals to
H=A’ 0 propagate
Through gates
18
The Real World
Physical electronic components are continuous, not
discrete!
− Transition from logic 1 to logic 0 does not take place
instantaneously in real digital systems
These are the building blocks of all digital components!
Logic 0 Input
+5 Voltage
20
Logic Gates
21
Three-Input Gates
22
Combinational Logic Circuit
from Logic Function
• Combinational Circuit Design:
• F = A’ + B•C’ + A’•B’
connect input signals and logic gates:
− Circuit input signals from function variables (A, B, C)
− Circuit output signal function output (F)
− Logic gates from logic operations
A F
23
Logic Evaluation
Circuit of logic gates :
Logic Expression :
24
Logic Evaluation
Circuit of logic gates :
25
Logic Evaluation
26
Combinational Logic Optimization
In order to design a cost-effective and
efficient circuit, we must minimize A B C F G
− the circuit’s size
0 0 0 1 1
− area
− propagation delay 0 0 1 1 1
− time required for an input signal 0 1 0 1 1
change to be observed correctly at 0 1 1 1 1
the output line
Observe the truth table of 1 0 0 0 0
F = A’ + B•C’ + A’•B’
G = A’ + B•C’ 1 0 1 0 0
are identical same function 1 1 0 1 1
1 1 1 0 0
Use G to implement the logic circuit
− less components
27
Proof Using Truth Table
AB'C ( A C )( B 'C )
n times
C
G=A’ + B•C’ B
A G
29
Boolean Algebra
VERY nice machinery used to manipulate
(simplify) Boolean functions
George Boole (1815-1864): “An investigation of
the laws of thought”
Terminology:
− Literal: A variable or its complement
A, B’, x’
− Product term: literals connected by •
X.Y
A.B’.C.D,
− Sum term: literals connected by +
A+B’
A’+B’+C
30
Boolean Algebra Properties
Let X: boolean variable, A B F=A+B
0,1: constants 0 0 0
0 1 1
1 0 1
1. X + 0 = X -- Zero Axiom 1 1 1
2. X • 1 = X -- Unit Axiom A B F=A•B
3. X + 1 = 1 -- Unit Property 0 0 0
4. X • 0 = 0 -- Zero Property 0 1 0
1 0 0
1 1 1
Example: ( AB' D) E 1 1
31
Boolean Algebra Properties (cont.)
0,1: constants 0 0 0
0 1 1
1 0 1
1. X + X = X -- Idempotent
2. X • X = X -- Idempotent 1 1 1
3. X + X’ = 1 -- Complement
A B F=A•B
4. X • X’ = 0 -- Complement
5. (X’)’ = X -- Involution 0 0 0
0 1 0
Example: 1 0 0
1 1 1
( AB' D)( AB' D)' 0
32
The Duality Principle
The dual of an expression is obtained by exchanging
(• and +), and (1 and 0) in it,
− provided that the precedence of operations is not changed.
Do not exchange x with x’
Example:
− Find H(x,y,z), the dual of F(x,y,z) = x’yz’ + x’y’z
− H = (x’+y+z’) (x’+y’+ z)
Dual does not always equal the original expression
34
More Boolean Algebra
Properties
Let X,Y, and Z: boolean variables
10. X+Y=Y+X 11. X • Y = Y • X -- Commutative
12. X + (Y+Z) = (X+Y) + Z 13. X•(Y•Z) = (X•Y)•Z -- Associative
14. X•(Y+Z) = X•Y + X•Z 15. X+(Y•Z) = (X+Y) • (X+Z)
-- Distributive
16. (X + Y)’ = X’ • Y’ 17. (X • Y)’ = X’ + Y’ -- DeMorgan’s
In general,
( X1 + X2 + … + Xn )’ = X1’•X2’ • … •Xn’
35
Associative Laws for AND
A
=B
C C
(AB)C=ABC
B
A
C = B
A C
A(BC)=ABC
36
Proof of Associative Law
( XY ) Z X (YZ ) XYZ
Associative Laws:
( X Y ) Z X (Y Z ) X Y Z
Proof of Associative Law for AND
X Y Z XY YZ Z X(YZ))XY(
0 0 0 0 0 0 0
1 0 0 0 0 0 0
0 1 0 0 0 0 0
1 1 0 1 0 0 0
0 0 1 0 0 0 0
1 0 1 0 0 0 0
0 1 1 0 1 0 0
1 1 1 1 1 1 1
37
Distributive Law
Distributive Laws: X (Y Z ) XY XZ
X YZ ( X Y )( X Z )
Valid only for Boolean
algebra not for ordi-
nary algebra
( X Y )( X Z ) X ( X Z ) Y ( X Z ) XX XZ YX YZ
C X XZ XY YZ X 1 XZ XY YZ
X (1 Z Y ) YZ X 1 YZ X YZ
38
Absorption Property
(Covering)
1. x + x•y = x
2. x•(x+y) = x (dual)
• Proof:
x + x•y = x•1 + x•y
= x•(1+y)
= x•1
=x
QED (2 true by duality)
39
Absorption Property
(Covering)
1. x + x’•y = x + y
2. x•(x’+y) = x y (dual)
• Proof of 2:
x • (x’+ y) = x•x’ + x•y
= 0 + (x•y)
= x•y
QED (1 true by duality)
40
DeMorgan’s Laws
( X Y )' X ' Y '
Proof ( XY )' X 'Y '
X Y ’X’ Y X+Y ’) X + Y ( ’X’ Y XY ’) XY ( ’X’ + Y
0 0 1 1 0 1 1 0 1 1
1 0 0 1 1 0 0 0 1 1
0 1 1 0 1 0 0 0 1 1
1 1 0 0 1 0 0 1 0 0
1. xy + x’z + yz = xy + x’z
2. (x+y)•(x’+z)•(y+z) = (x+y)•(x’+z) --
(dual)
Proof:
xy + x’z + yz = xy + x’z + (x+x’)yz
= xy + x’z + xyz + x’yz
= (xy + xyz) + (x’z +
x’zy)
= xy + x’z
QED (2 true by duality). 42
Consensus Theorem
Example:
a' b'ac bc'b' c ab a' b'ac bc'
43
Consensus Theorem
Example:
Reducing an expression
by adding a term and eliminate.
45
Consensus Theorem
Example:
Reducing an expression
by adding a term and eliminate.
Consensus
Term added
Final expression F A' B ' BCE ' ACDE
46
Algebraic Manipulation
• Boolean algebra: A useful tool for simplifying
digital circuits.
• Why do simplification?
− Simpler can mean cheaper, smaller, faster
48
Algebraic Manipulation
Example: Simplify F = x’yz + x’yz’ + xz.
F= x’yz + x’yz’ + xz yx
= x’y(z+z’) + xz
F
= x’y•1 + xz z
= x’y + xz
x
y
F
z
50
Sum of Products (SOP)
Sum of product form: AB'CD' E AC ' E
Still considered to be
( A B )(C D E ) F
in product of sum form: AB' C ( D' E )
53
Circuits for SOP and POS form
‘
D’
C E
D’ + A
E B’
C
A
C'
E’
B’
A
C B’
D' + D’ C
E
E
A
C’ +
E’
Product of sum form:
54
Multiplying Out and Factoring
To obtain a sum-of-product form Multiplying out using distributive laws
X (Y Z ) XY XZ
( X Y )( X Z ) X YZ
678
Theorem for multiplying out: ( X + Y )(X ' + Z ) = XZ + X ' Y (3-3)
1 44 2 4 43
Example:
6 78
A1B + C ' = ( A + C )(A '+ B)
4 2 A43
The use of Theorem 3-3 for factoring:
55
Multiplying out (Another Proof)
678
Theorem for multiplying out: ( X + Y )( X ' + Z ) = XZ + X ' Y (3-3)
1 44 2 4 43
( X Y )( X 'Z ) XX ' XZ YZ YZ
0 XZ X ' Y YZ
XZ X ' Y
Factoring Expressions
57
Graphic Look at Algebraic Manipulation
-All various forms of an arbitrary
Boolean function with a unique
An Arbitrary Boolean Function
truth table may be considered
points in the big circle
-Assume brown x is an arbitrary
starting point
-Assume green x is the optimal
point
-Amber manipulation path is a
correct but long path from the
starting point to the optimal
-Green path is a better path to
the optimal point
-Correct manipulations remain
within the circle
-Any incorrect manipulation
takes you out of the circle (the
red arrow)
58
Conversion of English Sentences
to Boolean Equations
The first step in designing a logic network:
− Translate English sentences to Boolean
Eqns.
− Break down each sentence into phrases
− Associate a Boolean variable with each phrase
(possible if a phrase can have a “true”/”false” value)
Example:
− Turn on light if it is night and a movement is
detected.
− F=A.B
59
Main Steps
Three main steps in designing a
single-output combinational
switching network:
− Find a switching (Boolean) function
which specifies the desired behavior.
− Simplify the function.
− Realize the simplified function using
logic elements.
60
Example
Four chairs in a row:
− Occupied: ‘1’
− Empty: ‘0’
− F = ‘1’ iff there are no adjacent empty
chairs.
A B C D
61
Example
F = (B’C’ + A’B’ + C’D’)’
F = (B+C).(A+B).(C+D)
= (B+AC).(C+D)
= BC + BD + AC + ACD
= BC + BD + AC
62
Circuit Analysis
Circuit to be analyzed:
65
Circuit Analysis
Circuit to be analyzed:
66
Circuit Analysis
Circuit to be analyzed:
69
Complementation: Example
70
Complement of a Function
• •↔+
• 1↔0
• X ↔ X’
Interchange 1s to 0s in the truth table
column showing F.
The complement of a function IS NOT
THE SAME as the dual of a function.
71
De Morgan’s Law for a Complex
Expression
• Example:
((A + B’).C’.D + EF)’
= ((A’.B) + C + D’) . (E’ + F’)
• Note:
Don’t change operator precedence
72
Shannon Theorem
73
Relationship Among
Theorem: Representations
* Any Boolean function that can be expressed as a truth table can be written as
an expression in Boolean Algebra using AND, OR, NOT.
unique
? Truth Table
not ?
unique ed co v
e r e
cov covered red gate
Boolean not
representation
Expression unique
covered (schematic)
[convenient for [close to
manipulation] implementaton]
76
Ckt to Boolean + Boolean to TT
Circuit of logic gates :
77
Boolean to Ckt
• Combinational Circuit Design:
• F = A’ + B•C’ + A’•B’
connect input signals and logic gates:
− Circuit input signals from function variables (A, B, C)
− Circuit output signal function output (F)
− Logic gates from logic operations
A F
78
Minterms and Maxterms
• Minterm:
x y z Minterm Maxterm
a product term in
which all the variables 0 0 0 x’y’z’ = m0 x+y+z = M0
appear exactly once, 0 0 1 x’y’z = m1 x+y+z’ = M1
either complemented
0 1 0 x’yz’ = m2 x+y’+z = M2
or uncomplemented
• Maxterm: 0 1 1 x’yz = m3 x+y’+z’= M3
80
Canonical Forms (cont.)
• Canonical Sum-Of-Products:
The minterms included are those mj’s
such that F( ) = 1 in row j of the truth
table for F( ).
• Canonical Product-Of-Sums:
The maxterms included are those Mj’s
such that F( ) = 0 in row j of the truth
table for F( ).
81
Example
a b c f1
f1(a,b,c) = m1 + m2 + m4 + m6
0 0 0 0
0
= a’b’c + a’bc’ + ab’c’ + 0 0 1 1 1
abc’
0 1 0 2 1
0 1 1 3 0
f1(a,b,c) = M0 • M3 • M5 • M7
1 0 0 4 1
= (a+b+c)•(a+b’+c’)• 1 0 1 5 0
(a’+b+c’)•(a’+b’+c’). 1 1 0 6 1
1 1 1 7 0
82
Shorthand: ∑ and ∏
• f1(a,b,c) = ∑ m(1,2,4,6),
m1+ m2 + m4 + m6.
• f1(a,b,c) = ∏ M(0,3,5,7),
M0 . M3 . M5 . M7.
83
Conversion Between Canonical Forms
84
Standard Forms (NOT Unique)
Standard forms are “like” canonical
forms,
− Not all variables need appear in the
individual product (SOP) or sum (POS)
terms.
• Example:
f1(a,b,c) = a’b’c + bc’ + ac’
is a standard sum-of-products form
f1(a,b,c) = (a+b+c)•(b’+c’)•(a’+c’)
is a standard product-of-sums form.
85
Graphic Look at SoP and PoS
An Arbitrary Boolean Function
86
Alternative Implementations
A
F(A,B,C) = Sm(3,4,5,6,7)
F = A' B C + A B' C' + A B' C + A B C' + A B C
B
F2
A + BC
F3
F(A,B,C) = PM(0,1,2)
= (A + B + C) (A + B + C') (A + B' + C)
87
Conversion of SOP from
standard to canonical
Expand non-canonical terms by inserting
equivalent of 1 in each missing variable
− x: (x + x’) = 1
Remove duplicate minterms
f1(a,b,c) = a’b’c + bc’ + ac’
= a’b’c + (a+a’)bc’ + a(b+b’)c’
= a’b’c + abc’ + a’bc’ + abc’ +
ab’c’
= a’b’c + abc’ + a’bc + ab’c’
88
Conversion of POS from
standard to canonical
Expand noncanonical terms by adding 0 in
terms of missing variables (e.g., xx’ = 0) and
using the distributive law
Remove duplicate maxterms
f1(a,b,c) = (a+b+c)•(b’+c’)•(a’+c’)
= (a+b+c)•(aa’+b’+c’)•(a’+bb’+c’)
= (a+b+c)•(a+b’+c’)•(a’+b’+c’)•
(a’+b+c’)•(a’+b’+c’)
=
(a+b+c)•(a+b’+c’)•(a’+b’+c’)•(a’+b+c’)
89
More Logic Gates
• NAND:
NOT-AND
− Its output = 1, only if both inputs are not 1.
− (A • B)’
A B )A.B(
’
0 0 1
0 1 1
1 0 1
1 1 0
has traditionally been the universal gate in digital circuits.
− It is simple to implement in hardware and can be used to construct
the other gates.
90
More Logic Gates
• NOR:
NOT-OR
− Its output = 1, only if no input is 1.
− (A + B)’
A B ’)A+B(
0 0 1
0 1 0
1 0 0
1 1 0
91
More Logic Gates
• XOR:
Inequality
− Its output = 1, only if exactly one input is 1.
− (A B)
A B A XOR B
0 0 0
0 1 1
1 0 1
1 1 0
(A B) = A.B’ + A’.B
92
More Logic Gates
• 3-input XOR:
A B C A XOR B XOR C
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
93
More Logic Gates
• XNOR:
Equality
− Its output = 1, only both inputs are equal.
− (A B)’
A B A XNOR B
0 0 1
0 1 0
1 0 0
1 1 1
94
Theorems for XOR
X 0 X
X 1 X '
X X 0
X X ' 1
X Y Y X (commutativ e law)
( X Y ) Z X (Y Z ) X Y Z (associativ e law)
X (Y Z ) XY XZ (distributi ve law)
95
Problem Solving
More often, we describe a logic function using the English-
language connectives “and,” “or,” and “not.”
• Example: CE Lift
The MOVE output is 1 if
− a button in a floor (OUTSIDEB) is 1, and OPENB
button is 0 and door lift is closed (CLOSED = 1)
OUTSIDEB is 1 if
− OUTBUTTON1 is 1 or OUTBUTTON2 is 1 or
OUTBUTTON3 is 1
INSIDEB is 1 if
− KEY1 is 1 or KEY2 is 1 or KEY3 is 1
96
Problem Solving
Sometimes we have to work with imprecise word
descriptions of logic functions,
• Example:
“The ERROR output should be 1 if the GEAR,
CLUTCH, and BRAKE inputs are inconsistent.”
97
Example
• A 4-bit Prime Number Detector
)F = SN3,N2,N1,N0(1, 2, 3, 5, 7, 11, 13
=N3¢.N2¢.N1¢.N0 + N3¢.N2¢.N1.N0¢ + N3¢.N2¢.N1.N0+
N3¢.N2.N1¢.N0 + N3¢.N2.N1.N0 + N3.N2¢.N1.N0 +
N3.N2.N1¢.N0
=N3¢.N1¢.N0 + N3¢.N2¢.N1 + N3¢.N2.N1.N0 +
N3.N2¢.N1.N0 + N3.N2.N1¢.N0
…=• براي عبارات پيچيده ،کار بهينه سازي سخت تر مي
شود.
• روشي سيستماتيک و آسان تر :نقشة کارنو
شما را از جبر بول بي نياز نمي کند. • 98
7-Segment Decoder
• Seven-segment display:
7 LEDs (light emitting diodes), each one
controlled by an input a
1 means “on”, 0 means “off”
f b
Display digit “3”? g
Set a, b, c, d, g to 1
Set e, f to 0 e c
d
99
7-Segment Decoder
C0
C5 C1
C6
C4 C2
C3
C C C C C C C
0 1 2 3 4 5 6
4-bit Binary-to-7-segment
control signal
decoder
A B C D
100
7-Segment Decoder
• 7-Segment Decoder:
Input is a 4-bit binary code 4 inputs (A, B,
C, D).
Output is a 7-bit code (a,b,c,d,e,f,g) that
allows for the decimal equivalent to be
displayed.
a
• Example:
Input: 0000 f g b
Output: 1111110
e c
(a=b=c=d=e=f=1, g=0)
d
101
Binary-to-7Segment Truth Table
??
102
Binary-to-7Segment Truth Table
??
103