1-bit Binary Adder CSE Cout Cin • Inputs: A, B, Carry-in 311 • Outputs: Sum, Carry-out A A A A A B B B B B S S S S S A B Cin Cout S 0 0 0 0 0 0 0 0 1 1 A 0 1 0 0 1 S Foundations of 0 1 1 1 0 B 1 0 0 0 1 Cout Cin 1 0 1 0 1 1 1 0 1 0 1 1 1 1 1 Computing I S = A’ B’ Cin + A’ B Cin’ + A B’ Cin’ + A B Cin Cout = A’ B Cin + A B’ Cin + A B Cin’ + A B Cin Fall 2014 Apply Theorems to Simplify Expressions Gates Again! The theorems of Boolean algebra can simplify expressions X Y – e.g., full adder’s carry-out function X Y 0 1 1 0 Cout = A’ B Cin + A B’ Cin + A B Cin’ + A B Cin = A’ B Cin + A B’ Cin + A B Cin’ + A B Cin + A B Cin = A’ B Cin + A B Cin + A B’ Cin + A B Cin’ + A B Cin X Y Z 0 0 0 = (A’ + A) B Cin + A B’ Cin + A B Cin’ + A B Cin X 0 1 0 Z = (1) B Cin + A B’ Cin + A B Cin’ + A B Cin 1 0 0 Y = B Cin + A B’ Cin + A B Cin’ + A B Cin + A B Cin 1 1 1 = B Cin + A B’ Cin + A B Cin + A B Cin’ + A B Cin = B Cin + A (B’ + B) Cin + A B Cin’ + A B Cin = B Cin + A (1) Cin + A B Cin’ + A B Cin X Y Z = B Cin + A Cin + A B (Cin’ + Cin) 0 0 0 X Z = B Cin + A Cin + A B (1) 0 1 1 adding extra terms 1 0 1 = B Cin + A Cin + A B Y 1 1 1 creates new factoring opportunities
More Gates! A 2-bit Ripple-Carry Adder X Y Z X 0 0 1 A B A 1 B 1 A 0 B 0 A 2 B 2 Z 0 1 1 Y 1 0 1 1 1 0 1-Bit Adder X Y Z C in C out 0 C in C out C in C out A X 0 0 1 B Z 0 1 0 Y 1 0 0 A 1 1 0 Cout Cin B Sum 0 Sum 1 Sum 2 C in C out X Y Z Cin X 0 0 0 Z 0 1 1 Y 1 0 1 A 1 1 0 B Sum Cin X Y Z X 0 0 1 Z 0 1 0 Y Sum 1 0 0 1 1 1 Mapping Truth Tables to Logic Gates CSE 311: Foundations of Computing Fall 2014 Given a truth table: A B C F Lecture 5: Canonical Forms, Predicate Logic 0 0 0 0 1. Write the Boolean expression 0 0 1 0 2. Minimize the Boolean expression 0 1 0 1 3. Draw as gates 0 1 1 1 4. Map to available gates 1 0 0 0 1 1 0 1 1 1 1 0 0 F = A’BC’+A’BC+AB’C+ABC 1 1 1 1 = A’B(C’+C)+AC(B’+B) 2 = A’B+AC 3 notA notA 4 B B F F A A C C
Canonical Forms Sum-of-Products Canonical Form • also known as Disjunctive Normal Form (DNF) • Truth table is the unique signature of a Boolean function • also known as minterm expansion • The same truth table can have many gate realizations F = 001 011 101 110 111 – we’ve seen this already F = + A’BC + AB’C + ABC’ + ABC A’B’C – depends on how good we are at Boolean simplification A B C F F’ 0 0 0 0 1 • Canonical forms 0 0 1 1 0 0 1 0 0 1 – standard forms for a Boolean expression 0 1 1 1 0 – we all come up with the same expression 1 0 0 0 1 1 0 1 1 0 1 1 0 1 0 1 1 1 1 0 Sum-of-Products Canonical Form Product-of-Sums Canonical Form • Also known as Conjunctive Normal Form (CNF) Product term (or minterm) – ANDed product of literals – input combination for which output is true • Also known as maxterm expansion – each variable appears exactly once, true or inverted (but not both) F = 000 010 100 A B C minterms F = (A + B + C) (A + B’ + C) (A’ + B + C) F in canonical form: 0 0 0 A’B’C’ F(A, B, C) = A’B’C + A’BC + AB’C + ABC’ + ABC 0 0 1 A’B’C A B C F F’ 0 1 0 A’BC’ 0 0 0 0 1 canonical form ≠ minimal form 0 0 1 1 0 0 1 1 A’BC F(A, B, C) = A’B’C + A’BC + AB’C + ABC + ABC’ 0 1 0 0 1 1 0 0 AB’C’ 0 1 1 1 0 = (A’B’ + A’B + AB’ + AB)C + ABC’ 1 0 1 AB’C 1 0 0 0 1 = ((A’ + A)(B’ + B))C + ABC’ 1 0 1 1 0 1 1 0 ABC’ = C + ABC’ 1 1 0 1 0 1 1 1 ABC 1 1 1 1 0 = ABC’ + C = AB + C
s-o-p, p-o-s, and de Morgan’s theorem Product-of-Sums Canonical Form Sum term (or maxterm) Complement of function in sum-of-products form: – ORed sum of literals – input combination for which output is false – F’ = A’B’C’ + A’BC’ + AB’C’ – each variable appears exactly once, true or inverted (but not both) A B C maxterms F in canonical form: Complement again and apply de Morgan’s and 0 0 0 A+B+C F(A, B, C) = (A + B + C) (A + B’ + C) (A’ + B + C) 0 0 1 A+B+C’ get the product-of-sums form: 0 1 0 A+B’+C canonical form ≠ minimal form – (F’)’ = (A’B’C’ + A’BC’ + AB’C’)’ 0 1 1 A+B’+C’ F(A, B, C) = (A + B + C) (A + B’ + C) (A’ + B + C) 1 0 0 A’+B+C = (A + B + C) (A + B’ + C) – F = (A + B + C) (A + B’ + C) (A’ + B + C) 1 0 1 A’+B+C’ (A + B + C) (A’ + B + C) 1 1 0 A’+B’+C = (A + C) (B + C) 1 1 1 A’+B’+C’ Predicate Logic Predicate Logic • Propositional Logic • Propositional Logic – If the tortoise walks at a rate of one node per – Allows us to analyze complex propositions in step, and the hare walks at a rate of two nodes terms of their simpler constituent parts joined per step, ... by connectives • Predicate Logic • Predicate Logic – If the tortoise is on node x, and the hare is on – Lets us analyze them at a deeper level… node 2x, then …
Predicate Logic Domain of Discourse Predicate or Propositional Function We must specify a “domain of discourse”, which is the possible things we’re talking about. – A function that returns a truth value, e.g., “ x is a cat” “ x is a cat” “ x is prime” (e.g., mammals) “student x has taken course y ” “ x is prime” “ x > y ” (e.g., numbers) “ x + y = z ” or Sum(x, y, z) “5 < x” student x has taken course y ” Predicates will have variables or constants as (e.g., students and courses) arguments. Quantifiers Statements with Quantifiers Domain: ∀ x P(x) • ∃ x Even(x) Positive Integers P(x) is true for every x in the domain Even(x) ∀ x Odd(x) • read as “for all x, P of x” Odd(x) Prime(x) Greater(x,y) (or “x > y”) • ∀ x (Even(x) ∨ Odd(x)) ∃ x P(x) Equal(x,y) (or “x = y”) There is an x in the domain for which P(x) is true Sum(x,y,z) • ∃ x (Even(x) ∧ Odd(x)) read as “there exists x, P of x” • ∀ x Greater(x+1, x) • ∃ x (Even(x) ∧ Prime(x))
Statements with Quantifiers English to Predicate Logic Cat(x) Domain: • “Red cats like tofu” • ∀ x ∃ y Greater (y, x) Red(x) Positive Integers LikesTofu(x) Even(x) Odd(x) • ∀ x ∃ y Greater (x, y) Prime(x) Greater(x,y) (or “x > y”) Equal(x,y) • ∀ x ∃ y (Greater(y, x) ∧ Prime(y)) (or “x = y”) • “Some red cats don’t like tofu” Sum(x,y,z) • ∀ x (Prime(x) → (Equal(x, 2) ∨ Odd(x)) • ∃ x ∃ y (Sum(x, 2, y) ∧ Prime(x) ∧ Prime(y)) Negations of Quantifiers Negations of Quantifiers • not every positive integer is prime • ∀ x PurpleFruit(x) Domain: Fruit • “All fruits are purple” • ¬∀ x PurpleFruit(x) PurpleFruit(x) • some positive integer is not prime • “Not all fruits are purple” How about ∃ x PurpleFruit(x) ? • • prime numbers do not exist • “There is a purple fruit” • If it’s the negation, all situations should be covered by a statement and its negation • every positive integer is not prime • Consider the domain {Orange} : Neither statement is true! How about ∃ x ¬ PurpleFruit(x) ? • • “There is a fruit that isn’t purple”
De Morgan’s Laws for Quantifiers de morgan’s laws for quantifiers ¬∀ x P(x) ≡ ∃ x ¬ P(x) ¬∀ x P(x) ≡ ∃ x ¬ P(x) ¬∃ x P(x) ≡ ∀ x ¬ P(x) ¬ ∃ x P(x) ≡ ∀ x ¬ P(x) “ There is no largest integer ” ¬ ∃ x ∀ y ( x ≥ y) ≡ ∀ x ¬ ∀ y ( x ≥ y) ≡ ∀ x ∃ y ¬ ( x ≥ y) ≡ ∀ x ∃ y (y > x) “ For every integer there is a larger integer ” scope of quantifiers Scope of Quantifiers vs. example: ∃ x (P(x) ∧ ∧ Q(x)) ∃ x P(x) ∧ ∧ ∃ x Q(x) Notlargest(x) ≡ ∃ y Greater (y, x) ∧ ∧ ∧ ∧ ≡ ∃ z Greater (z, x) truth value: doesn’t depend on y or z “bound variables” does depend on x “free variable” quantifiers only act on free variables of the formula they quantify ∀ x ( ∃ y (P(x,y) → ∀ x Q(y, x)))
Recommend
More recommend