21
Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions

Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions

Embed Size (px)

Citation preview

Page 1: Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions

Computer Systems 1Fundamentals of Computing

Simplifying Boolean Expressions

Page 2: Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions

Computer Systems 1 (2004-2005)

CS1 - Week 20

Useful logic circuits Simplifying Boolean Expressions Expression laws Karnaugh maps Using simplified expressions to create circuits

Page 3: Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions

Computer Systems 1 (2004-2005)

Useful Logic Circuit Half adder circuit

Used for simple binary addition Two input values

X Y

Two outputs Sum (z) Carry (c)

X Y S C0 0 0 00 1 1 01 0 1 01 1 0 1

Page 4: Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions

Computer Systems 1 (2004-2005)

Simplifying Boolean Expressions

George Boole “Boolean Algebra”

Boolean expressions can be derived to explain logic circuits Aided by truth tables

Complex expressions (and thus circuits) can often be simplified By using more complex gates

NAND, NOR, XOR, etc. Expressions can also be reduced using Boolean algebraic

laws Attempt to simplify expressions There are loads! We’ll look at the most useful

Page 5: Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions

Computer Systems 1 (2004-2005)

Logic Rules Commutative laws:

X+Y = Y+X X•Y = Y•X

Associative laws: X+(Y+Z) = (X+Y)+Z X •(Y•Z) = (X•Y)•Z

Distributive laws: X•(Y+Z) = X•Y + X•Z X+Y•Z = (X+Y)•(X+Z)

De Morgans laws: (X+Y) = X •Y (X•Y) = X+Y

Page 6: Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions

Computer Systems 1 (2004-2005)

Logic Rules Laws of absorption:

X+X•Y = X X•(X+Y) = X

Laws of tautology: X+X = X X•X = X

Law of complementation: X = X

Other identities: X+X = 1 X•X = 0 X+1 = 1 X•1 = X X+0 = X X•0 = 0

Page 7: Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions

Computer Systems 1 (2004-2005)

Logic Rules Example simplification using rules:

A.B.C + A.B.C = A.B.(C + C) (Distributive laws)

= A.B.1 (useful identities)

= A.B (useful identities)

Page 8: Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions

Computer Systems 1 (2004-2005)

Karnaugh Maps

Invented by Maurice Karnaugh Logic expressions quickly become complex to

read and understand Simplification is not easy

We have to remember all of the laws we can apply to an expression

Karnaugh maps provide easy mechanism to simplify expressions Uses a graphical method Does NOT cover all laws

Karnaugh map is derived from a truth table and / or expression

Page 9: Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions

Computer Systems 1 (2004-2005)

Karnaugh Maps

Simple example... One square in the table for each row in the

truth table Uses a co-ordinate system E.g.- Expression X•Y + X•Y + X•Y

Truth Table-> Map->X Y OUT0 0 00 1 11 0 11 1 1

Y~ YX~ 0 1X 1 1

Page 10: Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions

Computer Systems 1 (2004-2005)

Karnaugh Maps

Once map is drawn we try to simplify the expression Find all adjacent pairs of 1’s (horizontally and vertically) Draw loops round each pair Try to include every 1 on the map in a loop

A 1 can belong to more than one loop Use as few loops as possible Loops must group 1’s to the power

of 2 2, 4, 8, etc.

Y~ YX~ 0 1X 1 1

Page 11: Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions

Computer Systems 1 (2004-2005)

Karnaugh Maps Continuing simplification...

Take each loop in turn as an individual expression Red loop

Spans X and X but only Y Therefore we can set it as simply Y

X•Y+X•Y = (X+X)•Y (Distributive Law) = Y (useful identities laws)

Green loop Spans Y and Y but only X Therefore we can set it simply as X X•Y+X•Y = X•(Y+Y) (Distributive Law) =X (useful identities laws)

Finally we OR our loop expressions together = X+Y (X OR Y)

