Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra....

24
01/21/2009 Wei Lu CS2813 1 Computer Organization I Lecture 6: Boolean Algebra

Transcript of Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra....

Page 1: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 1

Computer Organization I

Lecture 6: Boolean Algebra

Page 2: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 2

� Two Principles in Boolean Algebra(1) Duality Principle

(2) Complement Principle

� Standard Form of Logic Expression(1) Sum of Minterm

(2) Product of Maxterm

Overview

Page 3: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 3

Objectives

� Know how to obtain the dual of a logic expression

� Know how to obtain the complement of a logic expression

� Understand the Minterm and Maxterm

� Know how to write a logic expression using Minterm

� Know how to write a logic expression using Maxterm

Page 4: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 4

Two Principles in Boolean Algebra - Duality Principle

� The dual of a logical expression is obtained by interchanging + (OR) and · (AND) and 0 and 1.

� The identity is self-dual if the dual expression is equal to the original expression

• Example: F = (A + C) · B + 0

dual F = (A · C + B) · 1 = A · C + B

• Example: G = X · Y + (W + Z)

dual G = (X + Y) · (W · Z) = (X + Y) · (W + Z)

• Example: H = A · B + A · C + B · C

dual H = (A + B) · (A + C) · (B + C)

= (A + B · C) · (B + C)

= A · B + A · C + B · C

• Are any of these functions self-dual?

Page 5: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 5

Two Principles in Boolean Algebra - Duality Principle

� Duality Principle states that the Boolean equation remains valid if we take the dual of the expression on both sides of the equal sign

• Example: A + 0 = A, according to duality principle, we have

A · 1 = A, one of the basic rules of Boolean algebra

• Example: X + X · Y = X + Y, using duality principle, we

have

X · (X + Y) = X · Y

Page 6: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 6

Two Principles in Boolean Algebra - Complement Principle

Example: F = X · Y · Z + X · Y · Z

complement F, F = (X + Y + Z) · (X + Y + Z)

Example: G = (A + B · C) · D + E

complement G, G = (A · (B + C) + D) · E

Example: H = A + B + C

complement H, H = A · B · C = A + B + C

� The complement of a function F represented by F, which is obtained from interchanging AND and OR operators, and complement each constant value and literal

Page 7: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 7

Standard Forms of Logic Expression- What is Standard Forms?

• motivation of standard forms

We have known one Boolean function can be represented by

different Boolean expressions with a unique truth table. It is

useful to specify Boolean functions in a specific form that:

– Allows comparison for equality,

– Has a correspondence to the truth table

This specific form is called standard form of a logic expression

• standard forms usually contain:– Sum of Minterms (SOM)

– Product of Maxterms (POM)

Page 8: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 8

Standard Forms of Logic Expression- What is Minterm?

• Minterm is a product (AND) term in which all the variables appeared exactly once, either normal or complemented form.

Example: X · Y · Z is a product term consisting of an “AND”

operation and 3 literals X, Y and Z

• Given that each binary variable may appear normal (e.g., X) or complemented (e.g., X), there are 2n minterms for n variables.

• Example: Two variables (X and Y) produce 2 x 2 = 4 combinations

XY (both normal)

XY (X normal, Y complemented)

XY (X complemented, Y normal)

XY (both complemented)

• Thus there are four minterms of two variables.

Page 9: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 9

Standard Forms of Logic Expression- What is Maxterm?

• Maxterm is a sum (OR) term in which all the variables appeared exactly once, either normal or complemented form.

• Given that each binary variable may appear normal (e.g., X) or complemented (e.g., X), there are 2n maxterms for n variables.

• Example: Two variables (X and Y) produce 2 x 2 = 4 combinations

X + Y (both normal)

X + Y (X normal, Y complemented)

X + Y (X complemented, Y normal)

X + Y (both complemented)

• Thus there are four maxterms of two variables.

Page 10: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 10

Standard Forms of Logic Expression- Standard Order of Minterm and Maxterm

• All variables will be presented in a minterm or maxterm and will be list in the same order (usually alphabetically)

• Example: For variables a, b, c:

– Maxterms: (a + b + c), (a + b + c)

– Terms: (b + a + c), a c b, and (c + b + a) are NOT in standard order.

– Minterms: a b c, a b c, a b c

– Terms: (a + c), b c, and (a + b) do not contain all variables

Page 11: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 11

Standard Forms of Logic Expression- Index of Minterm and Maxterm

• Minterms and maxterms are designated with a subscript

• The subscript is an index number, corresponding to a binary pattern, is used to represent the complemented or normal state of each variable list in a standard order.

• For Minterms:

– “1” means the variable is “Normal or Not Complemented”

– “0” means the variable is “Complemented”.

• For Maxterms:

– “0” means the variable is “Normal/Not Complemented”

– “1” means the variable is “Complemented”.

Page 12: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 12

Standard Forms of Logic Expression- Index Example in Three Variables

• Example: (for three variables)

• Assume the variables are called X, Y, and Z.

• The standard order is X, then Y, then Z.

• The Index 0 (base 10) = 000 (base 2) for three variables. All

three variables are complemented for minterm 0 (X,Y,Z)

and no variables are complemented for Maxterm 0 (X,Y,Z).

– Minterm 0, called m0 is X,Y,Z

– Maxterm 0, called M0 is (X + Y + Z)

– Minterm 6 ?

called m6 is X,Y,Z

– Maxterm 6 ?

called M6 is (X + Y + Z)

Page 13: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 13

Standard Forms of Logic Expression- Index Example in Four Variables

Index Binary Minterm Maxterm

i Pattern mi Mi

0 0000 ABCD A+B+C+D

1 0001 ABCD ?

3 0011 ? A+B+C+D

5 0101 ABCD A+B+C+D

7 0111 ? A+B+C+D

10 1010 ABCD A+B+C+D

13 1101 ABCD ?

15 1111 ABCD A+B+C+D

Page 14: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 14

Standard Forms of Logic Expression- Relationship of Minterm and Maxterm

• Review: DeMorgan's Theorem

X · Y = X + Y and X + Y = X · Y

• Two-variable example:

M2 = X + Y and m2 = X · Y

Thus M2 is the complement of m2 and vice-versa.

• Since DeMorgan's Theorem holds for n variables, the

above holds for terms of n variables

• i.e. giving:

Mi = mi and mi = Mi

Thus Mi is the complement of mi.

·

Page 15: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 15

Standard Forms of Logic Expression- Minterm, Maxterm and Truth Table

A B m0

AB

m1

AB

0 0 1 0

0 1 0 1

1 0 0 0

1 1 0 0

m2

AB

m3

AB

0 0

0 0

1 0

0 1

M0

A + B

M1

A + B

0 1

1 0

1 1

1 1

M2

A + B

M3

A + B

1 1

1 1

0 1

1 0

Each column in the maxterm function is the complement of the column

in the minterm function since Mi is the complement of mi.

Page 16: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 16

Standard Forms of Logic Expression- Why call Minterm and Maxterm?

A B m0

AB

m1

AB

0 0 1 0

0 1 0 1

1 0 0 0

1 1 0 0

m2

AB

m3

AB

0 0

0 0

1 0

0 1

M0

A + B

M1

A + B

0 1

1 0

1 1

1 1

M2

A + B

M3

A + B

1 1

1 1

0 1

1 0

• In the table:

– Each minterm has one and only one 1 present in the 2n terms (i.e. has a minimum number of 1). All other entries are 0.

– Each maxterm has one and only one 0 present in the 2n terms All other entries are 1 (has a maximum number of 1).

Page 17: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 17

Standard Forms of Logic Expression

• We can implement any function by "ORing" the mintermscorresponding to "1" entries in the truth table. These are called the Sum Of Minterms (SOM) function.

• We can implement any function by "ANDing" the maxtermscorresponding to "0" entries in the truth table. These are called the Product Of Maxterms (POM) function.

• This gives us two standard forms:

– Sum of Minterms (SOM)

– Product of Maxterms (POM)

for stating any Boolean function.

Page 18: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 18

Standard Forms of Logic Expression- SOM Example

