abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mvcContain.c File Reference
#include "mvc.h"

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START void 
Mvc_CoverRemoveDuplicates (Mvc_Cover_t *pCover)
 DECLARATIONS ///. More...
 
static void Mvc_CoverRemoveContained (Mvc_Cover_t *pCover)
 
int Mvc_CoverContain (Mvc_Cover_t *pCover)
 FUNCTION DEFINITIONS ///. More...
 

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 47 of file mvcContain.c.

48 {
49  int nCubes;
50  nCubes = Mvc_CoverReadCubeNum( pCover );
51  if ( nCubes < 2 )
52  return 0;
53  Mvc_CoverSetCubeSizes(pCover);
55  Mvc_CoverRemoveDuplicates( pCover );
56  if ( nCubes > 1 )
57  Mvc_CoverRemoveContained( pCover );
58  return (nCubes != Mvc_CoverReadCubeNum(pCover));
59 }
static ABC_NAMESPACE_IMPL_START void Mvc_CoverRemoveDuplicates(Mvc_Cover_t *pCover)
DECLARATIONS ///.
Definition: mvcContain.c:72
int Mvc_CubeCompareSizeAndInt(Mvc_Cube_t *pC1, Mvc_Cube_t *pC2, Mvc_Cube_t *pMask)
Definition: mvcCompare.c:91
int Mvc_CoverReadCubeNum(Mvc_Cover_t *pCover)
Definition: mvcApi.c:45
static void Mvc_CoverRemoveContained(Mvc_Cover_t *pCover)
Definition: mvcContain.c:108
int Mvc_CoverSetCubeSizes(Mvc_Cover_t *pCover)
Definition: mvcUtils.c:272
void Mvc_CoverSort(Mvc_Cover_t *pCover, Mvc_Cube_t *pMask, int(*pCompareFunc)(Mvc_Cube_t *, Mvc_Cube_t *, Mvc_Cube_t *))
FuNCTION DEFINITIONS ///.
Definition: mvcSort.c:47
void Mvc_CoverRemoveContained ( Mvc_Cover_t pCover)
static

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 108 of file mvcContain.c.

109 {
110  Mvc_Cube_t * pCubeBeg, * pCubeEnd, * pCubeLarge;
111  Mvc_Cube_t * pCube, * pCube2, * pPrev;
112  unsigned sizeCur;
113  int Result;
114 
115  // since the cubes are sorted by size, it is sufficient
116  // to compare each cube with other cubes that have larger sizes
117  // if the given cube implies a larger cube, the larger cube is removed
118  pCubeBeg = Mvc_CoverReadCubeHead(pCover);
119  do
120  {
121  // get the current cube size
122  sizeCur = Mvc_CubeReadSize(pCubeBeg);
123 
124  // initialize the end of the given size group
125  pCubeEnd = pCubeBeg;
126  // find the beginning of the next size group
127  Mvc_CoverForEachCubeStart( Mvc_CubeReadNext(pCubeBeg), pCube )
128  {
129  if ( sizeCur == Mvc_CubeReadSize(pCube) )
130  pCubeEnd = pCube;
131  else // pCube is the first cube in the new size group
132  break;
133  }
134  // if we could not find the next size group
135  // the containment check is finished
136  if ( pCube == NULL )
137  break;
138  // otherwise, pCubeBeg/pCubeEnd are the first/last cubes of the group
139 
140  // go through all the cubes between pCubeBeg and pCubeEnd, inclusive,
141  // and for each of them, try removing cubes after pCubeEnd
142  Mvc_CoverForEachCubeStart( pCubeBeg, pCubeLarge )
143  {
144  pPrev = pCubeEnd;
145  Mvc_CoverForEachCubeStartSafe( Mvc_CubeReadNext(pCubeEnd), pCube, pCube2 )
146  {
147  // check containment
148  Mvc_CubeBitNotImpl( Result, pCube, pCubeLarge );
149  if ( !Result )
150  { // pCubeLarge implies pCube - remove pCube
151  Mvc_CoverDeleteCube( pCover, pPrev, pCube );
152  Mvc_CubeFree( pCover, pCube );
153  // don't update the previous cube
154  }
155  else
156  { // update the previous cube
157  pPrev = pCube;
158  }
159  }
160  // quit, if the main cube was the last one of this size
161  if ( pCubeLarge == pCubeEnd )
162  break;
163  }
164 
165  // set the beginning of the next group
166  pCubeBeg = Mvc_CubeReadNext(pCubeEnd);
167  }
168  while ( pCubeBeg );
169 }
#define Mvc_CubeReadNext(Cube)
MACRO DEFINITIONS ///.
Definition: mvc.h:121
#define Mvc_CubeBitNotImpl(Res, Cube1, Cube2)
Definition: mvc.h:429
#define Mvc_CoverDeleteCube(pCover, pPrev, pCube)
Definition: mvc.h:506
void Mvc_CubeFree(Mvc_Cover_t *pCover, Mvc_Cube_t *pCube)
Definition: mvcCube.c:114
#define Mvc_CoverForEachCubeStartSafe(Start, Cube, Cube2)
Definition: mvc.h:546
Mvc_Cube_t * Mvc_CoverReadCubeHead(Mvc_Cover_t *pCover)
Definition: mvcApi.c:46
#define Mvc_CoverForEachCubeStart(Start, Cube)
Definition: mvc.h:542
#define Mvc_CubeReadSize(Cube)
Definition: mvc.h:124
void Mvc_CoverRemoveDuplicates ( Mvc_Cover_t pCover)
static

DECLARATIONS ///.

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

FileName [mvcContain.c]

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

Synopsis [Making the cover single-cube containment ABC_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

]

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 72 of file mvcContain.c.

73 {
74  Mvc_Cube_t * pPrev, * pCube, * pCube2;
75  int fEqual;
76 
77  // set the first cube of the cover
78  pPrev = Mvc_CoverReadCubeHead(pCover);
79  // go through all the cubes after this one
80  Mvc_CoverForEachCubeStartSafe( Mvc_CubeReadNext(pPrev), pCube, pCube2 )
81  {
82  // compare the current cube with the prev cube
83  Mvc_CubeBitEqual( fEqual, pPrev, pCube );
84  if ( fEqual )
85  { // they are equal - remove the current cube
86  Mvc_CoverDeleteCube( pCover, pPrev, pCube );
87  Mvc_CubeFree( pCover, pCube );
88  // don't change the previous cube cube
89  }
90  else
91  { // they are not equal - update the previous cube
92  pPrev = pCube;
93  }
94  }
95 }
#define Mvc_CubeReadNext(Cube)
MACRO DEFINITIONS ///.
Definition: mvc.h:121
#define Mvc_CubeBitEqual(Res, Cube1, Cube2)
Definition: mvc.h:417
#define Mvc_CoverDeleteCube(pCover, pPrev, pCube)
Definition: mvc.h:506
void Mvc_CubeFree(Mvc_Cover_t *pCover, Mvc_Cube_t *pCube)
Definition: mvcCube.c:114
#define Mvc_CoverForEachCubeStartSafe(Start, Cube, Cube2)
Definition: mvc.h:546
Mvc_Cube_t * Mvc_CoverReadCubeHead(Mvc_Cover_t *pCover)
Definition: mvcApi.c:46