December 29, (c) Boolean Product combines 2 values in the same way that && does. It is denoted with a dot:

Boolean Algebra December 29, 2002 We all know that information in computers is represented as zeros (0) and ones (1), but how does the computer manipu...
Author: Lydia Perkins
0 downloads 0 Views 57KB Size
Boolean Algebra December 29, 2002 We all know that information in computers is represented as zeros (0) and ones (1), but how does the computer manipulate these things? The answer is with tiny little machines called gates. The Computer Architecture course describes how these gates work, but we can formulate a mathematics which describes the interaction of these gates so that we can better design our computers. This mathematics is called, Boolean Algebra. 1. We will use 0,1 as the only values in our system. 2. We will have 3 basic operators on expressions in our system: (a) Complement returns the opposite of the value, and is denoted by a horizontal bar: ¯0 = 1 and ¯1 = 0. (b) Boolean Sum combines two values in the same way that || does in C++. It is denoted with a plus sign: 0 + 0 = 0, 0 + 1 = 1, 1 + 0 = 1, 1+1=1 (c) Boolean Product combines 2 values in the same way that && does. It is denoted with a dot: 0 · 0 = 0, 0 · 1 = 0, 1 · 0 = 0, 1 · 1 = 1. Sometimes, we just leave out the dot. (d) Order of operations are: ¯, (), ·, + 3. Find the value of 1 + 0 · (0 + 1). 4. Of course, we can have variables in our system. This results in a boolean function. (a) The degree of the function is the number a variables. (b) We describe the function as a table of all possible values of the variables, as well as the corresponding values for the function:

x 0 0 1 1

y 0 1 0 1

x 0 0 0 0 1 1 1 1

x·y 0 0 0 1

1

y 0 0 1 1 0 1 0 1

z 0 1 0 1 0 0 1 1

x · (y + z) 0 0 0 0 1 0 0 0

(c) How many functions are there of degree n? 5. Boolean Identities. There are a set of identities in boolean logic which can be used for manipulating boolean equations: x ¯=x Double Complement x + x = x, x · x = x Idempotent Laws x + 0 = x, x · 1 = x Identity x + 1 = 1, x · 0 = 0 Domination x + y = y + x, xy = yx Commutative x + (y + z) = (x + y) + z, x(yz) = (xy)z Associative x(y + z) = xy + xz Distributive (xy) = x ¯ + y¯, x + y = x ¯ · y¯ DeMorgan’s Law x + xy = x Absorption x+x ¯=1 Unit Property x¯ x=0 Zero Property 6. what are: x(x + y)? (x + y)(x + z)? 7. How would you show one of these laws is valid? 8. Sum with x 0 0 0 0 1 1 1 1

of Product expansions- Given an arbitrary table describing a boolean function, can we come up a correct boolean expression that generates the table? Of course we can. y z F 0 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 1 0 1 0 1 1 1 0

(a) We look at when the value of the function is true. We note that above, function F is true either in line 3 OR line 7. (b) For each row where the value is true, we note that that row only applies when all of x,y, and z, have those particular values. Row 3 onl;y applies when x is 0 AND y is 1 AND z is 0. (c) If we stick these two things together we can form a disjunction (OR) of conjunctions (AND): x ¯y¯ z + xy¯ z. (d) The resulting form is also known as sum-of-products expansion or disjunctive normal form. (e) All boolean expressions can be transformed into these sum-of-products. How can I prove that? You can always build a table and then read off the s-o-p from that. (f) You can also apply the identities to it to massage it into s-o-p form. The usual process is to apply the distributive law, and if there are terms missing variables, use identity, unit, and distributive again. (g) Try (a+b)(c+d). 9. Functional Completeness. (a) We say that the set of operators ·, +,¯ are functionally complete, because using them, we can generate all possible function. (b) but other sets of operators are also functionally complete, such as ·,¯. Why? Hint: Use DeMorgan’s (c) NAND is a new operator, which is the opposite of AND (not and, NAND, get it?). NAND is represented as |, and is, by itself, functionally complete. How could that be? Well, ·,¯is functionally

2

complete, and we can replace each with |: x ¯=x|x

x · y = (x | y) | (x | y)