• In order to make F equal to 1, F is equal to m0 OR m2 or m5 OR m7, thus "ORing" the minterms corresponding to "1“ we have the SOM of F = m0 + m2 + m5 + m7 = ABC + ABC + ABC + ABC

A B C m0

ABC

m1

ABC

0 0 0 1 0

0 0 1 0 1

0 1 0 0 0

0 1 1 0 0

m2

ABC

m3

ABC

0 0

0 0

1 0

0 1

m4

ABC

m5

ABC

0 0

0 0

0 0

0 0

m6

ABC

m7

ABC

0 0

0 0

0 0

0 0

1 0 0 0 0

1 0 1 0 0

1 1 0 0 0

1 1 1 0 0

0 0

0 0

0 0

0 0

1 0

0 1

0 0

0 0

0 0

0 0

1 0

0 1

F

?

1

0

1

0

0

1

0

1

Page 19: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 19

Standard Forms of Logic Expression- POM Example

• In order to make sure F equal to 0, F is equal to M1 AND M3 AND M4 AND M6, thus “ANDing" the maxterms corresponding to “0“we have the POM of F = M1 · M3 · M4 · M6 = (A+B+C) · (A+B+C) · (A+B+C) · (A+B+C)

A B C M0

A+B+C

M1

A+B+C

0 0 0 0 1

0 0 1 1 0

0 1 0 1 1

0 1 1 1 1

M2

A+B+C

M3

A+B+C

1 1

1 1

0 1

1 0

M4

A+B+C

M5

A+B+C

1 1

1 1

1 1

1 1

M6

A+B+C

M7

A+B+C

1 1

1 1

1 1

1 1

1 0 0 1 1

1 0 1 1 1

1 1 0 1 1

1 1 1 1 1

1 1

1 1

1 1

1 1

0 1

1 0

1 1

1 1

1 1

1 1

0 1

1 0

F

?

1

0

1

0

0

1

0

1

Page 20: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 20

Standard Forms of Logic Expression- Conversion from SOM to POM

• F (A,B,C) = m1 + m3 + m4 + m6 = ƩƩƩƩm (1,3,4,6), ƩƩƩƩ is the logical sum of minterms

• F (A,B,C) = F (A,B,C) = m1 + m3 + m4 + m6 = m1·m3·m4·m6

= M1 · M3 · M4 · M6 = ∏∏∏∏M(1,3,4,6)

A B C m0

ABC

m1

ABC

0 0 0 1 0

0 0 1 0 1

0 1 0 0 0

0 1 1 0 0

m2

ABC

m3

ABC

0 0

0 0

1 0

0 1

m4

ABC

m5

ABC

0 0

0 0

0 0

0 0

m6

ABC

m7

ABC

0 0

0 0

0 0

0 0

1 0 0 0 0

1 0 1 0 0

1 1 0 0 0

1 1 1 0 0

0 0

0 0

0 0

0 0

1 0

0 1

0 0

0 0

0 0

0 0

1 0

0 1

F

1

0

1

0

0

1

0

1

F

0

1

0

1

1

0

1

0

Page 21: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 21

Standard Forms of Logic Expression- SOM Examples

• Example: Implement F in Minterms:

F (A,B,C) = m1 + m4 + m7

F (A,B,C,D,E) = m2 + m9 + m17 + m23

Page 22: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 22

Standard Forms of Logic Expression- POM Examples

Example: Implement F in Maxterms:

F (A,B,C) = M0 · M2 · M3 · M5 · M6

F (A,B,C,D) = M3 · M8 · M11 · M14

Page 23: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 23

Summary

• Duality and Complement Principles

• Two Standard Forms of Logic Expressions(1) Sum of Minterm

(2) Product of Maxterm

Page 24: Lecture 6: Boolean Algebra - UVicwlu/Teaching/Winter/lecture 6.pdf · Lecture 6: Boolean Algebra. 01/21/2009 Wei Lu CS2813 2 Two Principles in Boolean Algebra (1) Duality Principle

01/21/2009 Wei Lu CS2813 24

Thank youQ & A