synthesis of two-level circuits n define two-level circuit n prime implicants (pis) n methods of...

25
Synthesis of Two-Level Circuits Define Two-Level Circuit Prime Implicants (PIs) Methods of Finding PIs Selecting PIs Multiple Output Functions Read HS 127-165

Upload: samuel-bennett

Post on 28-Dec-2015

221 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

Synthesis of Two-Level Circuits

Define Two-Level CircuitPrime Implicants (PIs)Methods of Finding PIsSelecting PIsMultiple Output Functions

Read HS 127-165

Page 2: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-2 - David Zar - 04/19/23

Introduction We now begin applying the ideas from general Boolean algebras

to formula minimization

We are interested in circuit implementations that are optimal in some sense» We consider the Boolean function algebra over the switching algebra

({0,1},·)» We will need some sense of optimality

We will initially focus on “two-level” circuits» For such circuits there are at most two gates between inputs and

outputs (not counting possible inverters used to form complements of the inputs

» All Boolean functions over the switching algebra can be implemented by two-level circuits

» Such circuits are generally very fast because of the small propagation delay from input to output

» Such circuits are very simple to analyze and minimum cost implementations can be found directly

» The methods we develop will form a starting point for multi-level circuits

Page 3: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-3 - David Zar - 04/19/23

Two-Level Formulas Definition: A letter is a constant or a variable. A literal is a letter

or its complement.

For example, let x1 and x2 be variables defined over the switching algebra. Then 0, 1, x1, and x2 are letters. Also, 0, 1, x1, x1

0, x2, x20

and are literals.

Definition: A product term is a formula with one of the following forms1. The constant 12. A nonconstant literal3. A conjunction (meet) of nonconstant literals where no letter appears

more than once

Definition: A sum term is a formula with one of the following forms1. The constant 02. A nonconstant literal3. A disjunction (join) of nonconstant literals where no letter appears

more than once

For example, xy0z is a product term, x+y0+z is a sum term, x is both, and x(y+z) is neither

Page 4: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-4 - David Zar - 04/19/23

Two-Level Formulas (cont.) Definition: A sum of products or disjunctive normal formula (abbreviated SOP

or ) is a formula with one of the following forms1. The constant 12. A product term3. A disjunction (join) of product terms

Definition: A product of sums or conjunctive normal formula (abbreviated POS or is a formula with one of the following forms1. The constant 02. A sum term3. A conjunction (meet) of sum terms

For example, xy+xy0+z is a sum of products, (x+y)(x+y0)z is a product of sums, x is both, and xy+(x+z)(y+z) is neither.

We define the cost of a formula to be determined by the number of terms and literals it contains1. For two SOP formulas g and h, the cost of g is less than the cost of h if g has fewer

product terms. If they have the same number of product terms, then the cost of g is lower if it has fewer literals

2. For two POS formulas g and h, the cost of g is less than that of h if g has fewer sum terms. If they have the same number of sum terms, then the cost of g is lower if it has fewer literals

3. We compare a POS formula with a SOP formula by comparing the number of terms and literals in a similar fashion

Definition: A two-level formula is either a SOP or POS formula

Page 5: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-5 - David Zar - 04/19/23

Implicants Definition: An implicant of a function f is a product term p that is covered by f.

That is, p·f.

As an example, xy0, xyz, and yz are implicants of xy0+yz

A key to thinking about what an implicant is is to look at the related word “implies.” That is, if p·f then whenever p=1 it must be that f=1 so that “p implies f.”

Definition: A prime implicant of f is an implicant of f that is not covered by any other implicant of f. That is, if p is a prime implicant of f, then for any other implicant q of f, then p£ q.

As an example, xy0, yz, and xz are prime implicants of xy0 + yz, but xyz is not.

Note that if p is an implicant that is not prime, then there exists a literal in p that can be removed to yield another implicant

Definition: An essential prime implicant is a prime implicant that covers a minterm which is not covered by any other implicant

For example, xy0 and yz are essential prime implicants of xy0+yz, but xz is not:xy0 contains xy0z and xy0 z0

yz contains xyz and x0yzxz contains xyz and xy0z each of which is covered by one of the above implicants

Page 6: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-6 - David Zar - 04/19/23

Quine’s Theorem

Quine's Prime Implicant Theorem: A minimal SOP formula must always consist of a sum of prime implicants if any definition of cost is used in which the addition of a single literal to any formula increases the cost of the formula.

Proof: follows by assuming that a minimum cost SOP formula exists that contains a non-prime implicant. This implicant can be replaced by an implicant with one fewer literal without changing the function. This contradicts the assertion that the original formula was minimum cost.

The consequence of Quine's theorem for us is that when we want to find a minimum cost SOP formula we need only look at sums of prime implicants and not all possible sums of minterms

Page 7: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-7 - David Zar - 04/19/23

Consensus Theorem Consider the relationship between implication and the consensus theorem

A syllogism is a logical form consisting of:1. a major premise (such as “all humans are mortal”)2. a minor premise (such as “I am human”)3. conclusion (“I am mortal”)

A premise can be represented in terms of letters representing predicates. For example, “all humans are mortal” can be written h)m where h is predicate which may be true or false depending upon the individual in question and m is a predicate which also may be true or false

The proposition x)y can be considered a function that maps {TRUE, FALSE}2 to {TRUE, FALSE} in such a way that the function is true if x is false or if y is true whenever x is true.

