You are on page 1of 50

ECE 20B, Winter 2004

Introduction to Electrical Engineering, II LECTURE NOTES #2


Instructor: Email: Telephone: Office: Andrew B. Kahng (lecture) abk@ucsd.edu 858-822-4884 office 3802 AP&M

Class Website: http://vlsicad.ucsd.edu/courses/ece20b/wi04/

Goals for Lecture


Binary logic and gates Boolean Algebra Canonical forms for function representation Function simplification Examples Corresponds to MK, 2.1-2.4 (some 2.5)

ECE 20B, Winter 2004

Binary Logic and Gates (MK 2.1)


Binary variables take on one of two values. Logical operators operate on binary values and binary variables. Basic logical operators are the logic functions AND, OR and NOT. Logic gates implement logic functions. Boolean Algebra: a useful mathematical system for specifying and transforming logical functions. We study Boolean Algebra as foundation for designing digital systems.
ECE 20B, Winter 2004

Binary Variables
The two binary values have different names:
True/False On/Off Yes/No 1/0

We will use 1 and 0 to denote the two values. Variable identifiers:


A, B, y, or z for now RESET, START_IT, or ADD1 later

ECE 20B, Winter 2004

Logical Operations
The three basic logical operations are:
AND OR NOT

AND is denoted by a dot (). OR is denoted by a plus (+). NOT is denoted by a bar ( ) over, a single quote mark (') after, or ~ before the variable.
ECE 20B, Winter 2004

Notation Examples
Examples:
Y = A B is read Y is equal to A and B. z = x + y is read z is equal to x OR y. X = A is read X is equal to NOT A.

Note: The statement:


1 + 1 = 2 (read one plus one is equal to two)

is not the same as


1 + 1 = 1 (read 1 or 1 is equal to 1).
6

ECE 20B, Winter 2004

Operator Definitions
Operations are defined on the values "0" and "1" for each Operator: AND OR NOT

00=0 01=0 10=0 11=1

0+0=0 0+1=1 1+0=1 1+1=1

0=1 1=0

ECE 20B, Winter 2004

Truth Tables
Truth tables list the output value of a function for all possible input values Truth tables for basic logic operations: AND Y Z = XY 0 0 1 0 0 0 1 1 OR Z = X+Y 0 1 1 1 NOT X 0 1

X 0 0 1 1

X 0 0 1 1

Y 0 1 0 1

Z=X
1 0

ECE 20B, Winter 2004

Logic Function Implementation


Using Switches
For inputs:
logic 1 is switch closed logic 0 is switch open
Switches in parallel => OR

For outputs:
logic 1 is light on logic 0 is light off.

Switches in series => AND

For NOT, a switch such that for inputs:


logic 1 is switch open logic 0 is switch closed
ECE 20B, Winter 2004

Logic Gates
In the earliest computers, switches were opened and closed by energizing coils to produce magnetic fields. The switches in turn opened and closed current paths. Later, vacuum tubes that open and close current paths replaced the relays. Today, transistors are used as electronic switches that open and close current paths.
ECE 20B, Winter 2004

10

Logic Gates (continued)


Implementation of logic functions with transistors (See text website Supplement A2-8)
logic 1 +V F using p-type transistors From G1 +V +V


X .Y

+V

X X

X1 X2 Xn

G = X +Y

F using n-type transistors logic 0

X Y


From G2 (b) NOR

(a) General structure

(c) NAND

(d) NOT

Transistor or tube based implementations of logic functions are called logic gates or just gates
ECE 20B, Winter 2004

11

Logic Gate Symbols and Behavior


Logic gates have special symbols:

And waveform behavior in time as follows:

ECE 20B, Winter 2004

12

Logic Diagrams and Expressions


Truth Table
XYZ 000 001 010 011 100 101 110 111 0 1 0 0 1 1 1 1 F = X + Y Z

Logic Diagram
X

Y Z

Expression

F= X + YZ

Boolean expressions, truth tables and logic diagrams describe the same function! Truth tables are unique; expressions and logic diagrams are not. This gives flexibility in implementing functions.
ECE 20B, Winter 2004

13

Boolean Algebra (MK 2.2)


An algebraic structure defined on a set of at least two elements, B, together with two binary operators (denoted + and ) that satisfies the following identities: Closure of B with respect to +, (see slide 6) Identity elements 0 and 1 such that: 1. X + 0 = X 2. X 1 = X 3. X + 1 = 1 4. X 0 = 0 5. X + X = X 6. XX = X For each element X, an element X (inverse) s.t.: 7. X + X = 1 8. X X = 0 9. X = X
ECE 20B, Winter 2004

14

Boolean Algebra (cont.)


11. XY = YX 13. X(YZ) = (XY)Z 15. X + YZ = (X + Y)(X + Z) 17. X + Y = X Y The identities are organized into dual pairs. These pairs have names as follows: 1-4 Existence of 0 and 1 5-6 Idempotence 7-8 Existence of complement 9 Involution 10-11 Commutative Laws 12-13 Associative Laws 14-15 Distributive Laws 16-17 DeMorgans Laws If the meaning is unambiguous, we leave out the symbol
ECE 20B, Winter 2004

10. X + Y = Y + X 12. X + (Y + Z) = (X + Y) + Z 14. X(Y + Z) = XY + XZ 16. XY = X + Y

15

Duality
The dual of an algebraic expression is obtained by interchanging + and and interchanging 0s and 1s. The identities appear in dual pairs. When there is only one identity on a line the identity is selfdual, i. e., the dual expression = the original expression. Unless it happens to be self-dual, the dual of an expression does not equal the expression itself.

ECE 20B, Winter 2004

16

Boolean Algebraic Proofs - Example 1


X + XY = X (Absorption Theorem)

Proof Steps Justification (identity or theorem) X + XY = X1 + XY (identity 2) = X(Y + Y) + XY (identity 7) = XY + XY + XY (identity 14) = XY + XY (identity 5, applied to XY) = X(Y + Y) (identity 14) = X1 = X (identity 5, identity 2)
ECE 20B, Winter 2004

17

Boolean Algebraic Proofs - Example 2


XY + XZ + YZ = XY + XZ (Consensus Theorem)

Proof Steps Justification (identity or theorem) YZ = YZ(X + X) (identity 2, identity 7) = XYZ + XYZ (identity 14) XY + XZ + XYZ + XYZ = XY(1 + Z) + XZ(1 + Y) (identity 2, identity 7) = XY + XZ (identity 3, identity 2)

ECE 20B, Winter 2004

18

Boolean Operator Precedence


The order of evaluation in Boolean Expressions is:

Parentheses
NOT AND OR Because AND takes precedence over OR, parentheses must be placed around the OR operator more frequently.
ECE 20B, Winter 2004

19

Useful Theorems
x y + x y = y (x + y ) (x + y ) = y x + xy = x x (x + y ) = x x + x y = x + y x (x + y ) = x y Minimization Absorption Simplification

(x + y ) (x + z ) (y + z ) = (x + y ) (x + z )
x + y = xy xy = x + y

xy + xz + yz = xy + xz

Consensus

DeMorgan' s Laws

Exercise: Prove DeMorgans Laws

ECE 20B, Winter 2004

20

Boolean Function Evaluation


F1 = xy z F2 = x + yz F3 = x y z + x y z + x y F4 = x y + x z
x 0 0 0 0 1 1 1 1 y 0 0 1 1 0 0 1 1 z F1 0 0 1 0 0 0 1 0 0 0 1 0 0 1 1 0 F2 0 1 0 0 1 1 1 1 F3 F4

ECE 20B, Winter 2004

21

Expression Simplification
Simplify to contain the smallest number of literals (complemented and uncomplemented variables):

A B + ACD + A BD + AC D + A BCD =
= AB + AC + ABD = AB + A(C + BD) or = AB + AC + BCD = AC + B(A + CD)

ECE 20B, Winter 2004

22

Complementing Functions
Use DeMorgan's Theorem to complement a function:
1. Interchange AND and OR operators 2. Complement each literal

Example: Complement

xy z + x yz

ECE 20B, Winter 2004

23

Canonical Forms (MK 2.3)


It is useful to specify Boolean functions in a form that:
Allows comparison for equality. Has a correspondence the truth tables

Canonical forms:
Sum of Minterms (SOM) or Sum of Products (SOP) Product of Maxterms (POM) or Product of Sums (POS)
ECE 20B, Winter 2004

24

Minterms
Minterms are AND terms with every variable in true or complemented form. Each binary variable may appear in uncomplemented (e.g., x) or complemented (e.g., x) form there are 2n minterms for n variables. EXAMPLE: Two variables, combined with an AND operator, X Y have 2*2 or 4 combinations:

XY (both normal) X Y (X normal, Y complemented) XY (X complemented, Y normal) X Y (both complemented)


There are four minterms of two variables.
25

ECE 20B, Winter 2004

Maxterms
Maxterms are OR terms with every variable in true or complemented form. Each binary variable may appear in uncomplemented (e.g., x) or complemented (e.g., x) form there are 2n maxterms for n variables. Two variables, combined with an OR operator, X + Y, have 2*2 or 4 combinations: X + Y (both normal) X + Y (x normal, y complemented) X + Y (x complemented, y normal) X + Y (both complemented)
ECE 20B, Winter 2004

26

Maxterms and Minterms


Examples: Two variable minterms and maxterms.
Index Maxterm Minterm 0 x + y x y 1 x + y x y 2 x y x + y 3 x y x +y The index above is important for describing which variables in the terms are true and which are complemented.
ECE 20B, Winter 2004

27

Standard Order
Minterms and maxterms are designated with a subscript The subscript is a number, corresponding to a binary pattern The bits in the pattern represent the complemented or normal state of EVERY variable, listed in a STANDARD order. All variables will be present in a minterm or maxterm and will be listed in the same order (usually alphabetically) Example: For variables a, b, c: Maxterms: (a + b +c), (a + b + c) Minterms: a bc, a b c, ab c Terms: (b + a + c), ac b, and (c + b + a) are NOT in standard order. Terms: (a + c), b c, and (a + b) do not contain all ECE 20B, Wintervariables 2004

28

Purpose of the Index


The index for the minterm or maxterm, expressed as a binary number, is used to determine whether each variable occurs in true form or complemented form. For Minterms:
1 means the variable is Not Complemented and 0 means the variable is Complemented.

For Maxterms:
0 means the variable is Not Complemented and 1 means the variable is Complemented.
29

ECE 20B, Winter 2004

Index Example in Three Variables


Example: (for three variables) Assume the variables are called X, Y, and Z.

the standard order is X, then Y, then Z.

The Index 0 (base 10) = 000 (base 2 to three digits) so all three variables are complemented for minterm 0 ( X , Y, Z) and no variables are complemented for Maxterm 0 (X,Y,Z)
Minterm 0, called m0 is X Y Z . Maxterm 0, called M0 is (X + Y + Z).

ECE 20B, Winter 2004

30

Four Variables Index Examples


Index i 0 1 3 5 7 10 13 15
ECE 20B, Winter 2004

Binary Minterm Maxterm Mi Pattern mi abcd a + b + c + d 0000 abcd a + b + c + d 0001 abcd a + b + c + d 0011 abcd a + b + c + d 0101 abcd a + b + c + d 0111 1010 abcd a + b + c + d 1101 abcd a + b + c + d abcd a + b + c + d 1111
31

Minterm and Maxterm Relationship


DeMorgan's Theorem: x y = x + y and x + y = x y Two-variable example: M 2 = x + y and m 2 = xy Thus M2 is the complement of m2 and vice-versa. Since DeMorgan's Theorem holds for n variables, the above holds for terms of n variables giving: M i = m i and m i = M i Thus Mi is the complement of mi.

ECE 20B, Winter 2004

32

Function Tables for Both


Minterms of 2 variables
xy 00 01 10 11 m0 1 0 0 0 m1 m2 m3 0 0 0 1 0 0 0 1 0 0 0 1

Maxterms of 2 variables
x y M0 00 0 01 1 10 1 11 1 M1 1 0 1 1 M2 1 1 0 1 M3 1 1 1 0

Each column in the maxterm function table is the complement of the column in the minterm function table since Mi is the complement of mi.
ECE 20B, Winter 2004

33

Observations
In the function tables:
Each minterm has one and only one 1 present in the 2n terms (a minimum of ones). All other entries are 0. Each maxterm has one and only one 0 present in the 2n terms All other entries are 1 (a maximum of ones).

We can implement any function by "ORing" the minterms corresponding to a "1" in the function table. We can implement any function by "ANDing" the maxterms corresponding to a "0" in the function table. This gives us two canonical forms: Sum of Minterms (SOM), and Product of Maxterms (POM) for stating any Boolean function.
ECE 20B, Winter 2004

34

Minterm Function Example


Example: Find F1 = m1 + m4 + m7 F1 = xy z + x y z + x y z
x y z index m1 000 0 0 001 1 1 010 2 0 011 3 0 100 4 0 101 5 0 110 6 0 111 7 0
ECE 20B, Winter 2004

+ + + + + + + + +

m4 0 0 0 0 1 0 0 0

+ m7 = F1 + 0 =0 + 0 =1 + 0 =0 + 0 =0 + 0 =1 + 0 =0 + 0 =0 + 1 =1
35

Minterm Function Example


F(A, B, C, D, E) = m2 + m9 + m17 + m23

ECE 20B, Winter 2004

36

Maxterm Function Example


Example: Implement F1 in maxterms: F1 = M0 M2 M3 M5 M6 F1 = (x + y + z) (x + y + z)(x + y + z ) ( x + y + z )( x + y + z)
xyz 000 001 010 011 100 101 110 111
ECE 20B, Winter 2004

i 0 1 2 3 4 5 6 7

M0 M2 M3 M5 M6 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1

= F1 =0 =1 =0 =0 =1 =0 =0 =1

37

Maxterm Function Example


F( A , B, C, D ) = M 3 M 8 M11 M14

ECE 20B, Winter 2004

38

Canonical Sum of Minterms


Any Boolean Function can be expressed as a Sum of Minterms.
For the function table, the minterms used are the terms corresponding to the 1's For expressions, expand all terms first to explicitly list all minterms. Do this by ANDing any term missing a variable v with a term (v + v).

Example: Implement f = x + x y as a sum of minterms. First expand terms: f = x ( y + y ) + x y Then distribute terms: f = xy + x y + x y
Express as sum of minterms: f = m3+m2+m0
ECE 20B, Winter 2004

39

Another SOM Example


Example: F = A + B C There are three variables, A, B, and C which we take to be the standard order. Expanding the terms with missing variables:

Collect terms (removing all but one of duplicate terms): Express as SOM:
ECE 20B, Winter 2004

40

Shorthand SOM Form


From the previous example, we started with:
F=A+BC We ended up with: F = m1+m4+m5+m6+m7 This can be denoted in the formal shorthand: F( A , B, C) = m(1,4,5,6,7 ) (We explicitly show the standard variables in order and drop the m designators.)

ECE 20B, Winter 2004

41

Canonical Product of Maxterms


Any Boolean Function can be expressed as a Product of Maxterms (POM).
For the function table, the maxterms used are the terms corresponding to the 0's. For an expression, expand all terms first to explicitly list all maxterms. Do this by first applying the second distributive law , ORing terms missing variable v with a term equal to and then applying the distributive law again.

vv

Example: Convert to product of maxterms:


First apply the distributive law: Add missing variable z:

f ( x, y , z ) = x + x y x + x y = (x + x )(x + y ) = 1 (x + y ) = x + y
x + y + z z = ( z + y + z )(x + y + z )

Express as POM: f = M2M3


ECE 20B, Winter 2004

42

Complements and Conversion


To complement a function expressed as SOm (or, POM), just select the missing minterms (Maxterms) Or, the complement of the SOm (POM) function is given by the POM (SOm) with the same indices. To convert SOM SOP, find the missing indices, and then use the other form Example: F(x,y,z) = m(1,3,5,7) F(x,y,z) = m(0,2,4,6) F(x,y,z) = M(1,3,5,7) F(x,y,z) = M(0,2,4,6)
ECE 20B, Winter 2004

43

Standard Sum-of-Products (SOP)


A Sum of Minterms form for n variables can be written down directly from a truth table.
Implementation of this form is a two-level network of gates such that: The first level consists of n-input AND gates, and The second level is a single OR gate (with fewer than 2n inputs).

This form:
is usually not a minimum literal expression, and leads to a more expensive implementation (in terms of two levels of AND and OR gates) than needed.
ECE 20B, Winter 2004

44

Standard Sum-of-Products (SOP)


Try to combine terms to get a lower literal cost expression less expensive implementation. Example: F( A , B, C) = m(1,4,5,6,7 )

ECE 20B, Winter 2004

45

SOP

AND/OR Two-level Implementation

Which implementation is simpler?


A B C A B C A B C A B C A B C
ECE 20B, Winter 2004

A B C

46

Standard Product-of-Sums (POS)


A Product of Maxterms form for n variables can be written down directly from a truth table.
Implementation of this form is a two-level network of gates such that: The first level consists of n-input OR gates, and The second level is a single AND gate (with fewer than 2n inputs).

This form:
is usually not a minimum literal expression, and leads to a more expensive implementation (in terms of two levels of AND and OR gates) than needed.
ECE 20B, Winter 2004

47

Standard Product-of-Sums (POS)


Try to combine terms to get a lower literal cost expression less expensive implementation. Example: F( A , B, C) = M ( 0, 2, 3)

ECE 20B, Winter 2004

48

OR/AND Two-level Implementation


Which implementation is simpler?
A B C A B C A B C

A C A B

ECE 20B, Winter 2004

49

Cost of Implementation
Canonical SOP, POS representations can differ in literal cost
Boolean algebra: manipulate equations into simpler forms reduces the (two-level) implementation cost

Is there only one minimum-cost circuit? Is there a systematic procedure to obtain a minimum-cost circuit?

ECE 20B, Winter 2004

50

You might also like