210 likes | 329 Views
Computer Systems 1 Fundamentals of Computing. Simplifying Boolean Expressions. CS1 - Week 20. Useful logic circuits Simplifying Boolean Expressions Expression laws Karnaugh maps Using simplified expressions to create circuits. Useful Logic Circuit. Half adder circuit
E N D
Computer Systems 1Fundamentals of Computing Simplifying Boolean Expressions
CS1 - Week 20 • Useful logic circuits • Simplifying Boolean Expressions • Expression laws • Karnaugh maps • Using simplified expressions to create circuits 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) 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 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 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 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) 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 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-> 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 powerof 2 • 2, 4, 8, etc. 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) Computer Systems 1 (2004-2005)
Karnaugh Maps • Three variable example… • Map variables can be drawn in one of two ways OR 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) 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) 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 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 Computer Systems 1 (2004-2005)
Practice Exercise • Write down a Boolean expression for this circuit (3 marks) • Using the circuit diagram and your expression from (1) draw a truthtable for the logic circuit (4 marks) • Using the truth table from (2) draw a Karnaugh map for this system (4 marks) • Use the Karnaugh map from (3) to derive a simpler expression for this system (2 marks) • Draw this simplified circuit, using the expression in (4) (2 marks) TOTAL=15 marks Computer Systems 1 (2004-2005)
Practice Exercise - Answers • 2. Computer Systems 1 (2004-2005)
Practice Exercise - Answers 3. Computer Systems 1 (2004-2005)
A B C Practice Exercise - Answers 4. 5. 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 Computer Systems 1 (2004-2005)