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

Go to the source code of this file.

Functions

static void Mvc_CoverCopyColumn (Mvc_Cover_t *pCoverOld, Mvc_Cover_t *pCoverNew, int iColOld, int iColNew)
 
void Mvc_CoverSupport (Mvc_Cover_t *pCover, Mvc_Cube_t *pSupp)
 FUNCTION DEFINITIONS ///. More...
 
void Mvc_CoverSupportAnd (Mvc_Cover_t *pCover, Mvc_Cube_t *pSupp)
 
int Mvc_CoverSupportSizeBinary (Mvc_Cover_t *pCover)
 
int Mvc_CoverSupportVarBelongs (Mvc_Cover_t *pCover, int iVar)
 
void Mvc_CoverCommonCube (Mvc_Cover_t *pCover, Mvc_Cube_t *pComCube)
 
int Mvc_CoverIsCubeFree (Mvc_Cover_t *pCover)
 
void Mvc_CoverMakeCubeFree (Mvc_Cover_t *pCover)
 
Mvc_Cover_tMvc_CoverCommonCubeCover (Mvc_Cover_t *pCover)
 
int Mvc_CoverCheckSuppContainment (Mvc_Cover_t *pCover1, Mvc_Cover_t *pCover2)
 
int Mvc_CoverSetCubeSizes (Mvc_Cover_t *pCover)
 
int Mvc_CoverGetCubeSize (Mvc_Cube_t *pCube)
 
int Mvc_CoverCountCubePairDiffs (Mvc_Cover_t *pCover, unsigned char pDiffs[])
 
Mvc_Cover_tMvc_CoverRemap (Mvc_Cover_t *p, int *pVarsRem, int nVarsRem)
 
void Mvc_CoverInverse (Mvc_Cover_t *pCover)
 
Mvc_Cover_tMvc_CoverRemoveDontCareLits (Mvc_Cover_t *pCover)
 
Mvc_Cover_tMvc_CoverCofactor (Mvc_Cover_t *p, int iValue, int iValueOther)
 
Mvc_Cover_tMvc_CoverFlipVar (Mvc_Cover_t *p, int iValue0, int iValue1)
 
Mvc_Cover_tMvc_CoverUnivQuantify (Mvc_Cover_t *p, int iValueA0, int iValueA1, int iValueB0, int iValueB1)
 
Mvc_Cover_tMvc_CoverTranspose (Mvc_Cover_t *pCover)
 
int Mvc_UtilsCheckUnusedZeros (Mvc_Cover_t *pCover)
 

Variables

static ABC_NAMESPACE_IMPL_START int bit_count [256]
 DECLARATIONS ///. More...
 

Function Documentation

int Mvc_CoverCheckSuppContainment ( Mvc_Cover_t pCover1,
Mvc_Cover_t pCover2 
)

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

Synopsis [Returns 1 if the support of cover2 is contained in the support of cover1.]

Description []

SideEffects []

SeeAlso []

Definition at line 247 of file mvcUtils.c.

248 {
249  int Result;
250  assert( pCover1->nBits == pCover2->nBits );
251  // set the supports
252  Mvc_CoverAllocateMask( pCover1 );
253  Mvc_CoverSupport( pCover1, pCover1->pMask );
254  Mvc_CoverAllocateMask( pCover2 );
255  Mvc_CoverSupport( pCover2, pCover2->pMask );
256  // check the containment
257  Mvc_CubeBitNotImpl( Result, pCover2->pMask, pCover1->pMask );
258  return !Result;
259 }
#define Mvc_CubeBitNotImpl(Res, Cube1, Cube2)
Definition: mvc.h:429
Mvc_Cube_t * pMask
Definition: mvc.h:92
void Mvc_CoverSupport(Mvc_Cover_t *pCover, Mvc_Cube_t *pSupp)
FUNCTION DEFINITIONS ///.
Definition: mvcUtils.c:58
int nBits
Definition: mvc.h:87
#define assert(ex)
Definition: util_old.h:213
void Mvc_CoverAllocateMask(Mvc_Cover_t *pCover)
Definition: mvcCover.c:168
Mvc_Cover_t* Mvc_CoverCofactor ( Mvc_Cover_t p,
int  iValue,
int  iValueOther 
)

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

Synopsis [Returns the cofactor w.r.t. to a binary var.]

Description []

SideEffects []

SeeAlso []

Definition at line 518 of file mvcUtils.c.

