abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
aigCanon.c File Reference
#include "aig.h"
#include "bool/kit/kit.h"
#include "bool/bdc/bdc.h"
#include "aig/ioa/ioa.h"

Go to the source code of this file.

Data Structures

struct  Aig_VSig_t_
 
struct  Aig_Tru_t_
 
struct  Aig_RMan_t_
 

Macros

#define RMAN_MAXVARS   12
 DECLARATIONS ///. More...
 
#define RMAX_MAXWORD   (RMAN_MAXVARS <= 5 ? 1 : (1 << (RMAN_MAXVARS - 5)))
 

Typedefs

typedef struct Aig_VSig_t_ Aig_VSig_t
 
typedef struct Aig_Tru_t_ Aig_Tru_t
 
typedef struct Aig_RMan_t_ Aig_RMan_t
 

Functions

Aig_RMan_tAig_RManStart ()
 FUNCTION DEFINITIONS ///. More...
 
static int Aig_RManTableHash (unsigned *pTruth, int nVars, int nBins, int *pPrimes)
 
Aig_Tru_t ** Aig_RManTableLookup (Aig_RMan_t *p, unsigned *pTruth, int nVars)
 
void Aig_RManTableResize (Aig_RMan_t *p)
 
int Aig_RManTableFindOrAdd (Aig_RMan_t *p, unsigned *pTruth, int nVars)
 
void Aig_RManStop (Aig_RMan_t *p)
 
void Aig_RManQuit ()
 
void Aig_RManPrintVarProfile (unsigned *pTruth, int nVars, unsigned *pTruthAux)
 
void Aig_RManSortNums (int *pArray, int nVars)
 
void Aig_RManPrintSigs (Aig_VSig_t *pSigs, int nVars)
 
void Aig_RManComputeVSigs (unsigned *pTruth, int nVars, Aig_VSig_t *pSigs, unsigned *pAux)
 
static int Aig_RManCompareSigs (Aig_VSig_t *p0, Aig_VSig_t *p1, int nVars)
 
int Aig_RManVarsAreUnique (Aig_VSig_t *pMints, int nVars)
 
void Aig_RManPrintUniqueVars (Aig_VSig_t *pMints, int nVars)
 
unsigned Aig_RManSemiCanonicize (unsigned *pOut, unsigned *pIn, int nVars, char *pCanonPerm, Aig_VSig_t *pSigs, int fReturnIn)
 
static Aig_Obj_tBdc_FunCopyHop (Bdc_Fun_t *pObj)
 
void Aig_RManSaveOne (Aig_RMan_t *p, unsigned *pTruth, int nVars)
 
void Aig_RManRecord (unsigned *pTruth, int nVarsInit)
 

Variables

static Aig_RMan_ts_pRMan = NULL
 

Macro Definition Documentation

#define RMAN_MAXVARS   12

DECLARATIONS ///.

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