We can represent this Boolean function via the formula x)y=x0+y

The syllogism can be written via the formula (h)m)¢(I)h))(I)m) which is equivalent to (h0+m)(I’+h))(I0+m)

Note that the implied term is the consensus of the other two terms from the consensus theorem for Boolean algebras that states (x+y)(x0+z)(y+z)=(x+y)(x0+z) : think (h0+m)(h+I’)(m+I0)

A special case of the consensus theorem xy+x0z+yz=xy+x0z follows when z=y:xY+x0 Y+Y=xY+x0Y. Since Y covers both xY and x0Y, this is Y=xY+x0Y.

The capital Y is meant to indicate that Y may represent a product of literals not including x or x0

Though a convoluted way of proving that Y=xY+x0Y, it justifies calling Y the consensus term of xY and x0Y

Page 8: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-8 - David Zar - 04/19/23

Adjacency and Minimization Definition: Two product terms are said to be adjacent if the just defined

version of the consensus theorem can be applied to them

That is, two product terms are said to be adjacent if they are of the form xY and x’Y.

If two product terms are adjacent, and both terms are implicants for some Boolean function f, then Y is also an implicant of f and any function using only Y will be of lower cost than one using both xY and x’Y.

This is the basis of Boolean function minimization and is what we all used to minimize using Karnaugh maps:

101

0 0 1 00 0 0

x

yz

00 01 11 10

Y=yz: xyz and x’yz are both implicants of f.Hence, we eliminate x and say the minimal function is simply f=yz.

Page 9: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-9 - David Zar - 04/19/23

Minimization Problem We will break the minimization problem up into two sub-problems:

1. Determining all prime implicants of a function2. Determining a sum of those implicants which is a minimum cost

representation of the function

There are many ways to find prime implicants:» Mathematically,» Via Karnaugh Maps,» Iteratively.

Once we have all the prime implicants, we can find a sum of them that will provide a minimum cost function.

Page 10: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-10 - David Zar - 04/19/23

For example if

then the table would be constructed as shown on the right:

Recall that if the switching function f is incompletely specified, it corresponds to the interval [f1,f1+f-] where f1 is the sum of minterms for which the function must be 1 and f- is the sum of minterms for which the function is don't care

PIs by Iterative Methods Definition: A complete sum is a SOP formula composed of all the prime implicants of the

function it represents

A complete sum for a function f can be determined in the following steps:1. Write the function f in minterm canonical form2. Consider all pairs of adjacent terms, mark them as not prime, and form their consensus term3. Repeat the above step until no new terms can be found4. The terms that are not marked are the prime implicants of f, the marked terms are not prime and may be

removed from the formula

This can be more easily tracked in tabular form:

The first column contains the minterms of f grouped by the number of uncomplemented literals

Page 11: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-11 - David Zar - 04/19/23

PIs and Don’t Cares Definition: A prime implicant of an incompletely specified function given by (f1,f-) is a

product term p such that1. p· f1+f-

2. p¢f103. p is not contained in any other implicant of (f1,f-)

