14
1 5/19/2008 <Computer Engineering> 1 Computer Engineering Chapter 3 Boolean Algebra Hiroaki Kobayashi 5/19/2008 5/19/2008 <Computer Engineering> 2 Agenda in Chapter 3 What is “Boolean Algebra” Basic Boolean/Logical Operations (Operators) Truth Table to Describe Logical Functions/Expressions Driving Logical Expressions from Truth Tables Simplification of Logical Expressions

Computer Engineering Chapter 3 Boolean Algebra 5/19/2008 <Computer Engineering> 1 Computer Engineering Chapter 3 Boolean Algebra Hiroaki Kobayashi 5/19/2008 5/19/2008 <Computer

  • Upload
    lamlien

  • View
    240

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Computer Engineering Chapter 3 Boolean Algebra 5/19/2008 <Computer Engineering> 1 Computer Engineering Chapter 3 Boolean Algebra Hiroaki Kobayashi 5/19/2008 5/19/2008 <Computer

1

5/19/2008 <Computer Engineering> 1

Computer Engineering Chapter 3 Boolean Algebra

Hiroaki Kobayashi 5/19/2008

5/19/2008 <Computer Engineering> 2

Agenda in Chapter 3

•  What is “Boolean Algebra”

•  Basic Boolean/Logical Operations (Operators)

•  Truth Table to Describe Logical Functions/Expressions

•  Driving Logical Expressions from Truth Tables

•  Simplification of Logical Expressions

Page 2: Computer Engineering Chapter 3 Boolean Algebra 5/19/2008 <Computer Engineering> 1 Computer Engineering Chapter 3 Boolean Algebra Hiroaki Kobayashi 5/19/2008 5/19/2008 <Computer

2

5/19/2008 <Computer Engineering> 3

Boolean Algebra:Mathematical Foundation of Computers

ON 1 OFF 0

  Information is represented as a combination of on or off, high voltage or low voltage signal

Computer World

Define mathematics on values of True /False and their operations

Mathematical world: Boolean Algebra

5/19/2008 <Computer Engineering> 4

Terminology in Boolean Algebra

–  Boolean/Logical Values •  True, 1 (0) or •  False, 0 (1)

–  Boolean/Logical Variable •  Variable that takes a Boolean value (true or false) •  X, Y, ・・・

–  Boolean/Logical Operations •  Operations defined for logic values, true or false and/or logical variables •  AND (・)、OR(+)、NOT・・・

–  Boolean/Logical Expression •  Expression composed of Boolean values and/or variable and their

operations •  X+Y・Z

Page 3: Computer Engineering Chapter 3 Boolean Algebra 5/19/2008 <Computer Engineering> 1 Computer Engineering Chapter 3 Boolean Algebra Hiroaki Kobayashi 5/19/2008 5/19/2008 <Computer

3

5/19/2008 <Computer Engineering> 5

Basic Boolean/Logical Operations

•  AND (・) –  The AND function is defined as the

function that generates the output of true if two inputs A and B are both 1, otherwise the output becomes 0.

–  E.g. two input logical AND operation •  Z=f(A,B)=A AND B = A・B

  Truth Table •  Listing of all possible input

combinations correlated with the output when a specific operation is applied.

Truth table of AND

Circuit model of the AND operation

5/19/2008 <Computer Engineering> 6

•  OR (+) –  Generate true if either of two

inputs is true –  E.g. two input OR

•  Z=f(A,B)=A OR BA+B •  NOT (Negation, )

–  Negation of input, generate 1 if input is 0,

0 if input is 1. –  one input –  E.g. Z=A

Basic Boolean/Logical Operations (Cont’d)

Truth table of OR Circuit model

Truth table & circuit model

A

Page 4: Computer Engineering Chapter 3 Boolean Algebra 5/19/2008 <Computer Engineering> 1 Computer Engineering Chapter 3 Boolean Algebra Hiroaki Kobayashi 5/19/2008 5/19/2008 <Computer

4

5/19/2008 <Computer Engineering> 7

Other Logical Operators

Possible Logical Operators for two inputs

Meaning

5/19/2008 <Computer Engineering> 8

Completeness

•  What kinds of operators are necessary to represent any logical expressions?

  Completeness: a set of operators to represent any logical expressions •  Any logical expressions are derived in canonical sum of products form

  {AND, OR, NOT} is a set of operators with completeness

Page 5: Computer Engineering Chapter 3 Boolean Algebra 5/19/2008 <Computer Engineering> 1 Computer Engineering Chapter 3 Boolean Algebra Hiroaki Kobayashi 5/19/2008 5/19/2008 <Computer

5

5/19/2008 <Computer Engineering> 9

•  Logical Expressions/Equations –  Composed of logical AND/OR/

NOT operations –  E.g.

