Top Banner
Chapter 2: Boolean Algebra and Logic Gates CPIT 210
48

Chapter2-Boolean Algebra Logic Gates - kau

Jan 26, 2022

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Chapter2-Boolean Algebra Logic Gates - kau

Chapter 2: Boolean Algebra and Logic

Gates

CPIT 210

Page 2: Chapter2-Boolean Algebra Logic Gates - kau

Outlines

1. Introduction2. Basic Boolean operations 3. Digital Logic Gates4. Universal Gates5. Boolean Expressions6. Boolean Algebra7. Simplification of Boolean Functions8. Canonical and Standard Forms

Page 3: Chapter2-Boolean Algebra Logic Gates - kau

Introductionn In chapter 1, we’ve talked about how

arbitrary numbers can be represented using just the two binary values 1 and 0.

n Now we’ll interpret voltages as the logical values “true” and “false” instead. We’ll show:n How logical functions can be defined for

expressing computationsn How to build circuits that implement our functions

in hardware

Page 4: Chapter2-Boolean Algebra Logic Gates - kau

Introductionn Earlier, we used electrical voltages to represent

two discrete values 1 and 0, from which binary numbers can be formed.

n It’s also possible to think of voltages as representingtwo logical values, true and false.

n For simplicity, we often still write digits instead:n 1 is truen 0 is false

n We will use this interpretation along with special operations to design functions and hardware for doing arbitrary computations.

Page 5: Chapter2-Boolean Algebra Logic Gates - kau

Introduction

n Computers take inputs and produce outputs, just like functions in math!

n We can represent logical functions in two analogous ways too:n A finite, but non-unique Boolean expression. n A truth table, which will turn out to be unique and finite.

Page 6: Chapter2-Boolean Algebra Logic Gates - kau

Basic Boolean operations

n There are three basic operations for logical values:

x y xy0 0 00 1 01 0 01 1 1

x y x+y0 0 00 1 11 0 11 1 1

x x’0 11 0

AND(product)oftwoinputs

OR(sum)oftwoinputs

NOT(complement)ononeinput

xy,orx•y x+y x’

Operation:

Expression:

Truthtable:

Page 7: Chapter2-Boolean Algebra Logic Gates - kau

Digital Logic Gates

n A gate is an electronic device that produces a result based on two or more input values.n In reality, gates consist of one to six transistors,

but digital designers think of them as a single unit.

n Integrated circuits contain collections of gates suited to a particular purpose.

Page 8: Chapter2-Boolean Algebra Logic Gates - kau

Digital Logic Gates

n The three simplest gates are the AND, OR, and NOT gates.

n They correspond directly to their respective Boolean operations, as you can see by their truth tables.

Page 9: Chapter2-Boolean Algebra Logic Gates - kau

Digital Logic Gatesn Another very useful gate is the exclusive OR

(XOR) gate. n The output of the XOR operation is true only when

the values of the inputs differ.

Note the special symbol Åfor the XOR operation.

Page 10: Chapter2-Boolean Algebra Logic Gates - kau

Digital Logic Gatesn The exclusive NOR (XNOR) gate. n The output of the XNOR operation is true only

when the values of the inputs similar.

x y XNOR0 0 10 1 01 0 01 1 1

xy

x Å yx � y

x y + x y

Page 11: Chapter2-Boolean Algebra Logic Gates - kau

Digital Logic Gates

n NAND and NOR are two very important gates. Their symbols and truth tables are shown at the right.

Page 12: Chapter2-Boolean Algebra Logic Gates - kau
Page 13: Chapter2-Boolean Algebra Logic Gates - kau
Page 14: Chapter2-Boolean Algebra Logic Gates - kau
Page 15: Chapter2-Boolean Algebra Logic Gates - kau

L

J

Multiple Gates

Page 16: Chapter2-Boolean Algebra Logic Gates - kau

n NAND and NOR are known as universal gates because they are inexpensive to manufacture and any Boolean function can be constructed using only NAND or only NOR gates.

n NAND and NOR are two very important gates. Their symbols and truth tables are shown at the right.

Universal Gates

