- 350 Views
- Uploaded on

Download Presentation
## PowerPoint Slideshow about 'Single Function Quine-McCluskey 2-Level Minimization' - vianca

**An Image/Link below is provided (as is) to download presentation**

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

### Single Function Quine-McCluskey 2-Level Minimization

Shantanu Dutt

University of Illinois at Chicago

Acknowledgement: Transcribed to Powerpoint by Huan Ren from Prof. Shantanu Dutt’s handwritten notes

Basic Two-Level Minimization Steps

The basic steps are the same for K-Map and Quine McCluskey (QM):

- Form all PIs
- Determine a minimum cost set of PIs to cover all minterms (MTs)
- Determine EPIs, include them in the final expression and delete all MTs they cover
- Determine a min cost set of the remaining PIs to cover the remaining MTs (this is a really hard problem—NP-hard, i.e., takes a worst-case exponential computation time to solve optimally

- Necessary conditionsfor combining 2 implicants to form a larger implicant that covers them (if the conditions are met, then we need to look at the ternary notations to determine combinability) :
- Two MTs/DCs in only adj. groups can be combined only if their integer values differ by a power of 2
- Two implicants in adj. groups can be combined only if their difference sets are the same andthepairwise absolute differences of their MT/DC list arranged in increasing order are the same and a power of 2 (e.g.: (i) g=(1,3), h=(5,7), DS for both is {2} & |(1,3)-(5,7)| = (4,4) and g,h are combinable—same # that is a power of 2; the # 4 is added to the diff. set of the combined implicants to obtain the diff. set of the larger implicant. (ii) g=(3,7), h=(9,13), DS for both is {4}, |(3,7)-(9,13)| = (6,6) and thus g,h are not combinable—same # but not a power of 2

QM: The PI Table (PIT)—Min-Cost MT Covering

2a

Inclusion removal/deletion: Removal of those PIs from the PIT that are to be included in the final expr. Thus the MTs they cover are also removed.

QM: The PIT—Min-Cost MT Covering (cont.)

2b

Exclusion removal/deletion: Removal of those PIs from the PIT that are not to be included in the final expr. Thus the MTs they cover are not removed.

Row

covering

Inclusion removal/deletion

2a

2a

2b

QM: The PIT—Min-Cost MT Covering (cont.)

C

Covering

by one MT/col

of another

Exclusion deletions

C

In these cases both PIs cover each other,

But that may not always be the case

Note: Both the row covering and col covering rules reduce the complexity of the min-cost covering problem. However, row-covering does not necessarily preserve optimality (why?), while col-covering does.

C

C

Covering

by one PI/row

of another

A row Ri is said to cover row Rj, if Ri has X’s in all the cols that Rj has X’s in (& possibly more)

A col Ci is said to cover col Cj, if Ci has X’s in all the rows that Cj has X’s in (and possibly more)

- Identify “pseudo-EPIs” (EPIs in the reduced PIT), and remove them (inclusion removal—removal from PIT, and inclusion in the min. expression) and the MTs they cover.
- Repeat above steps until all MTs covered

QM: The PIT—Min-Cost MT Covering (cont.)

C

Covering

by one MT/col

of another

Exclusion deletions

C

Pseudo-EPIs

C

PI3

C

PI4

PI2

Inclusion deletions

f = PI1 + PI2 + PI3 + PI4

QM: The PI Table—Min-Cost MT Covering (cont.)

*

C

C

(for incl. removal)

Better heuristics than random choice can be used, as shown in subsequent slides

Q-M: Don’t Cares

- Q-M for functions with don’t cares:
- Difference from Q-M without X’s:
- Include X’s along w/ MTs when forming PIs using the tabular method (or using K-Maps)
- Eliminate PI’s that are composed of only X’s
- Don’t include X’s in the PI chart/table

AB

CD

00

01

11

10

AD

ABC

00

0

4

12

8x

01

1 1

5 1

13 x

91

CD

11

3 x

7 x

15

11

AC

10

2x

61

14

10

PI3

PI4

PI1

Note: Do not remove intermediate implicants that have only X’s (why?). Only final PIs w/ only X’s should be removed from the final set of Pis.

QM: The Iterative Technique for Min-Cost Covering

- In the PI Table (PIT), identify all EPIs, include them in the min. expression & delete MTs they cover
- Repeat
- While there are MTs remaining and the reduced PIT(RPIT) is not cyclic do
- Again check if EPIs can be identified in the RPIT—these new EPIs are called pseudo or secondary EPIs
- While no pseudo EPIs can be identified do
- If there are still MTs in the RPIT and no more pseudo EPIs, reduce the RPIT further by using only the col covering rule and only row covering in which the covering row has cost <= that of the covered row. /* these coverings are optimal—proof? */
- If no rule could be applied above then apply only one row covering rule w/ the least difference in cost between covering and covered row (break ties by max # of remaining MTs covered by the covering row). /* this part is sub-optimal so need to apply in a limited manner */
- End While
- End While
- If the RPIT is cyclic, make it acyclic by choosing a PI for inclusion in the min expression that either:
- Covers the max # of remaining MTs (break ties based on smaller cost—number of literals in the PI’s product term, and break further ties randomly) (Rule 3)
- OR has the smallest cost/(# of covered MTs) (break ties by max. # of MTs covered, and further ties randomly) (Rule 4)
- Until(all MTs are covered)

32-mt

PI B

32-mt

PI C

C

16 X’s

16 X’s

2-mt PI A

15 X’s

15 X’s

Non-opt. ex:

In a 7-var.

func, cost(A)

= 6+1 =7,

cost(B+C)

= (2+1)+(2+1)

= 6

C

- Row covering rule (Rule 1): If row i covers row j, delete the covered (subset) row, row j. If both rows i and j cover each other, delete the row w/ higher cost (# of literals)
- Col covering rule (Rule 2): If col i covers col j delete the covering (superset) column, col i. If both cols I and j cover each other, then delete one of them arbitrarily

Cyclic PI Table

bc

bc

- Cyclic PI set in K-map (no EPIs)
- Cost of a PI = # literals + 1
- All red PIs have the same cost (each covers 2 MTs)
- The blue PI has a smaller cost as it covers 2 MTs and 2 DCs.

de

de

a=0

a=1

Min-cost PI

Cost

PIs

1

2

3

4

5

6

4+1

PI1

Note: PI4=4,6,12,14 →

# of literals = 3 →

cost(PI4) = 3+1 = 4

[# of literals +1]

4+1

PI2

4+1

PI3

3+1

PI4

4+1

PI5

4+1

PI6

5

2

2

1

2

4

5

3

Cyclic PI Table (Contd.)- Rule 3: Heuristic for breaking the cycle in a cyclic PI chart
- Choose a PI that covers the largest # of min terms
- Break a tie by choosing the PI that has the least cost (fewest literals) .
- Break a further tie by choosing a PI in the tie arbitrarily.

- For previous example, # of MT’s covered are given to be the same
- If cost is not taken into account to break ties (and if so, this also amounts to randomly choosing a PI)
- Choose PI1 arbitrarily (remove it and all MTs it covers)
- Reduced PIT on the right

c

*

c

*

c

Cost = 5+5+5=15

Cyclic PI Table (Contd.)

- If cost is used to break ties of max MTs covered—Rule 3 (OR choice made by least cost/MT—Rule 4)
- By above criterion, choose PI4 first

3

4

4

3

PIs

1

2

3

4

5

6

PI1

PI2

3

*

PI3

1

*

PI4

2

PI5

*

4

PI6

Cost = 4+5+5 = 14

PI2=4,5,12,13

PI3=9,11,13,15

PI4=0,16

PI5=9,25

PI6=12,28

PI7=15,31

PI8=16,17,24,25

PI9=17,19

PI10=19,23

PI11=23,31

PI12=24,28

Cyclic PI Table (Contd.)BC

BC

00

01

11

10

00

01

11

10

DE

DE

00

01

41

12 1

8

00

161

20

28 1

241

01

1 1

5 x

13 1

9 1

01

171

21

29

251

11

3 x

7

151

11x

11

191

231

311

27

10

2x

6

14

10

10

18

22

30

26

A=0

A=1

8

5

1

1

1

1

2

3

4

6

1

6

6

9

9

7

7

9

8

7

8

11

10

11

- Taking # of MTs covered and cost into consideration (Rule 3, and in this case this is the same as applying the alternate Rule 4): Choose PI8 first

*

*

*

*

*

*

cost = 4+3+4+3+4+4 (AND gates’ cost) +

6 (6 PIs OR gate cost) = 22+6 = 28

3

2

5

4

1

1

1

4

4

5

5

- # of MTs covered is ignored and only cost is taken into account w/ ties broken randomly (neither Rule 3 nor Rule 4 used)
- Choose PI2 first based on cost (Note also: PI2’s cost/MT = 4/3, while PI8’s is 4/4, so this is not a good choice by Rule 4, nor Rule 3 as PI2 does not cover the max. # of MTs)

*

*

*

Reduced chart table: f=PI2+PI4+PI12+……

- Again cyclic! Choose PI3 by cost

or

5

4

1

1

1

2

3

4

5

5

6

6

4

*

*

*

This cost is 4 more than when using # of MTs as the selection criteria in an acyclic PI table

Time-Complexity and Optimality of QM

- Let p be the # of PIs and m the # of MTs in an n-variable function
- # of iterations of QM: In each iteration at least 1 col or row is deleted (incl. or excl. deletions). Thus # of iterations is O(p+m).
- Each iteration takes O(m*p2 + p*m2) time due to worst-case of all pair-wise comparisons among rows and cols to determine row and col coverings, and O(m*p) to determine EPIs (or psuedo-EPIs).
- Thus total time complexity is O((p+m)*(m*p2 + p*m2)) = O(max(m*p3, p2*m2, p*m3))
- What are the worst case values of p and m as functions of n?
- Optimality issues in examples below.

8-mt PI E

4-mt PI C

6 X’s

8-mt PI E

2-mt PI A

X

4-mt PI B

4-mt PI C

4 X’s

4 X’s

X

2-mt PI A

X

6 X’s

4-mt PI B

4 X’s

8-mt PI F

X

8-mt PI D

Optimal Soln in a non-cyclic situation: for a 4-var. function: E+D+A or B+C. QM gives us B+C in spite of “bad” coverings (C covers E; B covers D). Bad coverings will not always lead to a non-optimal solns, but they can.

4 X’s

8-mt PI D

Optimal Soln. in a cyclic situation: Either F+B+C or E+D+A. Either can be obtained by applying Rule 3 or 4 to the above cyclic situation to choose either of E, F or D first.

However, QM is not optimal, i.e., it will not give us an optimal solution for all problems.

Optimality of QM (contd.)

- QM is not optimal due to the sub-optimal use of row covering when the covered row is of less cost than the covered one, i.e., if applying such “bad” coverings, QM may not give us an optimal solution.

Example

- Can forming PI pairs and looking for covering from pair to single PIs help in avoiding this non-optimality? No, it can actually result in more bad coverings of single PIs by PI-pairs (since PI-pairs are most likely to have larger cost than single Pis), though good coverings of this type are always going to be optimal (just like good coverings between single PIs).
- How about pair-to-pair covering? This opens up covering possibilities that were not there between single PIs, and good pair to pair coverings should also preserve optimality. In the above example, PI pair A+D will cover all others like A+C or B+C using good covering, and will end up as the optimal solution (only remaining PI). So the process to be followed is:
- Use regular QM until the only options are bad covering(s) or the PIT/RPIT is cyclic
- If the above happen, switch to PI-pair coverings, i.e., rows of the PIT are now PI pairs (the defns of good & bad row/PI-pair covs. remain the same) and singlePIs, and when a PI pair Pij is chosen, costs of the single PIs in Pij, & other PI pairs that contain one of the PIs of Pij are appropriately reduced
- However, a similar problem comes up if the only pair-to-pair coverings are bad ones or there are none. So this approach can mitigate the sub-optimality of single PI bad coverings (or no coverings in a cyclic PIT) due to good pair-to-pair coverings that open up, but not always.
- We can take the concept further to triple-PIs, etc., but in the extreme this approach “degenerates” into Petrick’s algorithm, which essentially considers all possible multi-PI sets that cover all MTs, and thus cover each other (and we only apply good coverings in this case, which are guaranteed to exist until we get an optimal solution).

32-mt PI D

8-mt PI C

30 X’s

2

8-mt PI A

2 X’s

Optimal Soln: for a 7-var. function: A+D of cost (4+1) + (2+1) = 8. QM gives us either A+C or B+C, both of cost (4+1) + (4+1) = 10, due to “bad” coverings (C of cost 4+1 covers D of cost 2+1)

4

4

8-mt PI B

4 X’s

Optimality of QM (contd.): Proof of optimality of “good” covering

- Theorem: If row/PI PIj covers row/PI Pk in an PIT/RPIT and cost(PIj) <= cost(PIk) (this is the so-called “good” covering), then if PIk is exclusion deleted from the RPIT (i.e., PIk will not be included in the final SOP expression f), then this does not lead to a cost of the final SOP expression f that is greater than the cost of f if PIk is not exclusion deleted.
- Proof: For a PI PIr, let MT(PIr) be the set of MTs in the current RPIT covered by PIr.
- Case 1: MT(PIj) = MT(PIk). If PIk is included in f, then a smaller or same-cost solution can be obtained by replacing PIk by PIj and have PIj cover MT(PIk) (and thus the same MTs as before are covered by f after this change).
- Case 2: MT(PIk) is a subset of MT(PIj). Let MT(PIj - PIk) be the set of MTs in the current RPIT covered by PIj and not by PIk. There are 2 subcases here:
- Case 2a: Less cost is incurred by covering MT(PIj - PIk) by PIj than any other single or multiple PIs. In other words, PIj is part of the optimal solution. Thus if PIk is chosen to cover MT(PIk), then this solution’s cost can be reduced by deleting PIk from the solution and not affecting the coverage of MT(PIk), since these MTs are covered by PIj that is already part of the optimal solution.
- Case 2b: Less cost is incurred by covering MT(PIj - PIk) by a set S of one or more PIs (see figure below where S = {PIr, PIm}) other than PIj (this can happen if PIs in S become pseudo-PIs later on in the QM process due to other MTs [i.e., MTs not in MT(PIj - PIk)], and are thus needed in f in any case, and they cover MT(PIj - PIk) essentially for free). In this case also, as in Case 1, if PIk is part of the final solution (to cover MT(PIk)), then a smaller or same-cost solution can be obtained by replacing PIk by PIj and and have PIj cover MT(PIk) (and thus the same MTs as before are covered by f after this change).
- Thus in all cases, PIj can replace PIk if the latter is present in f to result in a smaller or same-cost solution , while still covering all the MTs. Hence exclusion-deleting PIk due to “good” covering by PIj, does not lead to a cost of the final SOP expression f that is greater than the cost of f if PIk is considered for inclusion in it.
- QED

MT(PIj – PIk)

Current or future pseudo-singleton cols

Set S in Case 2b

Download Presentation

Connecting to Server..