Electronic circuits an application of propositional logic Why

  • Slides: 62
Download presentation
Electronic circuits: an application of propositional logic Why talk about chips when we’re really

Electronic circuits: an application of propositional logic Why talk about chips when we’re really interested in logic? • • • Show propositional-logic expressions play a crucial part in the way chips (and hence computers) work Show logical inference allows us to optimise the way in which electronic circuits are built Thereby highlight some computational aspects of propositional logic Our strategy: we’ll be looking over the shoulders of engineers, trying to understand what they are doing. We shall use slides adapted from a course on Computer Architecture by Luddy Harrison and Howard Huang, University of Illinois at Urbana Champaign, Spring 2006 (We shall be taking many liberties: leaving things out, making additions, and annotating existing slides. ) Introduction to CS 231 0

 • • • Computers use voltages to represent information. In modern CPUs the

• • • Computers use voltages to represent information. In modern CPUs the voltage is usually limited to 1. 6 -1. 8 V to minimize power consumption. It’s convenient for us to translate these analog voltages into the discrete, or digital, values 1 and 0. But how can two lousy digits be useful for anything? – First, we’ll see how to represent numbers with just 1 s and 0 s. Volts – Then we’ll introduce special operations 1. 8 for computing with 1 s and 0 s, by treating them as 1 the logical values “true” and “false. ” 0 © 2000 -2002 Howard Huang 0 1

The Modest Switch • • At the heart of a computer lies one extremely

The Modest Switch • • At the heart of a computer lies one extremely simple component: – A controllable switch The usual Electrical switch we use every day – The electric switch we use turns current on and off – But we need to turn it on and off by hand – The result of turning the switch on? • The “top end” in the figure becomes raised to a high voltage • Which makes the current flow through the bulb • The Controllable Switch • No hands • Voltage controls if the switch is on or off • High voltage at input: switch on • Otherwise it is off Introduction to CS 231 2

Using the switch Input Output is high (voltage) if and only if the input

Using the switch Input Output is high (voltage) if and only if the input is high Output Now we can make one circuit control another switch… Neat! This is getting boring. . Introduction to CS 231 3

Lets use them creatively Output is high if both the inputs input 1 AND

Lets use them creatively Output is high if both the inputs input 1 AND input 2 are high Input 1 If either of the inputs is low, the output is low. Output Input 2 This is called an AND gate This is an electronic implementation of the (i. e. , conjunction) of propositional logic Now, can you make an OR gate with switches (i. e. , inclusive disjunction)? Introduction to CS 231 4

OR Gate Input 1 Output Input 2 Output is low iff both inputs are

OR Gate Input 1 Output Input 2 Output is low iff both inputs are low I. e. Output is high if either of the inputs (or both) are high (input 1 OR input 2) Introduction to CS 231 5

The two diagrams simplified (without earth) • Current flows iff A is closed and

The two diagrams simplified (without earth) • Current flows iff A is closed and B is closed: A B Input • Output Current flows iff A is closed or B is closed (or both): A Input Output B Introduction to CS 231 6

Basic Gates • There are three basic kinds of logic gates Operation: AND of

Basic Gates • There are three basic kinds of logic gates Operation: AND of two inputs OR of two inputs NOT (complement) on one input Logic gate: • Two Questions: • How can we implement them? • What can we build with them? And How? Introduction to CS 231 7

How to make switches? • • • In principle one might use mechanical power

How to make switches? • • • In principle one might use mechanical power or hydrolic pressure Most often: Complementary Metal-Oxide Semi-conductors (CMOS: These circuits work with separate sources of high and low power. ). . . We leave all this to the engineers. Just remember: • • They can now manufacture millions of transistors on a single silicon chip Still, the size of chips is one of their main worries. The smaller the size, – the smaller the propagation delay (typically) – the less power is consumed – the less heat is generated – the cheaper it is to make the processor Introduction to CS 231 8

What can we do with Gates? Example: adding numbers automatically • • • How

