src/misc/mvc/mvcContain.c File Reference

#include "mvc.h"
Include dependency graph for mvcContain.c:

Go to the source code of this file.

Functions

static void Mvc_CoverRemoveDuplicates (Mvc_Cover_t *pCover)
static void Mvc_CoverRemoveContained (Mvc_Cover_t *pCover)
int Mvc_CoverContain (Mvc_Cover_t *pCover)

Function Documentation

int Mvc_CoverContain ( Mvc_Cover_t pCover  ) 

FUNCTION DEFINITIONS ///Function*************************************************************

Synopsis [Removes the contained cubes.]

Description [Returns 1 if the cover has been changed.]

SideEffects []

SeeAlso []

Definition at line 44 of file mvcContain.c.

00045 {
00046     int nCubes;
00047     nCubes = Mvc_CoverReadCubeNum( pCover );
00048     if ( nCubes < 2 )
00049         return 0;
00050     Mvc_CoverSetCubeSizes(pCover);
00051     Mvc_CoverSort( pCover, NULL, Mvc_CubeCompareSizeAndInt );
00052     Mvc_CoverRemoveDuplicates( pCover );
00053     if ( nCubes > 1 )
00054         Mvc_CoverRemoveContained( pCover );
00055     return (nCubes != Mvc_CoverReadCubeNum(pCover));
00056 }

void Mvc_CoverRemoveContained ( Mvc_Cover_t pCover  )  [static]

Function*************************************************************

Synopsis [Removes contained cubes from the sorted cube list.]

Description []

SideEffects []

SeeAlso []

Definition at line 105 of file mvcContain.c.

00106 {
00107     Mvc_Cube_t * pCubeBeg, * pCubeEnd, * pCubeLarge;
00108     Mvc_Cube_t * pCube, * pCube2, * pPrev;
00109     unsigned sizeCur;
00110     int  Result;
00111 
00112     // since the cubes are sorted by size, it is sufficient 
00113     // to compare each cube with other cubes that have larger sizes
00114     // if the given cube implies a larger cube, the larger cube is removed
00115     pCubeBeg = Mvc_CoverReadCubeHead(pCover);
00116     do
00117     {
00118         // get the current cube size
00119         sizeCur = Mvc_CubeReadSize(pCubeBeg);
00120 
00121         // initialize the end of the given size group
00122         pCubeEnd = pCubeBeg;
00123         // find the beginning of the next size group
00124         Mvc_CoverForEachCubeStart( Mvc_CubeReadNext(pCubeBeg), pCube )
00125         {
00126             if ( sizeCur == Mvc_CubeReadSize(pCube) ) 
00127                 pCubeEnd = pCube;
00128             else // pCube is the first cube in the new size group
00129                 break;
00130         }
00131         // if we could not find the next size group
00132         // the containment check is finished
00133         if ( pCube == NULL )
00134             break;
00135         // otherwise, pCubeBeg/pCubeEnd are the first/last cubes of the group
00136 
00137         // go through all the cubes between pCubeBeg and pCubeEnd, inclusive,
00138         // and for each of them, try removing cubes after pCubeEnd
00139         Mvc_CoverForEachCubeStart( pCubeBeg, pCubeLarge )
00140         {
00141             pPrev = pCubeEnd;
00142             Mvc_CoverForEachCubeStartSafe( Mvc_CubeReadNext(pCubeEnd), pCube, pCube2 )
00143             {
00144                 // check containment
00145                 Mvc_CubeBitNotImpl( Result, pCube, pCubeLarge );
00146                 if ( !Result )
00147                 { // pCubeLarge implies pCube - remove pCube
00148                     Mvc_CoverDeleteCube( pCover, pPrev, pCube );
00149                     Mvc_CubeFree( pCover, pCube );
00150                     // don't update the previous cube
00151                 }
00152                 else
00153                 {   // update the previous cube
00154                     pPrev = pCube;
00155                 }
00156             }
00157             // quit, if the main cube was the last one of this size
00158             if ( pCubeLarge == pCubeEnd )
00159                 break;
00160         }
00161 
00162         // set the beginning of the next group
00163         pCubeBeg = Mvc_CubeReadNext(pCubeEnd);
00164     }
00165     while ( pCubeBeg );
00166 }

void Mvc_CoverRemoveDuplicates ( Mvc_Cover_t pCover  )  [static]

CFile****************************************************************

FileName [mvcContain.c]

PackageName [MVSIS 2.0: Multi-valued logic synthesis system.]

Synopsis [Making the cover single-cube containment free.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - February 1, 2003.]

Revision [

Id
mvcContain.c,v 1.4 2003/04/03 23:25:42 alanmi Exp

] DECLARATIONS ///

Function*************************************************************

Synopsis [Removes adjacent duplicated cubes from the cube list.]

Description []

SideEffects []

SeeAlso []

Definition at line 69 of file mvcContain.c.

00070 {
00071     Mvc_Cube_t * pPrev, * pCube, * pCube2;
00072     int  fEqual;
00073 
00074     // set the first cube of the cover
00075     pPrev = Mvc_CoverReadCubeHead(pCover);
00076     // go through all the cubes after this one
00077     Mvc_CoverForEachCubeStartSafe( Mvc_CubeReadNext(pPrev), pCube, pCube2 )
00078     {
00079         // compare the current cube with the prev cube
00080         Mvc_CubeBitEqual( fEqual, pPrev, pCube );
00081         if ( fEqual )
00082         { // they are equal - remove the current cube
00083             Mvc_CoverDeleteCube( pCover, pPrev, pCube );
00084             Mvc_CubeFree( pCover, pCube );
00085             // don't change the previous cube cube
00086         }
00087         else
00088         { // they are not equal - update the previous cube
00089             pPrev = pCube;
00090         }
00091     }
00092 }


Generated on Tue Jan 5 12:19:16 2010 for abc70930 by  doxygen 1.6.1