80 likes | 230 Views
This presentation explains Petrick's Algorithm, an algebraic method used for optimal cost covering in digital logic design. The steps include obtaining prime implicants, creating a prime implicant table (PIT), and forming expressions representing potential covers. The computational complexity of the algorithm is discussed, highlighting its practicality for scenarios with fewer terms compared to other methods. Examples and exercises illustrate its application in finding minimal solutions, emphasizing the efficiency of the Quine-McCluskey (Q-M) algorithm in real-world applications.
E N D
ECE 465Petrick’s Algorithm for 2-level Minimization Shantanu Dutt University of Illinois at Chicago Acknowledgement: Transcribed to Powerpoint by Huan Ren from Prof. Shantanu Dutt’s handwritten notes
Petrick’s Algorithm for Choosing Minimal Cost cover • The PIT portion of Q-M can get optimal in most cases and near-optimal cost coverings, but will not be optimal in all cases. • Can use an algebraic method called Petrick’s algorithm.
Petrick’s Algorithm • 1. Obtain all PIs using Q-M. • 2. Create a PIT and remove all EPIs and corresponding columns (MTs). • 3. Write a POS expr. representing all possible covers of remaining MTs • a) For each MT mi write an expr. C(mi) that is the sum/OR of all PIs that cover it --- the PIs are the variables in this expression. • b) Form a POS expression C that is the product/AND of all C(mi)’s --- this indicates that all MTs need to be covered. • 4. Convert the POS expr. to SOP using the distr. law. Use involution and absorption to simplify ((a*a=a, a+a=a) (a+ab=a))—note that these minimization rules come about in this problem from concepts of non-replication and lower cost than strictly from Boolean algeabra. • Each product term in the SOP expr. represents one possible cover (correct functional expression = sum of the Pis in the product term). • 5. Select the cover with the lowest cost. total # of literals + # of PIs
Minimal solution Cost=8 +3 Cost=9 +3 Absorb PI1+ PI6 PI2+ PI3 PI1+ PI2 PI4+ PI5 PI5+ PI6 PI3+ PI4 PI1PI3PI5+PI2PI4PI6+PI1PI3PI4PI6+PI2PI3PI5PI6+PI1PI2PI4PI5+ PI2PI3PI4PI6+PI1PI2PI4PI6+ PI2PI4 PI5PI6 C=(PI1+PI2PI6)(PI5+PI4PI6)(PI3+PI2PI4) =(PI1PI5+PI1PI4PI6+PI2PI5PI6+PI2PI4PI6)(PI3+PI2 PI4) Petrick’s Algorithm (Contd.) Example 1 X’s
Petrick’s Algorithm (Contd.) • Exercise: Use this algorithm to obtain the least cost cover for the example in which we used the max. MT covering heuristic to get the minimal solution.
Petrick’s Algorithm (Contd.) • Computational complexity of Petrick’s algorithm is very high If m=# of MTs n = # of vars, pi = # of PIs covering MTi, pav = avg # of PIs covering a MT Since MTi=an-1…..a0, a PI covering MTi will have X some positions j. Can choose, say, n/2 X’s with in ways, w/ each way not covering any other way, i.e., each way is a PI covering MTi The time complexity T (in terms of # of time to gen. product terms in C) = m*Pi=1mpi T = O(m*2nm = O(2n*2**n)) Or T = O(m*(pav)m ) = O(m*(pav)2**n)) worst-case # of basic operations to gen. the reqd. product terms in C 1 trillion=240 T=32 trillion trillion trillion operations (in the worst case) If each oper takes 1 ns, time taken can be 295 ~ 32k trillion trillion secs ! (in the worst case)
QM PIT (Covering Stage) Complexity If m=# of MTs n = # of vars, pi = # of PIs covering MTi, pav = avg # of PIs covering a MT, p = total # of PIs • The time taken to determine row covering is O(mp2) (look at all PI pairs—naïve method, and each pair takes O(m) time to determine if there is covering betw. them) • Similarly, O(m2p) for determining column covering relations • If after every row covering, we detect an EPI, or if we detect a col. covering, we reduce # of MTs by at least 1; so we would require m iterations, and thus O(max(m2p2, m3p) time until all MTs are covered. • Or, we do not get any EPIs or col. covering until we do lots of row coverings until finally 1 PI is left that covers all MTs (worst case). This will take p iterations, and thus a total time of O(max(mp3, m2p2)). • So overall complexity (using no appropriate data structures) is O(max(p3m, m2p2, mp3)). • Compare this to O(m*(pav)m) ~ O((p/m)m) for a large enough m, for Petrick’s, and we see that QM is much less complex (m appears as an exponent in Petrick’s as opposed to as the base of a low-order polynomial in QM).
Graphical comparison of Petrick’s and QM’s time complexities • As can be seen, Petrick’s run-time quickly becomes huge and impractical for n > 7, while QM’s is much more reasonable and thus could potentially be used in a CAD tool. • Further, as we have seen, besides the cyclic PIT scenario, QM’s non-optimality stems from the rare (and thus very low probability) case of “bad” row covering (cost(covering PI) > cost(covered PI). Thus on the average, QM produces good (near-optimal) solutions. • Thus overall, QM is a very good and practical algorithm to use for, say, n > 5.