In other words, p is a prime implicant of (f1,f-) if it is a prime implicant of f1+f- that covers at least one minterm of f1

We can find the prime implicants of an incompletely specified function (f1,f-) by finding the prime implicants of the completely specified function f1+f- and removing those that don't cover any minterms of f1

As an example, let f1=yz0+xy0z and f-=x0z» The minterms of f1 are {xyz0, x0yz0, xy0z}» The minterms of f- are {x0y0z, x0yz}

In the table, we mark those terms that do not cover any minterms of f1 with the letter d, and when we're finished, the prime implicants of f1+f- that are marked with d are ignored because they are not prime implicants of (f1,f-)

Page 12: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-12 - David Zar - 04/19/23

Complete Sums The above method uses the simplified form of consensus Y=xY+x0Y.

We don't need to go all the way down to minterm canonical form if we are willing to apply the more general form consensus xY+x0 Z=xY+x0 Z+YZ

Theorem: A SOP formula is a complete sum if and only if» No term includes any other term» If the consensus of two terms in the formula exist, it is covered by some

term in the formula

This suggests that given a SOP formula, we can build a complete sum by adding the consensus terms from all possible combinations of terms and removing any terms covered by another term

As an example, consider the SOP formula f=wx+x0y+xyz

» Combining the first two terms yields f=wx+x0y+xyz+wy» Combining the second and third terms yields

f=wx+x0y+xyz+wy+yyz=wx+x0y+xyz+wy+yz» The last term contains the third term and no other consensus terms can be

formed, so the complete sum for f is f=wx+x0y+wy+yz

Page 13: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-13 - David Zar - 04/19/23

PIs by Recursive Methods If F and G are formulas which are complete sums, then a complete sum

for F¢ G can be formed by:» Multiplying out F and G, applying the idempotent and distributive properties

and using x¢x0=0» Eliminate all terms contained in some other term

Since a POS formula consists of products of complete sums, we can repeatedly apply the above theorem to generate a complete sum directly from a POS formula

We can always derive a POS formula from Boole's expansion theorem which gives a recursive algorithm

If we apply the theorem above to each level in the recursion, we can generate a complete sum by recursively applying a very simple algorithm CS(F):» Determine a “splitting variable” x that appears in the most terms of F» Let Fx0 be the return value from CS when passed the formula F with x=0» Let Fx be the return value from CS when passed the formula F with x=1» Multiply out and simplify G=(x+Fx0)(x0+Fx)» Return G

Page 14: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-14 - David Zar - 04/19/23

Find Sum of PIs Thus far, we have found the PIs but that’s only step 1.

The question that remains is how to select a subset of the prime implicants such that the sum covers the function and is of minimum cost

In general, this problem is conceptually simple to solve but requires checking each of a large number of possible solutions and picking the best one

We base the approach on a key assumption: We just require one optimal solution, even though more may exist that are also optimal

We break the problem into two steps:1. Do as much simplification as possible2. Enumerate all possible solutions of the simplified problem and pick the best

one

The basic problem we are trying to solve is to find the subset of prime implicants whose sum covers all the minterms and is the lowest cost

The problem is commonly formulated as the selection of columns out of a constraint matrix or assigning values in a constraint equation

Page 15: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-15 - David Zar - 04/19/23

Constraint Matrix The constraint matrix for the covering problem is a matrix with

component values of 0 and 1 with» One row for every minterm» One column for every prime implicant» The value 1 at row i and column j if prime implicant pj covers minterm mi

and the value 0 otherwise» The problem is to choose a subset of the columns such that each row has a

value 1 in at least one of the chosen columns and the total cost of the columns is minimal

» Formally, let C be a matrix of m rows and n columns such that Cij2{0,1} and such that 8 i 9 j 3 Cij=1. Let the cost associated with a set S of prime implicants be denoted c(S). The covering problem is to find a subset Sµ {1,2,...,n} that satisfies

Page 16: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-16 - David Zar - 04/19/23

Constraint Matrix Example As an example, let f=yz+x0y+y0z0+xyz+x0z0 for which the complete

sum is f=x0y+x0z0+y0z0+yz.» There are four prime implicants and we name them p1 through p4

