and boolean algebra · 8/6/2018 5 representations of boolean functions • a function can be...

6
8/6/2018 1 Lect 05 Boolean Algebra & Functions Canonical Form CS221: Digital Design CS221: Digital Design Dr. A. Sahu Dept of Comp. Sc. & Engg. Indian Institute of Technology Guwahati 1 Outline Gates in Digital System Basic Gates (AND, OR & NOT) Universal Gates (NAND & NOR) Others : XOR, XNOR Boolean Algebra Boolean Algebra Axioms Boolean Functions Canonical form of Function SOP and POS 2 Boolean Algebra Boolean Algebra Axioms and Rules Axioms/Rules Equations Closure If a and b are BLN a+b and a*b are BLN. Cardinality If a is BLN a’ is BLN. Commutative (a + b) = (b + a) (a * b) = (b * a) Associative (a+b)+c = a+(b+c) (a*b)*c = a*(b*c) Distributive a*(b+c)=(a*b)+(a*c) a+(b*c) =(a+b)*(a+c) Identity a + 0 = a a *1 =a Complement a + a’ = 1 a *a’ =0 Op Precedence ( ) > > * > + Involution (a’)’=a Boolean Algebra Axioms and Rules Axioms/Rules Equations Idempotent a+a=a a*a=a Boundness a+1=1 a*0=0 Absorption a +(a*b) = a a * (a+b) = a Adorption (X + Y')Y XY XY' + Y X+Y Adorption (X + Y')Y = XY , XY' + Y = X+Y uniting XY + XY' = X (X + Y)(X + Y') = X duality Dual (S) by interchanging * & +, 0 &1 shannon F(A,B…Z)= A’ . F(0,B..Z) + A. F(1,B…Z) Consensus XY + X'Z + YZ = XY + X'Z DeMorgans (a+b)’ = a’ * b’ (a*b)’=a’ + b’ N-bit Boolean Algebra Single bit to n-bit Boolean Algebra Let a = 1101010, b = 1011011 a + b = 1101010 + 1011011 ------------------ 1111011

Upload: others

Post on 18-Jan-2021

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: and Boolean Algebra · 8/6/2018 5 Representations of Boolean Functions • A function can be represented in different ways – English, Equation, Circuit, and Truth Table English

8/6/2018

1

Lect 05

Boolean Algebra & FunctionsCanonical Form

CS221: Digital DesignCS221: Digital DesignDr. A. Sahu

Dept of Comp. Sc. & Engg.Indian Institute of Technology Guwahati

1

Outline• Gates in Digital System

– Basic Gates  (AND, OR  &  NOT)– Universal  Gates (NAND & NOR)– Others : XOR, XNOR

• Boolean AlgebraBoolean Algebra–Axioms 

• Boolean Functions• Canonical form of Function

–SOP and POS2

Boolean Algebra

Boolean Algebra Axioms and RulesAxioms/Rules EquationsClosure If a and b are BLN a+b and a*b are BLN.

Cardinality If a is BLN a’ is BLN.

Commutative (a + b) = (b + a) (a * b) = (b * a)

Associative (a+b)+c = a+(b+c) (a*b)*c = a*(b*c)

Distributive a*(b+c)=(a*b)+(a*c) a+(b*c) =(a+b)*(a+c)

Identity a + 0 = a a *1 =a Complement a + a’ = 1 a *a’ =0 Op  Precedence

( ) > ’ > * > +

Involution (a’)’=a

Boolean Algebra Axioms and RulesAxioms/Rules EquationsIdempotent a + a = a                    a * a = aBoundness a + 1 = 1                    a * 0 = 0Absorption a +(a*b) = a             a * (a+b) = a

Adorption (X + Y')Y XY XY' + Y X + YAdorption (X + Y')Y = XY,         XY' + Y = X + Y uniting XY + XY' = X                 (X + Y)(X + Y') = Xduality Dual (S) by interchanging * & +, 0 &1shannon F(A,B…Z)= A’ . F(0,B..Z) + A. F(1,B…Z)Consensus    XY + X'Z + YZ = XY + X'ZDeMorgans (a+b)’ = a’ * b’                  (a*b)’=a’ + b’

N-bit Boolean Algebra• Single bit to n-bit Boolean Algebra• Let a = 1101010, b = 1011011

– a + b = 1101010 + 1011011 ------------------

1111011 –

Page 2: and Boolean Algebra · 8/6/2018 5 Representations of Boolean Functions • A function can be represented in different ways – English, Equation, Circuit, and Truth Table English

8/6/2018

2

N-bit Boolean Algebra• Single bit to n-bit Boolean Algebra• Let a = 1101010, b = 1011011

–a * b = 1101010 – * 1011011 -------------------------– = 1001010

N-bit Boolean Algebra• Single bit to n-bit Boolean Algebra• Let a = 1101010, b = 1011011

– a’ = 1101010’ – = 0010101

Proof by Truth Table• Consider the distributive theorem:

a + (b * c) = (a + b)*(a + c)Is it true for a two bit Boolean Algebra?

• Can prove using a truth table• Can prove using a truth table– How many possible combinations of a, b, and c

are there?• Three variables, each with two values

–2*2*2 = 23 = 8

Proof by Truth Tableaa bb cc b*cb*c a+(b*c)a+(b*c) a+ba+b a+ca+c (a+b)*(a+c)(a+b)*(a+c)00 00 00 00 00 00 00 0000 00 11 00 00 00 11 0000 11 00 00 00 11 00 0000 11 00 00 00 11 00 0000 11 11 11 11 11 11 1111 00 00 00 11 11 11 1111 00 11 00 11 11 11 1111 11 00 00 11 11 11 1111 11 11 11 11 11 11 11

Proof using Theorems• Use the properties of Boolean Algebra to proof

(x + y)(x + x) = x• Warning, make sure you use the laws precisely

(x + y)(x + x) Given(x + y)(x + x) Given

(x + y)x Idempotent

x(x + y) Commutative

x Absorption x(x+y)=xx+xy=x(1+y)=x

How to prove 2+2=5?

2

2

9 9 9 92 2 4 ( 4 )2 2 2 2

9 9 91 6 2 . 4 . ( )2 2 2

9 9 9 9

+ = − + = − +

= − + +

We know 2+2=4

2 2

2 2 2

9 9 9 92 0 ( ) 2 5 4 5 ( )2 2 2 2

9 9 9 9 95 2 . 4 . ( ) ( 5 )2 2 2 2 2

9 95 52 2

= − + + = − + +

= − + + = − +

= − + =

12

Where is the mistake?√x2=x  is true only when x≥0

Page 3: and Boolean Algebra · 8/6/2018 5 Representations of Boolean Functions • A function can be represented in different ways – English, Equation, Circuit, and Truth Table English

8/6/2018

3

Converting to Boolean Equations• Convert the following English statements to a Boolean equation

–Q1. a is 1 and b is 1.•Answer: F = a AND b = ab

a

Answer: F = a AND b  = ab

–Q2. either of a or b is 1.•Answer: F = a OR b = a+b

Converting to Boolean Equations• Convert the following English statements to a Boolean equation

–Q3. both a and b are not 0.• Answer:

a

–(a) Option 1: F = NOT(a) AND NOT(b)  = a’b’–(b) Option 2: F = a OR b = a+b

–Q4. a is 1 and b is 0.• Answer: F = a AND NOT(b) = ab’

Example: Converting a Boolean Equation to a Circuit of Logic Gates 

• Q: Convert the following equation to logic gates: F = a AND NOT( b OR NOT(c) ) 

aF

(a)

ab

c

F

(b)

a

Some Circuit Drawing Conventions

Xy

F

No Yes

No

Yes

Logic Gates: XOR, XNOR 

• XOR A B A XOR B0 0 0

0 1 11 0 1

• XNOR

17

1 1 0

A B A XNOR B

0 0 10 1 01 0 0

1 1 1

Logic Gates: NAND, NOR

• NAND A B A NAND B0 0 10 1 11 0 1

• NOR

18

1 1 0

A B A NOR B0 0 10 1 01 0 01 1 0

Page 4: and Boolean Algebra · 8/6/2018 5 Representations of Boolean Functions • A function can be represented in different ways – English, Equation, Circuit, and Truth Table English

8/6/2018

4

NAND & NOR are universal • (xx)’ = x’• ((xy)’ )’= xy• (x’y’)’= x+y

X(XX)’=X’

19

X

XY

(XY)’ ((XY)’)’=XY

X

Y

X’

Y’

(X’Y’)’=X+Y

NAND & NOR are universal • (x+x)’ = x’• ((x+y)’ )’= x+y• (x’+y’)’= x.y

X(X+X)’=X’

20

X

XY

(X+Y)’ ((X+Y)’)’=X+Y

X

Y

X’

Y’

(X’+Y’)’=XY

Multi‐input gateX1X2X3

Xn

X1+X2+X3+ … +Xn

21

X1X2X3

Xn

X1 . X2. X3. … .Xn

Physical logic gates with a large fan‐in tend to be slower than those with a small fan‐in

Boolean Functions

Boolean Functions: TerminologyF(a,b,c) = a’bc + abc’ + ab + c

• Variable–Represents a value (0 or 1), Three variables: a, b, and c

• Literal–Appearance of a variable, in true or complemented form

–Nine literals: a’, b, c, a, b, c’, a, b, and c

Boolean Functions: TerminologyF(a,b,c) = a’bc + abc’ + ab + c

• Product term–Product of literals, Four product terms: a’bc, abc’, ab, c

• Sum‐of‐products (SOP)–Above equation is in sum‐of‐products form.– “F = (a+b)c + d” is not. 

Page 5: and Boolean Algebra · 8/6/2018 5 Representations of Boolean Functions • A function can be represented in different ways – English, Equation, Circuit, and Truth Table English

8/6/2018

5

Representations of Boolean Functions• A function can be represented in different ways

– English, Equation, Circuit, and Truth Table

English 1: F outputs 1 when a is 0 and b is 0, or when a is 0 and b is 1.

Equation 1: F(a b) = a’b’ + a’b

English 2: F outputs 1 when a is 0, regardless of b’s value

function F Equation 2: F(a,b) = a’

Equation 1: F(a,b) = a b + a b

Representations of Boolean Functions

a

bF

• A function can be represented in different ways– English, Equation, Circuit, and Truth Table

a b F0 0 10 1 1

a F

Circuit 1 :F(a,b)

Circuit 2 : F(a,b)

(c)

function F

(d )Truth table

1 0 01 1 0

Representations of Boolean Functions

a

bF

Ci it 1(c)

English 1: F outputs 1 when a is 0 and b is 0, or when a is 0 and b is 1.English 2: F outputs 1 when a is 0, regardless of b’s value

(a)

(b)Equation 2: F(a,b) = a’

Equation 1: F(a,b) = a’b’ + a’b

a b F0 0 10 1 11 0 01 1 0

Above shows seven representations of the same functions F(a,b), using four different methods: English, Equation, Circuit, and Truth Table

a F

Circuit 1

Circuit 2(d)

function F

Truth table

1 1 0

Truth Table Representation of Functions

• Define value of F for each possible combination of input values

2 i t f ti

a b F0 00 11 01 1

a b c F0 0 00 0 10 1 00 1 1

1 0 01 0 1

a b c d F0 0 0 0

0 0 0 1

0 0 1 0

0 0 1 1

0 1 0 0

0 1 0 1

0 1 1 0– 2‐input function: 4 rows

– 3‐input function: 8 rows

– 4‐input function: 16 rows

1 1 01 1 1

0 1 1 0

0 1 1 1

1 0 0 0

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

Truth Table Representation of Functions

• Q: Use truth table to define function F(a,b,c) that is 1 when abc is 5 or greater in binary

a b c F0 0 0 00 0 1 00 1 0 00 1 1 01 0 0 01 0 1 11 1 0 11 1 1 1

Converting among Representations• Can convert from any representation to any other

• Common conversions– Equation to circuitEquation to circuit– Truth table to equation – Equation to truth table

• Easy ‐‐ just evaluate equation for each input combination (row)

• Creating intermediate columns helps

Page 6: and Boolean Algebra · 8/6/2018 5 Representations of Boolean Functions • A function can be represented in different ways – English, Equation, Circuit, and Truth Table English

8/6/2018

6

Converting among Representations

Q: Convert to equation

a b F Term 0 0 1 a’b’0 1 1 a’b1 0 01 1 0

F = a’b’ + a’b

Converting among RepresentationsQ: Convert to equation

a b c F Term0 0 0 00 0 1 00 1 0 00 1 1 01 0 0 01 0 1 1 ab’c1 1 0 1 abc’1 1 1 1 abc

F = ab’c + abc’ + abc

Converting among Representations

Q: Convert to truth table: F = a’b’ + a’b

Inputs  Output

a b a’b’ a’b F0 0 1 0 10 1 0 1 11 0 0 0 01 1 0 0 0

Standard Representation• How to determine two functions are the same?

• Use algebraic methods• But if we failed does that prove notBut if we failed, does that prove notequal? No.

• Solution: Convert to truth tables –Only ONE truth table representation of given same functions: Standard representation

Standard Representation: Truth TableOnly ONE truth table representation of given same functions: Standard representation

F=ab+a’a b F0 0

F=a’b’+a’b+aba b F0 0 1 a0 0 1

0 1 11 0 01 1 1

0 0 10 1 11 0 01 1 1