Você está na página 1de 43

ECE2072/TRC2300 Digital Systems:

Combinational logic

based on textbook
Contemporary Logic Design, 2nd Edition
by R. H. Katz and G. Borriello
COMMONWEALTH OF AUSTRALIA
Copyright Regulations 1969
WARNING
This material has been reproduced and communicated to you by or on behalf of
Monash University pursuant to Part VB of the Copyright Act 1968 (the Act).
The material in this communication may be subject to copyright under the Act. Any
further reproduction or communication of this material by you may be the subject of
copyright protection under the Act.
Do not remove this notice.

II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

Combinational logic

Basic logic

Logic realization

two-level logic and canonical forms


incompletely specified functions

Simplification

Boolean algebra, proofs by re-writing, proofs by perfect induction


logic functions, truth tables, and switches
NOT, AND, OR, NAND, NOR, XOR, . . ., minimal set

uniting theorem
grouping of terms in Boolean functions

Alternate representations of Boolean functions

cubes
Karnaugh maps

II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

Combinational digital circuits (Sec 2.1 Katz 2e)

A simple model of a digital system is a unit with inputs and


outputs:
inputs

system

outputs

Combinational means "memory-less"

a digital circuit is combinational if its output values


only depend on its input values

II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

Possible logic functions of two variables

There are 16 possible functions of 2 input variables:

in general, there are 2**(2**n) functions of n inputs


X
Y

X
0
0
1
1

Y
0
1
0
1

0
0
0
0

0
X and Y

II - Combinational Logic

0
0
0
1

0
0
1
0
X

0
0
1
1

0
1
0
0
Y

F
16
0
1
0
1

possible functions (F0F15)


0 0 1 1 1 1
1 1 0 0 0 0
1 1 0 0 1 1
0 1 0 1 0 1

X xor Y
X or Y

X=Y
X nor Y
not (X or Y)

Copyright 2004, Gaetano Borriello and Randy H. Katz

not Y

1
1
0
0

1
1
0
1

1
1
1
0

1
1
1
1

1
X nand Y
not (X and Y)

not X

Combinational logic symbols

Common combinational logic systems have standard symbols called


logic gates

Buffer, NOT
A

AND, NAND
A
B

easy to implement
with CMOS transistors
(the switches we have
available and use most)

OR, NOR
A
B

II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

Minimal set of functions

We can implement any logic function using only AND, OR


and NOT operations
Similarly, we implement all logic functions from NAND,
NOR, and NOT operations

For example, implementing


X and Y
is the same as implementing not (X nand Y)

In fact, we can do it with only NOR or only NAND gates

NOT is just a NAND or a NOR with both inputs tied together


X
0
1

Y
0
1

X nor Y
1
0

X
0
1

Y
0
1

X nand Y
1
0

NAND and NOR are dual operations


eg. X nand Y not ((not X) nor (not Y))

NOT, NOR, and NAND are the cheapest gates to physically


implement (fewest transistors), and are therefore the functions
we use the most in practice

II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

Laws & Theorems of Boolean Logic (2.2 Katz 2e)

Boolean algebra consists of

a set of elements: B = {0, 1}


binary operations: {+ , }

and a unary operation { }:

+ is logical OR ie. A OR B A+B


is logical AND ie. A AND B AB
is logical NOT eg. NOT A A A

such that the following axioms hold:

1. the set B contains at least two elements: a, b


2. closure:
3. commutativity:
4. associativity:
5. identity:
6. distributivity:
7. complementarity:
II - Combinational Logic

a + b is in B
a+b=b+a
a + (b + c) = (a + b) + c
a+0=a
a + (b c) = (a + b) (a + c)
a + a = 1

a b is in B
ab=ba
a (b c) = (a b) c
a1=a
a (b + c) = (a b) + (a c)
a a = 0

Copyright 2004, Gaetano Borriello and Randy H. Katz

Logic functions and Boolean algebra

Any logic function that can be expressed as a truth table can


be written as an expression in Boolean algebra using the
operators: , +, and
X
0
0
1
1

Y
0
1
0
1

XY
0
0
0
1

X
0
0
1
1

Y
0
1
0
1

X
1
1
0
0

X
0
0
1
1

Y
1
0
1
0

XY
0
0
0
1

X Y
1
0
0
0

X, Y are Boolean algebra variables