(d) NOR is not or, written as ↓, and is also functionally complete. 10. Logic gates (a) As we said before, this boolean logic stuff is important because it models gates inside the computer. How does it do this? (b) It so happens that we know hoe to build these gates so that they perform the same functions as the boolean operators: and, or, not, etc. Where an electric current is a 1, and no current is 0. (c) To build a circuit, just add gates as you read the expression. Examples a-plenty on page 714-717. (d) The adder is particularly interesing. 11. Circuit minimization (a) We often end up with a boolean expression is s-of-p from, because we build it from the table. (b) s-of-p form taken from a table is rarely the most efficient form. More clauses = more gates. more gates=more power consumed, more complexity, more things to break. (c) We want a few gates as possible, so we’ll apply a minimization technique known as Karnaugh Maps. (d) The key insight to K-maps is that non-minimal expressions in s-of-p form have pairs (or more) of clauses where one of the variables doesn’t matter. For example, xy¯ z + x¯ y z¯ + x ¯y¯z¯ = x¯ z+x ¯y¯z¯. It doesn’t matter what y is, x¯ z makes the whole expression true. (e) We can just scan our expression for situations like this to simplify, but in big expressions with lots of variables, they’re not easy to see. (f) K-maps are just a way to easily see when these cases occur. (g) K-maps also have the advantange that they work directly on the function table, and we generate the expression directly from them. This means we won’t even have to write down the more complicated expression. (h) So how does a K-map work? With 2 variables, you build a 2x2 table, and label the rows with one variable, and the columns with another. y y¯ x Fill it the middle of the table based on the values of the functions: x ¯ i.

x x ¯

y 0 0

y¯ 1 This is x¯ y+x ¯y¯. 1

ii.

x x ¯

y 1 0

y¯ 0 This is xy + x ¯y¯. 1

iii.

x x ¯

y 1 1

y¯ 0 This is xy + x ¯y + x ¯y¯. 1

(i) What we do is identify rectangular regions of 1’s. In these regions, if they’re bigger than just one square, a variable can be eliminated. In the examples above: i. y¯ ii. xy + x ¯y¯

3

iii. x ¯ + y¯ (j) Two variables is easy. What about more variables? We add a third variable like this: yz y¯ z y¯z¯ y¯z x x ¯ (k) VERY IMPORTANT! Note the order of the variables across the top! Neighboring columns must differ in only one of the two variables. This is called a Grey coding. More about that later. (l) Examples: i.

x x ¯

yz 1 0

y¯ z 1 1

y¯z¯ 0 0

y¯z 0 xyz + xy¯ z+x ¯y¯ z+x ¯y¯z = xy + y¯ z+x ¯y¯z 1

ii.

x x ¯

yz 1 1

y¯ z 1 1

y¯z¯ 0 0

y¯z 0 xyz + xy¯ z+x ¯yz + x ¯y¯ z+x ¯y¯z = y + x ¯y¯z = y + x ¯z 1

iii.

x x ¯

yz 1 1

y¯ z 1 0

y¯z¯ 1 1

y¯z 1 xyz + xy¯ z + x¯ y z + x¯ y z¯ + x ¯yz + x ¯y¯z + +¯ xy¯z¯ = x + y¯ + z¯ 1

(m) Notice, that the rectangles must have dimensions that are a power of 2: 1,2,4. Not 3. Why not? (n) Can we figure out how this works with 4 variables? yz y¯ z y¯z¯ y¯z wx w¯ x w¯ ¯x wx ¯ (o) Now, we have to think about wrapping from top to bottom as well as the left and right edges. Remember that the dimensions of the rectangles you draw must only be in powers of 2. (p) Examples: yz y¯ z y¯z¯ y¯z wx 1 0 0 1 x 0 1 1 0 i. w¯ w¯ ¯x 0 1 1 0 wx ¯ 1 0 0 1 wxyz + wx¯ y z + w¯ xy¯ z + w¯ xy¯z¯ + w¯ ¯ xy¯ z + w¯ ¯ xy¯z¯ + wxyz ¯ + wx¯ ¯ y z = xz + x ¯z¯ yz y¯ z y¯z¯ y¯z wx 1 1 1 0 x 1 1 1 0 ii. w¯ w¯ ¯x 1 1 1 0 wx ¯ 0 0 0 1 wxyz + wxy¯ z + wx¯ y z¯ + w¯ xyz + w¯ xy¯ z + w¯ xy¯z¯ + w¯ ¯ xyz + w¯ ¯ xy¯ z + w¯ ¯ xy¯z¯ + wx¯ ¯ yz = wy + w¯ z+x ¯y + x ¯z¯ + wx¯ ¯ yz yz y¯ z y¯z¯ y¯z wx 0 1 0 0 x 0 0 1 0 iii. w¯ w¯ ¯x 0 1 1 0 wx ¯ 1 0 0 1 wxy¯ z + w¯ xy¯z¯ + w¯ ¯ xy¯ z + w¯ ¯ xy¯z¯ + wxyz ¯ + wx¯ ¯ yz = wxy¯ z+x ¯y¯z¯ + w¯ ¯ xz¯ + wxz ¯ (q) Past 4 variables and things get hairy. We stop using K-maps, and start using other methods.

4

(r) Sometimes we have “don’t care” conditions. These happen when we don’t care what the output is for a particular input- maybe because we know that input will never occur. In those cases, we put a d in the K-map, and use it as a 1 or a 0, whichever will help our minimization. 12. So, recall our process for designing circuits: (a) Make a table of what output you want for each input. (b) Convert table to K-map. Minimize. (c) Convert to s-of-p boolean expression. (d) Design with gates. (e) Go to Radio Shack, start soldering.

5

Suggest Documents