31 #define BDD_FUNC_MAX 256 
   55     DdNode * bFunc, * bPart, * bTemp, * bVar;
 
  115     int i, Group, Left, Shift = 0, Count = 0;
 
  116     Group = nInputs / nParts;
 
  117     Left  = nInputs % nParts;
 
  118     for ( i = 0; i < Left; i++ )
 
  120         uParts[i] = (~((~0) << (Group+1))) << Shift;
 
  123     for (      ; i < nParts; i++ )
 
  125         uParts[i] = (~((~0) << Group)) << Shift;
 
  128     for ( i = 0; i < nParts; i++ )
 
  130     assert( Count == nInputs );
 
  147     for ( i = 0; i < nParts; i++ )
 
  149     for ( i = 0; i < nInputs; i++ )
 
  150         uParts[i % nParts] |= (1 << i);
 
  151     for ( i = 0; i < nParts; i++ )
 
  153     assert( Count == nInputs );
 
  170     for ( i = 0; i < nPats; i++ )
 
  171         if ( Pats[i] == pat )
 
  189     static char Pat0[256], Pat1[256];
 
  190     int v, m, nPats0, nPats1, nNumber = (1 << (nBits - 1));
 
  192     for ( v = 0; v < nVars; v++ )
 
  195         for ( m = 0; m < (1<<nVars); m++ )
 
  197             if ( (m & (1 << v)) == 0 )
 
  201                     Pat0[ nPats0++ ] = Pattern[m];
 
  202                     if ( nPats0 > nNumber )
 
  210                     Pat1[ nPats1++ ] = Pattern[m];
 
  211                     if ( nPats1 > nNumber )
 
  216         if ( m == (1<<nVars) )
 
  235     static char Pattern[256];
 
  238     DdNode * bCof, * bCube, * bTemp;
 
  239     int i, k, Result, nVars = 0;
 
  241     for ( i = 0; i < 32; i++ )
 
  242         if ( uMask & (1 << i) )
 
  243             pbVars[nVars++] = dd->
vars[i];
 
  247     for ( i = 0; i < (1 << nVars); i++ )
 
  295     if ( pnCofs ) *pnCofs = nCofs;
 
  296     return 10000 * n2Log + (nCofs - (1 << (n2Log-1))) * (nCofs - (1 << (n2Log-1)));
 
  312     unsigned uParts2[2] = { uParts[iPart1], uParts[iPart2] };
 
  313     int i, k, CostCur, CostBest, fChange = 0;
 
  314     assert( (uParts[iPart1] & uParts[iPart2]) == 0 );
 
  315     CostBest = 
Abc_ResCost( dd, bFunc, uParts[iPart1], NULL, NULL ) 
 
  316              + 
Abc_ResCost( dd, bFunc, uParts[iPart2], NULL, NULL );
 
  317     for ( i = 0; i < nInputs; i++ )
 
  318     if ( uParts[iPart1] & (1 << i) )
 
  320         for ( k = 0; k < nInputs; k++ )
 
  321         if ( uParts[iPart2] & (1 << k) )
 
  325             uParts[iPart1] ^= (1 << i) | (1 << k);
 
  326             uParts[iPart2] ^= (1 << i) | (1 << k);
 
  327             CostCur = 
Abc_ResCost( dd, bFunc, uParts[iPart1], NULL, NULL ) + 
Abc_ResCost( dd, bFunc, uParts[iPart2], NULL, NULL );
 
  328             if ( CostCur < CostBest )
 
  331                 uParts2[0] = uParts[iPart1];
 
  332                 uParts2[1] = uParts[iPart2];
 
  335             uParts[iPart1] ^= (1 << i) | (1 << k);
 
  336             uParts[iPart2] ^= (1 << i) | (1 << k);
 
  339     uParts[iPart1] = uParts2[0];
 
  340     uParts[iPart2] = uParts2[1];
 
  357     int i, k, nCofs, Cost, CostAll = 0, fCheck;
 
  358     for ( i = 0; i < nParts; i++ )
 
  360         Cost = 
Abc_ResCost( dd, bFunc, uParts[i], &nCofs, &fCheck );
 
  362         for ( k = 0; k < nInputs; k++ )
 
  363             printf( 
"%c", (uParts[i] & (1 << k))? 
'a' + k : 
'-' );
 
  364         printf( 
" %2d %d-%d %6d   ", nCofs, 
Abc_Base2Log(nCofs), fCheck, Cost );
 
  366     printf( 
"%4d\n", CostAll );
 
  382     int i, k, nBits, nCofs, Cost, fCheck;
 
  383     for ( i = 0; i < (1<<nInputs); i++ )
 
  386         if ( nBits < 3 || nBits > 6 )
 
  388         Cost = 
