abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
covInt.h File Reference
#include "base/abc/abc.h"

Go to the source code of this file.

Data Structures

struct  Min_Man_t_
 
struct  Min_Cube_t_
 

Macros

#define Min_CoverForEachCube(pCover, pCube)
 
#define Min_CoverForEachCubeSafe(pCover, pCube, pCube2)
 
#define Min_CoverForEachCubePrev(pCover, pCube, ppPrev)
 

Typedefs

typedef
typedefABC_NAMESPACE_HEADER_START
struct Min_Man_t_ 
Min_Man_t
 DECLARATIONS ///. More...
 
typedef struct Min_Cube_t_ Min_Cube_t
 

Functions

static int Min_CubeHasBit (Min_Cube_t *p, int i)
 
static void Min_CubeSetBit (Min_Cube_t *p, int i)
 
static void Min_CubeXorBit (Min_Cube_t *p, int i)
 
static int Min_CubeGetVar (Min_Cube_t *p, int Var)
 
static void Min_CubeXorVar (Min_Cube_t *p, int Var, int Value)
 
void Min_EsopMinimize (Min_Man_t *p)
 FUNCTION DEFINITIONS ///. More...
 
void Min_EsopAddCube (Min_Man_t *p, Min_Cube_t *pCube)
 
void Min_SopMinimize (Min_Man_t *p)
 FUNCTION DEFINITIONS ///. More...
 
void Min_SopAddCube (Min_Man_t *p, Min_Cube_t *pCube)
 
Min_Man_tMin_ManAlloc (int nVars)
 DECLARATIONS ///. More...
 
void Min_ManClean (Min_Man_t *p, int nSupp)
 
void Min_ManFree (Min_Man_t *p)
 
void Min_CoverCreate (Vec_Str_t *vCover, Min_Cube_t *pCover, char Type)
 
void Min_CubeWrite (FILE *pFile, Min_Cube_t *pCube)
 
void Min_CoverWrite (FILE *pFile, Min_Cube_t *pCover)
 
void Min_CoverWriteStore (FILE *pFile, Min_Man_t *p)
 
void Min_CoverWriteFile (Min_Cube_t *pCover, char *pName, int fEsop)
 
void Min_CoverCheck (Min_Man_t *p)
 
int Min_CubeCheck (Min_Cube_t *pCube)
 
Min_Cube_tMin_CoverCollect (Min_Man_t *p, int nSuppSize)
 
void Min_CoverExpand (Min_Man_t *p, Min_Cube_t *pCover)
 
int Min_CoverSuppVarNum (Min_Man_t *p, Min_Cube_t *pCover)
 
static Min_Cube_tMin_CubeAlloc (Min_Man_t *p)
 FUNCTION DEFINITIONS ///. More...
 
static Min_Cube_tMin_CubeAllocVar (Min_Man_t *p, int iVar, int fCompl)
 
static Min_Cube_tMin_CubeDup (Min_Man_t *p, Min_Cube_t *pCopy)
 
static void Min_CubeRecycle (Min_Man_t *p, Min_Cube_t *pCube)
 
static void Min_CoverRecycle (Min_Man_t *p, Min_Cube_t *pCover)
 
static int Min_CubeCountLits (Min_Cube_t *pCube)
 
static void Min_CubeGetLits (Min_Cube_t *pCube, Vec_Int_t *vLits)
 
static int Min_CoverCountCubes (Min_Cube_t *pCover)
 
static int Min_CubesDisjoint (Min_Cube_t *pCube0, Min_Cube_t *pCube1)
 
static void Min_CoverGetDisjVars (Min_Cube_t *pThis, Min_Cube_t *pCube, Vec_Int_t *vVars)
 
static int Min_CubesDistOne (Min_Cube_t *pCube0, Min_Cube_t *pCube1, Min_Cube_t *pTemp)
 
static int Min_CubesDistTwo (Min_Cube_t *pCube0, Min_Cube_t *pCube1, int *pVar0, int *pVar1)
 
static Min_Cube_tMin_CubesProduct (Min_Man_t *p, Min_Cube_t *pCube0, Min_Cube_t *pCube1)
 
static Min_Cube_tMin_CubesXor (Min_Man_t *p, Min_Cube_t *pCube0, Min_Cube_t *pCube1)
 
static int Min_CubesAreEqual (Min_Cube_t *pCube0, Min_Cube_t *pCube1)
 
static int Min_CubeIsContained (Min_Cube_t *pCube0, Min_Cube_t *pCube1)
 
static void Min_CubesTransform (Min_Cube_t *pCube, Min_Cube_t *pDist, Min_Cube_t *pMask)
 
static void Min_CubesTransformOr (Min_Cube_t *pCube, Min_Cube_t *pDist)
 
static void Min_CoverExpandRemoveEqual (Min_Man_t *p, Min_Cube_t *pCover)
 
static int Min_CoverContainsCube (Min_Man_t *p, Min_Cube_t *pCube)
 

Macro Definition Documentation

#define Min_CoverForEachCube (   pCover,
  pCube 
)
Value:
for ( pCube = pCover; \
pCube; \
pCube = pCube->pNext )

Definition at line 65 of file covInt.h.

#define Min_CoverForEachCubePrev (   pCover,
  pCube,
  ppPrev 
)
Value:
for ( pCube = pCover, \
ppPrev = &(pCover); \
pCube; \
ppPrev = &pCube->pNext, \
pCube = pCube->pNext )

Definition at line 75 of file covInt.h.

