• Tidak ada hasil yang ditemukan

Boolean Algebra and Logic Gates - CPIT 210

N/A
N/A
Protected

Academic year: 2025

Membagikan "Boolean Algebra and Logic Gates - CPIT 210"

Copied!
48
0
0

Teks penuh

(1)

Chapter 2:

Boolean Algebra and Logic Gates

CPIT 210

(2)

Outlines

1. Introduction

2. Basic Boolean operations 3. Digital Logic Gates

4. Universal Gates

5. Boolean Expressions 6. Boolean Algebra

7. Simplification of Boolean Functions

8. Canonical and Standard Forms

(3)

Introduction

n

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 computations

n

How to build circuits that implement our functions

in hardware

(4)

Introduction

n

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 representing two logical values, true and false.

n

For simplicity, we often still write digits instead:

n

1 is true

n

0 is false

n

We will use this interpretation along with special

operations to design functions and hardware for

doing arbitrary computations.

(5)

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.

(6)

Basic Boolean operations

n

There are three basic operations for logical values:

x y xy 0 0 0 0 1 0 1 0 0 1 1 1

x y x+y 0 0 0 0 1 1 1 0 1 1 1 1

x x’

0 1

1 0

AND (product)

of two inputs OR (sum) of

two inputs NOT (complement) on one input

xy, or xy x + y x’

Operation:

Expression:

Truth table:

(7)

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.

(8)

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.

(9)

Digital Logic Gates

n

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.

(10)

Digital Logic Gates

n

The exclusive NOR (XNOR) gate.

n

The output of the XNOR operation is true only when the values of the inputs similar.

x y XNOR

0 0 1

0 1 0

1 0 0

1 1 1

x

y x Å y

x  y x y + x y

(11)

Digital Logic Gates

n

NAND and NOR are two very

important gates.

Their symbols and truth tables are

shown at the right.

(12)
(13)
(14)
(15)

L J

Multiple Gates

(16)

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

(17)

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 universal

n

NAND gate is called universal gate

Universal Gates

(18)

n

Proving NOR gate is universal

n

NOR gate is called universal gate

Universal Gates

(19)

Boolean Expressions

n 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’)

(20)

Boolean Expressions

n 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 1

0 0 1 1

0 1 0 1

0 1 1 1

1 0 0 0

1 0 1 1

1 1 0 0

1 1 1 1

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

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

(21)

Boolean Expressions

n 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’

(22)

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.

Find the circuit’s inputs and outputs

Find a Boolean expression for the circuit

Find a truth table for the circuit

(23)

Boolean Algebra

n 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’

Can we make this circuit

“better”?

Cheaper: fewer gates

Faster: fewer delays from inputs to outputs

(24)

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 to

n having only two values (0 and 1) to work with

n having a complement operation

n the OR operation is not the same as addition

(25)

Boolean Algebra

n

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 AND

n

A unary (one-argument) operation NOT

n

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 Commutative

12. x + (y + z) = (x + y) + z 13. x(yz) = (xy)z Associative 14. x(y + z) = xy + xz 15. x + yz = (x + y)(x + z) Distributive

16. (x + y)’ = x’y’ 17. (xy)’ = x’ + y’ DeMorgan’s

(26)

Boolean Algebra

n

Here are some more useful laws. Notice the duals again!

1. x + xy = x 4. x(x + y) = x

2. xy + xy’ = x 5. (x + y)(x + y’) = x 3. x + x’y = x + y 6. x(x’ + y) = xy

xy + x’z + yz = xy + x’z (x + y)(x’ + z)(y + z) = (x + y)(x’ + z)

(27)

Boolean Algebra

n 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 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 0

x y z f’(x,y,z) 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 1 1 0 1 1 1 1 0 0 1 1 1 1

(28)

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’)

(29)

Simplification of Boolean Functions

n

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 [ Axiom 7; y’ + y = 1 ]

= x’ + xyz [ Axiom 2; x’ • 1 = x ’ ]

= (x’ + x)(x’ + yz) [ Distributive ]

= 1 • (x’ + yz) [ Axiom 7; x’ + x = 1 ]

= x’ + yz [ Axiom 2 ]

(30)

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 build

n It requires less power

n But we had to do some work to find the second form

(31)

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

(32)

§ 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

(33)

n

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

n

Example: Two variables (X and Y) produce 2 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

(34)

n

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

n

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)

Canonical and Standard Forms

Thus there are four maxterms of two variables.

(35)

n

Two variable minterms and maxterms.

n

The minterm m

i

should evaluate to 1 for each combination of x and y.

n

The maxterm is the complement of the minterm

x y Index Minterm Maxterm 0 0 0 m

0

= x y M

0

= x + y 0 1 1 m

1

= x y M

1

= x + y 1 0 2 m

2

= x y M

2

= x + y 1 1 3 m

3

= x y M

3

= x + y

Canonical and Standard Forms

(36)

Canonical and Standard Forms

M3 = x + y + z m3 = x y z