FileName [aigCanon.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [AIG package.]

Synopsis [Processing the library of semi-canonical AIGs.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - April 28, 2007.]

Revision [

Id:
aigCanon.c,v 1.00 2007/04/28 00:00:00 alanmi Exp

]

Definition at line 33 of file aigCanon.c.

#define RMAX_MAXWORD   (RMAN_MAXVARS <= 5 ? 1 : (1 << (RMAN_MAXVARS - 5)))

Definition at line 34 of file aigCanon.c.

Typedef Documentation

typedef struct Aig_RMan_t_ Aig_RMan_t

Definition at line 53 of file aigCanon.c.

typedef struct Aig_Tru_t_ Aig_Tru_t

Definition at line 43 of file aigCanon.c.

typedef struct Aig_VSig_t_ Aig_VSig_t

Definition at line 36 of file aigCanon.c.

Function Documentation

static int Aig_RManCompareSigs ( Aig_VSig_t p0,
Aig_VSig_t p1,
int  nVars 
)
inlinestatic

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

Synopsis [Computs signatures for all variables.]

Description []

SideEffects []

SeeAlso []

Definition at line 410 of file aigCanon.c.

411 {
412 // return memcmp( p0, p1, sizeof(int) + sizeof(int) * nVars );
413  return memcmp( p0, p1, sizeof(int) );
414 }
int memcmp()
void Aig_RManComputeVSigs ( unsigned *  pTruth,
int  nVars,
Aig_VSig_t pSigs,
unsigned *  pAux 
)

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

Synopsis [Computes signatures for all variables.]

Description []

SideEffects []

SeeAlso []

Definition at line 382 of file aigCanon.c.

383 {
384  int v;
385  for ( v = 0; v < nVars; v++ )
386  {
387  Kit_TruthCofactor0New( pAux, pTruth, nVars, v );
388  pSigs[2*v+0].nOnes = Kit_TruthCountOnes( pAux, nVars );
389  Kit_TruthCountOnesInCofs0( pAux, nVars, pSigs[2*v+0].nCofOnes );
390  Aig_RManSortNums( pSigs[2*v+0].nCofOnes, nVars );
391 
392  Kit_TruthCofactor1New( pAux, pTruth, nVars, v );
393  pSigs[2*v+1].nOnes = Kit_TruthCountOnes( pAux, nVars );
394  Kit_TruthCountOnesInCofs0( pAux, nVars, pSigs[2*v+1].nCofOnes );
395  Aig_RManSortNums( pSigs[2*v+1].nCofOnes, nVars );
396  }
397 }
void Kit_TruthCountOnesInCofs0(unsigned *pTruth, int nVars, int *pStore)
Definition: kitTruth.c:1486
void Aig_RManSortNums(int *pArray, int nVars)
Definition: aigCanon.c:329
void Kit_TruthCofactor0New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
Definition: kitTruth.c:521
int nOnes
Definition: aigCanon.c:39
static int Kit_TruthCountOnes(unsigned *pIn, int nVars)
Definition: kit.h:251
void Kit_TruthCofactor1New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
Definition: kitTruth.c:573
void Aig_RManPrintSigs ( Aig_VSig_t pSigs,
int  nVars 
)

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

Synopsis [Prints signatures for all variables.]

Description []

SideEffects []

SeeAlso []

Definition at line 353 of file aigCanon.c.

354 {
355  int v, i, k;
356  for ( v = 0; v < nVars; v++ )
357  {
358  printf( "%2d : ", v );
359  for ( k = 0; k < 2; k++ )
360  {
361  printf( "%5d ", pSigs[2*v+k].nOnes );
362  printf( "(" );
363  for ( i = 0; i < nVars; i++ )
364  printf( "%4d ", pSigs[2*v+k].nCofOnes[i] );
365  printf( ") " );
366  }
367  printf( "\n" );
368  }
369 }
void Aig_RManPrintUniqueVars ( Aig_VSig_t pMints,
int  nVars 
)

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

Synopsis [Returns 1 if all variables are unique.]

Description []

SideEffects []

SeeAlso []

Definition at line 447 of file aigCanon.c.

448 {
449  int i;
450  for ( i = 0; i < nVars; i++ )
451  if ( Aig_RManCompareSigs( &pMints[2*i], &pMints[2*i+1], nVars ) == 0 )
452  printf( "=" );
453  else
454  printf( "x" );
455  printf( "\n" );
456 
457  printf( "0" );
458  for ( i = 1; i < nVars; i++ )
459  if ( Aig_RManCompareSigs( &pMints[2*(i-1)], &pMints[2*i], nVars ) == 0 )
460  printf( "-" );
461  else if ( i < 10 )
462  printf( "%c", '0' + i );
463  else
464  printf( "%c", 'A' + i-10 );
465  printf( "\n" );
466 }
static int Aig_RManCompareSigs(Aig_VSig_t *p0, Aig_VSig_t *p1, int nVars)
Definition: aigCanon.c:410
void Aig_RManPrintVarProfile ( unsigned *  pTruth,
int  nVars,
unsigned *  pTruthAux 
)

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

Synopsis [Returns 1 if all variables are unique.]

Description []

SideEffects []

SeeAlso []

Definition at line 308 of file aigCanon.c.

309 {
310  int pStore2[32];
311  int i;
312  Kit_TruthCountOnesInCofsSlow( pTruth, nVars, pStore2, pTruthAux );
313  for ( i = 0; i < nVars; i++ )
314  printf( "%2d/%2d ", pStore2[2*i], pStore2[2*i+1] );
315  printf( "\n" );
316 }
void Kit_TruthCountOnesInCofsSlow(unsigned *pTruth, int nVars, int *pStore, unsigned *pAux)
Definition: kitTruth.c:1537
void Aig_RManQuit ( )

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

Synopsis [Stops recording.]

Description []

SideEffects []

SeeAlso []

Definition at line 283 of file aigCanon.c.

284 {
285 // extern void Ioa_WriteAiger( Aig_Man_t * pMan, char * pFileName, int fWriteSymbols, int fCompact );
286  char Buffer[20];
287  if ( s_pRMan == NULL )
288  return;
289  // dump the library file
290  sprintf( Buffer, "aiglib%02d.aig", s_pRMan->nVars );
291  Ioa_WriteAiger( s_pRMan->pAig, Buffer, 0, 1 );
292  // quit the manager
294  s_pRMan = NULL;
295 }
Aig_Man_t * pAig
Definition: aigCanon.c:57
static Aig_RMan_t * s_pRMan
Definition: aigCanon.c:82
char * sprintf()
void Aig_RManStop(Aig_RMan_t *p)
Definition: aigCanon.c:252
int nVars
Definition: aigCanon.c:56
void Ioa_WriteAiger(Aig_Man_t *pMan, char *pFileName, int fWriteSymbols, int fCompact)
Definition: ioaWriteAig.c:446
void Aig_RManRecord ( unsigned *  pTruth,
int  nVarsInit 
)

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

Synopsis [Records one function.]

Description []

SideEffects []

SeeAlso []

Definition at line 598 of file aigCanon.c.

599 {
600  int fVerify = 1;
601  Kit_DsdNtk_t * pNtk;
602  Kit_DsdObj_t * pObj;
603  unsigned uPhaseC;
604  int i, nVars, nWords;
605  int fUniqueVars;
606 
607  if ( nVarsInit > RMAN_MAXVARS )
608  {
609  printf( "The number of variables in too large.\n" );
610  return;
611  }
612 
613  if ( s_pRMan == NULL )
615  s_pRMan->nTotal++;
616  // canonicize the function
617  pNtk = Kit_DsdDecompose( pTruth, nVarsInit );
618  pObj = Kit_DsdNonDsdPrimeMax( pNtk );
619  if ( pObj == NULL || pObj->nFans == 3 )
620  {
621  s_pRMan->nTtDsd++;
622  Kit_DsdNtkFree( pNtk );
623  return;
624  }
625  nVars = pObj->nFans;
626  s_pRMan->nVarFuncs[nVars]++;
627  if ( nVars < nVarsInit )
628  s_pRMan->nTtDsdPart++;
629  else
630  s_pRMan->nTtDsdNot++;
631  // compute the number of words
632  nWords = Abc_TruthWordNum( nVars );
633  // copy the function
634  memcpy( s_pRMan->pTruthInit, Kit_DsdObjTruth(pObj), 4*nWords );
635  Kit_DsdNtkFree( pNtk );
636  // canonicize the output
637  if ( s_pRMan->pTruthInit[0] & 1 )
639  memcpy( s_pRMan->pTruth, s_pRMan->pTruthInit, 4*nWords );
640 
641  // canonize the function
642  for ( i = 0; i < nVars; i++ )
643  s_pRMan->pPerm[i] = i;
645  // check unique variables
646  fUniqueVars = Aig_RManVarsAreUnique( s_pRMan->pMints, nVars );
647  s_pRMan->nUniqueVars += fUniqueVars;
648 
649 /*
650  printf( "%4d : ", s_pRMan->nTotal );
651  printf( "%2d %2d ", nVarsInit, nVars );
652  Extra_PrintBinary( stdout, &uPhaseC, nVars );
653  printf( " " );
654  for ( i = 0; i < nVars; i++ )
655  printf( "%2d/%2d ", s_pRMan->pMints[2*i], s_pRMan->pMints[2*i+1] );
656  printf( "\n" );
657  Aig_RManPrintUniqueVars( s_pRMan->pMints, nVars );
658 Extra_PrintBinary( stdout, s_pRMan->pTruth, 1<<nVars ); printf( "\n\n" );
659 */
660 /*
661  printf( "\n" );
662  printf( "%4d : ", s_pRMan->nTotal );
663  printf( "%2d %2d ", nVarsInit, nVars );
664  printf( " " );
665  printf( "\n" );
666  Aig_RManPrintUniqueVars( s_pRMan->pMints, nVars );
667 // Aig_RManPrintSigs( s_pRMan->pMints, nVars );
668 */
669 
670 //Extra_PrintBinary( stdout, s_pRMan->pTruth, 1<<nVars ); printf( "\n\n" );
671 
672  if ( Aig_RManTableFindOrAdd( s_pRMan, s_pRMan->pTruth, nVars ) )
674 
675  if ( fVerify )
676  {
677  // derive reverse permutation
678  for ( i = 0; i < nVars; i++ )
679  s_pRMan->pPermR[i] = s_pRMan->pPerm[i];
680  // implement permutation
682  // implement polarity
683  for ( i = 0; i < nVars; i++ )
684  if ( uPhaseC & (1 << i) )
685  Kit_TruthChangePhase( s_pRMan->pTruth, nVars, i );
686 
687  // perform verification
688  if ( fUniqueVars && !Kit_TruthIsEqual( s_pRMan->pTruth, s_pRMan->pTruthInit, nVars ) )
689  printf( "Verification failed.\n" );
690  }
691 //Aig_RManPrintVarProfile( s_pRMan->pTruth, nVars, s_pRMan->pTruthTemp );
692 //Extra_PrintBinary( stdout, s_pRMan->pTruth, 1<<nVars ); printf( "\n" );
693 }
char pPermR[RMAN_MAXVARS]
Definition: aigCanon.c:72
int nTtDsd
Definition: aigCanon.c:76
unsigned nFans
Definition: kit.h:116
void Kit_TruthPermute(unsigned *pOut, unsigned *pIn, int nVars, char *pPerm, int fReturnIn)
Definition: kitTruth.c:233
int nTtDsdPart
Definition: aigCanon.c:77
void Kit_TruthChangePhase(unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:1259
char * memcpy()
static int Kit_TruthIsEqual(unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:274
int nUniqueVars
Definition: aigCanon.c:79
static int Abc_TruthWordNum(int nVars)
Definition: abc_global.h:256
Kit_DsdObj_t * Kit_DsdNonDsdPrimeMax(Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:1236
int nWords
Definition: abcNpn.c:127
Kit_DsdNtk_t * Kit_DsdDecompose(unsigned *pTruth, int nVars)
Definition: kitDsd.c:2314
static Aig_RMan_t * s_pRMan
Definition: aigCanon.c:82
Aig_RMan_t * Aig_RManStart()
FUNCTION DEFINITIONS ///.
Definition: aigCanon.c:99
unsigned Aig_RManSemiCanonicize(unsigned *pOut, unsigned *pIn, int nVars, char *pCanonPerm, Aig_VSig_t *pSigs, int fReturnIn)
Definition: aigCanon.c:479
unsigned pTruthTemp[RMAX_MAXWORD]
Definition: aigCanon.c:69
int Aig_RManVarsAreUnique(Aig_VSig_t *pMints, int nVars)
Definition: aigCanon.c:427
int nTotal
Definition: aigCanon.c:75
static unsigned * Kit_DsdObjTruth(Kit_DsdObj_t *pObj)
Definition: kit.h:148
int nVarFuncs[RMAN_MAXVARS+1]
Definition: aigCanon.c:74
#define RMAN_MAXVARS
DECLARATIONS ///.
Definition: aigCanon.c:33
unsigned pTruthInit[RMAX_MAXWORD]
Definition: aigCanon.c:66
int Aig_RManTableFindOrAdd(Aig_RMan_t *p, unsigned *pTruth, int nVars)
Definition: aigCanon.c:218
void Aig_RManSaveOne(Aig_RMan_t *p, unsigned *pTruth, int nVars)
Definition: aigCanon.c:558
Aig_VSig_t pMints[2 *RMAN_MAXVARS]
Definition: aigCanon.c:70
static void Kit_TruthNot(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:373
unsigned pTruth[RMAX_MAXWORD]
Definition: aigCanon.c:67
void Kit_DsdNtkFree(Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:163
char pPerm[RMAN_MAXVARS]
Definition: aigCanon.c:71
int nTtDsdNot
Definition: aigCanon.c:78
void Aig_RManSaveOne ( Aig_RMan_t p,
unsigned *  pTruth,
int  nVars 
)

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

Synopsis [Records one function.]

Description []

SideEffects []

SeeAlso []

Definition at line 558 of file aigCanon.c.

559 {
560  int i, nNodes, RetValue;
561  Bdc_Fun_t * pFunc;
562  Aig_Obj_t * pTerm;
563  // perform decomposition
564  RetValue = Bdc_ManDecompose( p->pBidec, pTruth, NULL, nVars, NULL, 1000 );
565  if ( RetValue < 0 )
566  {
567  printf( "Decomposition failed.\n" );
568  return;
569  }
570  // convert back into HOP
572  for ( i = 0; i < nVars; i++ )
573  Bdc_FuncSetCopy( Bdc_ManFunc( p->pBidec, i+1 ), Aig_IthVar(p->pAig, i) );
574  nNodes = Bdc_ManNodeNum(p->pBidec);
575  for ( i = nVars + 1; i < nNodes; i++ )
576  {
577  pFunc = Bdc_ManFunc( p->pBidec, i );
578  Bdc_FuncSetCopy( pFunc, Aig_And( p->pAig,
580  Bdc_FunCopyHop(Bdc_FuncFanin1(pFunc)) ) );
581  }
582  pTerm = Bdc_FunCopyHop( Bdc_ManRoot(p->pBidec) );
583  pTerm = Aig_ObjCreateCo( p->pAig, pTerm );
584 // assert( pTerm->fPhase == 0 );
585 }
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
Bdc_Fun_t * Bdc_ManRoot(Bdc_Man_t *p)
Definition: bdcCore.c:47
Aig_Man_t * pAig
Definition: aigCanon.c:57
int Bdc_ManDecompose(Bdc_Man_t *p, unsigned *puFunc, unsigned *puCare, int nVars, Vec_Ptr_t *vDivs, int nNodesMax)
Definition: bdcCore.c:291
Bdc_Man_t * pBidec
Definition: aigCanon.c:64
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:104
Bdc_Fun_t * Bdc_ManFunc(Bdc_Man_t *p, int i)
DECLARATIONS ///.
Definition: bdcCore.c:46
void Bdc_FuncSetCopy(Bdc_Fun_t *p, void *pCopy)
Definition: bdcCore.c:54
typedefABC_NAMESPACE_HEADER_START struct Bdc_Fun_t_ Bdc_Fun_t
INCLUDES ///.
Definition: bdc.h:42
Aig_Obj_t * Aig_IthVar(Aig_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Definition: aigOper.c:63
Definition: aig.h:69
Bdc_Fun_t * Bdc_FuncFanin0(Bdc_Fun_t *p)
Definition: bdcCore.c:50
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
static Aig_Obj_t * Bdc_FunCopyHop(Bdc_Fun_t *pObj)
Definition: aigCanon.c:544
int Bdc_ManNodeNum(Bdc_Man_t *p)
Definition: bdcCore.c:48
Bdc_Fun_t * Bdc_FuncFanin1(Bdc_Fun_t *p)
Definition: bdcCore.c:51
unsigned Aig_RManSemiCanonicize ( unsigned *  pOut,
unsigned *  pIn,
int  nVars,
char *  pCanonPerm,
Aig_VSig_t pSigs,
int  fReturnIn 
)

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

Synopsis [Canonicize the truth table.]

Description [Returns the phase. ]

SideEffects []

SeeAlso []

Definition at line 479 of file aigCanon.c.

480 {
481  Aig_VSig_t TempSig;
482  int i, Temp, fChange, Counter;
483  unsigned * pTemp, uCanonPhase = 0;
484  // collect signatures
485  Aig_RManComputeVSigs( pIn, nVars, pSigs, pOut );
486  // canonicize phase
487  for ( i = 0; i < nVars; i++ )
488  {
489 // if ( pStore[2*i+0] <= pStore[2*i+1] )
490  if ( Aig_RManCompareSigs( &pSigs[2*i+0], &pSigs[2*i+1], nVars ) <= 0 )
491  continue;
492  uCanonPhase |= (1 << i);
493  TempSig = pSigs[2*i+0];
494  pSigs[2*i+0] = pSigs[2*i+1];
495  pSigs[2*i+1] = TempSig;
496  Kit_TruthChangePhase( pIn, nVars, i );
497  }
498  // permute
499  Counter = 0;
500  do {
501  fChange = 0;
502  for ( i = 0; i < nVars-1; i++ )
503  {
504 // if ( pStore[2*i] <= pStore[2*(i+1)] )
505  if ( Aig_RManCompareSigs( &pSigs[2*i], &pSigs[2*(i+1)], nVars ) <= 0 )
506  continue;
507  Counter++;
508  fChange = 1;
509 
510  Temp = pCanonPerm[i];
511  pCanonPerm[i] = pCanonPerm[i+1];
512  pCanonPerm[i+1] = Temp;
513 
514  TempSig = pSigs[2*i];
515  pSigs[2*i] = pSigs[2*(i+1)];
516  pSigs[2*(i+1)] = TempSig;
517 
518  TempSig = pSigs[2*i+1];
519  pSigs[2*i+1] = pSigs[2*(i+1)+1];
520  pSigs[2*(i+1)+1] = TempSig;
521 
522  Kit_TruthSwapAdjacentVars( pOut, pIn, nVars, i );
523  pTemp = pIn; pIn = pOut; pOut = pTemp;
524  }
525  } while ( fChange );
526 
527  // swap if it was moved an even number of times
528  if ( fReturnIn ^ !(Counter & 1) )
529  Kit_TruthCopy( pOut, pIn, nVars );
530  return uCanonPhase;
531 }
void Aig_RManComputeVSigs(unsigned *pTruth, int nVars, Aig_VSig_t *pSigs, unsigned *pAux)
Definition: aigCanon.c:382
void Kit_TruthSwapAdjacentVars(unsigned *pOut, unsigned *pIn, int nVars, int Start)
DECLARATIONS ///.
Definition: kitTruth.c:46
void Kit_TruthChangePhase(unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:1259
static int Counter
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:355
static int Aig_RManCompareSigs(Aig_VSig_t *p0, Aig_VSig_t *p1, int nVars)
Definition: aigCanon.c:410
void Aig_RManSortNums ( int *  pArray,
int  nVars 
)

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

Synopsis [Sorts numbers in the increasing order.]

Description []

SideEffects []

SeeAlso []

Definition at line 329 of file aigCanon.c.

330 {
331  int i, j, best_i, tmp;
332  for ( i = 0; i < nVars-1; i++ )
333  {
334  best_i = i;
335  for ( j = i+1; j < nVars; j++ )
336  if ( pArray[j] > pArray[best_i] )
337  best_i = j;
338  tmp = pArray[i]; pArray[i] = pArray[best_i]; pArray[best_i] = tmp;
339  }
340 }
Aig_RMan_t* Aig_RManStart ( )

FUNCTION DEFINITIONS ///.

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

Synopsis [Allocates recording manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 99 of file aigCanon.c.

100 {
101  static Bdc_Par_t Pars = {0}, * pPars = &Pars;
102  Aig_RMan_t * p;
103  p = ABC_ALLOC( Aig_RMan_t, 1 );
104  memset( p, 0, sizeof(Aig_RMan_t) );
105  p->nVars = RMAN_MAXVARS;
106  p->pAig = Aig_ManStart( 1000000 );
107  Aig_IthVar( p->pAig, p->nVars-1 );
108  // create hash table
109  p->nBins = Abc_PrimeCudd(5000);
110  p->pBins = ABC_CALLOC( Aig_Tru_t *, p->nBins );
111  p->pMemTrus = Aig_MmFlexStart();
112  // bi-decomposition manager
113  pPars->nVarsMax = p->nVars;
114  pPars->fVerbose = 0;
115  p->pBidec = Bdc_ManAlloc( pPars );
116  return p;
117 }
char * memset()
Aig_Man_t * pAig
Definition: aigCanon.c:57
static int Abc_PrimeCudd(unsigned int p)
Definition: abc_global.h:383
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition: aigMan.c:47
Bdc_Man_t * Bdc_ManAlloc(Bdc_Par_t *pPars)
MACRO DEFINITIONS ///.
Definition: bdcCore.c:68
Aig_Tru_t ** pBins
Definition: aigCanon.c:60
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Bdc_Man_t * pBidec
Definition: aigCanon.c:64
Aig_MmFlex_t * pMemTrus
Definition: aigCanon.c:62
Aig_Obj_t * Aig_IthVar(Aig_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Definition: aigOper.c:63
#define RMAN_MAXVARS
DECLARATIONS ///.
Definition: aigCanon.c:33
int nVars
Definition: aigCanon.c:56
Definition: bdc.h:45
Aig_MmFlex_t * Aig_MmFlexStart()
Definition: aigMem.c:305
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
int nBins
Definition: aigCanon.c:59
void Aig_RManStop ( Aig_RMan_t p)

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

Synopsis [Deallocates recording manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 252 of file aigCanon.c.

253 {
254  int i;
255  printf( "Total funcs = %10d\n", p->nTotal );
256  printf( "Full DSD funcs = %10d\n", p->nTtDsd );
257  printf( "Part DSD funcs = %10d\n", p->nTtDsdPart );
258  printf( "Non- DSD funcs = %10d\n", p->nTtDsdNot );
259  printf( "Uniq-var funcs = %10d\n", p->nUniqueVars );
260  printf( "Unique funcs = %10d\n", p->nEntries );
261  printf( "Distribution of functions:\n" );
262  for ( i = 5; i <= p->nVars; i++ )
263  printf( "%2d = %8d\n", i, p->nVarFuncs[i] );
264  Aig_MmFlexStop( p->pMemTrus, 0 );
265  Aig_ManStop( p->pAig );
266  Bdc_ManFree( p->pBidec );
267  ABC_FREE( p->pBins );
268  ABC_FREE( p );
269 }
Aig_Man_t * pAig
Definition: aigCanon.c:57
int nTtDsd
Definition: aigCanon.c:76
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
int nTtDsdPart
Definition: aigCanon.c:77
Aig_Tru_t ** pBins
Definition: aigCanon.c:60
int nUniqueVars
Definition: aigCanon.c:79
Bdc_Man_t * pBidec
Definition: aigCanon.c:64
Aig_MmFlex_t * pMemTrus
Definition: aigCanon.c:62
int nTotal
Definition: aigCanon.c:75
int nVarFuncs[RMAN_MAXVARS+1]
Definition: aigCanon.c:74
int nVars
Definition: aigCanon.c:56
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Aig_MmFlexStop(Aig_MmFlex_t *p, int fVerbose)
Definition: aigMem.c:337
int nEntries
Definition: aigCanon.c:61
void Bdc_ManFree(Bdc_Man_t *p)
Definition: bdcCore.c:113
int nTtDsdNot
Definition: aigCanon.c:78
int Aig_RManTableFindOrAdd ( Aig_RMan_t p,
unsigned *  pTruth,
int  nVars 
)

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

Synopsis [Find or add new entry.]

Description [Returns 1 if this is a new entry.]

SideEffects []

SeeAlso []

Definition at line 218 of file aigCanon.c.

219 {
220  Aig_Tru_t ** ppSpot, * pEntry;
221  int nBytes;
222  ppSpot = Aig_RManTableLookup( p, pTruth, nVars );
223  if ( *ppSpot )
224  {
225  (*ppSpot)->nVisits++;
226  return 0;
227  }
228  nBytes = sizeof(Aig_Tru_t) + sizeof(unsigned) * Kit_TruthWordNum(nVars);
229  if ( p->nEntries == 3*p->nBins )
230  Aig_RManTableResize( p );
231  pEntry = (Aig_Tru_t *)Aig_MmFlexEntryFetch( p->pMemTrus, nBytes );
232  pEntry->Id = p->nEntries++;
233  pEntry->nVars = nVars;
234  pEntry->nVisits = 1;
235  pEntry->pNext = NULL;
236  memcpy( pEntry->pTruth, pTruth, sizeof(unsigned) * Kit_TruthWordNum(nVars) );
237  *ppSpot = pEntry;
238  return 1;
239 }
unsigned nVars
Definition: aigCanon.c:49
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
struct Aig_Tru_t_ Aig_Tru_t
Definition: aigCanon.c:43
char * Aig_MmFlexEntryFetch(Aig_MmFlex_t *p, int nBytes)
Definition: aigMem.c:366
char * memcpy()
unsigned nVisits
Definition: aigCanon.c:48
Aig_Tru_t ** Aig_RManTableLookup(Aig_RMan_t *p, unsigned *pTruth, int nVars)
Definition: aigCanon.c:150
int Id
Definition: aigCanon.c:47
Aig_Tru_t * pNext
Definition: aigCanon.c:46
Aig_MmFlex_t * pMemTrus
Definition: aigCanon.c:62
void Aig_RManTableResize(Aig_RMan_t *p)
Definition: aigCanon.c:174
unsigned pTruth[0]
Definition: aigCanon.c:50
int nEntries
Definition: aigCanon.c:61
int nBins
Definition: aigCanon.c:59
static int Aig_RManTableHash ( unsigned *  pTruth,
int  nVars,
int  nBins,
int *  pPrimes 
)
inlinestatic

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

Synopsis [Returns the hash key.]

Description []

SideEffects []

SeeAlso []

Definition at line 130 of file aigCanon.c.

131 {
132  int i, nWords = Kit_TruthWordNum( nVars );
133  unsigned uHash = 0;
134  for ( i = 0; i < nWords; i++ )
135  uHash ^= pTruth[i] * pPrimes[i & 0xf];
136  return (int)(uHash % nBins);
137 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
int nWords
Definition: abcNpn.c:127
Aig_Tru_t** Aig_RManTableLookup ( Aig_RMan_t p,
unsigned *  pTruth,
int  nVars 
)

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

Synopsis [Returns the given record.]

Description []

SideEffects []

SeeAlso []

Definition at line 150 of file aigCanon.c.

151 {
152  static int s_Primes[16] = {
153  1291, 1699, 1999, 2357, 2953, 3313, 3907, 4177,
154  4831, 5147, 5647, 6343, 6899, 7103, 7873, 8147 };
155  Aig_Tru_t ** ppSpot, * pEntry;
156  ppSpot = p->pBins + Aig_RManTableHash( pTruth, nVars, p->nBins, s_Primes );
157  for ( pEntry = *ppSpot; pEntry; ppSpot = &pEntry->pNext, pEntry = pEntry->pNext )
158  if ( Kit_TruthIsEqual( pEntry->pTruth, pTruth, nVars ) )
159  return ppSpot;
160  return ppSpot;
161 }
Aig_Tru_t ** pBins
Definition: aigCanon.c:60
static int Kit_TruthIsEqual(unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:274
static int Aig_RManTableHash(unsigned *pTruth, int nVars, int nBins, int *pPrimes)
Definition: aigCanon.c:130
static int s_Primes[MAX_PRIMES]
Definition: fxuPair.c:30
Aig_Tru_t * pNext
Definition: aigCanon.c:46
unsigned pTruth[0]
Definition: aigCanon.c:50
int nBins
Definition: aigCanon.c:59
void Aig_RManTableResize ( Aig_RMan_t p)

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

Synopsis [Find or add new entry.]

Description []

SideEffects []

SeeAlso []

Definition at line 174 of file aigCanon.c.

175 {
176  Aig_Tru_t * pEntry, * pNext;
177  Aig_Tru_t ** pBinsOld, ** ppPlace;
178  int nBinsOld, Counter, i;
179  abctime clk;
180  assert( p->pBins != NULL );
181 clk = Abc_Clock();
182  // save the old Bins
183  pBinsOld = p->pBins;
184  nBinsOld = p->nBins;
185  // get the new Bins
186  p->nBins = Abc_PrimeCudd( 3 * nBinsOld );
187  p->pBins = ABC_CALLOC( Aig_Tru_t *, p->nBins );
188  // rehash the entries from the old table
189  Counter = 0;
190  for ( i = 0; i < nBinsOld; i++ )
191  for ( pEntry = pBinsOld[i], pNext = pEntry? pEntry->pNext : NULL;
192  pEntry; pEntry = pNext, pNext = pEntry? pEntry->pNext : NULL )
193  {
194  // get the place where this entry goes in the Bins
195  ppPlace = Aig_RManTableLookup( p, pEntry->pTruth, pEntry->nVars );
196  assert( *ppPlace == NULL ); // should not be there
197  // add the entry to the list
198  *ppPlace = pEntry;
199  pEntry->pNext = NULL;
200  Counter++;
201  }
202  assert( Counter == p->nEntries );
203 // ABC_PRT( "Time", Abc_Clock() - clk );
204  ABC_FREE( pBinsOld );
205 }
static int Abc_PrimeCudd(unsigned int p)
Definition: abc_global.h:383
unsigned nVars
Definition: aigCanon.c:49
Aig_Tru_t ** pBins
Definition: aigCanon.c:60
static abctime Abc_Clock()
Definition: abc_global.h:279
Aig_Tru_t ** Aig_RManTableLookup(Aig_RMan_t *p, unsigned *pTruth, int nVars)
Definition: aigCanon.c:150
Aig_Tru_t * pNext
Definition: aigCanon.c:46
static int Counter
unsigned pTruth[0]
Definition: aigCanon.c:50
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
int nEntries
Definition: aigCanon.c:61
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
int nBins
Definition: aigCanon.c:59
int Aig_RManVarsAreUnique ( Aig_VSig_t pMints,
int  nVars 
)

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

Synopsis [Returns 1 if all variables are unique.]

Description []

SideEffects []

SeeAlso []

Definition at line 427 of file aigCanon.c.

428 {
429  int i;
430  for ( i = 0; i < nVars - 1; i++ )
431  if ( Aig_RManCompareSigs( &pMints[2*i], &pMints[2*(i+1)], nVars ) == 0 )
432  return 0;
433  return 1;
434 }
static int Aig_RManCompareSigs(Aig_VSig_t *p0, Aig_VSig_t *p1, int nVars)
Definition: aigCanon.c:410
static Aig_Obj_t* Bdc_FunCopyHop ( Bdc_Fun_t pObj)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 544 of file aigCanon.c.

545 { return Aig_NotCond( (Aig_Obj_t *)Bdc_FuncCopy(Bdc_Regular(pObj)), Bdc_IsComplement(pObj) ); }
Definition: aig.h:69
static int Bdc_IsComplement(Bdc_Fun_t *p)
Definition: bdc.h:54
void * Bdc_FuncCopy(Bdc_Fun_t *p)
Definition: bdcCore.c:52
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
static Bdc_Fun_t * Bdc_Regular(Bdc_Fun_t *p)
Definition: bdc.h:55

Variable Documentation

Aig_RMan_t* s_pRMan = NULL
static

Definition at line 82 of file aigCanon.c.