Page 17: Chapter2-Boolean Algebra Logic Gates - kau

n Universal Gates: A universal gate is a gate which can implement any Boolean function without need to use any other gate type.

n Proving NAND gate is universaln NAND gate is called universal gate

Universal Gates

Page 18: Chapter2-Boolean Algebra Logic Gates - kau

n Proving NOR gate is universaln NOR gate is called universal gate

Universal Gates

Page 19: Chapter2-Boolean Algebra Logic Gates - kau

Boolean Expressionsn We can use these basic operations to form more complex expressions:

f(x,y,z) = (x + y’)z + x’

n Some terminology and notation:n f is the name of the function.n (x,y,z) are the input variables, each representing 1 or 0. Listing the inputs is

optional, but sometimes helpful.n A literal is any occurrence of an input variable or its complement. The

function above has four literals: x, y’, z, and x’.n Precedence are important, but not too difficult.

n NOT has the highest precedence, followed by AND, and then OR.n Fully parenthesized, the function above would be kind of messy:

f(x,y,z) = (((x +(y’))z) + x’)

Page 20: Chapter2-Boolean Algebra Logic Gates - kau

Boolean Expressionsn A truth table shows all possible inputs and outputs of a function.n Remember that each input variable represents either 1 or 0.

n Because there are only a finite number of values (1 and 0).n A function with n variables has 2n possible combinations of inputs.

n Inputs are listed in binary order—in this example, from 000 to 111.

x y z f(x,y,z)0 0 0 10 0 1 10 1 0 10 1 1 11 0 0 01 0 1 11 1 0 01 1 1 1

f(0,0,0) =(0+1)0+1 =1f(0,0,1) =(0+1)1+1 =1f(0,1,0) =(0+0)0+1 =1f(0,1,1) =(0+0)1+1 =1f(1,0,0) =(1+1)0+0 =0f(1,0,1) =(1+1)1+0 =1f(1,1,0) =(1+0)0+0 =0f(1,1,1) =(1+0)1+0 =1

f(x,y,z)=(x+y’)z+x’

Page 21: Chapter2-Boolean Algebra Logic Gates - kau

Boolean Expressionsn Any Boolean expression can be converted into a circuit by combining basic

gates in a relatively straightforward way.n The diagram below shows the inputs and outputs of each gate.n The precedence are explicit in a circuit. We have to make sure that the

hardware does operations in the right order.

(x+y’)z+x’

Page 22: Chapter2-Boolean Algebra Logic Gates - kau

Boolean Expressions

n After finding the circuit inputs and outputs, you can come up with either an expression or a truth table to describe what the circuit does.

n You can easily convert between expressions and truth tables.

Findthecircuit’sinputsandoutputs

FindaBooleanexpression

forthecircuit

Findatruthtableforthecircuit

Page 23: Chapter2-Boolean Algebra Logic Gates - kau

Boolean Algebran Now we’ll learn how to how use Boolean algebra to simplify Booleans

expressions.n Last time, we saw this expression and converted it to a circuit:

(x+y’)z+x’Canwemakethiscircuit“better”?• Cheaper:fewergates• Faster:fewerdelaysfrominputstooutputs

Page 24: Chapter2-Boolean Algebra Logic Gates - kau

Boolean Algebra

n Normal mathematical expressions can be simplified using the laws of algebra

n For binary systems, we can use Boolean algebra, which is superficially similar to regular algebra

n There are many differences, due ton having only two values (0 and 1) to work withn having a complement operationn the OR operation is not the same as addition

Page 25: Chapter2-Boolean Algebra Logic Gates - kau

Boolean Algebran A Boolean algebra requires

n A set of elements B, which needs at least two elements (0 and 1)n Two binary (two-argument) operations OR and ANDn A unary (one-argument) operation NOTn The axioms below must always be true

1. x+0=x 2. x•1=x 3. x+1=1 4. x•0=0 5. x+x=x 6. x•x=x 7. x+x’=1 8. x•x’=0 9. (x’)’=x 10. x+y=y+x 11. xy=yx Commutative12. x+(y+z)=(x+y)+z 13. x(yz)=(xy)z Associative14. x(y+z)=xy+xz 15. x+yz=(x+y)(x+z) Distributive16. (x+y)’=x’y’ 17. (xy)’=x’+y’ DeMorgan’s