519 {
520  Mvc_Cover_t * pCover;
521  Mvc_Cube_t * pCube, * pCubeCopy;
522  // clone the cover
523  pCover = Mvc_CoverClone( p );
524  // copy the cube list
525  Mvc_CoverForEachCube( p, pCube )
526  if ( Mvc_CubeBitValue( pCube, iValue ) )
527  {
528  pCubeCopy = Mvc_CubeDup( pCover, pCube );
529  Mvc_CoverAddCubeTail( pCover, pCubeCopy );
530  Mvc_CubeBitInsert( pCubeCopy, iValueOther );
531  }
532  return pCover;
533 }
#define Mvc_CoverAddCubeTail(pCover, pCube)
Definition: mvc.h:501
Mvc_Cube_t * Mvc_CubeDup(Mvc_Cover_t *pCover, Mvc_Cube_t *pCube)
Definition: mvcCube.c:94
if(last==0)
Definition: sparse_int.h:34
Mvc_Cover_t * Mvc_CoverClone(Mvc_Cover_t *pCover)
Definition: mvcCover.c:79
#define Mvc_CoverForEachCube(Cover, Cube)
Definition: mvc.h:528
#define Mvc_CubeBitValue(Cube, Bit)
Definition: mvc.h:138
#define Mvc_CubeBitInsert(Cube, Bit)
Definition: mvc.h:139
void Mvc_CoverCommonCube ( Mvc_Cover_t pCover,
Mvc_Cube_t pComCube 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 155 of file mvcUtils.c.

156 {
157  Mvc_Cube_t * pCube;
158  // clean the support
159  Mvc_CubeBitFill( pComCube );
160  // collect the support
161  Mvc_CoverForEachCube( pCover, pCube )
162  Mvc_CubeBitAnd( pComCube, pComCube, pCube );
163 }
#define Mvc_CubeBitAnd(CubeR, Cube1, Cube2)
Definition: mvc.h:405
#define Mvc_CubeBitFill(Cube)
Definition: mvc.h:385
#define Mvc_CoverForEachCube(Cover, Cube)
Definition: mvc.h:528
Mvc_Cover_t* Mvc_CoverCommonCubeCover ( Mvc_Cover_t pCover)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 220 of file mvcUtils.c.

221 {
222  Mvc_Cover_t * pRes;
223  Mvc_Cube_t * pCube;
224  // create the new cover
225  pRes = Mvc_CoverClone( pCover );
226  // get the new cube
227  pCube = Mvc_CubeAlloc( pRes );
228  // get the common cube
229  Mvc_CoverCommonCube( pCover, pCube );
230  // add the cube to the cover
231  Mvc_CoverAddCubeTail( pRes, pCube );
232  return pRes;
233 }
#define Mvc_CoverAddCubeTail(pCover, pCube)
Definition: mvc.h:501
void Mvc_CoverCommonCube(Mvc_Cover_t *pCover, Mvc_Cube_t *pComCube)
Definition: mvcUtils.c:155
Mvc_Cube_t * Mvc_CubeAlloc(Mvc_Cover_t *pCover)
DECLARATIONS ///.
Definition: mvcCube.c:43
Mvc_Cover_t * Mvc_CoverClone(Mvc_Cover_t *pCover)
Definition: mvcCover.c:79
void Mvc_CoverCopyColumn ( Mvc_Cover_t pCoverOld,
Mvc_Cover_t pCoverNew,
int  iColOld,
int  iColNew 
)
static

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

Synopsis [Copies a column from the old cover to the new cover.]

Description [Copies the column (iColOld) of the old cover (pCoverOld) into the column (iColNew) of the new cover (pCoverNew). Assumes that the number of cubes is the same in both covers. Makes no assuptions about the current contents of the column in the new cover.]

SideEffects []

SeeAlso []

Definition at line 440 of file mvcUtils.c.

442 {
443  Mvc_Cube_t * pCubeOld, * pCubeNew;
444  int iWordOld, iWordNew, iBitOld, iBitNew;
445 
446  assert( Mvc_CoverReadCubeNum(pCoverOld) == Mvc_CoverReadCubeNum(pCoverNew) );
447 
448  // get the place of the old and new columns
449  iWordOld = Mvc_CubeWhichWord(iColOld);
450  iBitOld = Mvc_CubeWhichBit(iColOld);
451  iWordNew = Mvc_CubeWhichWord(iColNew);
452  iBitNew = Mvc_CubeWhichBit(iColNew);
453 
454  // go through the cubes of both covers
455  pCubeNew = Mvc_CoverReadCubeHead(pCoverNew);
456  Mvc_CoverForEachCube( pCoverOld, pCubeOld )
457  {
458  if ( pCubeOld->pData[iWordOld] & (1<<iBitOld) )
459  pCubeNew->pData[iWordNew] |= (1<<iBitNew);
460  else
461  pCubeNew->pData[iWordNew] &= ~(1<<iBitNew); // added by wjiang
462  pCubeNew = Mvc_CubeReadNext( pCubeNew );
463  }
464 }
#define Mvc_CubeWhichWord(Bit)
Definition: mvc.h:135
#define Mvc_CubeReadNext(Cube)
MACRO DEFINITIONS ///.
Definition: mvc.h:121
Mvc_CubeWord_t pData[1]
Definition: mvc.h:71
#define Mvc_CubeWhichBit(Bit)
Definition: mvc.h:136
int Mvc_CoverReadCubeNum(Mvc_Cover_t *pCover)
Definition: mvcApi.c:45
#define Mvc_CoverForEachCube(Cover, Cube)
Definition: mvc.h:528
#define assert(ex)
Definition: util_old.h:213
Mvc_Cube_t * Mvc_CoverReadCubeHead(Mvc_Cover_t *pCover)
Definition: mvcApi.c:46
int Mvc_CoverCountCubePairDiffs ( Mvc_Cover_t pCover,
unsigned char  pDiffs[] 
)

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

Synopsis [Counts the differences in each cube pair in the cover.]

Description [Takes the cover (pCover) and the array where the diff counters go (pDiffs). The array pDiffs should have as many entries as there are different pairs of cubes in the cover: n(n-1)/2. Fills out the array pDiffs with the following info: For each cube pair, included in the array is the number of literals in both cubes after they are made cube ABC_FREE.]

SideEffects []

SeeAlso []

Definition at line 342 of file mvcUtils.c.

343 {
344  Mvc_Cube_t * pCube1;
345  Mvc_Cube_t * pCube2;
346  Mvc_Cube_t * pMask;
347  unsigned char * pByte, * pByteStart, * pByteStop;
348  int nBytes, nOnes;
349  int nCubePairs;
350 
351  // allocate a temporary mask
352  pMask = Mvc_CubeAlloc( pCover );
353  // get the number of unsigned chars in the cube's bit strings
354  nBytes = pCover->nBits / (8 * sizeof(unsigned char)) + (int)(pCover->nBits % (8 * sizeof(unsigned char)) > 0);
355  // iterate through the cubes
356  nCubePairs = 0;
357  Mvc_CoverForEachCube( pCover, pCube1 )
358  {
360  {
361  // find the bit-wise exor of cubes
362  Mvc_CubeBitExor( pMask, pCube1, pCube2 );
363  // set the starting and stopping positions
364  pByteStart = (unsigned char *)pMask->pData;
365  pByteStop = pByteStart + nBytes;
366  // clean the counter of ones
367  nOnes = 0;
368  // iterate through the positions
369  for ( pByte = pByteStart; pByte < pByteStop; pByte++ )
370  nOnes += bit_count[*pByte];
371  // set the nOnes
372  pDiffs[nCubePairs++] = nOnes;
373  }
374  }
375  // deallocate the mask
376  Mvc_CubeFree( pCover, pMask );
377  return 1;
378 }
#define Mvc_CubeReadNext(Cube)
MACRO DEFINITIONS ///.
Definition: mvc.h:121
for(p=first;p->value< newval;p=p->next)
Mvc_CubeWord_t pData[1]
Definition: mvc.h:71
Mvc_Cube_t * Mvc_CubeAlloc(Mvc_Cover_t *pCover)
DECLARATIONS ///.
Definition: mvcCube.c:43
#define Mvc_CubeBitExor(CubeR, Cube1, Cube2)
Definition: mvc.h:401
#define Mvc_CoverForEachCube(Cover, Cube)
Definition: mvc.h:528
static ABC_NAMESPACE_IMPL_START int bit_count[256]
DECLARATIONS ///.
Definition: mvcUtils.c:28
int nBits
Definition: mvc.h:87
void Mvc_CubeFree(Mvc_Cover_t *pCover, Mvc_Cube_t *pCube)
Definition: mvcCube.c:114
#define Mvc_CoverForEachCubeStart(Start, Cube)
Definition: mvc.h:542
Mvc_Cover_t* Mvc_CoverFlipVar ( Mvc_Cover_t p,
int  iValue0,
int  iValue1 
)

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

Synopsis [Returns the cover, in which the binary var is complemented.]

Description []

SideEffects []

SeeAlso []

Definition at line 546 of file mvcUtils.c.

547 {
548  Mvc_Cover_t * pCover;
549  Mvc_Cube_t * pCube, * pCubeCopy;
550  int Value0, Value1, Temp;
551 
552  assert( iValue0 + 1 == iValue1 ); // should be adjacent
553 
554  // clone the cover
555  pCover = Mvc_CoverClone( p );
556  // copy the cube list
557  Mvc_CoverForEachCube( p, pCube )
558  {
559  pCubeCopy = Mvc_CubeDup( pCover, pCube );
560  Mvc_CoverAddCubeTail( pCover, pCubeCopy );
561 
562  // get the bits
563  Value0 = Mvc_CubeBitValue( pCubeCopy, iValue0 );
564  Value1 = Mvc_CubeBitValue( pCubeCopy, iValue1 );
565 
566  // if both bits are one, nothing to swap
567  if ( Value0 && Value1 )
568  continue;
569  // cannot be both zero because they belong to the same var
570  assert( Value0 || Value1 );
571 
572  // swap the bits
573  Temp = Value0;
574  Value0 = Value1;
575  Value1 = Temp;
576 
577  // set the bits after the swap
578  if ( Value0 )
579  Mvc_CubeBitInsert( pCubeCopy, iValue0 );
580  else
581  Mvc_CubeBitRemove( pCubeCopy, iValue0 );
582 
583  if ( Value1 )
584  Mvc_CubeBitInsert( pCubeCopy, iValue1 );
585  else
586  Mvc_CubeBitRemove( pCubeCopy, iValue1 );
587  }
588  return pCover;
589 }
#define Mvc_CoverAddCubeTail(pCover, pCube)
Definition: mvc.h:501
Mvc_Cube_t * Mvc_CubeDup(Mvc_Cover_t *pCover, Mvc_Cube_t *pCube)
Definition: mvcCube.c:94
#define Mvc_CubeBitRemove(Cube, Bit)
Definition: mvc.h:140
Mvc_Cover_t * Mvc_CoverClone(Mvc_Cover_t *pCover)
Definition: mvcCover.c:79
#define Mvc_CoverForEachCube(Cover, Cube)
Definition: mvc.h:528
#define Mvc_CubeBitValue(Cube, Bit)
Definition: mvc.h:138
#define assert(ex)
Definition: util_old.h:213
#define Mvc_CubeBitInsert(Cube, Bit)
Definition: mvc.h:139
int Mvc_CoverGetCubeSize ( Mvc_Cube_t pCube)

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

Synopsis [Counts the cube sizes.]

Description []

SideEffects []

SeeAlso []

Definition at line 308 of file mvcUtils.c.

309 {
310  unsigned char * pByte, * pByteStart, * pByteStop;
311  int nOnes, nBytes, nBits;
312  // get the number of unsigned chars in the cube's bit strings
313  nBits = (pCube->iLast + 1) * sizeof(Mvc_CubeWord_t) * 8 - pCube->nUnused;
314  nBytes = nBits / (8 * sizeof(unsigned char)) + (int)(nBits % (8 * sizeof(unsigned char)) > 0);
315  // clean the counter of ones
316  nOnes = 0;
317  // set the starting and stopping positions
318  pByteStart = (unsigned char *)pCube->pData;
319  pByteStop = pByteStart + nBytes;
320  // iterate through the positions
321  for ( pByte = pByteStart; pByte < pByteStop; pByte++ )
322  nOnes += bit_count[*pByte];
323  return nOnes;
324 }
unsigned int Mvc_CubeWord_t
STRUCTURE DEFINITIONS ///.
Definition: mvc.h:55
for(p=first;p->value< newval;p=p->next)
Mvc_CubeWord_t pData[1]
Definition: mvc.h:71
unsigned iLast
Definition: mvc.h:66
unsigned nUnused
Definition: mvc.h:67
static ABC_NAMESPACE_IMPL_START int bit_count[256]
DECLARATIONS ///.
Definition: mvcUtils.c:28
void Mvc_CoverInverse ( Mvc_Cover_t pCover)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 477 of file mvcUtils.c.

478 {
479  Mvc_Cube_t * pCube;
480  // complement the cubes
481  Mvc_CoverForEachCube( pCover, pCube )
482  Mvc_CubeBitNot( pCube );
483 }
#define Mvc_CoverForEachCube(Cover, Cube)
Definition: mvc.h:528
#define Mvc_CubeBitNot(Cube)
Definition: mvc.h:389
int Mvc_CoverIsCubeFree ( Mvc_Cover_t pCover)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 176 of file mvcUtils.c.

177 {
178  int Result;
179  // get the common cube
180  Mvc_CoverAllocateMask( pCover );
181  Mvc_CoverCommonCube( pCover, pCover->pMask );
182  // check whether the common cube is empty
183  Mvc_CubeBitEmpty( Result, pCover->pMask );
184  return Result;
185 }
void Mvc_CoverCommonCube(Mvc_Cover_t *pCover, Mvc_Cube_t *pComCube)
Definition: mvcUtils.c:155
Mvc_Cube_t * pMask
Definition: mvc.h:92
#define Mvc_CubeBitEmpty(Res, Cube)
Definition: mvc.h:413
void Mvc_CoverAllocateMask(Mvc_Cover_t *pCover)
Definition: mvcCover.c:168
void Mvc_CoverMakeCubeFree ( Mvc_Cover_t pCover)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 198 of file mvcUtils.c.

199 {
200  Mvc_Cube_t * pCube;
201  // get the common cube
202  Mvc_CoverAllocateMask( pCover );
203  Mvc_CoverCommonCube( pCover, pCover->pMask );
204  // remove this cube from the cubes in the cover
205  Mvc_CoverForEachCube( pCover, pCube )
206  Mvc_CubeBitSharp( pCube, pCube, pCover->pMask );
207 }
void Mvc_CoverCommonCube(Mvc_Cover_t *pCover, Mvc_Cube_t *pComCube)
Definition: mvcUtils.c:155
Mvc_Cube_t * pMask
Definition: mvc.h:92
#define Mvc_CubeBitSharp(CubeR, Cube1, Cube2)
Definition: mvc.h:409
#define Mvc_CoverForEachCube(Cover, Cube)
Definition: mvc.h:528
void Mvc_CoverAllocateMask(Mvc_Cover_t *pCover)
Definition: mvcCover.c:168
Mvc_Cover_t* Mvc_CoverRemap ( Mvc_Cover_t p,
int *  pVarsRem,
int  nVarsRem 
)

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

Synopsis [Creates a new cover containing some literals of the old cover.]

Description [Creates the new cover containing the given number (nVarsRem) literals of the old cover. All the bits of the new cover are initialized to "1". The selected bits from the old cover are copied on top. The numbers of the selected bits to copy are given in the array pVarsRem. The i-set entry in this array is the index of the bit in the old cover which goes to the i-th place in the new cover. If the i-th entry in pVarsRem is -1, it means that the i-th bit does not change (remains composed of all 1's). This is a useful feature to speed up remapping covers, which are known to depend only on a subset of input variables.]

SideEffects []

SeeAlso []

Definition at line 400 of file mvcUtils.c.

401 {
402  Mvc_Cover_t * pCover;
403  Mvc_Cube_t * pCube, * pCubeCopy;
404  int i;
405  // clone the cover
406  pCover = Mvc_CoverAlloc( p->pMem, nVarsRem );
407  // copy the cube list
408  Mvc_CoverForEachCube( p, pCube )
409  {
410  pCubeCopy = Mvc_CubeAlloc( pCover );
411  //Mvc_CubeBitClean( pCubeCopy ); //changed by wjiang
412  Mvc_CubeBitFill( pCubeCopy ); //changed by wjiang
413  Mvc_CoverAddCubeTail( pCover, pCubeCopy );
414  }
415  // copy the corresponding columns
416  for ( i = 0; i < nVarsRem; i++ )
417  {
418  if (pVarsRem[i] < 0)
419  continue; //added by wjiang
420  assert( pVarsRem[i] >= 0 && pVarsRem[i] < p->nBits );
421  Mvc_CoverCopyColumn( p, pCover, pVarsRem[i], i );
422  }
423  return pCover;
424 }
#define Mvc_CoverAddCubeTail(pCover, pCube)
Definition: mvc.h:501
Mvc_Cube_t * Mvc_CubeAlloc(Mvc_Cover_t *pCover)
DECLARATIONS ///.
Definition: mvcCube.c:43
#define Mvc_CubeBitFill(Cube)
Definition: mvc.h:385
#define Mvc_CoverForEachCube(Cover, Cube)
Definition: mvc.h:528
static void Mvc_CoverCopyColumn(Mvc_Cover_t *pCoverOld, Mvc_Cover_t *pCoverNew, int iColOld, int iColNew)
Definition: mvcUtils.c:440
int nBits
Definition: mvc.h:87
#define assert(ex)
Definition: util_old.h:213
Mvc_Cover_t * Mvc_CoverAlloc(Mvc_Manager_t *pMem, int nBits)
DECLARATIONS ///.
Definition: mvcCover.c:43
Mvc_Manager_t * pMem
Definition: mvc.h:93
Mvc_Cover_t* Mvc_CoverRemoveDontCareLits ( Mvc_Cover_t pCover)

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

Synopsis [This function dups the cover and removes DC literals from cubes.]

Description []

SideEffects []

SeeAlso []

Definition at line 496 of file mvcUtils.c.

497 {
498  Mvc_Cover_t * pCoverNew;
499  Mvc_Cube_t * pCube;
500 
501  pCoverNew = Mvc_CoverDup( pCover );
502  Mvc_CoverForEachCube( pCoverNew, pCube )
503  Mvc_CubeBitRemoveDcs( pCube );
504  return pCoverNew;
505 }
#define Mvc_CoverForEachCube(Cover, Cube)
Definition: mvc.h:528
void Mvc_CubeBitRemoveDcs(Mvc_Cube_t *pCube)
Definition: mvcCube.c:159
Mvc_Cover_t * Mvc_CoverDup(Mvc_Cover_t *pCover)
Definition: mvcCover.c:112
int Mvc_CoverSetCubeSizes ( Mvc_Cover_t pCover)

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

Synopsis [Counts the cube sizes.]

Description []

SideEffects []

SeeAlso []

Definition at line 272 of file mvcUtils.c.

273 {
274  Mvc_Cube_t * pCube;
275  unsigned char * pByte, * pByteStart, * pByteStop;
276  int nBytes, nOnes;
277 
278  // get the number of unsigned chars in the cube's bit strings
279  nBytes = pCover->nBits / (8 * sizeof(unsigned char)) + (int)(pCover->nBits % (8 * sizeof(unsigned char)) > 0);
280  // iterate through the cubes
281  Mvc_CoverForEachCube( pCover, pCube )
282  {
283  // clean the counter of ones
284  nOnes = 0;
285  // set the starting and stopping positions
286  pByteStart = (unsigned char *)pCube->pData;
287  pByteStop = pByteStart + nBytes;
288  // iterate through the positions
289  for ( pByte = pByteStart; pByte < pByteStop; pByte++ )
290  nOnes += bit_count[*pByte];
291  // set the nOnes
292  Mvc_CubeSetSize( pCube, nOnes );
293  }
294  return 1;
295 }
for(p=first;p->value< newval;p=p->next)
Mvc_CubeWord_t pData[1]
Definition: mvc.h:71
#define Mvc_CubeSetSize(Cube, Size)
Definition: mvc.h:128
#define Mvc_CoverForEachCube(Cover, Cube)
Definition: mvc.h:528
static ABC_NAMESPACE_IMPL_START int bit_count[256]
DECLARATIONS ///.
Definition: mvcUtils.c:28
int nBits
Definition: mvc.h:87
void Mvc_CoverSupport ( Mvc_Cover_t pCover,
Mvc_Cube_t pSupp 
)

FUNCTION DEFINITIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 58 of file mvcUtils.c.

59 {
60  Mvc_Cube_t * pCube;
61  // clean the support
62  Mvc_CubeBitClean( pSupp );
63  // collect the support
64  Mvc_CoverForEachCube( pCover, pCube )
65  Mvc_CubeBitOr( pSupp, pSupp, pCube );
66 }
#define Mvc_CubeBitOr(CubeR, Cube1, Cube2)
Definition: mvc.h:397
#define Mvc_CoverForEachCube(Cover, Cube)
Definition: mvc.h:528
#define Mvc_CubeBitClean(Cube)
Definition: mvc.h:381
void Mvc_CoverSupportAnd ( Mvc_Cover_t pCover,
Mvc_Cube_t pSupp 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 79 of file mvcUtils.c.

80 {
81  Mvc_Cube_t * pCube;
82  // clean the support
83  Mvc_CubeBitFill( pSupp );
84  // collect the support
85  Mvc_CoverForEachCube( pCover, pCube )
86  Mvc_CubeBitAnd( pSupp, pSupp, pCube );
87 }
#define Mvc_CubeBitAnd(CubeR, Cube1, Cube2)
Definition: mvc.h:405
#define Mvc_CubeBitFill(Cube)
Definition: mvc.h:385
#define Mvc_CoverForEachCube(Cover, Cube)
Definition: mvc.h:528
int Mvc_CoverSupportSizeBinary ( Mvc_Cover_t pCover)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 100 of file mvcUtils.c.

101 {
102  Mvc_Cube_t * pSupp;
103  int Counter, i, v0, v1;
104  // compute the support
105  pSupp = Mvc_CubeAlloc( pCover );
106  Mvc_CoverSupportAnd( pCover, pSupp );
107  Counter = pCover->nBits/2;
108  for ( i = 0; i < pCover->nBits/2; i++ )
109  {
110  v0 = Mvc_CubeBitValue( pSupp, 2*i );
111  v1 = Mvc_CubeBitValue( pSupp, 2*i+1 );
112  if ( v0 && v1 )
113  Counter--;
114  }
115  Mvc_CubeFree( pCover, pSupp );
116  return Counter;
117 }
void Mvc_CoverSupportAnd(Mvc_Cover_t *pCover, Mvc_Cube_t *pSupp)
Definition: mvcUtils.c:79
Mvc_Cube_t * Mvc_CubeAlloc(Mvc_Cover_t *pCover)
DECLARATIONS ///.
Definition: mvcCube.c:43
static int Counter
#define Mvc_CubeBitValue(Cube, Bit)
Definition: mvc.h:138
int nBits
Definition: mvc.h:87
void Mvc_CubeFree(Mvc_Cover_t *pCover, Mvc_Cube_t *pCube)
Definition: mvcCube.c:114
int Mvc_CoverSupportVarBelongs ( Mvc_Cover_t pCover,
int  iVar 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 130 of file mvcUtils.c.

131 {
132  Mvc_Cube_t * pSupp;
133  int RetValue, v0, v1;
134  // compute the support
135  pSupp = Mvc_CubeAlloc( pCover );
136  Mvc_CoverSupportAnd( pCover, pSupp );
137  v0 = Mvc_CubeBitValue( pSupp, 2*iVar );
138  v1 = Mvc_CubeBitValue( pSupp, 2*iVar+1 );
139  RetValue = (int)( !v0 || !v1 );
140  Mvc_CubeFree( pCover, pSupp );
141  return RetValue;
142 }
void Mvc_CoverSupportAnd(Mvc_Cover_t *pCover, Mvc_Cube_t *pSupp)
Definition: mvcUtils.c:79
Mvc_Cube_t * Mvc_CubeAlloc(Mvc_Cover_t *pCover)
DECLARATIONS ///.
Definition: mvcCube.c:43
#define Mvc_CubeBitValue(Cube, Bit)
Definition: mvc.h:138
void Mvc_CubeFree(Mvc_Cover_t *pCover, Mvc_Cube_t *pCube)
Definition: mvcCube.c:114
Mvc_Cover_t* Mvc_CoverTranspose ( Mvc_Cover_t pCover)

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

Synopsis [Transposes the cube cover.]

Description [Returns the cube cover that looks like a transposed matrix, compared to the matrix derived from the original cover.]

SideEffects []

SeeAlso []

Definition at line 804 of file mvcUtils.c.

805 {
806  Mvc_Cover_t * pRes;
807  Mvc_Cube_t * pCubeRes, * pCube;
808  int nWord, nBit, i, iCube;
809 
810  pRes = Mvc_CoverAlloc( pCover->pMem, Mvc_CoverReadCubeNum(pCover) );
811  for ( i = 0; i < pCover->nBits; i++ )
812  {
813  // get the word and bit of this literal
814  nWord = Mvc_CubeWhichWord(i);
815  nBit = Mvc_CubeWhichBit(i);
816  // get the transposed cube
817  pCubeRes = Mvc_CubeAlloc( pRes );
818  Mvc_CubeBitClean( pCubeRes );
819  iCube = 0;
820  Mvc_CoverForEachCube( pCover, pCube )
821  {
822  if ( pCube->pData[nWord] & (1<<nBit) )
823  Mvc_CubeBitInsert( pCubeRes, iCube );
824  iCube++;
825  }
826  Mvc_CoverAddCubeTail( pRes, pCubeRes );
827  }
828  return pRes;
829 }
#define Mvc_CoverAddCubeTail(pCover, pCube)
Definition: mvc.h:501
#define Mvc_CubeWhichWord(Bit)
Definition: mvc.h:135
Mvc_CubeWord_t pData[1]
Definition: mvc.h:71
Mvc_Cube_t * Mvc_CubeAlloc(Mvc_Cover_t *pCover)
DECLARATIONS ///.
Definition: mvcCube.c:43
#define Mvc_CubeWhichBit(Bit)
Definition: mvc.h:136
int Mvc_CoverReadCubeNum(Mvc_Cover_t *pCover)
Definition: mvcApi.c:45
#define Mvc_CoverForEachCube(Cover, Cube)
Definition: mvc.h:528
int nBits
Definition: mvc.h:87
Mvc_Cover_t * Mvc_CoverAlloc(Mvc_Manager_t *pMem, int nBits)
DECLARATIONS ///.
Definition: mvcCover.c:43
#define Mvc_CubeBitInsert(Cube, Bit)
Definition: mvc.h:139
Mvc_Manager_t * pMem
Definition: mvc.h:93
#define Mvc_CubeBitClean(Cube)
Definition: mvc.h:381
Mvc_Cover_t* Mvc_CoverUnivQuantify ( Mvc_Cover_t p,
int  iValueA0,
int  iValueA1,
int  iValueB0,
int  iValueB1 
)

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

Synopsis [Returns the cover derived by universal quantification.]

Description [Returns the cover computed by universal quantification as follows: CoverNew = Univ(B) [Cover & (A==B)]. Removes the second binary var from the support (given by values iValueB0 and iValueB1). Leaves the first binary variable (given by values iValueA0 and iValueA1) in the support.]

SideEffects []

SeeAlso []

Definition at line 606 of file mvcUtils.c.

608 {
609  Mvc_Cover_t * pCover;
610  Mvc_Cube_t * pCube, * pCubeCopy;
611  int ValueA0, ValueA1, ValueB0, ValueB1;
612 
613  // clone the cover
614  pCover = Mvc_CoverClone( p );
615  // copy the cube list
616  Mvc_CoverForEachCube( p, pCube )
617  {
618  // get the bits
619  ValueA0 = Mvc_CubeBitValue( pCube, iValueA0 );
620  ValueA1 = Mvc_CubeBitValue( pCube, iValueA1 );
621  ValueB0 = Mvc_CubeBitValue( pCube, iValueB0 );
622  ValueB1 = Mvc_CubeBitValue( pCube, iValueB1 );
623 
624  // cannot be both zero because they belong to the same var
625  assert( ValueA0 || ValueA1 );
626  assert( ValueB0 || ValueB1 );
627 
628  // if the values of this var are different, do not add the cube
629  if ( ValueA0 != ValueB0 && ValueA1 != ValueB1 )
630  continue;
631 
632  // create the cube
633  pCubeCopy = Mvc_CubeDup( pCover, pCube );
634  Mvc_CoverAddCubeTail( pCover, pCubeCopy );
635 
636  // insert 1's into for the first var, if both have this value
637  if ( ValueA0 && ValueB0 )
638  Mvc_CubeBitInsert( pCubeCopy, iValueA0 );
639  else
640  Mvc_CubeBitRemove( pCubeCopy, iValueA0 );
641 
642  if ( ValueA1 && ValueB1 )
643  Mvc_CubeBitInsert( pCubeCopy, iValueA1 );
644  else
645  Mvc_CubeBitRemove( pCubeCopy, iValueA1 );
646 
647  // insert 1's into for the second var (the cover does not depend on it)
648  Mvc_CubeBitInsert( pCubeCopy, iValueB0 );
649  Mvc_CubeBitInsert( pCubeCopy, iValueB1 );
650  }
651  return pCover;
652 }
#define Mvc_CoverAddCubeTail(pCover, pCube)
Definition: mvc.h:501
Mvc_Cube_t * Mvc_CubeDup(Mvc_Cover_t *pCover, Mvc_Cube_t *pCube)
Definition: mvcCube.c:94
#define Mvc_CubeBitRemove(Cube, Bit)
Definition: mvc.h:140
Mvc_Cover_t * Mvc_CoverClone(Mvc_Cover_t *pCover)
Definition: mvcCover.c:79
#define Mvc_CoverForEachCube(Cover, Cube)
Definition: mvc.h:528
#define Mvc_CubeBitValue(Cube, Bit)
Definition: mvc.h:138
#define assert(ex)
Definition: util_old.h:213
#define Mvc_CubeBitInsert(Cube, Bit)
Definition: mvc.h:139
int Mvc_UtilsCheckUnusedZeros ( Mvc_Cover_t pCover)

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

Synopsis [Checks that the cubes of the cover have 0's in unused bits.]

Description []

SideEffects []

SeeAlso []

Definition at line 842 of file mvcUtils.c.

843 {
844  unsigned Unsigned;
845  Mvc_Cube_t * pCube;
846  int nCubes;
847 
848  nCubes = 0;
849  Mvc_CoverForEachCube( pCover, pCube )
850  {
851  if ( pCube->nUnused == 0 )
852  continue;
853 
854  Unsigned = ( pCube->pData[pCube->iLast] &
855  (BITS_FULL << (32-pCube->nUnused)) );
856  if( Unsigned )
857  {
858  printf( "Cube %2d out of %2d contains dirty bits.\n", nCubes,
859  Mvc_CoverReadCubeNum(pCover) );
860  }
861  nCubes++;
862  }
863  return 1;
864 }
Mvc_CubeWord_t pData[1]
Definition: mvc.h:71
int Mvc_CoverReadCubeNum(Mvc_Cover_t *pCover)
Definition: mvcApi.c:45
unsigned iLast
Definition: mvc.h:66
unsigned nUnused
Definition: mvc.h:67
#define Mvc_CoverForEachCube(Cover, Cube)
Definition: mvc.h:528
#define BITS_FULL
Definition: mvc.h:45

Variable Documentation

ABC_NAMESPACE_IMPL_START int bit_count[256]
static
Initial value:
= {
0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8
}

DECLARATIONS ///.

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

FileName [mvcUtils.c]

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

Synopsis [Various cover handling utilities.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

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

Revision [

Id:
mvcUtils.c,v 1.7 2003/04/26 20:41:36 alanmi Exp

]

Definition at line 28 of file mvcUtils.c.