#define Min_CoverForEachCubeSafe (   pCover,
  pCube,
  pCube2 
)
Value:
for ( pCube = pCover, \
pCube2 = pCube? pCube->pNext: NULL; \
pCube; \
pCube = pCube2, \
pCube2 = pCube? pCube->pNext: NULL )

Definition at line 69 of file covInt.h.

Typedef Documentation

typedef struct Min_Cube_t_ Min_Cube_t

Definition at line 35 of file covInt.h.

typedef typedefABC_NAMESPACE_HEADER_START struct Min_Man_t_ Min_Man_t

DECLARATIONS ///.

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

FileName [covInt.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Mapping into network of SOPs/ESOPs.]

Synopsis [Internal declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
covInt.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 34 of file covInt.h.

Function Documentation

void Min_CoverCheck ( Min_Man_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 223 of file covMinUtil.c.

224 {
225  Min_Cube_t * pCube;
226  int i;
227  for ( i = 0; i <= p->nVars; i++ )
228  Min_CoverForEachCube( p->ppStore[i], pCube )
229  assert( i == (int)pCube->nLits );
230 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned nLits
Definition: covInt.h:59
#define Min_CoverForEachCube(pCover, pCube)
Definition: covInt.h:65
#define assert(ex)
Definition: util_old.h:213
int nVars
Definition: llb3Image.c:58
Min_Cube_t* Min_CoverCollect ( Min_Man_t p,
int  nSuppSize 
)

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

Synopsis [Converts the cover from the sorted structure.]

Description []

SideEffects []

SeeAlso []

Definition at line 264 of file covMinUtil.c.

265 {
266  Min_Cube_t * pCov = NULL, ** ppTail = &pCov;
267  Min_Cube_t * pCube, * pCube2;
268  int i;
269  for ( i = 0; i <= nSuppSize; i++ )
270  {
271  Min_CoverForEachCubeSafe( p->ppStore[i], pCube, pCube2 )
272  {
273  assert( i == (int)pCube->nLits );
274  *ppTail = pCube;
275  ppTail = &pCube->pNext;
276  assert( pCube->uData[0] ); // not a bubble
277  }
278  }
279  *ppTail = NULL;
280  return pCov;
281 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Min_Cube_t * pNext
Definition: covInt.h:56
#define Min_CoverForEachCubeSafe(pCover, pCube, pCube2)
Definition: covInt.h:69
unsigned nLits
Definition: covInt.h:59
#define assert(ex)
Definition: util_old.h:213
unsigned uData[1]
Definition: covInt.h:60
static int Min_CoverContainsCube ( Min_Man_t p,
Min_Cube_t pCube 
)
inlinestatic

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

Synopsis [Returns 1 if the given cube is contained in one of the cubes of the cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 620 of file covInt.h.

621 {
622  Min_Cube_t * pThis;
623  int i;
624 /*
625  // this cube cannot be equal to any cube
626  Min_CoverForEachCube( p->ppStore[pCube->nLits], pThis )
627  {
628  if ( Min_CubesAreEqual( pCube, pThis ) )
629  {
630  Min_CubeWrite( stdout, pCube );
631  assert( 0 );
632  }
633  }
634 */
635  // try to find a containing cube
636  for ( i = 0; i <= (int)pCube->nLits; i++ )
637  Min_CoverForEachCube( p->ppStore[i], pThis )
638  {
639  // skip the bubble
640  if ( pThis != p->pBubble && Min_CubeIsContained( pThis, pCube ) )
641  return 1;
642  }
643  return 0;
644 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Min_CubeIsContained(Min_Cube_t *pCube0, Min_Cube_t *pCube1)
Definition: covInt.h:522
unsigned nLits
Definition: covInt.h:59
#define Min_CoverForEachCube(pCover, pCube)
Definition: covInt.h:65
static int Min_CoverCountCubes ( Min_Cube_t pCover)
inlinestatic

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

Synopsis [Counts the number of cubes in the cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 274 of file covInt.h.

275 {
276  Min_Cube_t * pCube;
277  int Count = 0;
278  Min_CoverForEachCube( pCover, pCube )
279  Count++;
280  return Count;
281 }
#define Min_CoverForEachCube(pCover, pCube)
Definition: covInt.h:65
void Min_CoverCreate ( Vec_Str_t vCover,
Min_Cube_t pCover,
char  Type 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 85 of file covMinUtil.c.

86 {
87  Min_Cube_t * pCube;
88  assert( pCover != NULL );
89  Vec_StrClear( vCover );
90  Min_CoverForEachCube( pCover, pCube )
91  Min_CubeCreate( vCover, pCube, Type );
92  Vec_StrPush( vCover, 0 );
93 }
static void Vec_StrClear(Vec_Str_t *p)
Definition: vecStr.h:519
static void Vec_StrPush(Vec_Str_t *p, char Entry)
Definition: vecStr.h:535
ABC_NAMESPACE_IMPL_START void Min_CubeCreate(Vec_Str_t *vCover, Min_Cube_t *pCube, char Type)
DECLARATIONS ///.
Definition: covMinUtil.c:45
#define Min_CoverForEachCube(pCover, pCube)
Definition: covInt.h:65
#define assert(ex)
Definition: util_old.h:213
void Min_CoverExpand ( Min_Man_t p,
Min_Cube_t pCover 
)

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

Synopsis [Sorts the cover in the increasing number of literals.]

Description []

SideEffects []

SeeAlso []

Definition at line 294 of file covMinUtil.c.

295 {
296  Min_Cube_t * pCube, * pCube2;
297  Min_ManClean( p, p->nVars );
298  Min_CoverForEachCubeSafe( pCover, pCube, pCube2 )
299  {
300  pCube->pNext = p->ppStore[pCube->nLits];
301  p->ppStore[pCube->nLits] = pCube;
302  p->nCubes++;
303  }
304 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Min_Cube_t * pNext
Definition: covInt.h:56
#define Min_CoverForEachCubeSafe(pCover, pCube, pCube2)
Definition: covInt.h:69
unsigned nLits
Definition: covInt.h:59
void Min_ManClean(Min_Man_t *p, int nSupp)
Definition: covMinMan.c:83
int nVars
Definition: llb3Image.c:58
static void Min_CoverExpandRemoveEqual ( Min_Man_t p,
Min_Cube_t pCover 
)
inlinestatic

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

Synopsis [Sorts the cover in the increasing number of literals.]

Description []

SideEffects []

SeeAlso []

Definition at line 583 of file covInt.h.

584 {
585  Min_Cube_t * pCube, * pCube2, * pThis;
586  if ( pCover == NULL )
587  {
588  Min_ManClean( p, p->nVars );
589  return;
590  }
591  Min_ManClean( p, pCover->nVars );
592  Min_CoverForEachCubeSafe( pCover, pCube, pCube2 )
593  {
594  // go through the linked list
595  Min_CoverForEachCube( p->ppStore[pCube->nLits], pThis )
596  if ( Min_CubesAreEqual( pCube, pThis ) )
597  {
598  Min_CubeRecycle( p, pCube );
599  break;
600  }
601  if ( pThis != NULL )
602  continue;
603  pCube->pNext = p->ppStore[pCube->nLits];
604  p->ppStore[pCube->nLits] = pCube;
605  p->nCubes++;
606  }
607 }
static void Min_CubeRecycle(Min_Man_t *p, Min_Cube_t *pCube)
Definition: covInt.h:189
unsigned nVars
Definition: covInt.h:57
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Min_Cube_t * pNext
Definition: covInt.h:56
#define Min_CoverForEachCubeSafe(pCover, pCube, pCube2)
Definition: covInt.h:69
if(last==0)
Definition: sparse_int.h:34
unsigned nLits
Definition: covInt.h:59
static int Min_CubesAreEqual(Min_Cube_t *pCube0, Min_Cube_t *pCube1)
Definition: covInt.h:502
#define Min_CoverForEachCube(pCover, pCube)
Definition: covInt.h:65
void Min_ManClean(Min_Man_t *p, int nSupp)
Definition: covMinMan.c:83
int nVars
Definition: llb3Image.c:58
static void Min_CoverGetDisjVars ( Min_Cube_t pThis,
Min_Cube_t pCube,
Vec_Int_t vVars 
)
inlinestatic

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

Synopsis [Collects the disjoint variables of the two cubes.]

Description []

SideEffects []

SeeAlso []

Definition at line 321 of file covInt.h.

322 {
323  unsigned uData;
324  int i, w;
325  Vec_IntClear( vVars );
326  for ( w = 0; w < (int)pCube->nWords; w++ )
327  {
328  uData = pThis->uData[w] & (pThis->uData[w] >> 1) & 0x55555555;
329  uData &= (pCube->uData[w] ^ (pCube->uData[w] >> 1));
330  if ( uData == 0 )
331  continue;
332  for ( i = 0; i < 32; i += 2 )
333  if ( uData & (1 << i) )
334  Vec_IntPush( vVars, w*16 + i/2 );
335  }
336 }
unsigned nWords
Definition: covInt.h:58
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
unsigned uData[1]
Definition: covInt.h:60
static void Min_CoverRecycle ( Min_Man_t p,
Min_Cube_t pCover 
)
inlinestatic

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

Synopsis [Recycles the cube cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 205 of file covInt.h.

206 {
207  Min_Cube_t * pCube, * pCube2;
208  Min_CoverForEachCubeSafe( pCover, pCube, pCube2 )
209  Extra_MmFixedEntryRecycle( p->pMemMan, (char *)pCube );
210 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Min_CoverForEachCubeSafe(pCover, pCube, pCube2)
Definition: covInt.h:69
void Extra_MmFixedEntryRecycle(Extra_MmFixed_t *p, char *pEntry)
int Min_CoverSuppVarNum ( Min_Man_t p,
Min_Cube_t pCover 
)

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

Synopsis [Sorts the cover in the increasing number of literals.]

Description []

SideEffects []

SeeAlso []

Definition at line 317 of file covMinUtil.c.

318 {
319  Min_Cube_t * pCube;
320  int i, Counter;
321  if ( pCover == NULL )
322  return 0;
323  // clean the cube
324  for ( i = 0; i < (int)pCover->nWords; i++ )
325  p->pTemp->uData[i] = ~((unsigned)0);
326  // add the bit data
327  Min_CoverForEachCube( pCover, pCube )
328  for ( i = 0; i < (int)pCover->nWords; i++ )
329  p->pTemp->uData[i] &= pCube->uData[i];
330  // count the vars
331  Counter = 0;
332  for ( i = 0; i < (int)pCover->nVars; i++ )
333  Counter += ( Min_CubeGetVar(p->pTemp, i) != 3 );
334  return Counter;
335 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int nWords
Definition: abcNpn.c:127
for(p=first;p->value< newval;p=p->next)
static int Min_CubeGetVar(Min_Cube_t *p, int Var)
Definition: covInt.h:86
unsigned nWords
Definition: covInt.h:58
static int Counter
#define Min_CoverForEachCube(pCover, pCube)
Definition: covInt.h:65
void Min_CoverWrite ( FILE *  pFile,
Min_Cube_t pCover 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 140 of file covMinUtil.c.

141 {
142  Min_Cube_t * pCube;
143  Min_CoverForEachCube( pCover, pCube )
144  Min_CubeWrite( pFile, pCube );
145  printf( "\n" );
146 }
void Min_CubeWrite(FILE *pFile, Min_Cube_t *pCube)
Definition: covMinUtil.c:106
#define Min_CoverForEachCube(pCover, pCube)
Definition: covInt.h:65
void Min_CoverWriteFile ( Min_Cube_t pCover,
char *  pName,
int  fEsop 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 190 of file covMinUtil.c.

191 {
192  char Buffer[1000];
193  Min_Cube_t * pCube;
194  FILE * pFile;
195  int i;
196  sprintf( Buffer, "%s.%s", pName, fEsop? "esop" : "pla" );
197  for ( i = strlen(Buffer) - 1; i >= 0; i-- )
198  if ( Buffer[i] == '<' || Buffer[i] == '>' )
199  Buffer[i] = '_';
200  pFile = fopen( Buffer, "w" );
201  fprintf( pFile, "# %s cover for output %s generated by ABC on %s\n", fEsop? "ESOP":"SOP", pName, Extra_TimeStamp() );
202  fprintf( pFile, ".i %d\n", pCover? pCover->nVars : 0 );
203  fprintf( pFile, ".o %d\n", 1 );
204  fprintf( pFile, ".p %d\n", Min_CoverCountCubes(pCover) );
205  if ( fEsop ) fprintf( pFile, ".type esop\n" );
206  Min_CoverForEachCube( pCover, pCube )
207  Min_CubeWrite( pFile, pCube );
208  fprintf( pFile, ".e\n" );
209  fclose( pFile );
210 }
unsigned nVars
Definition: covInt.h:57
void Min_CubeWrite(FILE *pFile, Min_Cube_t *pCube)
Definition: covMinUtil.c:106
static int Min_CoverCountCubes(Min_Cube_t *pCover)
Definition: covInt.h:274
char * sprintf()
#define Min_CoverForEachCube(pCover, pCube)
Definition: covInt.h:65
char * Extra_TimeStamp()
int strlen()
void Min_CoverWriteStore ( FILE *  pFile,
Min_Man_t p 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 159 of file covMinUtil.c.

160 {
161  Min_Cube_t * pCube;
162  int i;
163  for ( i = 0; i <= p->nVars; i++ )
164  {
165  Min_CoverForEachCube( p->ppStore[i], pCube )
166  {
167  printf( "%2d : ", i );
168  if ( pCube == p->pBubble )
169  {
170  printf( "Bubble\n" );
171  continue;
172  }
173  Min_CubeWrite( pFile, pCube );
174  }
175  }
176  printf( "\n" );
177 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Min_CubeWrite(FILE *pFile, Min_Cube_t *pCube)
Definition: covMinUtil.c:106
#define Min_CoverForEachCube(pCover, pCube)
Definition: covInt.h:65
int nVars
Definition: llb3Image.c:58
static Min_Cube_t* Min_CubeAlloc ( Min_Man_t p)
inlinestatic

FUNCTION DEFINITIONS ///.

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

Synopsis [Creates the cube.]

Description []

SideEffects []

SeeAlso []

Definition at line 126 of file covInt.h.

127 {
128  Min_Cube_t * pCube;
129  pCube = (Min_Cube_t *)Extra_MmFixedEntryFetch( p->pMemMan );
130  pCube->pNext = NULL;
131  pCube->nVars = p->nVars;
132  pCube->nWords = p->nWords;
133  pCube->nLits = 0;
134  memset( pCube->uData, 0xff, sizeof(unsigned) * p->nWords );
135  return pCube;
136 }
char * memset()
unsigned nVars
Definition: covInt.h:57
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Min_Cube_t * pNext
Definition: covInt.h:56
char * Extra_MmFixedEntryFetch(Extra_MmFixed_t *p)
unsigned nWords
Definition: covInt.h:58
unsigned nLits
Definition: covInt.h:59
unsigned uData[1]
Definition: covInt.h:60
int nVars
Definition: llb3Image.c:58
static Min_Cube_t* Min_CubeAllocVar ( Min_Man_t p,
int  iVar,
int  fCompl 
)
inlinestatic

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

Synopsis [Creates the cube representing elementary var.]

Description []

SideEffects []

SeeAlso []

Definition at line 149 of file covInt.h.

150 {
151  Min_Cube_t * pCube;
152  pCube = Min_CubeAlloc( p );
153  Min_CubeXorBit( pCube, iVar*2+fCompl );
154  pCube->nLits = 1;
155  return pCube;
156 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned nLits
Definition: covInt.h:59
static void Min_CubeXorBit(Min_Cube_t *p, int i)
Definition: covInt.h:85
static Min_Cube_t * Min_CubeAlloc(Min_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition: covInt.h:126
int Min_CubeCheck ( Min_Cube_t pCube)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 244 of file covMinUtil.c.

245 {
246  int i;
247  for ( i = 0; i < (int)pCube->nVars; i++ )
248  if ( Min_CubeGetVar( pCube, i ) == 0 )
249  return 0;
250  return 1;
251 }
unsigned nVars
Definition: covInt.h:57
static int Min_CubeGetVar(Min_Cube_t *p, int Var)
Definition: covInt.h:86
static int Min_CubeCountLits ( Min_Cube_t pCube)
inlinestatic

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

Synopsis [Counts the number of cubes in the cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 224 of file covInt.h.

225 {
226  unsigned uData;
227  int Count = 0, i, w;
228  for ( w = 0; w < (int)pCube->nWords; w++ )
229  {
230  uData = pCube->uData[w] ^ (pCube->uData[w] >> 1);
231  for ( i = 0; i < 32; i += 2 )
232  if ( uData & (1 << i) )
233  Count++;
234  }
235  return Count;
236 }
unsigned nWords
Definition: covInt.h:58
unsigned uData[1]
Definition: covInt.h:60
static Min_Cube_t* Min_CubeDup ( Min_Man_t p,
Min_Cube_t pCopy 
)
inlinestatic

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

Synopsis [Creates the cube.]

Description []

SideEffects []

SeeAlso []

Definition at line 169 of file covInt.h.

170 {
171  Min_Cube_t * pCube;
172  pCube = Min_CubeAlloc( p );
173  memcpy( pCube->uData, pCopy->uData, sizeof(unsigned) * p->nWords );
174  pCube->nLits = pCopy->nLits;
175  return pCube;
176 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
char * memcpy()
unsigned nLits
Definition: covInt.h:59
static Min_Cube_t * Min_CubeAlloc(Min_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition: covInt.h:126
unsigned uData[1]
Definition: covInt.h:60
static void Min_CubeGetLits ( Min_Cube_t pCube,
Vec_Int_t vLits 
)
inlinestatic

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

Synopsis [Counts the number of cubes in the cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 249 of file covInt.h.

250 {
251  unsigned uData;
252  int i, w;
253  Vec_IntClear( vLits );
254  for ( w = 0; w < (int)pCube->nWords; w++ )
255  {
256  uData = pCube->uData[w] ^ (pCube->uData[w] >> 1);
257  for ( i = 0; i < 32; i += 2 )
258  if ( uData & (1 << i) )
259  Vec_IntPush( vLits, w*16 + i/2 );
260  }
261 }
unsigned nWords
Definition: covInt.h:58
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
unsigned uData[1]
Definition: covInt.h:60
static int Min_CubeGetVar ( Min_Cube_t p,
int  Var 
)
inlinestatic

Definition at line 86 of file covInt.h.

86 { return 3 & (p->uData[(2*Var)>>5] >> ((2*Var) & 31)); }
int Var
Definition: SolverTypes.h:42
unsigned uData[1]
Definition: covInt.h:60
static int Min_CubeHasBit ( Min_Cube_t p,
int  i 
)
inlinestatic

Definition at line 83 of file covInt.h.

83 { return (p->uData[(i)>>5] & (1<<((i) & 31))) > 0; }
unsigned uData[1]
Definition: covInt.h:60
static int Min_CubeIsContained ( Min_Cube_t pCube0,
Min_Cube_t pCube1 
)
inlinestatic

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

Synopsis [Returns 1 if pCube1 is contained in pCube0, bitwise.]

Description []

SideEffects []

SeeAlso []

Definition at line 522 of file covInt.h.

523 {
524  int i;
525  for ( i = 0; i < (int)pCube0->nWords; i++ )
526  if ( (pCube0->uData[i] & pCube1->uData[i]) != pCube1->uData[i] )
527  return 0;
528  return 1;
529 }
unsigned nWords
Definition: covInt.h:58
unsigned uData[1]
Definition: covInt.h:60
static void Min_CubeRecycle ( Min_Man_t p,
Min_Cube_t pCube 
)
inlinestatic

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

Synopsis [Recycles the cube.]

Description []

SideEffects []

SeeAlso []

Definition at line 189 of file covInt.h.

190 {
191  Extra_MmFixedEntryRecycle( p->pMemMan, (char *)pCube );
192 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Extra_MmFixedEntryRecycle(Extra_MmFixed_t *p, char *pEntry)
static int Min_CubesAreEqual ( Min_Cube_t pCube0,
Min_Cube_t pCube1 
)
inlinestatic

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

Synopsis [Makes the produce of two cubes.]

Description []

SideEffects []

SeeAlso []

Definition at line 502 of file covInt.h.

503 {
504  int i;
505  for ( i = 0; i < (int)pCube0->nWords; i++ )
506  if ( pCube0->uData[i] != pCube1->uData[i] )
507  return 0;
508  return 1;
509 }
unsigned nWords
Definition: covInt.h:58
unsigned uData[1]
Definition: covInt.h:60
static int Min_CubesDisjoint ( Min_Cube_t pCube0,
Min_Cube_t pCube1 
)
inlinestatic

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

Synopsis [Checks if two cubes are disjoint.]

Description []

SideEffects []

SeeAlso []

Definition at line 295 of file covInt.h.

296 {
297  unsigned uData;
298  int i;
299  assert( pCube0->nVars == pCube1->nVars );
300  for ( i = 0; i < (int)pCube0->nWords; i++ )
301  {
302  uData = pCube0->uData[i] & pCube1->uData[i];
303  uData = (uData | (uData >> 1)) & 0x55555555;
304  if ( uData != 0x55555555 )
305  return 1;
306  }
307  return 0;
308 }
unsigned nVars
Definition: covInt.h:57
unsigned nWords
Definition: covInt.h:58
#define assert(ex)
Definition: util_old.h:213
unsigned uData[1]
Definition: covInt.h:60
static int Min_CubesDistOne ( Min_Cube_t pCube0,
Min_Cube_t pCube1,
Min_Cube_t pTemp 
)
inlinestatic

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

Synopsis [Checks if two cubes are disjoint.]

Description []

SideEffects []

SeeAlso []

Definition at line 349 of file covInt.h.

350 {
351  unsigned uData;
352  int i, fFound = 0;
353  for ( i = 0; i < (int)pCube0->nWords; i++ )
354  {
355  uData = pCube0->uData[i] ^ pCube1->uData[i];
356  if ( uData == 0 )
357  {
358  if ( pTemp ) pTemp->uData[i] = 0;
359  continue;
360  }
361  if ( fFound )
362  return 0;
363  uData = (uData | (uData >> 1)) & 0x55555555;
364  if ( (uData & (uData-1)) > 0 ) // more than one 1
365  return 0;
366  if ( pTemp ) pTemp->uData[i] = uData | (uData << 1);
367  fFound = 1;
368  }
369  if ( fFound == 0 )
370  {
371  printf( "\n" );
372  Min_CubeWrite( stdout, pCube0 );
373  Min_CubeWrite( stdout, pCube1 );
374  printf( "Error: Min_CubesDistOne() looks at two equal cubes!\n" );
375  }
376  return 1;
377 }
void Min_CubeWrite(FILE *pFile, Min_Cube_t *pCube)
Definition: covMinUtil.c:106
unsigned nWords
Definition: covInt.h:58
unsigned uData[1]
Definition: covInt.h:60
static int Min_CubesDistTwo ( Min_Cube_t pCube0,
Min_Cube_t pCube1,
int *  pVar0,
int *  pVar1 
)
inlinestatic

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

Synopsis [Checks if two cubes are disjoint.]

Description []

SideEffects []

SeeAlso []

Definition at line 390 of file covInt.h.

391 {
392  unsigned uData;//, uData2;
393  int i, k, Var0 = -1, Var1 = -1;
394  for ( i = 0; i < (int)pCube0->nWords; i++ )
395  {
396  uData = pCube0->uData[i] ^ pCube1->uData[i];
397  if ( uData == 0 )
398  continue;
399  if ( Var0 >= 0 && Var1 >= 0 ) // more than two 1s
400  return 0;
401  uData = (uData | (uData >> 1)) & 0x55555555;
402  if ( (Var0 >= 0 || Var1 >= 0) && (uData & (uData-1)) > 0 )
403  return 0;
404  for ( k = 0; k < 32; k += 2 )
405  if ( uData & (1 << k) )
406  {
407  if ( Var0 == -1 )
408  Var0 = 16 * i + k/2;
409  else if ( Var1 == -1 )
410  Var1 = 16 * i + k/2;
411  else
412  return 0;
413  }
414  /*
415  if ( Var0 >= 0 )
416  {
417  uData &= 0xFFFF;
418  uData2 = (uData >> 16);
419  if ( uData && uData2 )
420  return 0;
421  if ( uData )
422  {
423  }
424  uData }= uData2;
425  uData &= 0x
426  }
427  */
428  }
429  if ( Var0 >= 0 && Var1 >= 0 )
430  {
431  *pVar0 = Var0;
432  *pVar1 = Var1;
433  return 1;
434  }
435  if ( Var0 == -1 || Var1 == -1 )
436  {
437  printf( "\n" );
438  Min_CubeWrite( stdout, pCube0 );
439  Min_CubeWrite( stdout, pCube1 );
440  printf( "Error: Min_CubesDistTwo() looks at two equal cubes or dist1 cubes!\n" );
441  }
442  return 0;
443 }
void Min_CubeWrite(FILE *pFile, Min_Cube_t *pCube)
Definition: covMinUtil.c:106
unsigned nWords
Definition: covInt.h:58
unsigned uData[1]
Definition: covInt.h:60
static void Min_CubeSetBit ( Min_Cube_t p,
int  i 
)
inlinestatic

Definition at line 84 of file covInt.h.

84 { p->uData[(i)>>5] |= (1<<((i) & 31)); }
unsigned uData[1]
Definition: covInt.h:60
static Min_Cube_t* Min_CubesProduct ( Min_Man_t p,
Min_Cube_t pCube0,
Min_Cube_t pCube1 
)
inlinestatic

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

Synopsis [Makes the produce of two cubes.]

Description []

SideEffects []

SeeAlso []

Definition at line 456 of file covInt.h.

457 {
458  Min_Cube_t * pCube;
459  int i;
460  assert( pCube0->nVars == pCube1->nVars );
461  pCube = Min_CubeAlloc( p );
462  for ( i = 0; i < p->nWords; i++ )
463  pCube->uData[i] = pCube0->uData[i] & pCube1->uData[i];
464  pCube->nLits = Min_CubeCountLits( pCube );
465  return pCube;
466 }
unsigned nVars
Definition: covInt.h:57
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Min_CubeCountLits(Min_Cube_t *pCube)
Definition: covInt.h:224
unsigned nLits
Definition: covInt.h:59
static Min_Cube_t * Min_CubeAlloc(Min_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition: covInt.h:126
#define assert(ex)
Definition: util_old.h:213
unsigned uData[1]
Definition: covInt.h:60
static void Min_CubesTransform ( Min_Cube_t pCube,
Min_Cube_t pDist,
Min_Cube_t pMask 
)
inlinestatic

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

Synopsis [Transforms the cube into the result of merging.]

Description []

SideEffects []

SeeAlso []

Definition at line 542 of file covInt.h.

543 {
544  int w;
545  for ( w = 0; w < (int)pCube->nWords; w++ )
546  {
547  pCube->uData[w] = pCube->uData[w] ^ pDist->uData[w];
548  pCube->uData[w] |= (pDist->uData[w] & ~pMask->uData[w]);
549  }
550 }
unsigned nWords
Definition: covInt.h:58
unsigned uData[1]
Definition: covInt.h:60
static void Min_CubesTransformOr ( Min_Cube_t pCube,
Min_Cube_t pDist 
)
inlinestatic

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

Synopsis [Transforms the cube into the result of distance-1 merging.]

Description []

SideEffects []

SeeAlso []

Definition at line 563 of file covInt.h.

564 {
565  int w;
566  for ( w = 0; w < (int)pCube->nWords; w++ )
567  pCube->uData[w] |= pDist->uData[w];
568 }
unsigned nWords
Definition: covInt.h:58
unsigned uData[1]
Definition: covInt.h:60
static Min_Cube_t* Min_CubesXor ( Min_Man_t p,
Min_Cube_t pCube0,
Min_Cube_t pCube1 
)
inlinestatic

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

Synopsis [Makes the produce of two cubes.]

Description []

SideEffects []

SeeAlso []

Definition at line 479 of file covInt.h.

480 {
481  Min_Cube_t * pCube;
482  int i;
483  assert( pCube0->nVars == pCube1->nVars );
484  pCube = Min_CubeAlloc( p );
485  for ( i = 0; i < p->nWords; i++ )
486  pCube->uData[i] = pCube0->uData[i] ^ pCube1->uData[i];
487  pCube->nLits = Min_CubeCountLits( pCube );
488  return pCube;
489 }
unsigned nVars
Definition: covInt.h:57
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Min_CubeCountLits(Min_Cube_t *pCube)
Definition: covInt.h:224
unsigned nLits
Definition: covInt.h:59
static Min_Cube_t * Min_CubeAlloc(Min_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition: covInt.h:126
#define assert(ex)
Definition: util_old.h:213
unsigned uData[1]
Definition: covInt.h:60
void Min_CubeWrite ( FILE *  pFile,
Min_Cube_t pCube 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 106 of file covMinUtil.c.

107 {
108  int i;
109  assert( (int)pCube->nLits == Min_CubeCountLits(pCube) );
110  for ( i = 0; i < (int)pCube->nVars; i++ )
111  if ( Min_CubeHasBit(pCube, i*2) )
112  {
113  if ( Min_CubeHasBit(pCube, i*2+1) )
114  fprintf( pFile, "-" );
115  else
116  fprintf( pFile, "0" );
117  }
118  else
119  {
120  if ( Min_CubeHasBit(pCube, i*2+1) )
121  fprintf( pFile, "1" );
122  else
123  fprintf( pFile, "?" );
124  }
125  fprintf( pFile, " 1\n" );
126 // fprintf( pFile, " %d\n", pCube->nLits );
127 }
unsigned nVars
Definition: covInt.h:57
static int Min_CubeCountLits(Min_Cube_t *pCube)
Definition: covInt.h:224
unsigned nLits
Definition: covInt.h:59
#define assert(ex)
Definition: util_old.h:213
static int Min_CubeHasBit(Min_Cube_t *p, int i)
Definition: covInt.h:83
static void Min_CubeXorBit ( Min_Cube_t p,
int  i 
)
inlinestatic

Definition at line 85 of file covInt.h.

85 { p->uData[(i)>>5] ^= (1<<((i) & 31)); }
unsigned uData[1]
Definition: covInt.h:60
static void Min_CubeXorVar ( Min_Cube_t p,
int  Var,
int  Value 
)
inlinestatic

Definition at line 87 of file covInt.h.

87 { p->uData[(2*Var)>>5] ^= (Value<<((2*Var) & 31)); }
int Var
Definition: SolverTypes.h:42
unsigned uData[1]
Definition: covInt.h:60
void Min_EsopAddCube ( Min_Man_t p,
Min_Cube_t pCube 
)

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

Synopsis [Adds the cube to storage.]

Description []

SideEffects []

SeeAlso []

Definition at line 291 of file covMinEsop.c.

292 {
293  assert( pCube != p->pBubble );
294  assert( (int)pCube->nLits == Min_CubeCountLits(pCube) );
295  while ( Min_EsopAddCubeInt( p, pCube ) );
296 }
int Min_EsopAddCubeInt(Min_Man_t *p, Min_Cube_t *pCube)
Definition: covMinEsop.c:220
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Min_CubeCountLits(Min_Cube_t *pCube)
Definition: covInt.h:224
unsigned nLits
Definition: covInt.h:59
#define assert(ex)
Definition: util_old.h:213
void Min_EsopMinimize ( Min_Man_t p)

FUNCTION DEFINITIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file covMinEsop.c.

48 {
49  int nCubesInit, nCubesOld, nIter;
50  if ( p->nCubes < 3 )
51  return;
52  nIter = 0;
53  nCubesInit = p->nCubes;
54  do {
55  nCubesOld = p->nCubes;
56  Min_EsopRewrite( p );
57  nIter++;
58  }
59  while ( 100.0*(nCubesOld - p->nCubes)/nCubesOld > 3.0 );
60 
61 // printf( "%d:%d->%d ", nIter, nCubesInit, p->nCubes );
62 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static ABC_NAMESPACE_IMPL_START void Min_EsopRewrite(Min_Man_t *p)
DECLARATIONS ///.
Definition: covMinEsop.c:79
Min_Man_t* Min_ManAlloc ( int  nVars)

DECLARATIONS ///.

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

FileName [covMinMan.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Mapping into network of SOPs/ESOPs.]

Synopsis [SOP manipulation.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
covMinMan.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

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

Synopsis [Starts the minimization manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file covMinMan.c.

46 {
47  Min_Man_t * pMan;
48  // start the manager
49  pMan = ABC_ALLOC( Min_Man_t, 1 );
50  memset( pMan, 0, sizeof(Min_Man_t) );
51  pMan->nVars = nVars;
52  pMan->nWords = Abc_BitWordNum( nVars * 2 );
53  pMan->pMemMan = Extra_MmFixedStart( sizeof(Min_Cube_t) + sizeof(unsigned) * (pMan->nWords - 1) );
54  // allocate storage for the temporary cover
55  pMan->ppStore = ABC_ALLOC( Min_Cube_t *, pMan->nVars + 1 );
56  // create tautology cubes
57  Min_ManClean( pMan, nVars );
58  pMan->pOne0 = Min_CubeAlloc( pMan );
59  pMan->pOne1 = Min_CubeAlloc( pMan );
60  pMan->pTemp = Min_CubeAlloc( pMan );
61  pMan->pBubble = Min_CubeAlloc( pMan ); pMan->pBubble->uData[0] = 0;
62  // create trivial cubes
63  Min_ManClean( pMan, 1 );
64  pMan->pTriv0[0] = Min_CubeAllocVar( pMan, 0, 0 );
65  pMan->pTriv0[1] = Min_CubeAllocVar( pMan, 0, 1 );
66  pMan->pTriv1[0] = Min_CubeAllocVar( pMan, 0, 0 );
67  pMan->pTriv1[1] = Min_CubeAllocVar( pMan, 0, 1 );
68  Min_ManClean( pMan, nVars );
69  return pMan;
70 }
char * memset()
unsigned nVars
Definition: covInt.h:57
void Min_ManClean(Min_Man_t *p, int nSupp)
Definition: covMinMan.c:83
static Min_Cube_t * Min_CubeAllocVar(Min_Man_t *p, int iVar, int fCompl)
Definition: covInt.h:149
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Extra_MmFixed_t * Extra_MmFixedStart(int nEntrySize)
static Min_Cube_t * Min_CubeAlloc(Min_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition: covInt.h:126
static int Abc_BitWordNum(int nBits)
Definition: abc_global.h:255
typedefABC_NAMESPACE_HEADER_START struct Min_Man_t_ Min_Man_t
DECLARATIONS ///.
Definition: covInt.h:34
void Min_ManClean ( Min_Man_t p,
int  nSupp 
)

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

Synopsis [Cleans the minimization manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 83 of file covMinMan.c.

84 {
85  // set the size of the cube manager
86  p->nVars = nSupp;
87  p->nWords = Abc_BitWordNum(2*nSupp);
88  // clean the storage
89  memset( p->ppStore, 0, sizeof(Min_Cube_t *) * (nSupp + 1) );
90  p->nCubes = 0;
91 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_BitWordNum(int nBits)
Definition: abc_global.h:255
int nVars
Definition: llb3Image.c:58
void Min_ManFree ( Min_Man_t p)

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

Synopsis [Stops the minimization manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 104 of file covMinMan.c.

105 {
106  Extra_MmFixedStop( p->pMemMan );
107  ABC_FREE( p->ppStore );
108  ABC_FREE( p );
109 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Extra_MmFixedStop(Extra_MmFixed_t *p)
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Min_SopAddCube ( Min_Man_t p,
Min_Cube_t pCube 
)

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

Synopsis [Adds the cube to storage.]

Description []

SideEffects []

SeeAlso []

Definition at line 433 of file covMinSop.c.

434 {
435  assert( Min_CubeCheck( pCube ) );
436  assert( pCube != p->pBubble );
437  assert( (int)pCube->nLits == Min_CubeCountLits(pCube) );
438  while ( Min_SopAddCubeInt( p, pCube ) );
439 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Min_CubeCountLits(Min_Cube_t *pCube)
Definition: covInt.h:224
int Min_CubeCheck(Min_Cube_t *pCube)
Definition: covMinUtil.c:244
unsigned nLits
Definition: covInt.h:59
int Min_SopAddCubeInt(Min_Man_t *p, Min_Cube_t *pCube)
Definition: covMinSop.c:361
#define assert(ex)
Definition: util_old.h:213
void Min_SopMinimize ( Min_Man_t p)

FUNCTION DEFINITIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file covMinSop.c.

48 {
49  int nCubesInit, nCubesOld, nIter;
50  if ( p->nCubes < 3 )
51  return;
52  nIter = 0;
53  nCubesInit = p->nCubes;
54  do {
55  nCubesOld = p->nCubes;
56  Min_SopRewrite( p );
57  nIter++;
58 // printf( "%d:%d->%d ", nIter, nCubesInit, p->nCubes );
59  }
60  while ( 100.0*(nCubesOld - p->nCubes)/nCubesOld > 3.0 );
61 // printf( "\n" );
62 
63 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static ABC_NAMESPACE_IMPL_START void Min_SopRewrite(Min_Man_t *p)
DECLARATIONS ///.
Definition: covMinSop.c:76