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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Min_CubeCreate (Vec_Str_t *vCover, Min_Cube_t *pCube, char Type)
 DECLARATIONS ///. More...
 
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)
 

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
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
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
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
ABC_NAMESPACE_IMPL_START void Min_CubeCreate ( Vec_Str_t vCover,
Min_Cube_t pCube,
char  Type 
)

DECLARATIONS ///.

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

FileName [covMinUtil.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Mapping into network of SOPs/ESOPs.]

Synopsis [Utilities.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file covMinUtil.c.

46 {
47  int i;
48  assert( (int)pCube->nLits == Min_CubeCountLits(pCube) );
49  for ( i = 0; i < (int)pCube->nVars; i++ )
50  if ( Min_CubeHasBit(pCube, i*2) )
51  {
52  if ( Min_CubeHasBit(pCube, i*2+1) )
53 // fprintf( pFile, "-" );
54  Vec_StrPush( vCover, '-' );
55  else
56 // fprintf( pFile, "0" );
57  Vec_StrPush( vCover, '0' );
58  }
59  else
60  {
61  if ( Min_CubeHasBit(pCube, i*2+1) )
62  // fprintf( pFile, "1" );
63  Vec_StrPush( vCover, '1' );
64  else
65 // fprintf( pFile, "?" );
66  Vec_StrPush( vCover, '?' );
67  }
68 // fprintf( pFile, " 1\n" );
69  Vec_StrPush( vCover, ' ' );
70  Vec_StrPush( vCover, Type );
71  Vec_StrPush( vCover, '\n' );
72 }
unsigned nVars
Definition: covInt.h:57
static int Min_CubeCountLits(Min_Cube_t *pCube)
Definition: covInt.h:224
static void Vec_StrPush(Vec_Str_t *p, char Entry)
Definition: vecStr.h:535
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
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