What can we do with Gates? Example: adding numbers automatically • • • How to add numbers, depends on how they are represented. E. g. , – Roman XVII – Decimal: 17 Try adding two long roman numbers! Decimal is better but – We have only two “values”, high and low, in our gates Decimal system (and the idea of “ 0”) was invented in India around 100 -500 AD Why did they use 10? Anything special about it? – Not really. – Probably the fact that we have 10 fingers influenced this Introduction to CS 231 9

Decimal review • Numbers consist of a bunch of digits, each with a weight

Decimal review • Numbers consist of a bunch of digits, each with a weight • These weights are all powers of the base, which is 10: • To find the decimal value of a number, multiply each digit by its weight and sum the products. (1 x 102) + (6 x 101) + (2 x 100) + (3 x 10 -1) + (7 x 10 -2) + (5 x 10 -3) = 162. 375 Introduction to CS 231 10

Converting binary to decimal • We can use the same trick to convert binary,

Converting binary to decimal • We can use the same trick to convert binary, or base 2, numbers to decimal. This time, the weights are powers of 2. – Example: 1101. 01 in binary – The decimal value is: (1 x 23) + (1 x 22) + (0 x 21) + (1 x 20) + (0 x 2 -1) + (1 x 2 -2) = 8 + 4 + 0 + 1 + 0. 25 = 13. 25 Introduction to CS 231 11

Binary addition example worked out • The trick when adding numbers: positional weights and

Binary addition example worked out • The trick when adding numbers: positional weights and carry ! • Exercise: what are the black numbers equivalent to in decimal? The initial carry in is implicitly 0 1 + 1 1 1 most significant bit (MSB) 1 0 0 1 1 0 1 (Carries) (Augend) (Addend) (Sum) least significant bit (LSB) Introduction to CS 231 12

Doing addition with gates • Lets do simple stuff first: – Can we add

Doing addition with gates • Lets do simple stuff first: – Can we add two numbers each with just 1 bit? • Bit: binary digit – 0+0 = 0, 0+1 = 1 , 1+0 = 1, and 1+1 = ? ? ? • 2. But 2 is not a symbol. • 10 (just as 5 + 5 is 10 in decimal) • Result is 0 with 1 carried over to the next bit. • So if we disregard the carry, then what we get is – 0+0 = 0, 0+1 = 1 , 1+0 = 1, and 1+1 = 0 • Does this remind you of something? Introduction to CS 231 13

Doing addition with gates • Lets do simple stuff first: – Can we add

Doing addition with gates • Lets do simple stuff first: – Can we add two numbers each with just 1 bit? • Bit: binary digit – 0+0 = 0, 0+1 = 1 , 1+0 = 1, and 1+1 = ? ? ? • 2. But 2 is not a symbol. • 10 (just as 5 + 5 is 10 in decimal) • Result is 0 with 1 carried over to the next bit. • So if we disregard the carry, then what we get is – 0+0 = 0, 0+1 = 1 , 1+0 = 1, and 1+1 = 0 • Does this remind you of something? • It’s the exclusive disjunction! Introduction to CS 231 14

Doing addition with gates • • Lets do simple stuff first: – Can we

Doing addition with gates • • Lets do simple stuff first: – Can we add two numbers each with just 1 bit? • Bit: binary digit – 0+0 = 0, 0+1 = 1 , 1+0 = 1, and 1+1 = ? ? ? • 2. But 2 is not a symbol. • 10 (just as 5 + 5 is 10 in decimal) • Result is 0 with 1 carried over to the next bit. So if we disregard the carry, then what we get is – 0+0 = 0, 0+1 = 1 , 1+0 = 1, and 1+1 = 0 • What rule governs the carry? • Carry=1 iff both inputs are 1 Introduction to CS 231 15

Doing addition with gates • • Lets do simple stuff first: – Can we