3 1

1 0

M4 = x + y + z m4 = x y z

4 0

0 1

M5 = x + y + z m5 = x y z

5 1

0 1

M6 = x + y + z m6 = x y z

6 0

1 1

1 1 0 0 y

1 0 0 0 x

1 0 1 0 z

M7 = x + y + z m7 = x y z

7

M2 = x + y + z m2 = x y z

2

M1 = x + y + z m1 = x y z

1

M0 = x + y + z m0 = x y z

0

Maxterm Minterm

Index

(37)

Canonical and Standard Forms

n

All variables should be present in a minterm or maxterm and 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 order

n

However, (b + a + c) is NOT in standard order (a + c) does NOT contain all variables

n

Minterms (a b c) and (a b c) are in standard order

n

However, (b a c) is not in standard order

n

(a c) does not contain all variables

(38)

Sum-Of-Minterm (SOM)

x y z F Minterm

0 0 0 0

0 0 1 1 m

1

= x y z

0 1 0 0

0 1 1 0

1 0 0 0

1 0 1 0

1 1 0 1 m

6

= x y z

1 1 1 1 m

7

= x y z

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

‘1’ entries

(39)

+ a b c d

SOM Examples

n

F ( a , b , c , d ) = ∑(2, 3, 6, 10, 11)

n

F ( a , b , c , d ) = m

2

+ m

3

+ m

6

+ m

10

+ m

11

n

G (a, b, c, d) = ∑(0, 1, 12, 15)

n

G (a, b, c, d) = m0 + m1 + m12 + m15

+ 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

(40)

Product-Of-Maxterm (POM)

x y z F Maxterm

0 0 0 1

0 0 1 1

0 1 0 0 M

2

= (x + y + z)

0 1 1 1

1 0 0 0 M

4

= (x + y + z)

1 0 1 1

1 1 0 0 M

6

= (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)

(41)

n

F ( a , b , c , d ) = ∏(1, 3, 6, 11)

n

F ( a , b , c , d ) = M

1

· M

3

· M

6

· M

11

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)

(42)

Observations

n

We can implement any function by "ORing" the minterms corresponding to the ‘1’ entries in the function table. A minterm evaluates to ‘1’ for its corresponding entry.

n

We can implement any function by "ANDing" the maxterms corresponding to ‘0’ entries in the function table. A maxterm evaluates 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.

(43)

Converting to SOM Form

n

A function that is not in the Sum-of-Minterms form can be converted to that form by means of a truth table

n

Consider F = y’ + x’ z’

x y z F Minterm

0 0 0 1 m0 = x y z 0 0 1 1 m1 = x y z 0 1 0 1 m2 = x y z

0 1 1 0

1 0 0 1 m4 = x y z 1 0 1 1 m5 = x y z

1 1 0 0

1 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

(44)

Converting to POS Form

n

A function that is not in the Product-of-Minterms form can be converted to that form by means of a truth table

n

Consider again: F = y + x z

x y z F Minterm

0 0 0 1

0 0 1 1

0 1 0 1

0 1 1 0 M

3

= (x+y+z)

1 0 0 1

1 0 1 1

1 1 0 0 M

6

= (x+y+z) 1 1 1 0 M

7

= (x+y+z)

F = ∏(3, 6, 7) = M3 · M6 · M7 =

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

(45)

Conversions Between Canonical Forms

F = m

1

+m

2

+m

3

+m

5

+m

7

= ∑(1, 2, 3, 5, 7) = x y z + x y z + x y z + x y z + x y z

F = M

0

· M

4

· M

6

= ∏(0, 4, 6) = ( x + y + z )( x + y + z )( x + y + z )

x y z F Minterm Maxterm

0 0 0 0 M0 = (x + y + z)

0 0 1 1 m1 = x’ y’ z

0 1 0 1 m2 = x’ y’ z

0 1 1 1 m3 = x y z

1 0 0 0 M4 = (x’ + y + z)

1 0 1 1 m5 = x y’ z

1 1 0 0 M6 = (x’ + y’ + z)

1 1 1 1 m7 = x y z

(46)

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 y

f = x y + x y + x y

f = m

3

+ m

2

+ m

0

= ∑(0, 2, 3)

§ Example 2: g = a + b c (3 variables) g = a (b + b)(c + c) + (a + a) b c

g = a b c + a b c + a b c + a b c + a b c + a b c g = a b c + a b c + a b c + a b c + a b c

g = m

1

+ m

4

+ m

5

+ m

6

+ m

7

= ∑ (1, 4, 5, 6, 7)

(47)

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 2

nd

distributive law:

f = (x + x) (x + y) = 1 · (x + y) = (x + y) = M

1

§ 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) = M

5

. M

2

= ∏ (2, 5)

(48)

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 + A F = B C + A

§ Simplified F contains 3 literals compared to 15

) 7 , 6 , 5 , 4 , 1 ( )

C , B , A (

F = S

Referensi

Dokumen terkait