chapter 2 boolean algebra and logic...
TRANSCRIPT
Department of Computer ScienceNational Tsing Hua University
Chih-Tsun Huang (黃稚存)
Chapter 2Boolean Algebra and
Logic Gates
Outline
Axiomatic Definition of Boolean Algebra Basic Theorems and Properties of Boolean
Algebra Boolean Functions Canonical and Standard Forms Other Logic Operations Digital Logic Gates Integrated Circuits
Fall 2010 CS2102 Chih-Tsun Huang 2
Basic Definitions
Set: a collection of objects with a common property.
Binary operator on a set S is a rule that assigns to a unique element, on each pair of element in S.
Axioms (postulates) of an algebra are the basic assumptions from which all theorems of the algebra can be proved.
It is assumed that there is an equivalent relation (=), which satisfies principle of substitution. Reflexive, symmetric, and transitive
Fall 2010 CS2102 Chih-Tsun Huang 3
Most Common Axioms to Formulate an Algebra Structure (1/2)
Closure
Associative law
Commutative law
Fall 2010 CS2102 Chih-Tsun Huang 4
Most Common Axioms to Formulate an Algebra Structure (2/2)
Identity element
Inverse
Distributive law
Fall 2010 CS2102 Chih-Tsun Huang 5
Axiomatic Definition
Boolean algebra An algebraic system of logic introduced by
George Boole in 1854
Switching algebra A 2-valued Boolean algebra introduced by Claude
Shannon in 1938
Huntington postulates A formal definition of Boolean algebra in 1904 Defined on a set B with binary operators + and •
with the equivalence relation =
Fall 2010 CS2102 Chih-Tsun Huang 6
Huntington Postulates (1/2)
Defined by a set B with binary operators + and • Closure with respect to + and • (P1)
An identity element with respect to + and • (P2)
Commutative with respective to + and • (P3)
Fall 2010 CS2102 Chih-Tsun Huang 7
Huntington Postulates (2/2)
Distributive law (P4) ‘•’ is distributive over ‘+’
‘+’ is distributive over ‘•’
(called the complement of x) such that ________________________ (P5)
There are at least 2 distinct elements in B (P6)
Fall 2010 CS2102 Chih-Tsun Huang 8
Notes The axioms are independent, none can be
proved from others. Associative law is not included, since it can be
derived (both + and •) from the given axioms. In ordinary algebra, + is not distributive over •. No additive or multiplicative inverses; no
subtraction or division operations. Complement is not available in ordinary algebra. We are going to define B as the set {0, 1} (two-
valued Boolean Algebra). In ordinary algebra, the set S can contain an infinite
set of elements.
Fall 2010 CS2102 Chih-Tsun Huang 9
Two-Valued Boolean Algebra(Switching Algebra) Defined on a set of two elements, The binary operators are the logical AND (•) and OR (+) The unary operation NOT (complement) is also included
for basic operations
The Huntington Postulates are valid We will use the term Boolean algebra for the
2-valued Boolean algebra in the following
Fall 2010 CS2102 Chih-Tsun Huang 10
}1,0{B
x y xy x y x+y x x 0 0 0 0 0 0 0 1 0 1 0 0 1 1 1 0 1 0 0 1 0 1 1 1 1 1 1 1
Huntington Postulates Test (1/3)
Closure Results of operators (from truth tables) are still in
{0, 1}
Identity elements
Commutative law Obvious from the symmetry of the truth tables
Fall 2010 CS2102 Chih-Tsun Huang 11
Huntington Postulates Test (2/3)
Fall 2010 CS2102 Chih-Tsun Huang 12
Distributive law Holds both for • over + and for + over •.
x y z y + z x·(y + z) x·y x·z (x·y) + (x·z)
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
Huntington Postulates Test (3/3)
Complement
The two-valued Boolean algebra has two distinct elements, 1 and 0, with 1 ≠ 0.
Fall 2010 CS2102 Chih-Tsun Huang 13
Duality Principle
Every algebraic expression deducible from the postulates of Boolean algebra remains valid if the operators and identity elements are interchanged: Binary operators: AND OR
Identity elements: 1 0
Fall 2010 CS2102 Chih-Tsun Huang 14
Postulates and Theorems of Boolean Algebra
Fall 2010 CS2102 Chih-Tsun Huang 15
Basic Theorems (1/5)Theorem 1 (Idempotency)
(a) x + x = x
(b) x • x = x
Fall 2010 CS2102 Chih-Tsun Huang 16
Basic Theorems (2/5)Theorem 2
(a) x + 1 = 1
(b) x • 0 = 0 by duality
Fall 2010 CS2102 Chih-Tsun Huang 17
Basic Theorems (3/5)
Theorem 3 (Involution) (x’)’ = x
P5 defines the complement of x, and the complement of x’ is both x and (x’)’
Theorem 4 (Associativity) (a) x + (y + z) = (x + y) + z,
(b) x(yz) = (xy)z
Can be proved by truth table
Fall 2010 CS2102 Chih-Tsun Huang 18
Basic Theorems (4/5)Theorem 5 (DeMorgan’s Theorem)
(x+y)’ = x’y’
(x y)’ = x’ + y’(Duality principle)
Fall 2010 CS2102 Chih-Tsun Huang 19
x y x + y (x + y)’ x’ y’ x’y’
0 0
0 1
1 0
1 1
Basic Theorems (5/5)Theorem 6 (Absorption)
(a) x + xy = x, x + xy = x • 1 + xy
Or proved by the truth table
(b) x(x + y) = x by duality
Fall 2010 CS2102 Chih-Tsun Huang 20
Operator Priority
Operator precedence Parentheses
NOT
AND
OR
Examples xy’ + z
(xy + z)’
Fall 2010 CS2102 Chih-Tsun Huang 21
Boolean Functions
A Boolean function is an algebraic expression formed with Binary variables Logic operators AND, OR Unary NOT Parentheses An equal sign Constant 0 or 1
Examples F2 = xy’+x’z F2 = x’y’z + x’yz + xy’
Fall 2010 CS2102 Chih-Tsun Huang 22
Boolean Functions
Can be represented by a truth table, with 2n
rows in the table (n: # of variables in the function)
There are infinite number of algebraic expressions to specify a given Boolean function Simplest one
Transform the Boolean function An algebraic expression a logic diagram
F1 = x + y’z
Fall 2010 CS2102 Chih-Tsun Huang 23
Gate Implementation
Fall 2010 CS2102 Chih-Tsun Huang 24
Boolean Functions
A literal is a variable or its complement in a Boolean expression F2 = x’y’z + x’yz + xy’ _____ literals,
1 OR term (sum term) and 3 AND terms (product terms)
Literal: an input to a gate
Term: implementation with a gate
Minimize the number of literals and terms A simpler (less expensive) circuit
Fall 2010 CS2102 Chih-Tsun Huang 25
Complement of A Function F is F’ DeMorgan’s theorem (A + B + C + D + … + F)’
(ABCD…F)’
Fall 2010 CS2102 Chih-Tsun Huang 26
Algebraic Manipulation1) x (x’ + y) =
2) x + x’y =
3) (x + y)(x + y’) =
4) xy + x’z + yz =
5) (x + y)(x’ + z)(y + z) = (x + y)(x’ + z) by duality from 4
Fall 2010 CS2102 Chih-Tsun Huang 27
Canonical and Standard FormsMinterms and Maxterms Minterm (mi) An AND term consists of all literals in their normal form or
in their complement form (standard product) E.g., two binary variable x and y,
xy, xy’, x’y, x’y’ n variables can be combined to form 2n minterms
Maxterm (Mi) An OR term consists of all literals in their normal form or in
their complement form (standard sum) E.g., x + y, x + y’, x’ + y, x’ + y’ n variables: 2n maxterms
Each maxterm is the complement of its corresponding minterm and vice versa. mi’ = Mi
Fall 2010 CS2102 Chih-Tsun Huang 28
Minterms and Maxterms Canonical forms
Sum-of-minterms (som)
Product-of-maxterms (pom)
Fall 2010 CS2102 Chih-Tsun Huang 29
x y z Minterms Notation Maxterms Notation
0 0 0 0 x’y’z’ m0 x + y + z M0
1 0 0 1 x’y’z m1 x + y + z’ M1
2 0 1 0 x’yz’ m2 x + y’ + z M2
3 0 1 1 x’yz m3 x + y’ + z’ M3
4 1 0 0 xy’z’ m4 x’ + y + z M4
5 1 0 1 xy’z m5 x’ + y + z’ M5
6 1 1 0 xyz’ m6 x’ + y’ + z M6
7 1 1 1 xyz m7 x’ + y’ + z’ M7
Examples (1/4)A Boolean function can be expressed by
A truth table Sum-of-minterms
f1 =
Product-of-maxterms
f1 =
f1’ =
(f1’)’ =Fall 2010 CS2102 Chih-Tsun Huang 30
x y z f1 f1’
0 0 0 0 0
1 0 0 1 1
2 0 1 0 0
3 0 1 1 0
4 1 0 0 1
5 1 0 1 0
6 1 1 0 0
7 1 1 1 1
Examples (2/4)A Boolean function can be expressed by
A truth table Sum-of-minterms
f2 = x’yz + xy’z + xyz
Product-of-maxtermsf2 = (x+y+z)(x+y+z’)(x+y’+z)(x’+y+z)
Fall 2010 CS2102 Chih-Tsun Huang 31
x y z f2 f2’
0 0 0 0 0
1 0 0 1 0
2 0 1 0 0
3 0 1 1 1
4 1 0 0 0
5 1 0 1 1
6 1 1 0 1
7 1 1 1 1
Examples (3/4)
F = A + B’C Using truth table first
Fall 2010 CS2102 Chih-Tsun Huang 32
A B C F
0 0 0 0
1 0 0 1
2 0 1 0
3 0 1 1
4 1 0 0
5 1 0 1
6 1 1 0
7 1 1 1
Examples (4/4)
Express the Boolean function F = xy + x’ as a product of maxterms
Fall 2010 CS2102 Chih-Tsun Huang 33
Canonical Forms
Fall 2010 CS2102 Chih-Tsun Huang 34
Standard Forms (1/2)
Canonical forms are seldom used
Standard forms Sum-of-products (sop) Product terms (implicants) are the AND terms, which
can have fewer literals than the minterms
Product-of-sums (pos) Sum terms are the OR terms, which can have fewer
literals than the maxterms
Standard forms are not unique!
Fall 2010 CS2102 Chih-Tsun Huang 35
Standard Forms (2/2)
Standard form examples f1 = xy + xy’z + x’yz (sop form)
f1’ = (x’ + y’)(x’ + y + z’)(x + y’ + z’) (pos form)
Nonstandard forms can have even fewer literals than standard forms xy + xy’z + xy’w = x(y + y’z + y’w) = x(y + y’(z + w))
xy + yz + zx = xy + (x + y)z = x(y + z) + yz = xz + y(x +z)
Fall 2010 CS2102 Chih-Tsun Huang 36
Logic Diagrams Two-level implementation
Multi-level implementation
Fall 2010 CS2102 Chih-Tsun Huang 37
Other Logic Operations
2n rows I the truth table of n binary variables
22nfunctions for n binary variables
16 functions of two variables
Fall 2010 CS2102 Chih-Tsun Huang 38
16 Boolean Functions of Two Variables
Fall 2010 CS2102 Chih-Tsun Huang 39
Digital Logic Gates (1/3)
Consider 16 functions Two functions are constants: 0 and 1
Four are unary (one-variable) functions Complement (inverter), transfer (buffer)
Inhibition and implication are neither commutative nor associative (seldom used in computer logic)
8 other binary functions AND, OR, NAND, NOR, XOR, Equivalence (XNOR),
inverter and buffer
Standard gates in digital logic systems
Fall 2010 CS2102 Chih-Tsun Huang 40
Digital Logic Gates (2/3)
Fall 2010 CS2102 Chih-Tsun Huang 41
Digital Logic Gates (3/3)
Fall 2010 CS2102 Chih-Tsun Huang 42
Extension to Multiple Inputs A gate can be extended to multiple inputs
Commutative and associative
OR: (x + y) + z = x + (y + z) = x + y + z
AND: (xy)z = x(yz) = xyz
NAND and NOR are commutative but not associative => not extendable
Fall 2010 CS2102 Chih-Tsun Huang 43
Multi-Input NOR and NAND Gates Multi-input NOR gate = complement of multi-input OR gate
Multi-input NAND gate = complement of multi-input AND gate
The cascaded NAND operations = sum of products
The cascaded NOR operations = product of sums
Fall 2010 CS2102 Chih-Tsun Huang 44
Multi-Input XOR and XNOR Gates The XOR and XNOR gates are commutative and associative
Two-input XOR gates are more common
XOR is an odd function: it is equal to 1 if the inputs variables have an odd number of 1's
Fall 2010 CS2102 Chih-Tsun Huang 45
Positive and Negative Logic
Two signal values two logic values
Positive logic: H = 1; L = 0
Negative logic: H = 0; L = 1
Fall 2010 CS2102 Chih-Tsun Huang 46
Integrated Circuits (IC) A device with multiple electrical components and
their interconnects manufactured on a single silicon substrate
Levels of integration Small-scale integration (SSI): <=10 gates Medium-scale integration (MSI): 10-100 gates Large-scale integration (LSI): hundreds-thousands gates Very large-scale integration (VLSI): > tens of thousands
gates Digital logic families: TTL: transistor-transistor logic ECL: emitter-coupled logic MOS: metal-oxide semiconductor CMOS: complementary MOS BiCMOS
Fall 2010 CS2102 Chih-Tsun Huang 47
Computer-Aided Design
Millions to billions of transistors Computer-based representation and aid Automate the design process Design entry Schematic capture Hardware description language (HDL)
Verilog, VHDL Synthesis Simulation, verification and testing Physical realization
ASIC: Application Specific IC FPGA: Field-Programmable Gate Array
Fall 2010 CS2102 Chih-Tsun Huang 48