II - Combinational Logic

Y
0
1
0
1

X
1
1
0
0

X Y
0
1
0
0

( X Y ) + ( X Y )
1
0
( X Y ) + ( X Y )
0
1

X=Y

Boolean expression that is


true when the variables X
and Y have the same value
and false, otherwise

Copyright 2004, Gaetano Borriello and Randy H. Katz

Axioms and theorems of Boolean algebra:


Duality

A dual of a Boolean expression is derived by replacing


by +, + by , 0 by 1, and 1 by 0, and leaving variables
unchanged.
Any theorem that can be proven is thus also proven for its dual
(the dual theory of duality is itself)!
duality:
X + Y + ... + 0 X Y ... 1
generalized duality:
f (X1,X2,...,Xn,0,1,+,) f(X1,X2,...,Xn,1,0,,+)
An expression and its dual are not equal:

Duality is a statement about theorems (a meta-theorem)


this is not a way to manipulate (re-write) expressions

II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

Axioms and theorems of Boolean algebra

identity
1. X + 0 = X
null
2. X + 1 = 1
idempotency:
3. X + X = X
involution:
4. (X) = X
complementarity:
5. X + X = 1
commutativity:
6. X + Y = Y + X
associativity:
7. (X + Y) + Z = X + (Y + Z)

II - Combinational Logic

1D. X 1 = X
2D. X 0 = 0
3D. X X = X

5D. X X = 0
6D. X Y = Y X
7D. (X Y) Z = X (Y Z)

Copyright 2004, Gaetano Borriello and Randy H. Katz

10

Axioms and theorems of Boolean algebra (contd)

distributivity:
8. X (Y + Z) = (X Y) + (X Z)
uniting:
9. X Y + X Y = X
absorption:
10. X + X Y = X
11. (X + Y) Y = X Y
factoring:
12. (X + Y) (X + Z) =
X Z + X Y
consensus:
13. (X Y) + (Y Z) + (X Z) =
X Y + X Z

II - Combinational Logic

8D. X + (Y Z) = (X + Y) (X + Z)
9D. (X + Y) (X + Y) = X
10D. X (X + Y) = X
11D. (X Y) + Y = X + Y
12D. X Y + X Z =
(X + Z) (X + Y)
13D. (X + Y) (Y + Z) (X + Z) =
(X + Y) (X + Z)

Copyright 2004, Gaetano Borriello and Randy H. Katz

11

Axioms and theorems of Boolean algebra:


De Morgans Law

De Morgans law establishes relationship between and +


X+Y = XY
The above expression also has a dual
XY = X+Y
generalized de Morgans:
f(X1,X2,...,Xn,0,1,+,) = f(X1,X2,...,Xn,1,0,,+)
De Morgans law can be used to find the compliment of a
function:

eg. find the compliment of: Z = A B + C D

Z = AB + CD
= (AB)(CD)
= (A+B)(C+D)
II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

12

Proving theorems (perfect induction)

Using perfect induction (complete truth table):

e.g., prove de Morgans law:

(X + Y) = X Y
NOR is equivalent to AND
with inputs complemented (see slide 6)

X
0
0
1
1

Y
0
1
0
1

X
1
1
0
0

Y
1
0
1
0

(X + Y)
1
0
0
0

X Y
1
0
0
0

(X Y) = X + Y
NAND is equivalent to OR
with inputs complemented (see slide 6)

X
0
0
1
1

Y
0
1
0
1

X
1
1
0
0

Y
1
0
1
0

(X Y)
1
1
1
0

X + Y
1
1
1
0

II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

13

Proving theorems (rewriting)

Using the axioms of Boolean algebra:

e.g., prove uniting:


distributivity (8)
complementarity (5)
identity (1D)

X Y + X Y = X
X Y + X Y
X (Y + Y)
X (1)

e.g., prove absorption:


identity (1D)
distributivity (8)
identity (2)
identity (1D)

II - Combinational Logic

X
X
X
X

= X (Y + Y)
= X (1)
= X9

X+XY

= X

+ XY
1 + XY
(1 + Y)
(1)

=
=
=
=

Copyright 2004, Gaetano Borriello and Randy H. Katz

X
X
X
X

1 + XY
(1 + Y)
(1)
9

14

Activity

Prove the following using the laws of Boolean algebra:

