2 Ver..4 George Boole was an English mathematician of XIX century can operate on logic (or Boolean) variables that can assume just 2 values: /, true/false, on/off, closed/open Usually value is associated to True, while to alse 2 - Claudio ornaro 3 4 Boolean algebra is suited for representing binary events, that is conditions that can assume just 2 values A light bulb can be turned on or off unctions operating on Boolean variables are called Boolean functions and can only produce values or A Boolean function, computed on the Boolean variables v,v 2,...,v n is denoted as: ( v, v2,, v n A Boolean function can be defined in many ways, among them the truth table: a list of the values that produces for every possible combination of the variables )
5 6 (v,v 2,v 3 ) can be defined as shown on the right side: Each Boolean variable can assume only 2 values, thus n variables can produce 2 n possible combinations, and each one is a row of the table v 3 v 2 v Description of an event by using a Boolean function To pass a certain exam, a student must match one of the following conditions: s/he passes the written pre-test and then the oral discussion s/he passes the written test and then the oral discussion 7 8 Each event is either independent or dependent (from the independent events) Each event is assigned a Boolean variable: a pre-test, =passed b written test, =passed c oral test, =passed e exam, =passed 3 variables allow 8 (2 3 ) combinations The truth table for the Boolean function passing the exam then is: Meaning of this row: the student passed pre-test (a=), didn t pass (or try) written test (b=) and passed oral test (c=), thus s/he passes the whole exam (e=) a b c e
9 After looking carefully, condition a =, b =, and c = cannot happen, because the oral examination can be tried only when the pretest or the written test has been passed (or both) or that combination the exam is not passed, but this is an impossible condition, so it could be useful to indicate a don t care condition (usually represented by a ). A don t care mark will be eventually replaced by either a or a as needed in a next stage Boolean variables can be combined by using Boolean (or logic) operators into Boolean (or logic) expressions The result of a logic operation is still a logic value (true or false) The most important operators are: AND, OR, NOT EXOR NAND, NOR, EXNOR 2 Operator AND (logic product) symbol: (like the algebraic product), it is often omitted it combines 2 values and produces a result following the rules below: = = = = Result is True if both operands are True I go to sea if it is sunny AND it is warm X= it is sunny Y= it is warm Z= I go to sea Z = X Y Both condition must be true to have that I go to the sea be true
3 4 Operator OR (Inclusive OR, logic sum) symbol: + (like the algebraic sum) it combines 2 values and produces a result following the rules below: + = + = + = + = Result is True if at least one operand is True I take car if it is raining OR it is cold I use car if it is raining OR it is cold X= it is raining Y= it is cold Z= I use car Z = X + Y At least one condition must be true to have that I use car be true 5 6 Operator NOT symbol: a little line over the variable or the expression to be negated, or just a sign it applies to just one value and produces a result following the rules below: = = Result is True if the operand is alse, and vice versa Operator EX-OR (Exclusive OR) symbol: it combines 2 values and produces a result following the rules below: = = = = Result is True if just one operand is True
7 8 Logic Expressions A logic (or Boolean) expression is composed by: logic variables constants and logic operators parentheses Examples a b c ab c(d ae) c e Logic Expressions In a logic expression the operator with the maximum priority is NOT, followed by AND and then OR This means that the following expressions are equivalent = a + b c = a + (b c) 9 2 Logic Expressions Two expressions and 2 are said equivalent when each input variable combination produce the same output value on both functions (they have the same truth tables) s 2 x x Logic Expressions Two expressions and 2 are said complementary when each input variable combination produce an opposite output value on both functions (they have complementary truth tables) s a b 2 a b
2 22 Logic Expressions Two expressions and 2 are said dual when: each OR of corresponds to an AND of 2 and vice versa each of corresponds to an of 2 and v.v. the order of operator evaluation is the same a b ( c ) 2 a ( b ( c )) note the added parentheses Logic expression reduction A reduced expression is faster to be evaluated and the corresponding circuit is smaller, faster, and less power consuming Reduction can be accomplished in many ways, among them: Boolean algebra axioms and theorems Karnaugh maps 23 24 Axioms and Th. Theorem of duality: if an equivalence holds, the dual equivalence holds as well Axioms and theorems. x = x + = 2. x = x x + = x 3. x x = x + x = 4. x x = x x + x = x 5. x y = y x x +y = y +x Axioms and Th. 6. x y z = (x y) z = x+y+z = (x+y) + z = = x (y z) = = x + (y+z) = = y (x z) = y + (x+z) 7. De Morgan s Theorem x y z = x+y+z+ x+y+z+ = x y z 8. x y+x z = x (y+z) (x+y) (x+z) = x+y z 9. x+x y = x x (x+y) = x. x y + x y = x (x+y) (x+y) = x. x+x y = x+y x (x+y) = x y 2. x y = x y+x y = x y x y=x y=x y=xy+xy
25 26 Axioms and Th. Some demonstrations 9. x+x y = x +x y = x (+y) = x = x 8. b. (x+y) (x+z) = xx+xz+xy+yz = = x+xz+xy+yz = = x +xz+xy+yz = = x (+z+y)+yz = x +yz = x+yz. x y+x y = x (y+y) = x = x. x+x y = x +xy = x (+y)+xy = x+xy+xy = = x+y rule Axioms and Th. In the previous equalities, variables x, y, and z can be considered both as single variables or as full logic expressions E.g. from rule bis: (a b+c d) + = where the parentheses content is considered as x Note that the complementary of x y is NOT x y, but is x y and this for the De Morgan s Theorem is equal to x+y Examples of reduction Reduce the following expressions. A B AB ( A B) AB A B B ( A B) AB A ( A B) AB rule rule 3b everything rule b 2. ( A B) AB C BA A C B C C rule b rule 4 rule 27 Examples of reduction Another demonstration of rule x+x y = x +xy = x (y+y)+xy = = xy+xy+xy = xy+xy+xy+xy = [rule 4b] = x(y+y)+y(x+x) = x+y Any term in OR may be duplicated, triplicated, etc. following rule 4b (backward): x=x+x+x+ Any term in AND may be duplicated, triplicated, etc. following rule 4a (backward): x=x x x 28
29 3 Logic unctions and Truth Tables To obtain the truth table from a logic function, the output value for each combination of the input values must be computed Compute the truth table of the following function: (a,b,c) = (ab + b) c Logic unctions and Truth Tables abc ab b ab + b c (ab+b) c 3 32 Expressions in Canonical orms SP Canonical orm Logical sum of products (SP) Each term (called minterm) is a product of all the variables (some could be affirmed, other negated) Example this expression is composed by 4 minterms (a,b,c) = abc+abc+abc+abc Expressions in Canonical orms PS Canonical orm Logical product of sums (PS) Each term (called maxterm) is a sum of all the variables (some could be affirmed, other negated) Example this expression is composed by 3 maxterms (a,b,c) = (a+b+c) (a+b+c) (a+b+c)
33 34 rom Truth Table to SP Because the function must give for some specific combination of input values, for each row with output value : write a product of all the variables (minterm) Each minterm must give for a specific combination of the input variables, so: negate each variable whose value is on the input combination corresponding to the minterm Sum the minterms rom Truth Table to SP a b c abc (a,b,c) = abc+abc+abc+abc 35 36 rom Truth Table to PS Because the function must give for some specific combination of input values, for each row with output value : write a sum of all the variables (maxterm) Each maxterm must give for a specific combination of the input variables, so: negate each variable whose value is on the input combination corresponding to the maxterm Multiply the maxterms rom Truth Table to PS a b c ( a b c ) (a,b,c)=(a+b+c) (a+b+c) (a+b+c) (a+b+c)
37 38 Expressions in Canonical orms To canonicalize an SP expression If in a product a variable is missing (e.g. x) multiply the product by (x+x) and solve removing duplicates Example (x,y,z) = xyz+yz+z = xyz+(x+x)yz+(x+x)(y+y)z = xyz+xyz+xyz+xyz+xyz+xyz+xyz Expressions in Canonical orms To canonicalize a PS expression If in a sum a variable is missing (e.g. x) add to the sum the term x x and solve removing duplicates Example (x,y,z) = (x+y+z) (x+z) x = (x+y+z) (x+yy+z) (x+yy+zz) = (x+y+z) (x+y+z) (x+y+z) etc. 39 4 Logic Circuits A logical function can be implemented in a digital electronic circuit Input variables are input signals Output variables are output signals Signals have just 2 values: low and high, associated to logic values and Logic operators corresponds to logic gates (e.g. in an AND gate, the output signal is high only when the 2 input signals are high) Logic Gates AND OR NOT NAND = NOR = EXOR EX-NOR =
4 42 Logic Gates Multiple-input gates exists and are equivalent to more gates connected (thanks to the associative property), but are faster A multiple-input EXOR gate gives when the number of input with value is odd Logic Circuits of logic circuit equivalent to a logic expression = a b + c Note how operator priority is provided by the relative position of the gates a b c 43 44 Logic Circuits Examples a b c ( a bc) ( abc a b). our doors (A, B, C, and D) separate two rooms. The doors are operated by 3 switches (X, Y, and Z) that, when pressed, close some doors: X closes A and C, Y closes B and D, Z closes B and C. Draw the corresponding truth table that produces only when all the doors are closed. Determine the corresponding function with the least number of variables.
45 46 Examples XYZ ABCD D =Door closed (Note the truth table is the bold part, columns ABCD are just intermediate values) D=XYZ+XYZ=XY Examples 2. Design a digital circuit with inputs:. a 2C value D composed by bits a and b 2. a selector: one bit s and outputs:. a 2C value U composed by bits x and y 2. an overflow indicator: one bit w that works in this way: U = D if s= U = D if s= w = if the 2C operation produces an incorrect result 47 Examples sab D U xy w + + -2-2 - - + - -2 -- -- - + x=sab+sab+sab y=sab+sab+sab+sab w=sab