Doing addition with gates • • Lets do simple stuff first: – Can we add two numbers each with just 1 bit? • Bit: binary digit – 0+0 = 0, 0+1 = 1 , 1+0 = 1, and 1+1 = ? ? ? • 2. But 2 is not a symbol. • 10 (just as 5 + 5 is 10 in decimal) • Result is 0 with 1 carried over to the next bit. So if we disregard the carry, then what we get is – 0+0 = 0, 0+1 = 1 , 1+0 = 1, and 1+1 = 0 • What rule governs the carry? • Carry=1 iff both inputs are 1 • It’s the logical conjunction (i. e. , ). Introduction to CS 231 16

Doing addition with gates • What does addition look like in a circuit? Half

Doing addition with gates • What does addition look like in a circuit? Half adder Result Carry Introduction to CS 231 17

Half adder: result Result Output is 1 iff exactly one of the 2 inputs

Half adder: result Result Output is 1 iff exactly one of the 2 inputs is 1 A special symbol for this gate: Exclusive OR Introduction to CS 231 18

XOR Introduction to CS 231 19

XOR Introduction to CS 231 19

Adding two bits • • • A half adder is used to add two

Adding two bits • • • A half adder is used to add two bits. The result consists of two bits: a sum (the right bit) and a carry out (the left bit) Here is the circuit and its block symbol 0 0 1 1 • +0 +1 =0 =1 =1 = 10 But, half adders do not take into account that there may have been a pre-existing carry. We shall write Cin, short for “Carry in(put)” (as opposed to Cout, which is short for “Carry out(put)”). Introduction to CS 231 20

Adding three bits • What we really need to do is add three bits:

Adding three bits • What we really need to do is add three bits: the augend addend, and the carry in from the right. 1 + 1 1 1 0 1 0 0 0 1 1 0 1 +0 +0 +1 +1 +0 +1 Introduction to CS 231 = 00 = 01 = 10 = 11 (The bitstring on the right is the binary representation of the sum of the three numbers on the left) 21

Full adder circuit • • • Why are these things called half adders and

Full adder circuit • • • Why are these things called half adders and full adders? You can build a full adder by putting together two half adders. In this way, Cin (as well as X and Y) is used as an input. Introduction to CS 231 22

An example of 4 -bit addition • Let’s put our initial example into this

An example of 4 -bit addition • Let’s put our initial example into this circuit: A=1011, B=1110 1 1 1 • • • 1 1 1 0 0 0 1 Step 1: Fill in all the inputs, including CI=0 Step 2: The circuit produces C 1 and S 0 (1 + 0 = 01) Step 3: Use C 1 to find C 2 and S 1 (1 + 0 = 10) Step 4: Use C 2 to compute C 3 and S 2 (0 + 1 = 10) Step 5: Use C 3 to compute CO and S 3 (1 + 1 = 11) The final answer is 11001 Introduction to CS 231 23

So, we have built a calculator • • It is not a computer yet…

So, we have built a calculator • • It is not a computer yet… Two new ideas and components are needed: – Addressable memory – Stored Program These are also based on electronic circuits (memory is achieved by feeding back the output of a gate to its input) Sorry to be a bit brief about this. . . Introduction to CS 231 24

Basic Boolean operations • There are three basic operations for logical values. Operation: AND

Basic Boolean operations • There are three basic operations for logical values. Operation: AND (product) of two inputs Expression: xy, or x y OR (sum) of two inputs x+y NOT (complement) on one input x’ Truth table: Introduction to CS 231 25

Boolean expressions • We can use these basic operations to form more complex expressions.

Boolean expressions • We can use these basic operations to form more complex expressions. For example: f(x, y, z) = (x + y’)z + x’ • Some terminology and notation: – f is the name of the function. – (x, y, z) are the input variables, each representing 1 or 0. – A literal is any occurrence of an input variable or its complement. The function above has four literals: x, y’, z, and x’. Introduction to CS 231 26

Truth tables • A truth table shows all possible inputs and outputs of a