Abc_ResCost( dd, bFunc, i, &nCofs, &fCheck );
 
  389         if ( nCofs > nCofMax )
 
  391         for ( k = 0; k < nInputs; k++ )
 
  392             printf( 
"%c", (i & (1 << k))? 
'a' + k : 
'-' );
 
  393         printf( 
"  n=%2d  c=%2d  l=%d-%d   %6d\n", 
 
  411     int i, k, n, iPart1, iPart2;
 
  412     for ( n = 0; n < nTimes; )
 
  418             i = rand() % nInputs;
 
  419             k = rand() % nInputs;
 
  422         for ( iPart1 = 0; iPart1 < nParts; iPart1++ )
 
  423             if ( uParts[iPart1] & (1 << i) )
 
  425         for ( iPart2 = 0; iPart2 < nParts; iPart2++ )
 
  426             if ( uParts[iPart2] & (1 << k) )
 
  428         if ( iPart1 == iPart2 )
 
  431         uParts[iPart1] ^= (1 << i) | (1 << k);
 
  432         uParts[iPart2] ^= (1 << i) | (1 << k);
 
  456     printf( 
"Ins =%3d. Outs =%2d. Nodes =%3d. Supp =%2d.\n", 
 
  460     if ( nSuppSize <= 6 )
 
  462         printf( 
"Support is less or equal than 6\n" );
 
  469         for ( i = 0; i < nIters; i++ )
 
  473                 printf( 
"Randomizing... \n" );
 
  485     else if ( nInputs > 12 && nInputs <= 18 )
 
  489         for ( i = 0; i < nIters; i++ )
 
  493                 printf( 
"Randomizing... \n" );
 
  509     else if ( nInputs > 18 && nInputs <= 24 )
 
  513         for ( i = 0; i < nIters; i++ )
 
  517                 printf( 
"Randomizing... \n" );
 
  587     for ( i = 0; i < (1 << nVars); i++ )
 
  616     printf( 
"Inputs = %2d.  Nodes = %2d.  LutSize = %2d.\n", nIns, 
Cudd_DagSize(bFunc), nLutSize );
 
  617     for ( i = 0; i <= nIns - nLutSize; i++ )
 
  637     int i, k, c, nCofs, nBits;
 
  643     for ( i = 0; i < (1 << nIns); i++ )
 
  646         if ( nBits != nLutSize && nBits != nLutSize -1 && nBits != nLutSize -2  )
 
  648         for ( c = k = 0; k < nIns; k++ )
 
  650             if ( (i & (1 << k)) == 0 )
 
  653             pbVarsNew[c++] = ddNew->
vars[k];
 
  659         for ( c = k = 0; k < nIns; k++ )
 
  661             if ( (i & (1 << k)) == 0 )
 
  666             printf( 
"%c", k + 
'a' );
 
  668         printf( 
" : %2d\n", nCofs );
 
  689     DdNode * bFunc0, * bFunc1, * bConst0, * bConst1;
 
  692     for ( i = 0; i < nOuts; i++ )
 
  704         assert( bFunc0 == bConst0 || bFunc1 == bConst0 );
 
  705         if ( bFunc0 == bConst0 )
 
  707             TermMask ^= (1 << i);
 
  713     assert( bFunc == bConst1 );
 
  730     DdNode * aFunc0, * aFunc1, * aFunc;
 
  746     return (*ppSlot = aFunc);
 
  762     DdNode * aFunc, * aTemp, * bTemp;
 
  787     DdNode * bFunc0, * bFunc1, * bFunc;
 
  804     return (*ppSlot = bFunc);
 
  820     DdNode * bFunc, * bTemp, * aTemp;
 
  845     DdNode * bFunc, * bTemp, * bExor, * bVar;
 
  848     for ( i = 0; i < nOuts; i++ )
 
  850         if ( (Mask & (1 << i)) == 0 )
 
  934     return Abc_NtkBddDecTry( pReo, dd, pFuncs, nIns, nOuts, ~(1<<(32-nOuts)), nOuts );
 
  952     Abc_Obj_t * pNode, * pNodeNew, * pNodePo;
 
  979         fprintf( stdout, 
"Abc_NtkCreateFromCharFunc(): Network check has failed.\n" );
 
  996     int nBddSizeMax   = 1000000;
 
  997     int fDropInternal =       0;
 
 1011         Abc_Print( -1, 
"Construction of global BDDs has failed.\n" );
 
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
 
#define BDD_FUNC_MAX
DECLARATIONS ///. 
 
static Vec_Ptr_t * Vec_PtrStart(int nSize)
 
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
 
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///. 
 
DdNode * Abc_NtkBddFindAddConst(DdManager *dd, DdNode *bFunc, int nOuts)
 
DdNode * Abc_NtkBddToAdd_rec(DdManager *dd, DdNode *bFunc, int nOuts, stmm_table *tTable, int fCompl)
 
#define CUDD_UNIQUE_SLOTS
 
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
 
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
 
stmm_table * stmm_init_table(stmm_compare_func_type compare, stmm_hash_func_type hash)
 
int Abc_ResCheckUnique(char Pats[], int nPats, int pat)
 
static int Vec_PtrPushUnique(Vec_Ptr_t *p, void *Entry)
 
void Extra_ReorderSetVerbosity(reo_man *p, int fVerbose)
 
void Cudd_Deref(DdNode *node)
 
DdNode * Cudd_addNewVarAtLevel(DdManager *dd, int level)
 
Abc_Ntk_t * Abc_NtkBddDec(Abc_Ntk_t *pNtk, int fVerbose)
 
DdNode * Cudd_addConst(DdManager *dd, CUDD_VALUE_TYPE c)
 
#define Cudd_IsConstant(node)
 
DdNode * Cudd_ReadLogicZero(DdManager *dd)
 
void Abc_ResStartPart(int nInputs, unsigned uParts[], int nParts)
 
void Extra_ReorderSetVerification(reo_man *p, int fVerify)
 
#define Cudd_Regular(node)
 
int Abc_ResCost(DdManager *dd, DdNode *bFunc, unsigned uMask, int *pnCofs, int *pCheck)
 
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
 
int st__ptrcmp(const char *, const char *)
 
DdNode * Abc_ConvertSopToBdd(DdManager *dd, char *pSop, DdNode **pbVars)
FUNCTION DEFINITIONS ///. 
 
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
 
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
 
Abc_Ntk_t * Abc_NtkCreateFromCharFunc(Abc_Ntk_t *pNtk, DdManager *dd, DdNode *bFunc)
 
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
 
#define Abc_NtkForEachCo(pNtk, pCo, i)
 
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///. 
 
static int Abc_NtkIsSopLogic(Abc_Ntk_t *pNtk)
 
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
 
DdNode * Cudd_bddIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
 
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
 
int Abc_ResCheckNonStrict(char Pattern[], int nVars, int nBits)
 
static int Vec_PtrSize(Vec_Ptr_t *p)
 
void Extra_ReorderSetMinimizationType(reo_man *p, reo_min_type fMinType)
 
static int Abc_ObjFaninId0(Abc_Obj_t *pObj)
 
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
 
int Cudd_ReadSize(DdManager *dd)
 
DdNode * Abc_NtkAddToBdd_rec(DdManager *dd, DdNode *aFunc, int nIns, int nOuts, stmm_table *tTable)
 
DdNode * Cudd_bddTransfer(DdManager *ddSource, DdManager *ddDestination, DdNode *f)
 
static void * Abc_ObjGlobalBdd(Abc_Obj_t *pObj)
 
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
 
ABC_DLL Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///. 
 
void Abc_NtkExploreCofs(DdManager *dd, DdNode *bFunc, DdNode **pbVars, int nIns, int nLutSize)
 
ABC_DLL void * Abc_NtkFreeGlobalBdds(Abc_Ntk_t *pNtk, int fFreeMan)
 
#define Cudd_IsComplement(node)
 
int Abc_NtkBddCofCount(DdManager *dd, DdNode *bFunc, DdNode **pbVars, int nVars)
 
DdNode * Cudd_addIthVar(DdManager *dd, int i)
 
DdNode * Cudd_Cofactor(DdManager *dd, DdNode *f, DdNode *g)
 
int Cudd_ReadPerm(DdManager *dd, int i)
 
int Cudd_ShuffleHeap(DdManager *table, int *permutation)
 
DdNode * Abc_NtkBddDecCharFunc(DdManager *dd, DdNode **pFuncs, int nOuts, int Mask, int nBits)
 
#define ABC_NAMESPACE_IMPL_END
 
DdManager * Cudd_Init(unsigned int numVars, unsigned int numVarsZ, unsigned int numSlots, unsigned int cacheSize, unsigned long maxMemory)
 
void Abc_ResSwapRandom(DdManager *dd, DdNode *bFunc, int nInputs, unsigned uParts[], int nParts, int nTimes)
 
ABC_DLL int Abc_SopIsConst0(char *pSop)
 
void Abc_ResPartitionTest(Abc_Ntk_t *pNtk)
 
static Abc_Obj_t * Abc_NtkCreatePi(Abc_Ntk_t *pNtk)
 
DdNode * Cudd_bddXnor(DdManager *dd, DdNode *f, DdNode *g)
 
void Abc_ResPrintAllCofs(DdManager *dd, DdNode *bFunc, int nInputs, int nCofMax)
 
static void Abc_Print(int level, const char *format,...)
 
int Abc_ResCofCount(DdManager *dd, DdNode *bFunc, unsigned uMask, int *pCheck)
 
int stmm_find_or_add(stmm_table *table, char *key, char ***slot)
 
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
 
#define ABC_NAMESPACE_IMPL_START
 
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
 
void Abc_NtkExploreCofs2(DdManager *dd, DdNode *bFunc, DdNode **pbVars, int nIns, int nLutSize)
 
void stmm_free_table(stmm_table *table)
 
int Abc_ResMigrate(DdManager *dd, DdNode *bFunc, int nInputs, unsigned uParts[], int iPart1, int iPart2)
 
DdNode * Abc_NtkBddDecInt(reo_man *pReo, DdManager *dd, DdNode **pFuncs, int nIns, int nOuts)
 
DdNode * Cudd_ReadOne(DdManager *dd)
 
DdNode * Cudd_addIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
 
#define Abc_NtkForEachCi(pNtk, pCi, i)
 
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///. 
 
#define Abc_ObjForEachFanin(pObj, pFanin, i)
 
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///. 
 
static int Abc_Base2Log(unsigned n)
 
DdNode * Cudd_bddIthVar(DdManager *dd, int i)
 
DdNode * Cudd_bddXor(DdManager *dd, DdNode *f, DdNode *g)
 
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
 
void Abc_ResStartPart2(int nInputs, unsigned uParts[], int nParts)
 
#define Cudd_NotCond(node, c)
 
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
 
DdNode * Abc_NtkAddToBdd(DdManager *dd, DdNode *aFunc, int nIns, int nOuts)
 
static void Vec_PtrClear(Vec_Ptr_t *p)
 
reo_man * Extra_ReorderInit(int nDdVarsMax, int nNodesMax)
FUNCTION DECLARATIONS ///. 
 
void Extra_ReorderQuit(reo_man *p)
 
int Cudd_ReduceHeap(DdManager *table, Cudd_ReorderingType heuristic, int minsize)
 
ABC_DLL void * Abc_NtkBuildGlobalBdds(Abc_Ntk_t *pNtk, int fBddSizeMax, int fDropInternal, int fReorder, int fVerbose)
 
#define stmm_foreach_item(table, gen, key, value)
 
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///. 
 
void Abc_ResPartition(DdManager *dd, DdNode *bFunc, int nInputs)
 
int Cudd_SupportSize(DdManager *dd, DdNode *f)
 
static Abc_Obj_t * Abc_NtkCreatePo(Abc_Ntk_t *pNtk)
 
static void ** Vec_PtrArray(Vec_Ptr_t *p)
 
DdNode * Abc_ResBuildBdd(Abc_Ntk_t *pNtk, DdManager *dd)
FUNCTION DEFINITIONS ///. 
 
int st__ptrhash(const char *, int)
 
DdNode * Abc_NtkBddDecTry(reo_man *pReo, DdManager *dd, DdNode **pFuncs, int nIns, int nOuts, int Mask, int nBits)
 
DdNode * Abc_NtkBddToAdd(DdManager *dd, DdNode *bFunc, int nOuts)
 
void Abc_ResPrint(DdManager *dd, DdNode *bFunc, int nInputs, unsigned uParts[], int nParts)
 
int Cudd_DagSize(DdNode *node)
 
static void Vec_PtrFree(Vec_Ptr_t *p)