•  Z=A+B・C

 Priority of logical operators  NOT>AND>OR •  Use ( ) if you give higher

priorities to specific terms/partial expressions

 Z=(A+B)・C

Logical Equations/Expressions

A    B   C     Z

Truth table of Z=A+B・C??

5/19/2008 <Computer Engineering> 10

How to Derive a Logical Expression from a Truth Table: Canonical Sum of Product

•  Minimum Term –  Product (AND) of all inputs, in which

each variable appears exactly once in either true or its negation

 Examples of minimum terms ABC,ABC

•  Canonical sum of product –  Logical expression consisting of

minimum terms e.g., ABC+ABC

Logical expression can be derived from a truth table in the canonical sum of product form Logical expression of Z??

Page 6: Computer Engineering Chapter 3 Boolean Algebra 5/19/2008 <Computer Engineering> 1 Computer Engineering Chapter 3 Boolean Algebra Hiroaki Kobayashi 5/19/2008 5/19/2008 <Computer

6

5/19/2008 <Computer Engineering> 11

How to derive a logical expression from a truth table

•  Truth table of exclusive OR –  True if the two inputs are

different.

Problem: Drive a logical expression!

5/19/2008 <Computer Engineering> 12

How to derive a logical expression from a truth table (Cont’d)

•  A rule to derive a logical expression from a truth table •  Z becomes 1 only if A=0 and B=1 or A=1 and B=0, so

  Pick up input combinations that generate 1

Z=A・B+A・B  Generate SUM (OR) of products that

generate 1   Logical expression is obtained in the

canonical sum of product form

A・B A・B

 For each input combination, AND input

variables to generate 1  If input is 0, its negation is ANDed  E.g., if (A,B)=(0,1), AND of A and B  A・B only generates 1 for inputs (0,1)

Page 7: Computer Engineering Chapter 3 Boolean Algebra 5/19/2008 <Computer Engineering> 1 Computer Engineering Chapter 3 Boolean Algebra Hiroaki Kobayashi 5/19/2008 5/19/2008 <Computer

7

5/19/2008 <Computer Engineering> 13

Exercise

Logical expression of Z??

5/19/2008 <Computer Engineering> 14

Completeness

•  What kinds of operators are necessary to represent any logical expressions? Is it the minimum set???

  Completeness: a set of operators to represent any logical expressions •  Any logical expressions are derived in canonical sum of products form   {AND, OR, NOT} is a set of operators with completeness  Question: {AND,OR,NOT} is the minimum set??

     X+Y=X+Y=XY OR can be represented by AND and NOT operations.

Not the minimum set!!

Minimum set of logical operators with completeness: {AND,NOT}、{OR,NOT}, {NAND},{NOR}

Page 8: Computer Engineering Chapter 3 Boolean Algebra 5/19/2008 <Computer Engineering> 1 Computer Engineering Chapter 3 Boolean Algebra Hiroaki Kobayashi 5/19/2008 5/19/2008 <Computer

8

5/19/2008 <Computer Engineering> 15

Laws and Theorems of Boolean Algebra

•  Duality –  It is derived from the original by replacing AND operation by OR

operations and vice versa, and replacing constant logic 0’s by logic 1’s and vice versa, while leaving the logical variables unchanged

Duality

5/19/2008 <Computer Engineering> 16

Laws and Theorems of Boolean Algebra(Cont’d)

•  Associative Law,(11,12),Commutative Law(13, 14), Distributive Law (17,18)

(11) (12)

(13) (14)

(15) (16)

(17) (18)

(19) (20)

Page 9: Computer Engineering Chapter 3 Boolean Algebra 5/19/2008 <Computer Engineering> 1 Computer Engineering Chapter 3 Boolean Algebra Hiroaki Kobayashi 5/19/2008 5/19/2008 <Computer

9

5/19/2008 <Computer Engineering> 17

Laws and Theorems of Boolean Algebra(Cont’d)

De Morgan’s Theorem

(21) (22)

(23) (24)

(25) (26)

(29) (30)

(31) (20)

(27)

(31)

5/19/2008 <Computer Engineering> 18

Simplification of Logical Expressions

Minimize the number of operators in expressions without changing their meaning •  Motivation

–  Simplified expressions lead to •  Easy to handle •  Fast computation and small area if the expression implemented as circuits

•  Basic strategy for simplification Find ORs of logical variable and its negation, i.e., (X+X), terms by

applying the distributive law, and reduce them by using (X+X)=1

That is, X1 ・ X2 ・・・ Xi ・ Xi+1 ・・・ XM-1+ X1 ・ X2 ・・・ Xi ・ Xi+1 ・・・ XM-1    = X1 ・ X2 ・・・ Xi-1 ・ Xi+1 ・・・ XM-1,(X+X)

   = X1 ・ X2 ・・・ Xi-1 ・ Xi+1 ・・・ XM-1, 1=(Xi + Xi)