» The function covers 5 minterms (x0y0z0, x0yz0, x0yz,xyz,xy0z0}» The constraint matrix C has the following form

Notice that p3 and p4 are essential prime implicants (they each cover a minterm that is not covered by any other prime implicant

If all prime implicants are the same cost, selecting {p1,p3,p4} is a minimum cost covering

Page 17: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-17 - David Zar - 04/19/23

Constraint Equation The constraint equation represents each prime implicant by a variable

pj in a switching algebra with:» The interpretation that pj=1 indicates that the prime implicant is included in

the final solution whereas pj=0 indicates that it is not» Each minterm is represented by a sum term i = j=1

n Cij pj where Cij=1 if the jth prime implicant covers the ith minterm

» The goal is to find an assignment of 0 and 1 values to the variables pj that the product of all terms equals one and the total cost is minimized

» Formally, let i be a sum term consisting of a subset of the (uncomplemented) letters p1 through pj. Let the cost associated with the assignment vector p=(p1, p2, ..., pn) be c(p). The covering problem is to find a vector p=(p1, p2, ..., pn) as

As an example, the function f from the previous example would yield a constraint equation (p2+p3)(p1+p2)p3p4=1» Again note that p3 and p4 are essential primes (must equal one)» If all prime implicants are of equal cost, selecting p1=1, p2=0, p3=1, and p4=1

is a minimal cost solution

Page 18: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-18 - David Zar - 04/19/23

Reduction Techniques The previous example was simple enough to solve almost

by inspection, in general we must consider (explicitly or implicitly) all possible solutions

We first consider methods of implicitly eliminating as many solutions as possible before we resort to a full enumeration

All essential primes must be included in the solution because they cover minterms that are otherwise uncovered» If a row of a constraint matrix has a single 1 value in it, the corresponding

column must be retained» The column and all rows it covers can be removed from the constraint

matrix yielding a simpler problem» If a sum term in a constraint equation consists of a single letter, then it

must be assigned the value 1 and the equation can be simplified noting that (1+pi)=1

» From the previous example, p3 and p4 are essential

Page 19: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-19 - David Zar - 04/19/23

Row Dominance Row or constraint dominance occurs if one minterm is covered

whenever another minterm is covered» Row k is said to dominate row l in a constraint matrix if row k has the

value 1 in every column for which row l has a 1 (row k may have other 1's as well)

» Since row l must be covered and doing so also covers row k, we can eliminate row k to yield a simpler problem

» For the following constraint matrix, row 1 dominates row 2 so row 1 can be eliminated from the problem

» One constraint term dominates another if the absorption property can be applied. That is, if we can simplify the equation by applying x(x+y)=x

» The constraint matrix above can be represented by the constraint equation (p1+p2+p4)(p1+p4)(p2+p3)=1. We can apply consensus to the first two terms yielding (p1+p4)(p2+p3)=1.

Page 20: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-20 - David Zar - 04/19/23

Column Dominance Column or variable dominance occurs if a prime implicant pk costs

no more than prime implicant pl but covers all the minterms that pl covers (pk may cover more minterms as well)» In this case, pl can be eliminated without fear of loosing the ability to find

an optimal solution» Column pk dominates column pl in a constraint matrix if it has 1's in all

rows where pl has 1s and prime pk is of no greater cost» For example, in matrix (4), column p2 dominates p3 if the cost of p2 is no

greater than the cost of p3

» In a constraint equation, variable pk dominates pl if the cost of pk is no greater than pl and pk appears in every term that pl appears in

» For example, in the previous constraint equation ((p1+p2+p4)(p1+p4)(p2+p3)=1), p2 occurs in every term that p3 occurs in

Page 21: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-21 - David Zar - 04/19/23

Exact Solutions Once all possible simplifications have been applied, we are forced to

begin enumerating possibilities to pick the cheapest

This can be done, for instance, by multiplying out the constraint equation to SOP form, simplifying via the idempotent property, and choosing the minterms of the lowest cost product term

The above approach can be quite tedious for constraint equations with more than a few sum terms

Instead, a solution can be found in a systematic way » Simplify the problem accounting for essential primes and dominance» Pick a splitting variable pj» Assign pj=0 and solve the reduced problem by first simplifying (accounting

for essential primes and dominance) and then enumerating the solutions to the reduced problem

» Assign pj=1 and solve the reduced problem by first simplifying (accounting for essential primes and dominance) and then enumerating the solutions to the reduced problem

» With a clever bounding technique, we can stop exploring entire branches of possibilities whenever we find that they cannot yield a cheaper solution than the best one we've already found

To apply the branch-and-bound idea, we need a way to lower-bound the cost of a solution

Page 22: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-22 - David Zar - 04/19/23

Multiple-Output Functions A multiple-output function is a vector-valued function with components that

are scalar-valued switching functions over a common set of inputs, f=(f1,f2,..., fn)

For example, f=(xz+yz,x0y+x0z0) is a multiple-output function

It is often of interest to find an implementation of a multiple-output function that minimizes the total cost over all outputs and not the cost of any single output. Here we address finding two-level formulas that minimize the total number of gates» Finding a minimum cost formula for each of the components is not necessarily a

minimum cost formula for the multiple-output function because it does not take into account implicants which may be shared between the functions

» For example, in the function f above, the formula given is a minimum cost sum of prime implicants for each of the components. However, the formula f=(xz+x0yz, x0z0+x0yz) involves fewer terms

» Note that the term x0yz need be formulated only once and it is not a prime implicant of either output

» The solution is to consider the covering problem using not only the prime implicants of the individual outputs, but of all possible products of the outputs

That is, consider the prime implicants of {f1, f2, ..., fn, f1f2, f1f3, ..., f1f2f3, ...,

f1f2f3... f

n}

Page 23: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-23 - David Zar - 04/19/23

Shorthand Notation We will use a shorthand notation for representing the implicants of multiple-

output functions» First choose some ordering of the inputs as in x1, x2, x3, ..., xm and some ordering of the

outputs as in f1,f2,f3,..., fn

» An implicant of the multiple-output function is a string of m symbols representing values of the inputs taken from the set {0,1,-}, a vertical line, and a string of n symbols representing values of the outputs taken from the set {0,1,-}

» A value of 1 in the ith position from the left indicates that the input xi must be 1 for the implicant to apply. Similarly, a value of 0 indicates that xi must be 0 for the implicant to apply, and - indicates that implicant applies regardless of the value of xi

» A value of 1 in the ith position right of the vertical bar indicates that the output fj must be 1 when the implicant applies and a value of - indicates that the output is don't care when the implicant applies. On the other hand, a value of 0 implies that the output is not necessarily 1 when the implicant applies

» Because of the don't care possibility for inputs, more than one implicant may apply for a given set of input values and in this case, the outputs are given as the join of the corresponding outputs for all matching implicants

» For example, the previous function f=(xz+yz,x0y+x0z0) can be written as

» The input x1=x=0, x2=y=1, x3=z=1 matches both middle implicants, and for this combination of inputs the output is f1=1+0=1 and f2=0+1=1

Page 24: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-24 - David Zar - 04/19/23

Tabular Method Revisited We can find the prime implicants through the tabular

method appropriately modified» Group the implicants by the number of 1s in the input sequence» When applying consensus to two minterms, the output sequence for

the new implicant is formed by the meet of the output sequences for the two minterms

» An implicant used to form a consensus term is checked only if its output sequence equals that of the consensus term

As an example, the function f (1-1|10+-11|10+01-|01+0-0|01) has prime implicants found by the table

000|01

0-0|01

010|01

01-|01

011|11

101|10

-11|011-1|10

111|10

Page 25: Synthesis of Two-Level Circuits n Define Two-Level Circuit n Prime Implicants (PIs) n Methods of Finding PIs n Selecting PIs n Multiple Output Functions

1-25 - David Zar - 04/19/23

Covering Problem Revisited The covering problem is handled through a slightly modified

method» Minterms for which multiple outputs are 1 are expanded into a sum

of minterms with a single output function given the value 1 (because some prime implicants may cover only some of the output functions)

For example, the minterm 011|11 is expanded as 011|10 + 011|01 and each are listed individually in the constraint matrix

With p1=011|11, p2=0-0|01, p3=01- |01, p4=-11|10, and p5=111|10, the constraint matrix becomes