Fabrizio PREGADIO, Liu Yiming - Superior Virtue, Inferior Virtue
Boolean Algebra Introduction Logical arguments are valid (or not) by virtue of their form, not...
Transcript of Boolean Algebra Introduction Logical arguments are valid (or not) by virtue of their form, not...
Boolean Algebra
IntroductionLogical arguments are valid (or not) by virtue of their form, not content
ExampleAll men are mortal (premise 1)Harry is a man (premise 2)-------------------------------------------Harry is mortal (conclusion)
This regularity allows implementation of logic by computers, which have no capacity to understand meaning
Boolean Algebra
Logical variables
P, Q, YourMamma, Waverly
take values 0 or 1 only
Logical operators OR operator AND operator
NOT operator
P1 P2 P1 + P2
0011
0101
0111
P1 P2 P1 P2
0011
0101
0001
P P’
01
10
Boolean Algebra
Truth tablesArbitrary functions can be composed from these elementary operators acting on variables
Example
Properties of truth tables1) If there are n variables, there will be 2n rows2) Rows are listed in counting order3) Intermediate results may be shown in inserted columns
P1 P2 P3 (P1 + P2) (P1 + P2) P3 [(P1 + P2) P3]΄
00001111
00110011
01010101
00111111
00010101
11101010
Boolean Algebra
Other logical operatorsOR, AND, and NOT operators are sufficient to represent any logical function; however, other operators will prove useful in digital design
NAND and NOR
XOR
P Q P NAND Q
0 0 1 1
0 1 0 1
1 1 1 0
P Q P NOR Q
0 0 1 1
0 1 0 1
1 0 0 0
P1 P2 P1 XOR P2
0 0 1 1
0 1 0 1
0 1 1 0
Boolean Algebra
Tautology, Equivalence, and Logical LawsA tautology is a function that is always true
Example
Equivalence operator
P P ́ P + P ́0 1
1 0
1 1
P1 P2 P1 ≡ P2 0 0 1 1
0 1 0 1
1 0 0 1
Boolean Algebra
Tautology, Equivalence, and Logical Laws (cont.)If an equivalence is a tautology, then the two expressions are interchangeable. Why? Because a function is completely defined by its truth values.
Example
This is one form of DeMorgan’s Law
P1 P2 (P1 + P2) ́ (P1 ́ P2 )́ (P1 + P2) ́≡ (P1 ́ P2 )́ 0 0 1 1
0 1 0 1
1 0 0 0
1 0 0 0
1 1 1 1
Boolean Algebra
SimplificationGoal: Reduce size of a functionMethod 1: Successive application of equivalence theoremsSample theoremstheorem dual
(T1) X + 0 ≡ X (T1)d X ∙ 1 ≡ X
(T2) X + 1 ≡ 1 (T2)d X ∙ 0 ≡ 0
(T3) X + X ≡ X (T3)d XX ≡ X
(T4) X + X΄ ≡ 1 (T4)d XX’ ≡ 0
(T5) (X΄)΄ ≡ X
(T6) X + Y ≡Y + X (T6)d XY ≡ YX
(T7) (X + Y)΄ ≡ (X΄ ∙ Y΄) (T7)d (XY)΄ ≡ (X΄ + Y΄)
(T8) (X + Y) + Z ≡ X + (Y + Z) (T8)d (XY) Z X(YZ)
(T9) XY + XZ ≡ X(Y + Z) (T9)d (X + Y) (X + Z) ≡ X + YZ
(T10) X + XY≡ X (T10)d X(X + Y) ≡ X
Boolean Algebra
Simplification (method 1)Fact about the theorems
1) 0 and 1 are constants that always take these values2) AND can be implicit (as with multiplication in numerical algebra)3) All equivalences can be proven with a truth table4) Every theorem is accompanied by its dual obtained by switching
all 0’s and 1’s and all ∙’s and +’s. When these switches are made, a new valid theorem is obtained.5) Every symbol in every identity can be systematically replaced by arbitrary expressions.6) A number of theorems are identical to those of numerical algebra(e.g., (T8) and (T9), but not (T9)d)
Boolean Algebra
Simplification (method 1)Example 1step justification1. PQ + PQ΄ given2. P(Q + Q΄) (T9)3. P(1) (T4)4. P (T1)d
Example 2step justification
1. P1P2 + P1΄P3 + P2P3 given
2. P1P2 + P1΄P2 + P2P3(1) (T1)d
3. P1P2 + P1’P3 + P2P3(P1 + P1΄) (T4)4. P1P2 + P1΄P3 + P1P2P3 + P1΄P2P3 (T9), (T6)d
5. P1P2 + P1P2P3 + P1΄P3 + P1΄P2P3 (T6)6. P1P2(1 + P3) + P1’P3(1 + P2) (T9), two applications7. P1P2(1) + P1΄P3(1) (T2)8. P1P2 + P1΄P3 (T1)
Note: This simplification involves expansion before contraction
Boolean Algebra
Simplification (method 2)Motivation
Simplification with equivalence theorems is unsystematic(witness the 2nd example)
AlternativeReduce function to sum of minterms (SOP) or product of maxterms
(POS), then simplify on a Karnaugh map
Boolean Algebra
Simplification (method 2)Minterms and Maxterms
minterm product of variables with variable negated if corresponding value is 0
maxterm sum of variables with variable negated if corresponding value is 1
Minterms and maxterms for 4 variable functions
# W X Y Z minterm maxterm
0123456789101112131415
0000000011111111
0000111100001111
0011001100110011
0101010101010101
W΄X΄Y΄Z΄
W΄X΄Y΄ZW΄X΄YZ΄
W΄X΄YZW΄XY΄Z΄
W΄XY΄ZW΄XYZ΄
W΄XYZWX΄Y΄Z΄
WX΄Y΄ZWX΄YZ΄
WX΄YZWXY΄Z΄
WXY΄ZWXYZ΄
WXYZ
W + X + Y + ZW + X + Y + Z΄
W + X + Y΄ + ZW + X + Y΄ + Z΄
W + X΄+ Y + ZW + X΄ + Y + Z΄
W + X΄+ Y΄ + ZW + X΄+ Y΄ + Z΄
W΄+ X + Y + ZW΄ + X + Y + Z΄
W΄ + X + Y΄ + ZW΄ + X + Y΄ + Z΄
W΄ + X΄ + Y + ZW΄ + X΄ + Y + Z΄
W΄+ X΄ + Y΄ + ZW΄ + X΄ + Y΄ + Z΄
Boolean Algebra Simplification (method 2)
TheoremEvery function can be rewritten as 1) Sum of the minterms where the function is 1 (SOP), or2) Product of the maxterms where the function is 0 (POS)
Example F = Y΄(X + W) + Z΄ SOP: F = W΄X΄Y΄Z΄ + W΄X΄YZ΄ + W΄XY΄Z΄ + W΄XY΄Z +
W΄XYZ΄ + WX΄Y΄Z΄ + WX΄Y΄Z΄’ + WX΄YZ΄ + WXY΄Z’ + WXY΄Z + WXYZ΄, or
F = WXYZ(0,2,4,5,6,8,9,10,12,13,14). POS: F = (W + X + Y + Z΄)(W + X + Y΄ + Z΄)(W + X΄+Y’+ Z΄)
(W΄ + X + Y΄ + Z΄) (W΄+ X΄ + Y΄ + Z΄), or
F = WXYZ(1,3,7,11,15).
# W X Y Z F = Y΄ (X + W) + Z΄
0123456789
101112131415
0000000011111111
0000111100001111
0011001100110011
0101010101010101
1010111011101110
Boolean Algebra Simplification (method 2, aside)
How many operators are necessary?AND, OR and NOT can be used to represent any SOPand therefore any function
But, an SOP with only positive literals can be rendered with only NAND’s by replacing all operators with NAND Example AB + CD ≡ (A NAND B) NAND (C NAND D)
And, can achieve NOT as follows: P’ ≡ P NAND P
Therefore, NAND suffices to represent any function.
Example AC’ + A’B + BC ≡ (A NAND (C NAND C)) NAND ((A NAND A) NAND B) NAND (B
NAND C)
Boolean Algebra Simplification (method 2)
Karnaugh maps
Procedure
1) Enter the minterms for the function on the map.
2) Determine all the prime implicants of the function.
3) Determine the smallest subset of these prime implicants that cover all the prime implicants.4) Name these implicants and construct the final expression.
Boolean Algebra Simplification (method 2)
Karnaugh maps
Step 1:Enter terms F = W΄XYZ + WXY΄ + WXY + X΄YZ + W΄X΄Y΄Z΄
= WXYZ(0,7,8,9,12,13,14,15)
Note: Gray code ordering on map
W XY Z
0 0 0 1 1 1 1 0
0 0
0 1
1 1
1 0
0
1
2
3
4
5
6
7
1 2
1 3
1 4
1 5
8
9
1 0
1 1
1
1
1
1
1
1
1
1
Boolean Algebra Simplification (method 2)
Karnaugh maps
Step 2: Determine prime implicants (PI’s)
What is a PI?i. Consists of 2n minterms, where n is an integer
ii. It forms a continuous rectangle over the 3D torus formed by joining the ends of the map
iii. It is not subsumed by a larger PI
0
1
4
5
8 1 2
9 1 3
2
3
6
7
1 0 1 4
11 1 5
Boolean Algebra
Simplification (method 2)Karnaugh maps
Step 2: Determine prime implicants (PI’s)
Example
W X0 0 0 1 1 0
0 1
1 1
1 0
1 1
1 1 1
1
1 1
1
1 2
3
41
0 0
Y Z
Boolean Algebra Simplification (method 2)
Karnaugh maps
Step 3: Find minimal set of PI’si. Find all essential prime implicants (those that contain a minterm not covered by any other PI)ii. Cover rest of minterms with other PI’s
Example
All are necessary (all have distinguished minterms)
W X0 0 0 1 1 0
0 1
1 1
1 0
1 1
1 1 1
1
1 1
1
1 2
3
41
0 0
Y Z
Boolean Algebra Simplification (method 2)
Karnaugh maps
Step 4: Name the PI’s in the minimal set
Rule: The name of the PI will correspond to a product of the variables that don’t change, with the variable negated if it always 0, and not negated otherwise.
Example (PI 1)
WXY΄Z΄ + WXY΄Z + WXYZ΄ + WXY΄Z΄≡ WX(Y΄Z΄ + Y΄Z + YZ΄ + Y΄Z΄)≡ WX(Y΄(Z΄ + Z) + Y(Z΄ + Z)≡ WX(Y΄(1) + Y(1))≡ WX(Y΄(1) + Y(1))≡ WX(Y΄ + Y)≡ WX(1)≡ WX
W X0 0 0 1 1 0
0 1
1 1
1 0
1 1
1 1 1
1
1 1
1
1 2
3
41
0 0
Y Z
Boolean Algebra Simplification (method 2)
Karnaugh maps
Step 4: Name the PI’s in the minimal set.
Full set of PI’s for this example:
WX + WY΄ + X΄Y΄Z΄ + XYZ
Comparison with original expression
W΄XYZ + WXY΄ + WXY + X΄YZ + W΄X΄Y΄Z
(5 product terms reduced to 4, 17 literals to 10)
W X0 0 0 1 1 0
0 1
1 1
1 0
1 1
1 1 1
1
1 1
1
1 2
3
41
0 0
Y Z
Boolean Algebra Simplification (method 2)
Karnaugh maps
Another example WXYZ(0,1,2,3,4,5,6,14,15)
PI’sW΄X΄ comprising minterms 0,1,2,3W΄Y΄ comprising minterms 0,1,4,5W΄Z΄ comprising minterms 0,2,4,6XYZ΄ comprising minterms 6,14 not essentialWXY comprising minterms 14,15
Essential PI’s cover all minterms W΄X΄ + W΄Y΄ + W΄Z΄ + WXY
Y Z0 0 0 1 1 1 1 0
0 0
0 1
1 1
1 0
0
1
2
3
4
5
6
7
1 2
1 3
1 4
1 5
8
9
1 0
1 1
1
1
1 1 1
1
1
1
1
Y Z1 1 1 0
0 0
0 1
1 1
1 0
1
1
1 1 1
1
1
1
1
2
4
51
W X0 0 0 1
3
Boolean Algebra Simplification (method 2)
Karnaugh maps, POS minimization
WXYZ(0,1,2,3,4,5,6,14,15)
PI’sW΄ + X, comprising maxterms 8,9,10,11W΄ + Y, comprising maxterms 8,9,12,13W + X΄ + Y΄ + Z΄, comprising maxterm 7
Essential PI’s cover all minterms (W΄ + X)(W΄ + Y)(W + X΄ + Y΄ + Z΄) slightly better than SOP minimization
W XY Z
0 0 0 1 1 1 1 0
0 0
0 1
1 1
1 0
1
1
1 1 1
1
1
1
1
1
1
2
3
Boolean Algebra Simplification (method 2)
Karnaugh maps, a hard example
SOP and POS minimization does not work
But, if target representation is changed, a single term results! (W XOR X) XOR (Y XOR Z)
Furthermore, a small counting machine covers minterms regardless of number of variables
MORAL: Finding the optimal circuit is non-trivial. This makes Digital Design an art as well as an engineering task.
W XY Z
0 0 0 1 1 1 1 0
0 0
0 1
1 1
1 0
0
1
2
3
4
5
6
7
1 2
1 3
1 4
1 5
8
9
1 0
1 1
1
1
1
1 1
1
1
1
p
Boolean Algebra
Simplification (method 2)Karnaugh maps
Summary of minimization
o r ig in a lex p r es s io n
tr u th tab le
m in ter m s o nKar n au g h
m in im izedS O P
m in im izedP O S
m in im u m o fm in im u m s
m in im als e t o f P I 's
Boolean Algebra
Summary of topicsFunctionsTruth tablesTautologies and equivalenceSimplification with equivalenceSimplification with Karnaugh maps
minterms and maxtermsPrime ImplicantsSOP and POS minimization
Simplification depends on representation (the art of design)