(X Y) + (Y Z) + (X Z) = X Y + X Z
(X Y) + (Y Z) + (X Z)
identity

(X Y) + (1) (Y Z) + (X Z)

complementarity

(X Y) + (X + X) (Y Z) + (X Z)

distributivity

(X Y) + (X Y Z) + (X Y Z) + (X Z)

commutativity

(X Y) + (X Y Z) + (X Y Z) + (X Z)

factoring

(X Y) (1 + Z) + (X Z) (1 + Y)

null

(X Y) (1) + (X Z) (1)

identity

(X Y) + (X Z) 9

II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

15

Realising Boolean Formulas: From Boolean


expressions to logic gates (Sec 2.3 Katz Ed2))

NOT X

~X

X
0
1

Y
Z

AND X Y

OR

X+Y

II - Combinational Logic

XY

XY

XY

Y
1
0

X
Y

X
0
0
1
1

Y
0
1
0
1

Z
0
0
0
1

X
Y

X
0
0
1
1

Y
0
1
0
1

Z
0
1
1
1

Copyright 2004, Gaetano Borriello and Randy H. Katz

16

From Boolean expressions to logic gates (contd)

NAND

NOR

X
Y

X
Y

XOR
XY

XNOR
X=Y

II - Combinational Logic

X
Y

X
Y

X
0
0
1
1

Y
0
1
0
1

Z
1
1
1
0

X
0
0
1
1

Y
0
1
0
1

Z
1
0
0
0

X
0
0
1
1

Y
0
1
0
1

Z
0
1
1
0

X xor Y = X Y + X Y
X or Y but not both
("inequality", "difference")

X
0
0
1
1

Y
0
1
0
1

Z
1
0
0
1

X xnor Y = X Y + X Y
X and Y are the same
("equality", "coincidence")

Copyright 2004, Gaetano Borriello and Randy H. Katz

17

From Boolean expressions to logic gates (contd)


Z = A B (C + D) = (A (B (C + D)))
T2
T1
use of 3-input gate
A

B
C
D

T1
T2

A
B

C
D

Note: there is usually more than one way to map expressions


to gates!

II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

18

Waveform view of logic functions

Just a sideways truth table

but note how edges dont line up exactly


it takes time for a gate to switch its output!
time

change in Y takes time to "propagate" through gates


II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

19

Implementing Boolean functions (Sec 2.4 Katz


Ed2)

Technology independent

canonical forms
two-level forms
multi-level forms

Technology choices

packages of a few gates


regular logic
two-level programmable logic
multi-level programmable logic

II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

20

Canonical forms

Truth table is the unique signature of a Boolean function


The same truth table can have many gate realizations
Canonical forms

are unique for any function (deterministic)


standard forms for a Boolean expression

Two canonical forms:

Sum-of-Products
Product-of-Sums

II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

21

Sum-of-products canonical forms

Also known as disjunctive normal form


Also known as minterm expansion
F = 001

011

101

110

111

F = ABC + ABC + ABC + ABC + ABC


A
0
0
0
0
1
1
1
1

B
0
0
1
1
0
0
1
1

C
0
1
0
1
0
1
0
1

II - Combinational Logic

F
0
1
0
1
0
1
1
1

F
1
0
1
0
1
0
0
0

F = ABC + ABC + ABC

Copyright 2004, Gaetano Borriello and Randy H. Katz

22

Sum-of-products canonical form (contd)

Product term (or minterm)

A
0
0
0
0
1
1
1
1

ANDed product of literals input combination for which output is true


each variable appears exactly once, true or inverted (but not both)
B
0
0
1
1
0
0
1
1

C
0
1
0
1
0
1
0
1

minterms
ABC m0
ABC m1
ABC m2
ABC m3
ABC m4
ABC m5
ABC m6
ABC
m7

short-hand notation for


minterms of 3 variables
II - Combinational Logic

F in canonical form:
F(A, B, C) = m(1,3,5,6,7)
= m1 + m3 + m5 + m6 + m7
= ABC + ABC + ABC + ABC + ABC
canonical form minimal form
F(A, B, C) = ABC + ABC + ABC + ABC + ABC
= (AB + AB + AB + AB)C + ABC
= ((A + A)(B + B))C + ABC
= C + ABC
= ABC + C
= AB + C

