DISCRETE MATHEMATICS Lecture 21

472 Views

Download Presentation
## DISCRETE MATHEMATICS Lecture 21

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -

**DISCRETE MATHEMATICSLecture 21**Dr. Kemal Akkaya Department of Computer Science**§ 11.1: What is Boolean Algebra?**• A minor generalization of propositional logic. • In general, an algebra is any mathematical structure satisfying certain standard algebraic axioms. • Boolean algebra just generalizes the rules of propositional logic to sets other than {T,F}. • E.g., to the set {0,1} of base-2 digits, or the set {VL, VH} of low and high voltage levels in a circuit. • It thus provides the operations and the rules for working with the set {0, 1} • We will see that this algebraic perspective lends itself to the design of digital logic circuits. Claude Shannon’s Master’s thesis!**Complement, Addition, Product**• Correspond to logical NOT, OR, and AND. • We will denote the two logic values as0:≡F and 1:≡T, instead of False and True. • Using numbers encourages algebraic thinking. • New, more algebraic-looking notation for the most common Boolean operators: Precedence order→**Examples**• Let B = {0, 1} then • The variable is called a Boolean variable if it takes only values in B. Consequently x + x = x x2 = x . x = xx = x • Boolean complement, • Addition 0 + 0 = 0, 0 + 1 = 1, 1 + 0 = 1, 1 + 1 = 1 • Product 0 . 0 = 0, 1 . 0 = 0, 0 . 1 = 0, 1 . 1 = 1**Boolean Functions**• Let B = {0, 1}, the set of Boolean values. • For all nZ+, any function f:Bn→B is called a Boolean function of degree n. • There are 22ⁿ distinct Boolean functions of degree n. • Because 2n rows in truth table, with 0 or 1 in each.**Boolean Functions**Question: How many different Boolean functions of degree 1 are there? Solution: There are four of them, F1, F2, F3, and F4:**Boolean Functions**Question: How many different Boolean functions of degree 2 are there? Solution: There are sixteen of them, F1, F2, F3, …, F16 DegreeHow manyDegreeHow many 0 2 4 65,536 1 4 5 4,294,967,296 2 16 6 18,446,744,073,709,551,616. 3 256**Boolean Expressions**• Let x1, …, xn be n different Boolean variables. • n may be as large as desired. • A Boolean expression (recursive definition) is a string of one of the following forms: • Base cases: 0, 1, x1, …, or xn. • Recursive cases: E1, (E1E2), or (E1+E2), where E1 and E2 are Boolean expressions: x1.x2 or x1x2 + x3 etc. • A Boolean expression represents a Boolean function. • Furthermore, every Boolean function (of a given degree) can be represented by a Boolean expression.**Boolean equivalents & operations on Boolean expressions**• Two Boolean expressions e1 and e2 that represent the exact same function f are called equivalent. We write e1e2, or just e1=e2. • Implicitly, the two expressions have the same value for all values of the free variables appearing in e1 and e2. • The operators ¯, +, and · can be extended from operating on expressions to operating on the functions that they represent, in the obvious way. • Let F and G be Boolean functions of degree n. The Boolean sum F+G and Boolean product FG are then defined by • (F + G)(b1, b2, …, bn) = F(b1, b2, …, bn) + G(b1, b2, …,bn) • (FG)(b1, b2, …, bn) = F(b1, b2, …, bn) G(b1, b2, …, bn)**Double complement:**x = x Idempotent laws: x + x = x, x · x = x Identity laws: x + 0 = x, x · 1 = x Domination laws: x + 1 = 1, x · 0 = 0 Commutative laws: x + y = y + x, x · y = y · x Associative laws: x + (y + z) = (x + y) + z x· (y · z) = (x· y) · z Distributive laws: x + y·z = (x + y)·(x + z) x · (y + z) = x·y + x·z De Morgan’s laws: (x · y) = x + y, (x + y) = x · y Absorption laws: x + x·y = x, x · (x + y) = x Some popular Boolean identities**Duality**• There are useful identities of Boolean expressions that can help us to transform an expression A into an equivalent expression B. • We can derive additional identities with the help of the dual of a Boolean expression. • The dual of a Boolean expression is obtained by • interchanging Boolean sums and Boolean products • interchanging 0s and 1s.**Duality**Examples: The dual of x(y+z) is x+yz. The dual of x.1+(y+z) is (x+0)(yz). • An identity between functions represented by Boolean expressionsremains validwhen the duals of both sides of the identity are taken. • This is called Duality principle • For example, absorption law x∙(x + y) = x. • By taking the duals of both sides of this identity, we obtain the equation x + x∙y = x, which is also an identity (and also called an absorption law).**Boolean Functions/Expressions**• Let f:B3→B, where f(x, y, z) = x∙y+z This Boolean function is determined by evaluating f for each of the eight possible assignment to the variables x, y, z.**§11.2 – Representing Boolean Functions**• Definition: A literalis a Boolean variable or its complement. That is if f is a Boolean function on the n variables x1, x2, …, xn, each term xi or its complement –xi, for 1≤ i ≤ n is called a literal. • f(x, y, z) = x∙y+z : x, y and z are literals • A mintermof the Boolean variables x1,x2, …,xn is a Boolean product y1y2…yn, where yi=xi or yi=-xi. • x∙y∙z is a minterm • Hence, a minterm is a product of n literals, with one literal for each variable and is referred to as a fundamental conjunction.**Simplifying Boolean Functions/Expressions**• Let f:B4→B, where f (x, y, z, w) = DeMorgan’s Law Law of Double Complement Associative Law of + Absorption Law (and Commutative Laws of + and . ) Commutative and Associative Laws of + Idempotent Law of +**Sum-of-Products Expansions**• A representation of f as a sum of fundamental conjunctions is called a disjunctive normal form (dnf) of f. • xyz + xyz + … • Dual to the dnf is the conjunctive normal form (cnf). • (x+y+z).(x+y+z). … • Theorem: Any Boolean function can be represented as a sum of products of variables and their complements.**Functional Completeness**• Since every Boolean function can be represented using the set {∙, +,─} thus the operators are functionally complete. • By De Morgan Law we can eliminate Boolean sum thus making {∙,─}functionally complete. • Two operators of NAND | and NOR ↓ can provide the necessary functionality for {∙,─}and thus are functionally complete.**§11.3 – Logic Gates**• Application of Boolean Algebra • Inverter, Or, And gate symbols. • Multi-input gates. • Logic circuits and examples. • Adders, “half,” “full,” and n-bit.**Logic Gate Symbols**x • Inverter (logical NOT,Boolean complement). • AND gate (Booleanproduct). • OR gate (Boolean sum). • XOR gate (exclusive-OR,sum mod 2). x x·y y x x+y y x x⊕y y**Multi-input AND, OR, XOR**• Can extend these gates to arbitrarilymany inputs. • Two commonlyseen drawing styles: • Note that the second style keeps the gate icon relatively small. x1 x1x2x3 x2 x3 x1⋮ x5 x1…x5**NAND, NOR, XNOR**x • Just like the earlier icons,but with a small circle onthe gate’s output. • Denotes that output is complemented. • The circles can also be placed on inputs. • Means, input is complementedbefore being used. y x y x y**Buffer**x x • What about an invertersymbol without a circle? • This is called a buffer. It is the identity function. • It serves no logical purpose, but… • It represents an explicit delay in the circuit. • This is sometimes useful for timing purposes. • All gates, when physically implemented, incur a non-zero delay between when their inputs are seen and when their outputs are ready.**Combinational Logic Circuits**• These are circuits composed of Boolean gates whose outputs depend only on their most recent inputs, not on earlier inputs. • Thus these circuits have no useful memory. • Their state persists while the inputs are constant, but is irreversibly lost when the input signals change.**Examples**Examples: • Majority voting circuit. • XOR using OR / AND / NOT. • Also, some binary adders: • Half adder using OR/AND/NOT. • Full adder from half-adders.**xy +**xy xy Combinational Circuit Example x xy y x y**§11.4 – Minimizing Circuits**• Minimize the number of primitive Boolean logic gates needed to implement the circuit. • Ultimately, this also roughly minimizes the number of transistors, the chip area, cost and energy expenditure. • It is also often useful to minimize the number of combinational stages or logical depth of the circuit. • This roughly minimizes the delay or latency through the circuit, the time between input and output. • One solution is using Karnaugh Maps • Karnaugh Maps or K-map is an alternative to the truth-table form for representing a function. The map consists of cells that correspond to the rows of the truth table. The purpose of the map is to allow easy recognition of the cells that are adjacent and can be combined.**K-map Example**Find K-Map for y y x x Minterms in any cells that are adjacent, either in the same row or the same column, can be combined. For example:**More K-Map Examples**• How about three variables? 1) 2) 3)**yz**yz yz x Can we simplify it? yz x**yz**yz yz x Get the adjacent terms / combine yz x**Minimizing DNF Expressions**• Using DNF (or CNF) guarantees there is always some circuit that implements any desired Boolean function. • However, it may be far larger than needed! • We would like to find the smallest sum-of-products expression that yields a given function. • This will yield a fairly small circuit. • However, circuits of other forms (not CNF or DNF) might be even smaller for complex functions.**yz**wx 4-degree functions yz yz yz wx wx wx