dam lank pring 27 E 3 Identity Pre-Lecture Problem Do it! Do it now! What are you waiting for?! Use Logical Equivalences to show!! $! & & $! p ^ T p p _ F p Domination p _ T T p ^ F F Idempotency p _ p p p ^ p p Foundations of omputing I ommutativity p _ q q _ p p ^ q q ^ p bsorption p _ (p ^ q) p p ^ (p _ q) p Double Negation ssociativity (p _ q) _ r p _ (q _ r) (p ^ q) ^ r p ^ (q ^ r) Negation p _ p T p ^ p F Law of Implication Distributivity p ^ (q _ r) (p ^ q) _ (p ^ r) p _ (q ^ r) (p _ q) ^ (p _ r) DeMorgan s Laws (p _ q) p ^ q (p ^ q) p _ q ontrapositive p p p! q p _ q p! q q! p ombinational Logic Example essions of lass: We would like to compute the number of lectures or quiz sections remaining at the start of a given day of the week. Inputs: Day of the Week, Lecture/ection flag Output: Number of sessions left Examples: Input: (Wednesday, Lecture) Output: 2 Input: (Monday, ection) Output: Implementation in oftware public'int classesleftinmorning(weekday,'lecture_flag)'{ switch'(weekday)'{ case'undy: case'mondy: return'lecture_flag?'3':'; case'tuedy: case'wednedy: return'lecture_flag?'2':'; case'thurdy: return'lecture_flag?'':'; case'fridy: return'lecture_flag?'':'; case'turdy: return'lecture_flag?'':'; } } Implementation with ombinational Logic Defining Our Inputs! Encoding: How many bits for each input/output? inary number for weekday One bit for each possible output Weekday Input: inary number for weekday unday =, Monday =, We care about these in binary: Weekday Lecture? Weekday Number inary unday () 2 Monday () 2 Tuesday 2 () 2 Wednesday 3 () 2 Thursday 4 () 2 2 3 Friday 5 () 2 aturday 6 () 2
onverting to a Truth Table! onverting to a Truth Table! case'undy'or'mondy: return'lecture_flag?'3':'; case'tuedy'or'wednedy: return'lecture_flag?'2':'; case'thurdy: return'lecture_flag?'':'; case'fridy: return'lecture_flag?'':'; case'turdy: return'lecture_flag?'':'; Weekday Lecture? c c c 2 c 3 UN UN MON MON TUE TUE WED case'undy'or'mondy: return'lecture_flag?'3':'; case'tuedy'or'wednedy: return'lecture_flag?'2':'; case'thurdy: return'lecture_flag?'':'; case'fridy: return'lecture_flag?'':'; case'turdy: return'lecture_flag?'':'; Weekday Lecture? c c c 2 c 3 WED THU! FRI FRI T! -! Let s begin by finding an expression for c 3. To do this, we look at the rows where c 3 = (true). DY == UN && L == DY == MON && L == d 2 d d == && L == d 2 == && d == && d == && L == d 2 d d == && L == d 2 == && d == && d == && L == ubstituting DY for the binary representation. plitting up the bits of the day; so, we can write a formula.
d 2 d d L d 2 d d L Replacing with oolean lgebra d 2 d d L d 2 d d L Either situation causes c 3 to be true. o, we or them. Truth Table to Logic (Part 2) Truth Table to Logic (Part 3) Now, we do c 2. Now, we do c : d 2 d d L d 2 d d L d 2 d d L d 2 d d L??? d 2 d d L Truth Table to Logic (Part 3) Now, we do c : d 2 d d L d 2 d d L d 2 d d L d 2 d d L d 2 d d d 2 d d L No matter what L is, we always say it s. o, we don t need L in the expression. Truth Table to Logic (Part 3) Now, we do c : d 2 d d L d 2 d d L d 2 d d L d 2 d d L d 2 d d d 2 d d L No matter what L is, we always say it s. o, we don t need L in the expression. c = d 2 d d L + d 2 d d L + d 2 d d L + d 2 d d L + d 2 d d + d 2 d d L
Truth Table to Logic (Part 4) c = d 2 d d L + d 2 d d L + d 2 d d L + d 2 d d L + d 2 d d + d 2 d d L Finally, we do c : d 2 d d L d 2 d d d 2 d d Truth Table to Logic (Part 4) c = d 2 d d L + d 2 d d + d 2 d d c = d 2 d d L + d 2 d d L + d 2 d d L + d 2 d d L + d 2 d d + d 2 d d L Here s c 3 as a circuit: d NOT 2 ND d NOT OR ND d NOT L E 3: Foundations of omputing Lecture 4: oolean lgebra, ircuits, anonical Forms oolean lgebra oolean algebra to circuit design oolean algebra a set of elements containing {, } binary operations { +, } and a unary operation { } such that the following axioms hold:. the set contains at least two elements:, For any a, b, c in : 2. closure: a + b is in a b is in 3. commutativity: a + b = b + a a b = b a 4. associativity: a + (b + c) = (a + b) + c a (b c) = (a b) c 5. identity: a + = a a = a 6. distributivity: a + (b c) = (a + b) (a + c) a (b + c) = (a b) + (a c) 7. complementarity: a + a = a a = xioms and Theorems of oolean lgebra identity:. X + = X D. X = X null: 2. X + = 2D. X = idempotency: 3. X + X = X 3D. X X = X involution: 4. (X ) = X complementarity: 5. X + X = 5D. X X = commutativity: 6. X + Y = Y + X 6D. X Y = Y X associativity: 7. (X + Y) + Z = X + (Y + Z) 7D. (X Y) Z = X (Y Z) distributivity: 8. X (Y + Z) = (X Y) + (X Z) 8D. X + (Y Z) = (X + Y) (X + Z) xioms and Theorems of oolean lgebra uniting: 9. X Y + X Y = X 9D. (X + Y) (X + Y ) = X absorption:. X + X Y = X D. X (X + Y) = X. (X + Y ) Y = X Y D. (X Y ) + Y = X + Y factoring: 2. (X + Y) (X + Z) = 2D. X Y + X Z = X Z + X Y (X + Z) (X + Y) consensus: 3. (X Y) + (Y Z) + (X Z) = 3D. (X + Y) (Y + Z) (X + Z) = X Y + X Z (X + Y) (X + Z) de Morgan s: 4. (X + Y +...) = X Y... 4D. (X Y...) = X + Y +...
Proving Theorems (Rewriting) Using the laws of oolean lgebra: Proving Theorems (Rewriting) Using the laws of oolean lgebra: prove&the&theorem:&&&&&&&&&&&&&&&&x2 2Y2+2X2 2Y 2=222X prove&the&theorem:&&&&&&&&&&&&&&&&x2 2Y2+2X2 2Y 2=222X X2 Y2+2X2 Y 2=2 distributivity (8) complementarity2(5) identity2(d) X2 Y2+2X2 Y =2 X2 2(Y2+2Y ) =222X2 () =222X2 prove&the&theorem:&&&&&&&&&&&&&&&&&&&&&x2+2x2 2Y222=222X prove&the&theorem:&&&&&&&&&&&&&&&&&&&&&x2+2x2 2Y222=222X X22+22X2 2Y2 =2 identity2(d) distributivity (8) uniting2(2) identity2(d) X22+22X2 2Y2 =222X2 2222+22X2 2Y =222X2 2(2+2Y) =222X2 () =222X2 Proving Theorems (Truth Table) Using complete truth table: For example, de Morgan s Law: (X2+2Y) 2=2X 2 2Y NOR2is2equivalent2to2ND2 with2inputs2complemented (X2 2Y) 2=2X 2+2Y NND2is2equivalent2to2OR2 with2inputs2complemented X Y X Y (X2+2Y) 2222X 2 2Y 222222222222222222 X Y X Y (X2 2Y) X 2+2Y 2 22 222222 2222222222222 implifying using oolean lgebra c3 = d2 d d L + d2 d d L = d2 d (d + d) L = d2 d () L = d2 d L d2 d L NOT NOT ND Let s make a circuit that adds three single bit inputs together into a single binary number Let s make a circuit that adds three single bit inputs together into a single binary number + + + + + + + + + + + + + + + + + + + +
Larger um? Inputs:,2,2 Outputs: TwoRbit2um + To get a sum of numbers with more bits, we can combine two of our original circuit together! Larger um? Larger um? arry From Right arry From Right + Discard2This2it OUT IN To support this idea, we rename our inputs/outputs. IN OUT Inputs:,2,2arryRin Outputs: um,2arryrout OUT IN Inputs:,2,2arryRin OUT IN Outputs: um,2arryrout IN OUT IN OUT Derive an expression for IN OUT IN IN IN = IN + IN + IN + IN IN
Inputs:,2,2arryRin OUT IN Inputs:,2,2arryRin OUT IN Outputs: um,2arryrout Outputs: um,2arryrout IN OUT Derive an expression for OUT IN OUT IN OUT = IN + IN + = IN + IN + IN + IN OUT = IN + IN + IN + IN IN IN IN IN + IN = IN + IN + IN + IN pply Theorems to implify Expressions 2-bit Ripple-arry dder The theorems of oolean algebra can simplify expressions e.g., full adder s carry-out function 2 2 out =22 22in +22 2in +222in 2+222in =22 22in +222 2in +2222in 22+2222in +2222in =22 22in +2222in +222 2in +2222in 22+2222in =22( 2+2)22in +222 2in +2222in 22+2222in =22()22in +222 2in +2222in 22+2222in =222in +222 2in +222in 22+2222in +2222in =222in +222 2in +2222in +2222in 22+2222in =222in +222( 2+2)2in +2222in 22+2222in =222in +222()2in +2222in 22+2222in =222in +222in +2222(in 2+22in) =222in +222in +2222() =222in +222in +2222 adding2extra2terms2 creates2new2factoring2 opportunities in in in in.it/dder um out um out in out um in out um in out um 2 Mapping Truth Tables to Logic Gates anonical Forms 2 Given a truth table:. Write the oolean expression 2. Minimize the oolean expression 3. Draw as gates 4. Map to available gates F/=/ + + + =/ ( +)+( +) =/ + 3 not F 4 not ////F //// //// //// //// //// //// //// //// F Truth table is the unique signature of a oolean Function The same truth table can have many gate realizations We ve seen this already Depends on how good we are at oolean simplification anonical forms tandard forms for a oolean expression We all come up with the same expression
um-of-products anonical Form K Disjunctive Normal Form (DNF) K Minterm Expansion F F"=" "+" "+" "+" "+" Read T rows off truth table dd the minterms together 2 3 onvert to oolean lgebra F um-of-products anonical Form Product term (or minterm) NDed product of literals input combination for which output is true each variable appears exactly once, true or inverted (but not both) minterms F2in2canonical2form: F(,2,2) =2 2+2 2+2 2+2 2+2 canonical2form2 minimal2form F(,2,2) =2 2+2 2+2 2+22+2 2 =2( 2+2 2+2 2+2)2+2 =2(( 2+2)( 2+2))2+2 =22+2 =2 2+2 =22+2