Copyright 2004, Gaetano Borriello and Randy H. Katz

23

Product-of-sums canonical form

Also known as conjunctive normal form


Also known as maxterm expansion
F=
000
010
100
F = (A + B + C) (A + B + C) (A + B + C)
A
0
0
0
0
1
1
1
1

B
0
0
1
1
0
0
1
1

C
0
1
0
1
0
1
0
1

F
0
1
0
1
0
1
1
1

F
1
0
1
0
1
0
0
0

F = (A + B + C) (A + B + C) (A + B + C) (A + B + C) (A + B + C)
II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

24

Product-of-sums canonical form (contd)

Sum term (or maxterm)

A
0
0
0
0
1
1
1
1

B
0
0
1
1
0
0
1
1

ORed sum of literals input combination for which output is false


each variable appears exactly once, true or inverted (but not both)
C
0
1
0
1
0
1
0
1

maxterms
A+B+C
A+B+C
A+B+C
A+B+C
A+B+C
A+B+C
A+B+C
A+B+C

M0
M1
M2
M3
M4
M5
M6
M7

F in canonical form:
F(A, B, C) = M(0,2,4)
= M0 M2 M4
= (A + B + C) (A + B + C) (A + B + C)
canonical form minimal form
F(A, B, C) = (A + B + C) (A + B + C) (A + B + C)
= (A + B + C) (A + B + C)
(A + B + C) (A + B + C)
= (A + C) (B + C)

short-hand notation for


maxterms of 3 variables
II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

25

Mapping between canonical forms:


S-o-P, P-o-S, and de Morgans theorem

Sum-of-products

Apply de Morgans

(F) = (ABC + ABC + ABC)


F = (A + B + C) (A + B + C) (A + B + C)

Product-of-sums

F = ABC + ABC + ABC

F = (A + B + C) (A + B + C) (A + B + C) (A + B + C) (A + B + C)

Apply de Morgans

(F) = ( (A + B + C)(A + B + C)(A + B + C)(A + B + C)(A + B + C) )


F = ABC + ABC + ABC + ABC + ABC

II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

26

Four alternative two-level implementations


of F = AB + C
A

canonical sum-of-products

B
F1
C

minimized sum-of-products
F2

canonical product-of-sums
F3

minimized product-of-sums
F4

II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

27

Waveforms for the four alternatives

Waveforms are essentially identical

except for timing hazards (glitches)


delays almost identical (modeled as a delay per level, not type of
gate or number of inputs to gate)

II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

28

Incompletely specified functions

Example: binary coded decimal increment by 1

A
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1

BCD digits encode the decimal digits 0 9


in the bit patterns 0000 1001
B
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1

C
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1

II - Combinational Logic

D
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1

W
0
0
0
0
0
0
0
1
1
0
X
X
X
X
X
X

X
0
0
0
1
1
1
1
0
0
0
X
X
X
X
X
X

Y
0
1
1
0
0
1
1
0
0
0
X
X
X
X
X
X

Z
1
0
1
0
1
0
1
0
1
0
X
X
X
X
X
X

off-set of W
on-set of W
dont care (DC) set of W

these inputs patterns should


never be encountered in practice
"dont care" about associated
output values, can be exploited
in minimization

Copyright 2004, Gaetano Borriello and Randy H. Katz

29

Notation for incompletely specified functions

Dont cares and canonical forms

so far, only represented on-set


also represent dont-care-set
need two of the three sets (on-set, off-set, dc-set)

Canonical representations of the BCD increment by 1 function:

Z = m0 + m2 + m4 + m6 + m8 + d10 + d11 + d12 + d13 + d14 + d15


Z = [ m(0,2,4,6,8) + d(10,11,12,13,14,15) ]
Z = M1 M3 M5 M7 M9 D10 D11 D12 D13 D14 D15
Z = [ M(1,3,5,7,9) D(10,11,12,13,14,15) ]

II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

30

The uniting theorem

Key tool to simplification: A B + A B = A (B + B) = A1 = A


Essence of simplification of two-level logic

find two element subsets of the ON-set where only one variable
changes its value this single varying variable can be eliminated
and a single product term used to represent both elements
F = AB+AB = (A+A)B = B
A

II - Combinational Logic

B has the same value in both on-set rows


B remains

A has a different value in the two rows


A is eliminated

