CS/EE 3700 : Fundamentals of Digital System Design Chris J. Myers Lecture 4: Logic Optimization Chapter 4
Motivation Algebraic manipulation is not systematic. This chapter presents methods that can be automated in CAD tools. Although tools used for logic optimization, designers must understand the process.
Figure 4.1 The function f = m(0, 2, 4, 5, 6)
x 2 (a) Truth table(b) Karnaugh map m 0 m 2 m 3 m 1 x 1 x m 0 m 1 m 3 m 2 x 1 Figure 4.2 Location of two-variable minterms
Figure 2.15 A function to be synthesized
Figure 4.4 Location of three-variable minterms x 1 x 2 x (b) Karnaugh map x 2 x m 0 m 1 m 3 m m 4 m 5 m 7 m 6 x 1 (a) Truth table m 0 m 1 m 3 m 2 m 6 m 7 m 4 m 5
Figure 4.6 A four-variable Karnaugh map x 1 x 2 x 3 x x 2 x 4 x 1 x 3 m 0 m 1 m 5 m 4 m 12 m 13 m 8 m 9 m 3 m 2 m 6 m 7 m 15 m 14 m 11 m 10
x 1 x 2 x 3 x
x 1 x 2 x 3 x
x 1 x 2 x 3 x
x 1 x 2 x 3 x
Figure 4.8 A five-variable Karnaugh map x 1 x 2 x 3 x x 5 1= x 1 x 2 x 3 x x 5 0=
Terminology A variable either uncomplemented our complemented is called a literal. A product term that indicates when a function is equal to 1 is called an implicant. An implicant that cannot have any literal deleted and still be a valid implicant is called a prime implicant.
Figure 4.9 Three-variable function f = m(0, 1, 2, 3, 7) x 1 x 2 x
Terminology (cont) A collection of implicants that accounts for all input combinations in which a function evaluates to 1 is called a cover. An essential prime implicant includes a minterm covered by no other prime. Cost is number of gates plus number of gate inputs. Assume primary inputs available in both true and complemented form.
Minimization Procedure Generate all prime implicants. Find all essential prime implicants. If essential primes do not form a cover, then select minimal set of non-essential primes.
Figure 4.10 Four-variable function f = m(2, 3, 5, 6, 7, 10, 11, 13, 14) x 1 x 2 x 3 x
Figure 4.11 The function f = m(0, 4, 8, 10, 11, 12, 13, 15) x 1 x 2 x 3 x
Figure 4.12 The function f = m(0, 2, 4, 5, 10, 11, 13, 15) x 1 x 2 x 3 x
Minimization of POS Forms Find a cover of the 0’s and form maxterms. x 1 x 2 x
Figure 4.14 POS minimization of f = M(0, 1, 4, 8, 9, 12, 15) x 1 x 2 x 3 x
Incompletely Specified Functions Often certain input conditions cannot occur. Impossible inputs are called don’t cares. A function with don’t cares is called an incompletely specified function. Don’t cares can be used to improve the quality of the logic designed.
Figure 4.15 Two implementations of f = m(2, 4, 5, 6, 10) + D(12, 13, 14, 15) x 1 x 2 x 3 x d0 01d0 00d0 11d
Figure 4.15 Two implementations of f = m(2, 4, 5, 6, 10) + D(12, 13, 14, 15) x 1 x 2 x 3 x d0 01d0 00d0 11d
Multiple-Output Circuits Necessary to implement multiple functions. Circuits can be combined to obtain lower cost solution by sharing some gates.
Figure 4.16 An example of multiple-output synthesis x 1 x 2 x 3 x (a) Function 1 f 1 x 1 x 2 x 3 x (b) Functionf 2
f 1 f 2 x 2 x 3 x 4 x 1 x 3 x 1 x 3 x 2 x 3 x 4 (c) Combined circuit forf 1 f 2 and
Figure 4.17 An example of multiple-output synthesis x 1 x 2 x 3 x (a) Optimal realization of(b) Optimal realization of 1 f 3 f x 1 x 2 x 3 x
(c) Optimal realization of f 3 x 1 x 2 x 3 x x 1 x 2 x 3 x andtogetherf 4
Figure 4.17 An example of multiple-output synthesis f 3 f 4 x 1 x 4 x 3 x 4 x 1 x 1 x 2 x 2 x 4 x 4 (d) Combined circuit for f 3 f 4 and x 2
x 1 x 2 x 3 x (a) Function 0 f 1 x 1 x 2 x 3 x (b) Functionf
x 1 x 2 x 3 x (a) Optimal realization of(b) Optimal realization of f 3 f 4 x 1 x 2 x 3 x
Figure 4.18 DeMorgan’s theorem in terms of logic gates x 1 x 2 x 1 x 2 x 1 x 2 x 1 x 2 x 1 x 2 x 1 x 2 x 1 x 2 x 1 x 2 += (a) x 1 x 2 + x 1 x 2 = (b)
Figure 4.19 Using NAND gates to implement a sum-of-products x 1 x 2 x 3 x 4 x 5 x 1 x 2 x 3 x 4 x 5 x 1 x 2 x 3 x 4 x 5
Figure 4.20 Using NOR gates to implement a product-of-sums x 1 x 2 x 3 x 4 x 5 x 1 x 2 x 3 x 4 x 5 x 1 x 2 x 3 x 4 x 5
Multilevel Synthesis SOP or POS circuits have 2-levels of gates. Only efficient for functions with few inputs. Many inputs can lead to fan-in problems. Multilevel circuits can also be more area efficient.
Figure 4.21 Implementation in a CPLD
Figure 4.22 Implementation in an FPGA
Figure 4.23 Using 4-input AND gates to realize a 7-input product term 7 inputs
Figure 4.24 A factored circuit x 6 x 4 x 1 x 5 x 2 x 3 x 2 x 3 x 5
Example 4.5
Figure 4.25 A multilevel circuit x 1 x 2 x 3 x 4 f 1 f 2
Impact on Wiring Complexity Space on chip is used by gates and wires. Wires can be a significant portion. Each literal corresponds to a wire. Factoring reduces literal count, so it can also reduce wiring complexity.
Functional Decomposition Multilevel circuits often require less area. Complexity is reduced by decomposing 2-level function into subcircuits. Subcircuit implements function that may be used in multiple places.
Example 4.6
Figure 4.26 A multilevel circuit x 1 x 2 x 3 x 4 f g
Figure 4.27 The structure of a decomposition 1 x 2 x 3 x 4 f g h x x 1 x 2 x 3 x 4 f g
x 1 x 2 x 3 x x 1 x 2 x 3 x x 5 0=x 5 1= f
Figure 4.28 An example of decomposition x 1 x 2 x 5 x 4 f x 3 g k
Figure 4.29 a Implementation of XOR x 2 x 1 x 1 x 2 x 2 x 1 x 1 x 2 (a) Sum-of-products implementation (b) NAND gate implementation
Example 4.8
x 2 x 1 g x 1 x 2 (c) Optimal NAND gate implementation Figure 4.29 b Implementation of XOR f = x 1 x 2 = x 1 x 2 + x 1 x 2 = x 1 (x 1 + x 2 ) + x 2 (x 1 + x 2 )
Practical Issues Functional decomposition can be used to implement general logic functions in circuits with built-in constraints. Enormous numbers of possible subfunctions leads to necessity for heuristic algorithms.
Figure 4.30 Conversion to a NAND-gate circuit x 2 x 1 x 3 x 4 x 5 x 6 x 7 x 2 x 1 x 3 x 4 x 5 x 6 x 7 f f (a) Circuit with AND and OR gates (b) Inversions needed to convert to NANDs
Figure 4.30 Conversion to a NAND-gate circuit x 2 x 1 x 3 x 4 x 5 x 6 x 7 f (b) Inversions needed to convert to NANDs x 2 x 1 x 3 x 4 x 5 x 6 x 7 f
Figure 4.31 Conversion to a NOR-gate circuit x 2 x 1 x 3 x 4 x 5 x 6 x 7 f (a) Circuit with AND and OR gates x 2 x 1 x 3 x 4 x 5 x 6 x 7 f (a) Inversions needed to convert to NORs
Figure 4.31 Conversion to a NOR-gate circuit x 2 x 1 x 3 x 4 x 5 x 6 x 7 f x 2 x 1 x 3 x 4 x 5 x 6 x 7 f
Figure 4.32 Circuit example for analysis
x 1 x 2 x 5 x 4 f x 3 P 1 P 4 P 5 P 6 P 8 P 2 P 3 P 9 P 10 P 7 Figure 4.33 Circuit example for analysis
x 1 x 2 x 4 f x 5 (c) Circuit with AND and OR gates x 3 Figure 4.34 Circuit example for analysis x 1 x 2 x 3 x 4 x 5 f P 1 P 2 P 3 (a) NAND-gate circuit x 1 x 2 x 3 x 4 x 5 f (b) Moving bubbles to convert to ANDs and ORs
Figure 4.35 Circuit example for analysis
CAD Tools espresso – finds exact and heuristic solutions to the 2-level synthesis problem. sis – performs multilevel logic synthesis. Numerous commercial CAD packages are available from Cadence, Mentor, Synopsys, and others.
Figure 4.46 A complete CAD system Design conception Design correct? Chip configuration Timing simulation No Yes Design entry, initial synthesis, and functional simulation (see section 2.8) Physical design Logic synthesis/optimization
Figure 4.42 VHDL code for the function f = m(1, 4, 5, 6)
Figure 4.43 Logic synthesis options in MAX+PLUS II
Physical Design Physical design determines how logic is to be implemented in the target technology. –Placement determines where in target device a logic function is realized. –Routing determines how devices are to be interconnected using wires.
Figure 4.44 Results of physical design
Timing Simulation Functional simulation does not consider signal propagation delays. After physical design, more accurate timing information is available. Timing simulation can be used to check if a design meets performance requirements.
Figure 4.45 Timing simulation results (a) Timing in an FPGA (b) Timing in a CPLD
Figure 4.46 A complete CAD system Design conception Design correct? Chip configuration Timing simulation No Yes Design entry, initial synthesis, and functional simulation (see section 2.8) Physical design Logic synthesis/optimization
STD_LOGIC type Defined in ieee.std_logic_1164 package. Enumerated type with 9 values. ‘1’ – strong one‘0’ – strong zero ‘X’ – strong unknown‘Z’ – high impedence ‘H’ – weak one‘L’ – weak zero ‘W’ – weak unknown‘U’ – uninitialized ‘-’ – don’t care We will almost always use STD_LOGIC.
Figure 4.47 VHDL code using STD_LOGIC
Figure 4.48 VHDL code for the function f = m(0, 2, 4, 5, 6)
Figure 4.49 Implementation of the VHDL code for the function f = m(0, 2, 4, 5, 6) DQ PAL-like block (from interconnection wires) x 1 x 2 x 3 unused 0 0 1
DQ PAL-like block (from interconnection wires) x 1 x 2 x 3 unused 0 1 Figure 4.50 Implementation using XOR synthesis (f = x 3 x 1 x 2 x 3 )
Figure 4.51 VHDL code for f = m(0, 2, 4, 5, 6) implemented in a LUT
Figure 4.52 The VHDL code for f = m(2, 3, 9, 10, 11, 13)
Figure 4.53 VHDL code for a 7-variable function
Figure 4.54 Two implementations of a 7-variable function x 6 x 4 f x 5 0 x 7 x 2 x 3 x 2 x 7 x 4 x 5 0 x 6 x 1 x 3 x 1 x 4 x 5 x 6 x 1 x 3 x 6 x 2 x 3 x 7 x 2 x 4 x 5 x 7 (a) Sum-of-products realization x 1 x 7 x 2 x 6 x 1 x 6 x 2 x 7 + x 5 x 3 x 4 f (b) Factored realization x 1
Logic Function Representation Truth tables Algebraic expressions Venn diagrams Karnaugh maps n-dimensional cubes
Figure 4.36 Representation of f = m(1, 2, 3) x f x 2 x 1 x1 1x x 2
Figure 4.37 Representation of f = m(0, 2, 4, 5, 6)
Figure 4.38 Representation of f = m(0, 2, 3, 6, 7, 8, 10, 15)
n-Dimensional Hypercube Function of n variables maps to n-cube. Size of a cube is number of vertices. A cube with k x’s consists of 2 k vertices. n-cube has 2 n vertices. 2 vertices are adjacent if they differ in one coordinate. Each vertex in n-cube adjacent to n others.
Figure 4.39 The coordinate *-operation o o x 1 0 x B i A i 0 1 x A i B i * C = A * B such that 1.C = if A i * B i = for more than one i. 2.Otherwise, C i = A i * B i when A i * B i and C i = x for the coordinate where A i * B i = .
Using *-operation to Find Primes f is specified using a set of cubes, C k of f. Let c i and c j be any two cubes in C k. Apply *-operation to all pairs of cubes in C k : –G k+1 = c i * c j for all c i, c j in C k Form new cover for f as follows: –C k+1 = C k G k+1 – redundant cubes –A is redundant if exists a B s.t. A i = B i or B i = x for all i. Repeat until C k+1 = C k.
Example 4.14
Example 4.15
Figure 4.40 The coordinate #-operation o x B i A i 0 1 x A i B i # o C = A # B, such that 1.C = A if A i # B i = for some i. 2.C = if A i # B i = for all i. 3.Otherwise, C = i (A 1, A 2,..., B i,... A n ), where the union is for all i for which A i = x and B i x.
Finding Essential Primes Let P be set of all prime implicants. Let p i denote one prime implicant in P. Let DC denote the don’t cares vertices for f. Then p i is an essential prime implicant iff: –p i # (P – p i ) # DC
Example 4.16
Example 4.17
Procedure to Find Minimal Cover Let C 0 = ON DC be the initial cover of f. Find all primes, P, of C 0 using *-operation. Find the essential primes using #-operation. If essentials cover ON-set then done else –Delete any nonessential prime that is more expensive than some other prime. –Use branching technique to select lowest cost primes which cover ON-set.
Figure 4.41 An example four-variable function 1 x 2 x 3 x x 1 x 2 x 3 x d1 1 d d x 5 0=x 5 1= d x
Summary Described 2-level logic synthesis methods. Discussed multilevel logic synthesis. Introduced CAD tools for logic synthesis.