Cubical CAMP

download Cubical CAMP

of 6

Transcript of Cubical CAMP

  • 8/13/2019 Cubical CAMP

    1/6

    Cubical CAMP for Minimization of Boolean FunctionsNripendra N. Biswas C. Srikanth* James [email protected] [email protected] com [email protected] in

    Department of Electrical Communication EngineeringIndian Institute of Science

    Bangalore 560 012 India

    AbstractThe paper present s QC AM P a cube-based al-gor i thm for minimizat ion of single Boolean func-tions. Th e algorithm does not generate all the p r i m ecubes no r does it require the Off-set of the func-tion. Tw o significant contributions of Q C A M P aret he UN AT E- TE ST which te s t s i f a given funct ion isunaie funct ion .and the BIS EC T procedure whichminimizes a cyclic fun ctio n without taking recourse t obranching. A well known property of a unate func-tion is that the prime cubes subsuming a unate func-tion are all- essential pr im e cubes. Hence as soon asa f unc t ion passes the U NA TE -TE ST all i t s pr imecubes are recognized as solution cubes without any fur -ther processing. Many special fun ctio ns such as boththe On and Off-sets of Achilles heel functions whichE S P R E S S O 11 f inds hard to minimize are also unatefun ction s. Consequently as will be evident f r o m thecomputational results QCAMP exhibits far better per-formance compared to E S P R E S S O I I in all such andman y other funct ion s .

    1 IntroductionThe impo rtance of single function minimization al-gorithms is well known, since it forms the most basicand important ingredient of multiple outpu t minimiza-tion, a valuable tool in the design of VLSI circuits.However, VLSI technology demands that an algorithmshould be capable of handling a very large number ofinpu t variables. Thi s shift of emphasis from small ormedium to very large number of variables has madethe minterm based algorithms virtually obsolete in aVLSI environment. To respond to this new and chal-lenging situation many cube based algorithms havebeen developed[1,2,3,4]. Most of these evolve aroundtwo schools of philosophy. The Quine McClusky[5]school generates all prime cubes, which proves to bevery expensive in some situations. ESPRESS0[4]school generates the Off-set of the function. Thi salso renders the algorithm very inefficient in manycases. For example, although the On-set of a 30-variable Achilles heel function has only 10 c,ubes, its

    *During the course of this work C. Sr ihi th was a post grad-uate student in the Department of Electrical CoiimiwiicatioiiEiigg. of the hidiaii Institute of Science, Bangalore. He is iiowwith Motorola India Electroilics Limited MIEL), The Senate,33-A, Ulsoor Road, Bangalore-560 042 India.

    1063-9667/95 04.00Q 1995 IEEE

    Off-set has 59049 cubes. Hence even to minimizeonly these 10 cubes of the On-set, ESPRESSO I hasto spend considerable time in simply generating the59049 cubes of the Off-set. The third school of phi-losophy, namely that of the CAMP algorithm[6,7,8,9]avoids both these undesirable features. In this paperwe describe QCAMP, a cubical minimization proce-dure based on the CAMP philosophy.2 Ternary Notations and Cubical Op-

    erationsBefore we present the a lgorithm, the ternary nota-tions and cubical operations extensively used in thepaper may be explained. We assume that some of thebasic terms of logic design and switching theory, suchasminterm , product t erm, sum of product (S0P) form,minimum sum of product MSOP) form, conjunctiveothers are already familiar to the reader. In this pa-per a product term will be represented in the ternarynotation of 0, 1 and 2 where 0 represents a variable inthe complemented form, 1 in the true form, and 2 in-dicates the absence of the variable. For example, the4 variable function, f i ab bcd abcd acd willbe written as

    and disjunctive canonical rm (CCF and DCF) and

    f i 0122 2101 1010 1211Each product term is called a cube. The dimensionof a cube gives the number of variables absent in theproduct term which the cube represents. A mintermis a cube of dimension 0 and is therefore called a 0-cube. The cube 0122 representing ab has a dimension2, and is therefore a 2-cube. Note that the dimensionof a cube is given by the number of 2s. Also notethat a cube of dimension CY of an n-variable function isobtained by combining 2a minterms of the n-variablefunction. Again an a-cube of an n-variable function(0 5 a 5 n) is a product term of (n a number ofvariables.Definition 2.1 The distance between two cubes isthe number of bit positions where one cube has a 0(1)and the other a l(0).Thus the distance between 0122 and 2101 of thefunction f l given above is 0, whereas that between2101 and 1010 is 3 .Definition 2.2 Two cubes are said to be zntersectzngwith each other if the distance between them is 0.

    2649th International Conference on VLSI Design -January 996

  • 8/13/2019 Cubical CAMP

    2/6

    Definition 2.3 Two cubes are said to be adjacentwith each other if the distance between them is 1.Thus the cube 1211 is adjacent t o all the three othercubes of the function f i . To visualize the intersectionand adjacency of cubes pictorially, plot the four vari-able function on a Karnaugh map. A detailed discus-sion of these and the cubical operation sharp can befound in [9,10].In this paper, we shall also define the prime cubesin three categories as has been done in [9].Definition 2.4 If among the minterms subsuminga prime cube, there is at least one that is covered bythis and only this prime cube, then the prime cube iscalled an essentzal przme cube (EPC).The subcube of an EPC t ha t is covered by thisand only this prime cube is called a Dzstznguzshedrube. The minterms subsuming a distinguished cubeare called distinguished minterms.Definition 2.5 If each of the minterms subsuming aprime cube is covered by other essential prime cubes,then the prime cube is called a redundant przirie cube(RPC),Definition 2.6 : A prime cube which is neither es-sential nor redundant is called a selectzve przirie cubeAmong the minterms subsuming such a prime cubethere is at least one that is covered neither by an EPCnor by this and only this prime cube. Therefore theexistence of one SPC implies the existence of another.We now proceed to present the QCAMP algorithm.The algorithm has three phases. (1) The essentialprime cube or EPC phase; (2) The selective primecube or SPC phase and 3) The dont care or DCphase.

    3 The EPC Phase

    (SPC).

    In this phase all the EPCs of the given function areselected and stored in the solution cube matrix, SCM.The given function is input in two matrices. In thefirst, denoted as the the true cube matrix TCM , all thetrue cubes are written in the ternary notation. In theother, denoted as the dont care matrix DCM, only thedont care cubes are written in the ternary notation.The variables are written in decimal numbers 1,2 , andso on in the 0th row of the matrix, whereas the 0thcolumn has the serial number of the cubes. In the EPCphase, only the TCM is considered. Before processingthe T CM, it is checked whether the switching functionis unate.Definition 3.1 If, in the minimum-sum-of-productsform of a switching function, each variable appears inits true form or its complemented form, but not boththen the function is called a m a t e functzon[9] .3.1 The UNATE-TESTFirst the TCM is subjected to the UNATE-TEST.If the function passes the test then it is a unate func-tion and all the input cubes are put in the solutioncube matrix SCM, without any further processing.This is based on the following theorem[9].Theorem 3.1.1 A Switching function is unate if andonly if it can be expressed as a sum of prime cubes,all intersecting at a common subcube. Furthermore,all the prime cubes are essential prime cubes.

    The proof of the theorem can be found in Sec 3.10of [9].The UNATE-TEST is very simple and inexpensive.The TCM is scanned columnwise, starting from thefirst column. If there are only 1s or Os (ignoring 2s),but not both, in each of the columns then the func-tion is unate. This test effectively checks whether eachvariable of the function is appearing only in its trueor complemented form. Let us consider the 6-variablefunctionf = 220220 202220 022220 220202 202202+022202 220022 202022 022022

    The TCM for this switching function is as shown inTable 1 . The 0-th row of Table 1 gives the variablesin decimal numbers, and the 0-th column gives theserial number of cubes also in decimal number. If theUNATE-TEST is applied to this T CM, it will pass thetest and all the 9 cubes will be stored in the SCM asEPCs.If a function fails to pass the UNATE-TEST thenthe input cubes are made to grow into adjacentcubes as much as possible, and the derived matrixis called the Prime Cube Matrix (PCM Now theUNATE-TEST is applied again to the PtM. This isbecause the input function may not be initially ex-pressed as a sum of prime cubes. After expansion allthe cubes are prime cubes. If the function is unateit will pass the test at this stage, and all the primecubes are essential prime cubes and will be stored inthe SCM. Let us now consider a non-unate switching

    Table 1: A 6 variable unate function0 1 1 2 3 4 5 6

    2 2 0 2 2 02 0 2 2 2 00 2 2 2 2 02 2 0 2 0 22 0 2 2 0 20 2 2 2 0 22 2 0 0 2 22 0 2 0 2 20 2 2 0 2 2

    function having 5 cubesf3 = 0002 1020 2201 1112 0211

    This will obviously fail the IJNATE-TEST. Now thecubes are made to grow into the adjacent cubes. Thenew cube matrix having all the cubes in the fully ex-panded form consists only of prime cubes, and there-fore becomes the prime cube matrix PCM. The PCMof f3 is shown in Fig. l ( b ) . Note the important factth at two prime cubes 2121 and 1210 which will be gen-erated in the QM Quine McCluskey) algor ithm haveOff-set of the function. Now the UNATE-TEST is ap-plied to the PCM. It fails the test again indicat ing thatnot been generate here. Nor have we generated the

    265

  • 8/13/2019 Cubical CAMP

    3/6

    it is not a unate function. Now, each cube is subjectedto the EPCLTEST. If the result of the EPC-TEST ispositive, then the cube is an EP C, and is stored in thesolution cube matrix SCM.3.2 The EPC-TESTEach fully expanded cube of the PCM (Fig. l(b))is now subjected to the essential prime cube test,EPC-TEST. For this a matrix called adjacent and in-tersecting cube matr ix AIM, having all cubes whichare adjacent to or intersecting with the cube undertest is formed. From this another matrix called testmatrix T M is derived. T M is obtained from AIM bydeleting all the columns headed by Os and Is of thecube under test. The TM therefore, has CY number ofcolumns and m rows, where a is the dimension of thecube under test Ct, and m is the number of rows ofits AIM. The T M is therefore a cube matrix havingm cubes of N variables. It can be shown that thesecubes are those subcubes of Ct which can be coveredby other cubes of the function.

    T M

    00 2 22 1 1020 2 02 2201 10 0f o o x l l Z l 0 i 01 211 1 1

    2201 10201112 1112022100 2020 1 0

    11 11

    . .0211 1112(400 01 11 10

    00011110

    00011110

    b)00 01 11 10

    Figure 1: (a) Input CM of f3 (b) PCM (c) EPCs andSharped SPCs (d) Selected and expanded SPCs

    Table 2: THE EPC-TEST TABLESCube Under Test 0221 2201

    AIM 2002 I 2002

    expands toall-2 cubeE P C ?

    to the all-2 cube, then there is at least one subcube(which may be a 0-cube or a minterm) which is coveredby Ct and only Ct. Hence C, is an EPC. Table 2 givesthe EPC-TEST tables for the cubes 0221 and 2201.We see that the cube 0221 passes the EPC-TESTwhile 2201 fails the tes t. Among the other cubes of thePCM, cube 2002 will pass the EPC-TEST, whereascubes 1020 and 1112 will fail the EPC-TEST. Thusafter the EPC-TEST, all EPCs will be identified, andthe rest of the cubes will be either RPCs or SPCs TheEPCs are stored in the solution cube matrix SCM. TheEPC phase ends here and the SPC phase begins.

    The SPC Phase4.1 Iterative Mode EPC-SPC Proce-

    If at the end of the EPC phase, all cubes turnout to be EPCs then the algorithm terminates. If onthe other hand some or all cubes remain as RPCs orSPCs, then SP C phase begins. Now the EPCs storedin the SCM sharp the remaining cubes of the PCM.The sharped cubes for our example are shown as thethree unshaded cubes of Fig. l(c) . Note that after thisfirst sharp operation, all RPCs, if any, get eliminated.These sharped cubes (unshaded in Fig. l ( c ) ) are nowtreated as a new CM and also processed as a new CM.After the EPC phase of the new CM, in our exampletwo EPCs (shown dotted in Fig. l(c)) 1121 and 1210are formed. These are then made to expand into theentire function. As a result, the cube 1121 expands tocube 2121. The cube 1210 does not expand. N o cubeof the new CM is left out after the new EPCs are se-lected. Hence, the algorithm terminates, giving twoEPCs and two SPCs as solution cubes in the SCMThus, the function f3 after minimization becomes,

    dure

    f3 0221 2002 2121 1210If at any time of the iterative mode of the SPCphase the new CM does not generate an EPC, then thecubes of the new CM are only SPCs, and the functionis a cyclic function. Then the cyclic mode of the SPCphase begins.

    Hence if the cubes of TM can combine and expand toform the all-2 cube, then all the minterms of Ct canbe covered by other prime cubes and Ct cannot be anEPC. On the other hand if the T M does not expand

    266

  • 8/13/2019 Cubical CAMP

    4/6

    Table 3: BISECT ALGORITHM122 cc 2 21 c, 221 c, 12 2 c, 122 c,12 2 12 2 12 2 ca2 122 ca3 2 21 ca41 22 1 22 cbX 122 2 21 221221 221 Cal 2 21 221 12 2221 c?bl 122

    4.2 The Cyclic Mode BISECT Proce-Whenever any CM, either the input CM or any in-termediate CM in the iterative mode does not gener-ate even a single EPC, then this CM is that of a cyclicfunction. QCAMP then goes into the cyclic mode,and the BISECT procedure is invoked.Let us explain the procedure by working out thesolution of the following cyclic function plotted inFigure 2(a).

    dure

    f4 = 0122 1202 1022 2210 0221The function f4 has 5 prime cubes with no redundantcube. Let the processing st ar t from cube 1. Part (a)of Table 3 is the input CM. It goes through severalmodifications until i t comes to the minimum solutionform as given in part (e) of Table 3. The steps ofBISECT procedure are follows.First set up two count variables, acount (adjacentcount) and ecount (bisect and expand count). Initial-ize each of them to O.Take the first cube of the CM asthe cube under consideration. Call it C,. The algo-rithm for the BISECT procedure is as follows:

    1. Search in other cubes in serial order for a cube Cbwhich gets bisected by C,.2. If C, gets a Cb check if the half of Cb which is out-side C, is included wholly in one or more cubes of

    the function. If yes, then delete Cb, and continuesearch for another b for C,.3. If the half of cb which is outside C, is not in-cluded wholly, then expand this half of Cb in thefunction. Call the expanded cube Delete Cb(denoted by x in Table 3) .4 Move the cubes below c up. Place C; as the lastcube of the CM, and C, as the first cube of theCM.

    This completes one cycle of operations. Now, in themodified CM, C, which is the first cube becomes theC,, and the procedure repeats. Sometimes the outsidehalf of a Cb may not be able to expand in the function.In this case cube C, abandons this Cb and Cb is keptIf at any time c, does not get a Cb, it s tart s searchingfor a cube Ca that is adjacent to C,. A C, that doesnot get a Ca and then a Ce will surely get a Ca. henit gets a Ca, the acount is incremented and ecountis reset to 0. Similarly when a C, gets a C e ecountundisturbed in the CM) and searches r another Cb

    is incremented and acoent is reset to 0 (the currentvalue of the counts are shown after Ca and Cb in Table3). Whenever any one of the two counts equals thenumber of cubes in the CM, the procedure terminates,and the cubes of the CM becomes the solution cubes.When a C, gets a Ca the C a becomes the first cubeof the CM, and therefore, C, of the next cycle. Cubesbelow C a are moved up, and cube C, is placed as thelast cube of the CM. The cycle repeats itself, untilthe final SCM is obtained. To summarize, in eachcycle the C first tries to get a Cb and then a ce. nfailure, it gets a C a . In each cycle either the acountis incremented and ecount is reset to 0, or vice-versa.When one of the counts equals the number of cubes ofCM, the procedure terminates and the CM becomesthe SCM. Both at the beginning and end of BISECT,redundant cubes if any, are removed. Table 3 (a) to (e)show the 5 cycles of the BISECT algorithm to producethe 4 cube solution of the function f4

    f4 0122 2021 2210 f 1202

    00 01 11 10 00 01 11 10

    a) Input CM of f4 having 5 cubes (b) Bisectsolutionigure 2:o f4 having 4 cubes

    The DC PhaseBefore coming to the DC phase, the true cubes

    of the function are fully minimized, and the solutioncubes are stored in the solution cube matrix SCM.Now, the cubes of the SCM are made to expand andcombine further in the cubes of the don't care matrixDCM. Some of the cubes of the SCM may not expand.A new matri x is now formed having the expanded true

    267

  • 8/13/2019 Cubical CAMP

    5/6

    cubes, and is called XCM. Another matrix called in-cluded cube matrix ICM, having those true cubes ofS(:M which have expanded, is also formed. Considerthe function,

    The function as plotted on the Karnaugh map is alsoshown in Fig. 3(a). If an included cube IC is coveredby an expanded cube XC only partly and not fullythen the IC is split into subcubes, so tha t each subcubeis now covered fully, by an XC. Each subcube of a splitIC; is treated as a separate IC and is also stored as suchin the ICM.In XCM the XCs are arranged in ascending order oftheir dimensions. Another matrix called cover matrixCWM is now derived from the XCM and the ICM.Each row of the CVM represents an XC of the XCMand each column of the CVM represents an IC. CVMalso has an extra row and an extra column. The extrarow has the weights of each column, whereas the extracolumn has the weights of each row, where weight isdefined as follows:

    Definition 5 1 The number of 1s of a row (col-umn) will be called it s weight.All the solution cubes of the function are found byprocessing the CVM. While processing we will haveto delete some of the XCs and ICs. The weights ofeach row and column of the CVM are now computedand placed in the extra column and row of the CVM.Now, first search for a column having weight 1. Sucha column will be called a one weight colunin OWC. Ifan OWC exists, then select the XC of the row havingthe singleton 1 of the OWC as a solution cube. Deletethis row and also the ICs covered by this XC.

    00 01 11 10 00 01 11 1000011110

    Figure 3: (a) Input CM of f5 with the dont cares. (b)Final Solution of func,tion f5.Now, delete the selected row and the ICs coveredby the XC. If no OWC is found, then find the rowhaving the least weight. Such a row will be called al ea s t wezght row LWR. Search for a LWR starting fromthe first row of the table. Delete the first LWR found.Then compute the weights of the rows and columns

    once again. This gives a new table Search for OWC ,and repeat this procedure qintil all the rows of thetable are deleted. For the function f5 the CVM goesthrough 7 iterations, and yields two solution cubes.Thus fs minimizes tofs 2121 0022

    also shown in Figure 3(b).6 Special Functions

    There are some special functions which ESPRESSOI1 finds unreasonable and therefore hard to mini-mize. Achilles heel function is a good example of suchfunctions[4]. It is defined asf Xlx223 2425x6 x3k 2~3k lx3kwhere k. is any positive integerThis function is unate, has 3k variables, and itsminimum cover has k cubes. However, its complement

    has a minimum cover of 3k cubes.The 6-variable unate function shown in Table 1 isin fact the Off-set of a 6-variable (k = 2) Achillesheel function. The last property of Achilles heel func-tions (the Off-set having a minimum cover of 3k cubes)poses problem to ESPRESSO I1 since it has to gen-erate the complement of the function. QCAMP doesnot have this problem. However, a very helpful char-acteristics of the function, which apparently has notbeen utilized by ESPRESSO I is its unateness. Since,the function, and therefore also its complement areunate, once it is expressed as a sum of prime cubes,all the prime cubes will be EPCs due to Theorem 3.1 .1The computational results shown in Table 4 shows be-yond doubt the effectiveness of UNATE-TEST. Thefact that QCAMP is faster than ESPRESSO I forthe Achilles heel functions shows that UNATE-TESThas not been incorporated in the latte r. It will be agood thing if UNATE-TEST is incorporated in all theminimization algorithms.Another class of functions which we have calledODS$one diagonal short ) functions has all mintermsof the unction except a pair of opposite minterms.(Such a pair of opposite minterms constitute a diag-onal in an n-dimensional hypercube). An ODS func-tion of n variables is a cyclic function having moretha n one solution of n cubes. The BISECT algo-rithm of QCAMP handles the function as efficiently asESPRESSO 11. Figure 2(a) and (b) show a 4-variableODS function.7 Computational ResultsThe Table 4 compares the CPU time taken byESPRESSO I and QCAMP by running various func-tions on both the algorithms.8 Conclusion

    Apart from presenting a very efficient and eco-nomical algorithm for minimization of Boolean func-tions, the algorithm presents for the first time theIJNATE-TEST and a new way of handling cyclic func-tions in the BISECT procedure which does not re-quire branching , inasmuch as the processing maystart from any cube to obtain most of the time one

    268

  • 8/13/2019 Cubical CAMP

    6/6

    T a b l e 4: C o m p u t a t i o n R e s u l t s

    810111281243729

    2187128256512102420487

    FunctionName

    .8 < .I8.7 < .131.7 < .I103.5 < . 1.2 .I2.2 .622.0 6.9200.0 65.0

    .I < . 1.6 .22.2 58.4 2.032.7 8.1.2 1

    Achilles heel(On-set )

    91112

    Achilles heel(Off-set)

    9 1.1 .711 11.6 10.612 47.4 45.5

    X O R

    ODS

    Inpu tFile21,724,830,lO3 3 , l l36,12

    12,8115,24318,72921,2187

    8,1289,25610,51211,1024

    12,20487,129,1611,18

    i, n

    12,22

    No. of cubes CPU Secin S o h . on IBM RS 6000/580

    810111281243729

    2187128256512102420487

    number of input cubes

    of t h e m i n i m u m v al id so l u ti o n s. T h e U N A T E - T E S Ti s v er y i n e x p e n s i v e b u t i s e x t r e m e l y p o w e r f ul i n h a n -d l i n g even t h e O f f -se t o f A ch i ll e s hee l f un c t i o ns w h ichE S P R E S S O TI f i nd s h a r d to m i n im i z e . W e r e c o m m e n dt ha t U N A T E - T E S T b e i n co r p o r at e d i n E S P R E S S O11 a n d f o r t h a t m a t t e r , i n a l l B o ol e a n f u n c t i o n m in i -mizat o n a l g o r i t h m s .Acknowledgment- T h e a u t h o r s w i sh to r e c o r d t h e i ra p p r e c i a t i o n f o r t h e f a c u l ty a n d staff o f t h e S u p e r c o m -p u t e r E d u c a t i o n a n d R e s ea r ch C e n t r e , E R N E T a n dPROTOCOL l a b o r a t o r i e s of t h e ECE D e p a r t m e n t , o ft h e I n d i a n I n s t i t u t e o f S c ie n c e , B a n g a l o re , f o r e x t e n d -ing a l l f a c il i ti e s a n d c o o p e r a t i o n d u r i n g t h e p r o g r e s sof this w ork .References[l] S.J. Hong, R.G. Cain, D.L. Ostapko. MINI: A Hueris-tic approach for Logic MinimizationJBBM J Res . Dev .Vol. 18,September 1974, pages 443-458.[2] B. Gurunath, and N.N. Biswas. An Algorithm forMultiple Output Minimization. ZEEE Trans. Conaput.-Aided Design Vol. CAD-8, No. 9, September 1989,

    pages 1007-1013.[3] M.R. Dagenais, V.K. Agarwal, and N.C. Rumin. Mc-BOOLE: A New Procedure for Exact Logic Minimiza-tion. IEEE Trans. Contput.-Aaded Design Vol. CAD-5,No. 1, Jan uar y 1986, pages 229-238.

    [4] R.K. B rayton, G.D. Hach tel, C.T. McMullen, andA. L. Sangiovanni-Viucentelli, Logic Minimization Al-gor i t hm s for V L S I Synthesis, Kluwer Academic Pub-lishers, Boston, 1984.[ ] E.J. McCluskey. Minimization of Boolean func-tions.Bell Syst . Tech. Journal Vol. 35, No. 11, Novem-

    ber 1956, pages 1417-1444.[6] N N Biswas. Computer Aided Minimization Procedurefor Boolean functions. Proc. l l s t Des ign Auton ta tion

    Conference Albuquerque, N.Mex. , June 1984, pages[7] N.N. Biswas. Computer Aided Minimization Procedurefor Boolean funct ions . IEEE Trans Com p. A ided De-sign of Integrated Circuits and Systems Vol. CAD-5,No. 2, April 1986, pages 303-304.[8] N.N. Biswas. On Covering Distant Minterms by the

    C A M P A lgor i thm . IEE E Trans Comp. A ided Des ignof Integrated Circuits and System s Vol. CAD-9, No. 7,July 1990, pages 786-789.

    [9] N.N. Biswas. Logic Design Theory. Prent ice Hall, En-glewood Cliffs, NJ, 1993.[ lo] D.L. Dietmeyer. Logic Design of Digital Systems. 2ndedition, Allyn and Bacon, Boston, MA, 1978.

    699-702.

    269