Copyright 2004, Gaetano Borriello and Randy H. Katz

31

Karnaugh maps

Alternative to truth-tables to help visualize adjacencies

guide to applying the uniting theorem


on-set elements with only one variable changing value are
adjacent unlike the situation in a linear truth-table

A
0
1

0
0
1

1
0

2
3

B
II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

32

Karnaugh maps (contd)

Numbering scheme based on Graycode

e.g., 00, 01, 11, 10


only a single bit changes in code for adjacent map cells
AB
0

C 1

00

11

01

10

B
A
0

2
3

II - Combinational Logic

6
7

12

13

15

11

14

10

Copyright 2004, Gaetano Borriello and Randy H. Katz

13 = 1101= ABCD

33

Adjacencies in Karnaugh maps

Wrap from first to last column


Wrap top row to bottom row

A
000 010 110 100

C 001 011 111 101


B

II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

34

A simple example: 1-bit binary adder


Cout Cin

Inputs: A, B, Carry-in
Outputs: Sum, Carry-out

A
0
0
0
0
1
1
1
1

B
0
0
1
1
0
0
1
1

Cin Cout S
0
0
0
1
0
1
0
0
1
1
1
0
0
0
1
1
1
0
0
1
0
1
1
1

II - Combinational Logic

A
B

A
B

A
B

A
B

A
B

A
B
Cin

S
Cout

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

Copyright 2004, Gaetano Borriello and Randy H. Katz

35

Apply the theorems to simplify expressions

The theorems of Boolean algebra can simplify Boolean


expressions

e.g., full adders carry-out function (same rules apply to any function)

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
(A + A) B Cin + A B Cin + A B Cin + A B Cin
(1) B Cin + A B Cin + A B Cin + A B Cin
B Cin + A B Cin + A B Cin + A B Cin + A B Cin
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
B Cin + A Cin + A B (Cin + Cin)
B Cin + A Cin + A B (1)
B Cin + A Cin + A B

There must be an easier way!

II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

36

Karnaugh map examples

F=
1

Cout =

f(A,B,C) = m(0,4,5,7)

A
0

Cin 0

II - Combinational Logic

AB + ACin + BCin

AC + BC + AB

Copyright 2004, Gaetano Borriello and Randy H. Katz

obtain the
complement
of the function
by covering 0s
with subcubes
37

More Karnaugh map examples


A

G(A,B,C) = A

B
A

F(A,B,C) = m(0,4,5,7) = AC + BC

B
A

F' simply replace 1's with 0's and vice versa


F'(A,B,C) = m(1,2,3,6)= BC + AC

II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

38

Karnaugh map: 4-variable example

F(A,B,C,D) = m(0,2,3,5,6,7,8,10,11,14,15)
F = C + ABD + BD
A

II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

39

Karnaugh maps: dont cares

f(A,B,C,D) = m(1,3,5,7,9) + d(6,12,13)

without don't cares

f = AD + BCD

II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

40

Karnaugh maps: dont cares (contd)

f(A,B,C,D) = m(1,3,5,7,9) + d(6,12,13)

f = A'D + B'C'D
f = A'D + C'D

without don't cares


with don't cares

A
0

C
0

II - Combinational Logic

by using don't care as a "1"


a 2-cube can be formed
rather than a 1-cube to cover
this node
don't cares can be treated as
1s or 0s
depending on which is more
advantageous

Copyright 2004, Gaetano Borriello and Randy H. Katz

41

Activity

Minimize the function F = m(0, 2, 7, 8, 14, 15) + d(3, 6, 9, 12, 13)


A
A

F = AC +
AC +
BC +
AB +
ABD +
BCD

F = BC + ABD + BCD

F = AC + AB + BCD

B
II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

42

Combinational logic summary

Logic functions, truth tables, and switches

Axioms and theorems of Boolean algebra

two-level and incompletely specified functions

Simplification

networks of Boolean functions and their time behavior

Canonical forms

proofs by re-writing and perfect induction

Gate logic

NOT, AND, OR, NAND, NOR, XOR, . . ., minimal set

a start at understanding two-level simplification

Later

automation of simplification
multi-level logic
time behavior
hardware description languages
design case studies

II - Combinational Logic

Copyright 2004, Gaetano Borriello and Randy H. Katz

43

Você também pode gostar