Page 26: Chapter2-Boolean Algebra Logic Gates - kau

Boolean Algebran Here are some more useful laws. Notice the duals

again!

1. x+xy=x 4. x(x+y)=x2. xy+xy’=x 5. (x+y)(x+y’)=x3. x+x’y=x+y 6. x(x’+y)=xyxy+x’z+yz=xy+x’z (x+y)(x’+z)(y+z)=(x+y)(x’+z)

Page 27: Chapter2-Boolean Algebra Logic Gates - kau

Boolean Algebran The complement of a function always outputs 0 where the original

function outputted 1, and 1 where the original produced 0.n In a truth table, we can just exchange 0s and 1s in the output

column(s)

f(x,y,z)=x(y’z’+yz)

x y z f(x,y,z)0 0 0 10 0 1 10 1 0 10 1 1 11 0 0 01 0 1 01 1 0 11 1 1 0

x y z f’(x,y,z)0 0 0 00 0 1 00 1 0 00 1 1 01 0 0 11 0 1 11 1 0 01 1 1 1

Page 28: Chapter2-Boolean Algebra Logic Gates - kau

Boolean Algebra

n You can use DeMorgan’s law to keep “pushing” the complements inwards

f(x,y,z)=x(y’z’+yz)

f’(x,y,z)=(x(y’z’+yz))’=x’+(y’z’+yz)’=x’+(y+z)(y’+z’)

Page 29: Chapter2-Boolean Algebra Logic Gates - kau

Simplification of Boolean Functionsn We can now start doing some simplifications

x’y’+xyz+x’y=x’(y’+y)+xyz [Distributive;x’y’+x’y=x’(y’+y)]=x’•1+xyz [Axiom7;y’+y=1]=x’+xyz [Axiom2;x’•1=x’]=(x’+x)(x’+yz) [Distributive]=1• (x’+yz) [Axiom7;x’+x=1]=x’+yz [Axiom2]

Page 30: Chapter2-Boolean Algebra Logic Gates - kau

Simplification of Boolean Functions

n Here are two different but equivalent circuits.

n In general the one with fewer gates is “better”:n It costs less to buildn It requires less powern But we had to do some

work to find the second form

Page 31: Chapter2-Boolean Algebra Logic Gates - kau

Canonical and Standard Forms

n Minterms and Maxterms

n Sum-of-Minterm (SOM) Canonical Form

n Product-of-Maxterm (POM) Canonical Form

n Representation of Complements of Functions

n Conversions between Representations

Page 32: Chapter2-Boolean Algebra Logic Gates - kau

§ Literal:§ The appearance of a variable or its complement.

§ Product Term:§ one or more literals connected by AND operators.

§ Sum Term: § one or more literals connected by OR operators.

Canonical and Standard Forms

(1) x¢yz¢ + x¢yz + xy¢z¢ + xy¢z + xyz 5 sum terms, 15 literals

(2) x¢y + xy¢ + xyz 3 sum terms, 7 literals

(3) (x¢+y) ( x+y¢) (x+z) 3 product terms, 6 literals

(4) (x¢+y )( x+y¢) (y+z) 3 product terms, 6 literals

Page 33: Chapter2-Boolean Algebra Logic Gates - kau

n Minterms are AND sum terms with every variable present in either true or complemented form.

n Example: Two variables (X and Y) produce2 x 2 = 4 combinations:

XY (both normal)XY’ (X normal, Y complemented)X’Y (X complemented, Y normal)X’Y’ (both complemented)

n Thus there are four minterms of two variables.

Canonical and Standard Forms

Page 34: Chapter2-Boolean Algebra Logic Gates - kau

n Maxterms are OR product terms with every variable in true or complemented form.

n Example: Two variables (X and Y) produce2 x 2 = 4 combinations:

X+Y (both normal)X+Y’(x normal, y complemented)X’+Y(x complemented, y normal)X’+Y’(both complemented)