Truth tables • A truth table shows all possible inputs and outputs of a function. • Inputs are listed in binary order—in this example, from 000 to 111. f(x, y, z) = (x + y’)z + x’ f(0, 0, 0) f(0, 0, 1) f(0, 1, 0) f(0, 1, 1) f(1, 0, 0) f(1, 0, 1) f(1, 1, 0) f(1, 1, 1) = (0 + 1)0 + 1 = (0 + 1)1 + 1 = (0 + 0)0 + 1 = (0 + 0)1 + 1 = (1 + 1)0 + 0 = (1 + 1)1 + 0 = (1 + 0)0 + 0 = (1 + 0)1 + 0 =1 =1 =0 =1 Introduction to CS 231 27

Primitive logic gates • Each of our basic operations can be implemented in hardware

Primitive logic gates • Each of our basic operations can be implemented in hardware using a primitive logic gate. Operation: Expression: AND (product) of two inputs OR (sum) of two inputs xy, or x y x+y NOT (complement) on one input x’ Logic gate: Introduction to CS 231 28

Expressions and circuits • • • Any Boolean expression can be converted into a

Expressions and circuits • • • Any Boolean expression can be converted into a circuit by combining basic gates. – This follows from functional completeness! The diagram below shows the inputs and outputs of each gate. The precedences are explicit in a circuit. (x + y’)z + x’ Introduction to CS 231 29

Standard forms of expressions • • We can write expressions in many ways, but

Standard forms of expressions • • We can write expressions in many ways, but some ways are more useful than others A sum of products (SOP) expression contains: – Only OR (sum) operations at the “outermost” level – Each term that is summed must be a product of literals f(x, y, z) = y’ + x’yz’ + xz • • Any sum of products expression can be implemented using a two-level circuit – literals and their complements at the “ 0 th” level – AND gates at the first level – a single OR gate at the second level This diagram uses some shorthands… – NOT gates are implicit – literals are reused Introduction to CS 231 30

Minterms • • A minterm is a special product of literals, in which each

Minterms • • A minterm is a special product of literals, in which each input variable appears exactly once. A three-variable function, such as f(x, y, z), has 23 = 8 minterms: Each minterm is true for exactly one combination of inputs: x’y’z’ xy’z’ Minterm x’y’z’ x’y’z x’yz’ x’yz xy’z’ xy’z xyz’ xyz x’y’z x’yz’ xyz’ Is true when… x=0, y=0, z=0 x=0, y=0, z=1 x=0, y=1, z=0 x=0, y=1, z=1 x=1, y=0, z=0 x=1, y=0, z=1 x=1, y=1, z=0 x=1, y=1, z=1 x’yz xyz Shorthand m 0 m 1 m 2 m 3 m 4 m 5 m 6 m 7 Introduction to CS 231 31

Minterms • You have encountered these before. . . Introduction to CS 231 32

Minterms • You have encountered these before. . . Introduction to CS 231 32

Minterms • You have encountered these before. . . • . . . when

Minterms • You have encountered these before. . . • . . . when we proved that every truth function could be expressed using only and ( i. e. , functional completeness of { , } ) • Recall: – every T-row of the truth table gave rise to a minterm – we then formed the disjunction (“sum”) of these minterms. . . –. . . replacing p q by ( p q) Introduction to CS 231 33

Sum of minterms form • • So: Every function can be written as a

Sum of minterms form • • So: Every function can be written as a sum of minterms, in a unique way If you have a truth table for a function, you can write a “sum of minterms” expression just by picking out the rows of the table where the function output is 1. f = x’y’z’ + x’y’z + x’yz’ + x’yz + xyz’ = m 0 + m 1 + m 2 + m 3 + m 6 = m(0, 1, 2, 3, 6) f’ = xy’z’ + xy’z + xyz = m 4 + m 5 + m 7 = m(4, 5, 7) f’ contains all the minterms not in f Introduction to CS 231 34

(The dual idea: products of sums) • A product of sums (POS) expression contains:

(The dual idea: products of sums) • A product of sums (POS) expression contains: – Only AND (product) operations at the “outermost” level – Each term must be a sum of literals f(x, y, z) = y’ (x’ + y + z’) (x + z) • • • Product of sums expressions can be implemented with two-level circuits – literals and their complements at the “ 0 th” level – OR gates at the first level – a single AND gate at the second level Compare this with sums of products Analogous to minterms, one can now define maxterms. (Let’s not further pursue these in our logic class). Introduction to CS 231 35

Circuit analysis • • Circuit analysis involves figuring out what some circuit does. –

Circuit analysis • • Circuit analysis involves figuring out what some circuit does. – Every circuit computes some function, which can be described with Boolean expressions or truth tables. – So, the goal is to find an expression or truth table for the circuit. The first thing to do is figure out what the inputs and outputs of the overall circuit are. – This step is often overlooked! – The example circuit here has three inputs x, y, z and one output f. Introduction to CS 231 36

Write algebraic expressions. . . • Next, write expressions for the outputs of each

Write algebraic expressions. . . • Next, write expressions for the outputs of each individual gate, based on that gate’s inputs. – Start from the inputs and work towards the outputs. – It might help to do some algebraic simplification along the way. Introduction to CS 231 37

Write algebraic expressions. . . • • Next, write expressions for the outputs of

Write algebraic expressions. . . • • Next, write expressions for the outputs of each individual gate, based on that gate’s inputs. – Start from the inputs and work towards the outputs. – It might help to do some algebraic simplification along the way. Here is the example again. – We did a little simplification for the top AND gate. – You can see the circuit computes f(x, y, z) = xz + y’z + x’yz’ Introduction to CS 231 38

. . . or make a truth table • • It’s also possible to

. . . or make a truth table • • It’s also possible to find a truth table directly from the circuit. Once you know the number of inputs and outputs, list all the possible input combinations in your truth table. – A circuit with n inputs should have a truth table with 2 n rows. – Our example has three inputs, so the truth table will have 23 = 8 rows. All the possible input combinations are shown. Introduction to CS 231 39

Simulating the circuit • • Then you can simulate the circuit, either by hand

Simulating the circuit • • Then you can simulate the circuit, either by hand or with a program like Logic. Works, to find the output for each possible combination of inputs. For example, when xyz = 101, the gate outputs would be as shown below. – Use truth tables for AND, OR and NOT to find the gate outputs. – For the final output, we find that f(1, 0, 1) = 1. 1 0 1 1 1 0 0 0 Introduction to CS 231 40

Finishing the truth table • • Doing the same thing for all the other

Finishing the truth table • • Doing the same thing for all the other input combinations yields the complete truth table. This is simple, but tedious. Introduction to CS 231 41

Truth tables and expressions • • It’s easy to come up with an expression

Truth tables and expressions • • It’s easy to come up with an expression if you have a truth table. We saw that you can quickly convert a truth table into a “sum of minterms” expression. The minterms correspond to the truth table rows where the output is 1. Compare the proof that { , } is functionally complete (second lecture, also in tutorial exercise)! f(x, y, z) = x’y’z + x’yz’ + xy’z + xyz = m 1 + m 2 + m 5 + m 7 • You can then simplify this sum of minterms if desired. Introduction to CS 231 42

Let’s compare the resulting circuits • • Here are two different but equivalent circuits.

Let’s compare the resulting circuits • • Here are two different but equivalent circuits. In general the one with fewer gates is “better”: – It costs less to build – It requires less power – But we had to do some work to find the second form Introduction to CS 231 43

Karnaugh maps • • K-maps are a graphical technique for simplifying an expression into

Karnaugh maps • • K-maps are a graphical technique for simplifying an expression into a minimal sum of products (MSP) form: – There a minimal number of product terms in the expression. – Each term has a minimal number of literals. Circuit-wise, this leads to a minimal two-level implementation. Introduction to CS 231 44

Re-arranging the truth table • A two-variable function has four possible minterms. We can