Y~ YX~ 0 1X 1 1

Page 12: Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions

Computer Systems 1 (2004-2005)

Karnaugh Maps

Three variable example… Map variables can be drawn in one of two

ways

ORY Y Y~ Y~

X~X

Z Z~ Z~ Z

Y~•Z~ Y~•Z Y•Z Y•Z~X~X

Page 13: Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions

Computer Systems 1 (2004-2005)

Karnaugh Maps Three variable example...

X•Y•Z + X•Y•Z + X•Y•Z Green Loop

X and Z are constant Y changes = X.Z

Red Loop X and Y and constant Z changes = X.Y

Expression = X.Y + X.Z = X.(Y+Z)

Y~•Z~ Y~•Z Y•Z Y•Z~X~ 0 0 0 0X 0 1 1 1

Page 14: Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions

Computer Systems 1 (2004-2005)

Karnaugh Maps Three variable example…(alt. method)

X•Y•Z + X•Y•Z + X•Y•Z Green loop

X and Y are constant Z changes = X.Y

Red Loop X and Z are constant Y changes = X.Z

Expression = X.Y + X.Z = X.(Y+Z)

Y Y Y~ Y~X~ 0 0 0 0X 1 1 0 1

Z Z~ Z~ Z

Page 15: Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions

Computer Systems 1 (2004-2005)

Karnaugh Maps Three variable example with grouping

Clusters of 1’s can be grouped Groups of four 1’s

E.g.- X.Y.Z+X.Y.Z+X.Y.Z+X.Y.Z Z remains constant X changes Y changes Expression

= Z

Y~•Z~ Y~•Z Y•Z Y•Z~X~ 0 1 1 0X 0 1 1 0

Y Y Y~ Y~X~ 1 0 0 1X 1 0 0 1

Z Z~ Z~ Z

Page 16: Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions

Computer Systems 1 (2004-2005)

Karnaugh Maps Four variable example

Essentially same principals as before Sixteen ‘boxes’ on grid Looking for groupings of 2, 4, and 8 Look for values that remain constant

E.g.- X, Y, and Z change W is constant = W

Y~•Z~ Y~•Z Y•Z Y•Z~W~•X~ 0 0 0 0

W~•X 0 0 0 0W•X 1 1 1 1

W•X~ 1 1 1 1

Page 17: Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions

Computer Systems 1 (2004-2005)

Practice Exercise

1. Write down a Boolean expression for this circuit (3 marks)

2. Using the circuit diagram and your expression from (1) draw a truthtable for the logic circuit (4 marks)

3. Using the truth table from (2) draw a Karnaugh map for this system (4 marks)

4. Use the Karnaugh map from (3) to derive a simpler expression for this system (2 marks)

5. Draw this simplified circuit, using the expression in (4) (2 marks)

TOTAL=15 marks

Page 18: Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions

Computer Systems 1 (2004-2005)

Practice Exercise - Answers

1.

2.A B C A (inv) B (inv) A(inv)∙B B(inv) + C (A(inv)∙B) ∙ (B(inv) + C) (all inv)

0 0 0 1 1 0 1 10 0 1 1 1 0 1 10 1 0 1 0 1 0 10 1 1 1 0 1 1 01 0 0 0 1 0 1 11 0 1 0 1 0 1 11 1 0 0 0 0 0 11 1 1 0 0 0 1 1

Page 19: Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions

Computer Systems 1 (2004-2005)

Practice Exercise - Answers

3.

Page 20: Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions

Computer Systems 1 (2004-2005)

Practice Exercise - Answers

4. 5. A

B

C

Page 21: Computer Systems 1 Fundamentals of Computing Simplifying Boolean Expressions

Computer Systems 1 (2004-2005)

Week 18- that was easy!

Useful logic circuits Simplifying Boolean Expressions

Reducing complexity Expression laws Karnaugh maps

Two variable Three variable Four variable

Using simplified expressions to create circuits