Canonical and Standard Forms

Thus there are four maxterms of two variables.

Page 35: Chapter2-Boolean Algebra Logic Gates - kau

n Two variable minterms and maxterms.

n The minterm mi should evaluate to 1 for each combination of x and y.

n The maxterm is the complement of the minterm

x y Index Minterm Maxterm0 0 0 m0 = x y M0 = x + y0 1 1 m1 = x y M1 = x + y1 0 2 m2 = x y M2 = x + y1 1 3 m3 = x y M3 = x + y

Canonical and Standard Forms

Page 36: Chapter2-Boolean Algebra Logic Gates - kau

Canonical and Standard Forms

M3 = x + y + zm3 = x y z3110M4 = x + y + zm4 = x y z4001M5 = x + y + zm5 = x y z5101M6 = x + y + zm6 = x y z6011

1

100y

1

000x

1

010z

M7 = x + y + zm7 = x y z7

M2 = x + y + zm2 = x y z2M1 = x + y + zm1 = x y z1M0 = x + y + zm0 = x y z0

MaxtermMintermIndex

Page 37: Chapter2-Boolean Algebra Logic Gates - kau

Canonical and Standard Forms

n All variables should be present in a minterm or maxtermand should be listed in the same order (usually alphabetically)

n Example: For variables a, b, c:n Maxterms (a + b + c), (a + b + c) are in standard ordern However, (b + a + c) is NOT in standard order

(a + c) does NOT contain all variablesn Minterms (a b c) and (a b c) are in standard ordern However, (b a c) is not in standard ordern (a c) does not contain all variables

Page 38: Chapter2-Boolean Algebra Logic Gates - kau

Sum-Of-Minterm (SOM)

x y z F Minterm0 0 0 00 0 1 1 m1 = x y z0 1 0 00 1 1 01 0 0 01 0 1 01 1 0 1 m6 = x y z1 1 1 1 m7 = x y z

F = m1 + m6 + m7 = ∑ (1, 6, 7) = x y z + x y z + x y z

Focus on the ‘1’ entries

Page 39: Chapter2-Boolean Algebra Logic Gates - kau

+ a b c d

SOM Examplesn F (a, b, c, d) = ∑(2, 3, 6, 10, 11)n F (a, b, c, d) = m2 + m3 + m6 + m10 + m11

n G (a, b, c, d) = ∑(0, 1, 12, 15)n G (a, b, c, d) = m0 + m1 + m12 + m15

+ a b c da b c d + a b c d+ a b c d + a b c d

+ a b c da b c d + a b c d

Page 40: Chapter2-Boolean Algebra Logic Gates - kau

Product-Of-Maxterm (POM)

x y z F Maxterm0 0 0 10 0 1 10 1 0 0 M2 = (x + y + z)0 1 1 11 0 0 0 M4 = (x + y + z)1 0 1 11 1 0 0 M6 = (x + y + z)1 1 1 1

Focus on the ‘0’ entries

F = M2·M4·M6 = ∏ (2, 4, 6) = (x+y’+z) (x’+y+z) (x’+y’+z)

Page 41: Chapter2-Boolean Algebra Logic Gates - kau

n F (a, b, c, d) = ∏(1, 3, 6, 11)n F (a, b, c, d) = M1 · M3 · M6 · M11

n G (a, b, c, d) = ∏(0, 4, 12, 15)n G (a, b, c, d) = M0 · M4 · M12 · M15

POM Examples

(a+b+c+d) (a+b+c+d) (a+b+c+d) (a+b+c+d)

(a+b+c+d) (a+b+c+d) (a+b+c+d) (a+b+c+d)

Page 42: Chapter2-Boolean Algebra Logic Gates - kau

Observations

n We can implement any function by "ORing" the mintermscorresponding to the ‘1’ entries in the function table. A mintermevaluates to ‘1’ for its corresponding entry.

n We can implement any function by "ANDing" the maxtermscorresponding to ‘0’ entries in the function table. A maxtermevaluates to ‘0’ for its corresponding entry.

n The same Boolean function can be expressed in two canonical ways: Sum-of-Minterms (SOM) and Product-of-Maxterms(POM).