Re-arranging the truth table • A two-variable function has four possible minterms. We can re-arrange these minterms into a Karnaugh map. • Now we can easily see which minterms contain common literals. – Minterms on the left and right sides contain y’ and y respectively. – Minterms in the top and bottom rows contain x’ and x respectively. Introduction to CS 231 45

Karnaugh map simplifications • Imagine a two-variable sum of minterms: x’y’ + x’y •

Karnaugh map simplifications • Imagine a two-variable sum of minterms: x’y’ + x’y • Both of these minterms appear in the top row of a Karnaugh map, which means that they both contain the literal x’. • This expression can be simplified using equivalence laws: x’y’ + x’y = x’(y’ + y) = x’ 1 = x’ [ Distributive ] [ y + y’ = 1 ] [x 1=x] Introduction to CS 231 46

More two-variable examples • Another example expression is x’y + xy. – Both minterms

More two-variable examples • Another example expression is x’y + xy. – Both minterms appear in the right side, where y is uncomplemented. – Thus, we can reduce x’y + xy to just y. • How about x’y’ + x’y + xy? – We have x’y’ + x’y in the top row, corresponding to x’. – There’s also x’y + xy in the right side, corresponding to y. – This whole expression can be reduced to x’ + y. Introduction to CS 231 47

Summing: K-maps applied to 2 variables • Karnaugh-maps are applied to sums of minterms

Summing: K-maps applied to 2 variables • Karnaugh-maps are applied to sums of minterms • They can help you find simpler sums of minterm that are equivalent to the original ones, because some of their disjuncts (i. e. , minterms) contain literals that are negations of each other • We’ve seen examples involving minterms. . . xy’ +. . . + xy. . . =. . . x’y’ +. . . + x’y. . . =. . . x’y +. . . + xy. . . =. . . y. . . x’y’ +. . . + xy’. . . =. . . y’. . . • More complex cases can be handled too: Introduction to CS 231 48

A three-variable Karnaugh map • For a three-variable expression with inputs x, y, z,

A three-variable Karnaugh map • For a three-variable expression with inputs x, y, z, the arrangement of minterms is more tricky: • Another way to label the K-map (use whichever you like): Introduction to CS 231 49

Why the funny ordering? • With this ordering, any group of 2, 4 or

Why the funny ordering? • With this ordering, any group of 2, 4 or 8 adjacent squares on the map contains common literals that can be factored out. x’y’z + x’yz = x’z(y’ + y) = x’z 1 = x’z • • “Adjacency” includes wrapping around the left and right sides: = = x’y’z’ + x’yz’ + xyz’ z’(x’y’ + x’y + xy) z’(y’(x’ + x) + y(x’ + x)) z’(y’+y) z’ We’ll use this property of adjacent squares to do our simplifications. Introduction to CS 231 50

Example K-map simplification • • • Let’s consider simplifying f(x, y, z) = xy

Example K-map simplification • • • Let’s consider simplifying f(x, y, z) = xy + y’z + xz. First, you should convert the expression into a sum of minterms form, if it’s not already. – The easiest way to do this is to make a truth table for the function, and then read off the minterms. – You can either write out the literals or use the minterm shorthand. Here is the truth table and sum of minterms for our example: f(x, y, z) = x’y’z + xyz’ + xyz = m 1 + m 5 + m 6 + m 7 Introduction to CS 231 51

Making the example K-map • • Next up is drawing and filling in the

Making the example K-map • • Next up is drawing and filling in the K-map. – Put 1 s in the map for each minterm, and 0 s in the other squares. – You can use either the minterm products or the shorthand to show you where the 1 s and 0 s belong. In our example, we can write f(x, y, z) in two equivalent ways. f(x, y, z) = x’y’z + xyz’ + xyz • f(x, y, z) = m 1 + m 5 + m 6 + m 7 In either case, the resulting K-map is shown below. Introduction to CS 231 52

Grouping the minterms together • The most difficult step is grouping together all the