Page 10: Computer Engineering Chapter 3 Boolean Algebra 5/19/2008 <Computer Engineering> 1 Computer Engineering Chapter 3 Boolean Algebra Hiroaki Kobayashi 5/19/2008 5/19/2008 <Computer

10

5/19/2008 <Computer Engineering> 19

Example of Simplification

Simplify the following equation f=XYZ+XYZ+XYZ 4 operations (3 ANDs and 1 OR)  = XYZ+XYZ+XYZ+XYZ 5 operations  =XY(Z+Z)+XZ(Y+Y) 5 operations  =XY+XZ 3operations  =X(Y+Z) 2 operations

Exercise Simplify the following expressions  (a) f=XY+XYZ+YZ  (b) f=XY+YZ+XZ  (c)  f= XYZ+XYZ+XYZ+XYZ

5/19/2008 <Computer Engineering> 20

Karnaugh Map: Schematic Method for Simplification

•  Schematic representation to show the adjacencies of terms Two terms are adjacent if only one variable of them is different e.g., XYZ and XYZ •  How to represent an expression on Karnaugh Map

–  1 variable case:

f=X f=X

Input values

outputs

Page 11: Computer Engineering Chapter 3 Boolean Algebra 5/19/2008 <Computer Engineering> 1 Computer Engineering Chapter 3 Boolean Algebra Hiroaki Kobayashi 5/19/2008 5/19/2008 <Computer

11

5/19/2008 <Computer Engineering> 21

2-Variable Case: Drive an expression from a Truth Table via Karnaugh Map

•  Karnaugh Map for 2 variables

f=XY+XY+XY

Truth Table of f=X+Y Karnaugh Map Expression Canonical sum of product form)

5/19/2008 <Computer Engineering> 22

Simplification of an Expression using Karnaugh Map

Karnaugh map of f=XY+XY+XY

f=X+Y

X (output defined regardless of Y) (=X(Y+Y) )

Y (output defined regardless of X) (=Y(X+X))

Page 12: Computer Engineering Chapter 3 Boolean Algebra 5/19/2008 <Computer Engineering> 1 Computer Engineering Chapter 3 Boolean Algebra Hiroaki Kobayashi 5/19/2008 5/19/2008 <Computer

12

5/19/2008 <Computer Engineering> 23

Karnaugh Map for Three Variables

f=XYZ+XYZ   +XYZ+XYZ    +XYZ

Truth Table Karnaugh Map

Expression Canonical sum of product form)

Onl

y on

e bi

t diff

ers b

etw

een

neig

hbor

s

5/19/2008 <Computer Engineering> 24

Simplification of an Expression using Karnaugh Map: Three-Variable Case

f=XY+XZ+XZ

Page 13: Computer Engineering Chapter 3 Boolean Algebra 5/19/2008 <Computer Engineering> 1 Computer Engineering Chapter 3 Boolean Algebra Hiroaki Kobayashi 5/19/2008 5/19/2008 <Computer

13

5/19/2008 <Computer Engineering> 25

Simplification of an Expression using Karnaugh Map: 4-Variable Case

f=XYZW+XYZW+XYZW+XYZW+ XYZW+XYZW+XYZW+XYZW  =XW+YZW+XYZ+XYZW

Canonical Sum of products

Its simplest form

5/19/2008 <Computer Engineering> 26

Drive an Expression from a Table with Don’t-Care outputs

•  例:Carry signals for a BCD operation

X Y Z W f 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 1 1 0 0 1 0 0 0 0 1 0 1 0 0 1 1 0 0 0 1 1 1 0 1 0 0 0 0 1 0 0 1 1 1 0 1 0 * 1 0 1 1 * 1 1 0 0 * 1 1 0 1 * 1 1 1 0 * 1 1 1 1 *

Don’t care (out of consideration)

00 01 11 10

00 0 0 * 0 01 0 0 * 1 11 0 0 * * 10 0 0 * *

XY ZW

XZW

XW

XYZW Range defined for BCD operations

We can assume 1’s or 0’s for the simplification!!

Page 14: Computer Engineering Chapter 3 Boolean Algebra 5/19/2008 <Computer Engineering> 1 Computer Engineering Chapter 3 Boolean Algebra Hiroaki Kobayashi 5/19/2008 5/19/2008 <Computer

14

5/19/2008 <Computer Engineering> 27

Exercise (home work)

•  Simplify the following logical expressions by using Karnaugh Maps

•  F(X,Y,Z)=XYZ+ XYZ+ XYZ+ XYZ+ XYZ+ XYZ

•  F(X,Y,Z,W)=XYZW+ XYZW+ XYZW+ XYZW+ XYZW+ XYZW+ XYZW