n If a Boolean function has fewer ‘1’ entries then the SOM canonical form will contain fewer literals than POM. However, if it has fewer ‘0’ entries then the POM form will have fewer literals than SOM.

Page 43: Chapter2-Boolean Algebra Logic Gates - kau

Converting to SOM Formn A function that is not in the Sum-of-Minterms form can be

converted to that form by means of a truth tablen Consider F = y’ + x’ z’

x y z F Minterm0 0 0 1 m0 = x y z0 0 1 1 m1 = x y z0 1 0 1 m2 = x y z0 1 1 01 0 0 1 m4 = x y z1 0 1 1 m5 = x y z1 1 0 01 1 1 0

F = ∑(0, 1, 2, 4, 5) =

m0 + m1 + m2 + m4 + m5

x y z + x y z + x y z +

x y z + x y z

Page 44: Chapter2-Boolean Algebra Logic Gates - kau

Converting to POS Formn A function that is not in the Product-of-Minterms form can

be converted to that form by means of a truth tablen Consider again: F = y + x z

x y z F Minterm0 0 0 10 0 1 10 1 0 10 1 1 0 M3 = (x+y+z)1 0 0 11 0 1 11 1 0 0 M6 = (x+y+z)1 1 1 0 M7 = (x+y+z)

F = ∏(3, 6, 7) =

M3 · M6 · M7 =

(x+y+z) (x+y+z) (x+y+z)

Page 45: Chapter2-Boolean Algebra Logic Gates - kau

Conversions Between Canonical Forms

F = m1+m2+m3+m5+m7 = ∑(1, 2, 3, 5, 7) = x y z + x y z + x y z + x y z + x y zF = M0 · M4 · M6 = ∏(0, 4, 6) = (x+y+z)(x+y+z)(x+y+z)

x y z F Minterm Maxterm0 0 0 0 M0 = (x + y + z)0 0 1 1 m1 = x’ y’ z0 1 0 1 m2 = x’ y’ z0 1 1 1 m3 = x y z1 0 0 0 M4 = (x’ + y + z)1 0 1 1 m5 = x y’ z1 1 0 0 M6 = (x’ + y’ + z)1 1 1 1 m7 = x y z

Page 46: Chapter2-Boolean Algebra Logic Gates - kau

Algebraic Conversion to SOM§ Expand all terms first to explicitly list all minterms§ AND any term missing a variable v with (v + v)§ Example 1: f = x + x y (2 variables)

f = x (y + y) + x yf = x y + x y + x yf = m3 + m2 + m0 = ∑(0, 2, 3)

§ Example 2: g = a + b c (3 variables)g = a (b + b)(c + c) + (a + a) b cg = a b c + a b c + a b c + a b c + a b c + a b cg = a b c + a b c + a b c + a b c + a b cg = m1 + m4 + m5 + m6 + m7 = ∑ (1, 4, 5, 6, 7)

Page 47: Chapter2-Boolean Algebra Logic Gates - kau

Algebraic Conversion to POM§ Expand all terms first to explicitly list all maxterms§ OR any term missing a variable v with v · v§ Example 1: f = x + x y (2 variables)

Apply 2nd distributive law:f = (x + x) (x + y) = 1 · (x + y) = (x + y) = M1

§ Example 2: g = a c + b c + a b (3 variables)g = (a c + b c + a) (a c + b c + b) (distributive)g = (c + b c + a) (a c + c + b) (x + x y = x + y)g = (c + b + a) (a + c + b) (x + x y = x + y)g = (a + b + c) (a + b + c) = M5 . M2 = ∏ (2, 5)

Page 48: Chapter2-Boolean Algebra Logic Gates - kau

Standard SOP§ A Simplification Example:

§ Writing the minterm expression:F = A B C + A B C + A B C + ABC + ABC

§ Simplifying:F = A B C + A (B C + B C + B C + B C)F = A B C + A (B (C + C) + B (C + C))F = A B C + A (B + B)F = A B C + AF = B C + A

§ Simplified F contains 3 literals compared to 15

)7,6,5,4,1()C,B,A(F S=