Grouping the minterms together • The most difficult step is grouping together all the 1 s in the K-map. – Make rectangles around groups of one, two, four or eight 1 s. – All of the 1 s in the map should be included in at least one rectangle. – Do not include any of the 0 s. • Each group corresponds to one product term. For the simplest result: – Make as few rectangles as possible, to minimize the number of products in the final expression. – Make each rectangle as large as possible, to minimize the number of literals in each term. – It’s all right for rectangles to overlap, if that makes them larger. Introduction to CS 231 53

Reading the MSP from the K-map • Finally, you can find the MSP. –

Reading the MSP from the K-map • Finally, you can find the MSP. – Each rectangle corresponds to one product term. – The product is determined by finding the common literals in that rectangle. • For our example, we find that xy + y’z + xz = y’z + xy. Introduction to CS 231 54

Practice K-map 1 • Simplify the sum of minterms m 1 + m 3

Practice K-map 1 • Simplify the sum of minterms m 1 + m 3 + m 5 + m 6. Introduction to CS 231 55

Solutions for practice K-map 1 • Here is the filled in K-map, with all

Solutions for practice K-map 1 • Here is the filled in K-map, with all groups shown. – The magenta and green groups overlap, which makes each of them as large as possible. – Minterm m 6 is in a group all by its lonesome. • The final MSP here is x’z + y’z + xyz’. Introduction to CS 231 56

Four-variable K-maps • We can do four-variable expressions too! – The minterms in the

Four-variable K-maps • We can do four-variable expressions too! – The minterms in the third and fourth columns, and in the third and fourth rows, are switched around. – Again, this ensures that adjacent squares have common literals. • Grouping minterms is similar to the three-variable case, but: – You can have rectangular groups of 1, 2, 4, 8 or 16 minterms. – You can wrap around all four sides. Introduction to CS 231 57

Example: Simplify m 0+m 2+m 5+m 8+m 10+m 13 • The expression is already

Example: Simplify m 0+m 2+m 5+m 8+m 10+m 13 • The expression is already a sum of minterms, so here’s the K-map: • We can make the following groups, resulting in the MSP x’z’ + xy’z. Introduction to CS 231 58

K-maps can be tricky! • There may not necessarily be a unique MSP. The

K-maps can be tricky! • There may not necessarily be a unique MSP. The K-map below yields two valid and equivalent MSPs, because there are two possible ways to include minterm m 7. y’z + yz’ + xy • y’z + yz’ + xz Remember that overlapping groups is possible, as shown above. Introduction to CS 231 59

Limitations of K(arnaugh) -maps A postscript from Aberdeen. . . • • Simpification using

Limitations of K(arnaugh) -maps A postscript from Aberdeen. . . • • Simpification using K-maps is an essentially visual method intended for use by people. It’s not an algorithm and cannot be mechanised directly. With more than 5 -or-so variables, the method is no longer visually appealing for people. Real algorithms have also been developed and implemented. Best known: the Quine-Mc. Clusky algorithm, which can handle any number of variables, and always results in a minimal-size expression equivalent with the input. Introduction to CS 231 60

Am algorithm for circuit simplification • • Quine-Mc. Clusky algorithm (a very rough sketch!)

Am algorithm for circuit simplification • • Quine-Mc. Clusky algorithm (a very rough sketch!) – Input: a “sum of products” representation of a given function (e. g. , obtained via the truth table, as above). Then two steps: 1. List all the minterms in this representation, trying all their pairwise simplifications (e. g. , wxyz’ + wx’yz’ = wyz’), then all their pairwise simplifications, and so on. This gives you a set of candidate products, whose sum is equivalent to the input. 2. Then check which of these products is actually needed. This is done by checking which of the original minterms are “covered” by each of these products, then removing products that are not needed. (This is nondeterministic, since different choices may be possible. ) Algorithm originally invented for the teaching of logic! Details: Ken Rosen, “Discrete Mathematics and its Applications”, (fifth edition) chapter 10. Implementations on the web (e. g. , from Oefai, an AI institute at the University of Vienna) Introduction to CS 231 61