48 unsigned uSuppFanins, k;
49 int Above[16], Below[16];
50 int nAbove, nBelow, iFaninLit, i, x, y;
66 for ( y = 0; y < 16; y++ )
67 if ( uSuppFanins & (1 << y) )
70 for ( x = 0; x < nAbove; x++ )
71 for ( y = 0; y < nBelow; y++ )
72 pTable[Above[x]][Below[y]]++;
87 void Lpk_CreateCommonOrder(
char pTable[][16],
int piCofVar[],
int nCBars,
int pPrios[],
int nVars,
int fVerbose )
89 int Score[16] = {0}, pPres[16];
90 int i, y, x, iVarBest, ScoreMax, PrioCount;
93 for ( i = 0; i < nVars; i++ )
96 for ( i = 0; i < nCBars; i++ )
97 pPres[piCofVar[i]] = 0;
100 for ( i = 0; i < nVars; i++ )
104 for ( y = 0; y < nVars; y++ )
105 Score[i] += pTable[i][y];
106 for ( x = 0; x < nVars; x++ )
107 Score[i] -= pTable[x][i];
113 printf(
"Scores: " );
114 for ( i = 0; i < nVars; i++ )
115 printf(
"%c=%d ",
'a'+i, Score[i] );
122 for ( i = 0; i < nVars; i++ )
126 for ( PrioCount = 1; ; PrioCount++ )
131 for ( i = 0; i < nVars; i++ )
135 if ( ScoreMax < Score[i] )
141 if ( iVarBest == -1 )
145 printf(
"%d=", PrioCount );
146 for ( i = 0; i < nVars; i++ )
150 if ( Score[i] == ScoreMax )
152 pPrios[i] = PrioCount;
155 printf(
"%c",
'a'+i );
179 unsigned uSupps[8], uSuppFanin, uSuppTotal, uSuppLarge;
180 int i, pTriv[8], PrioMin, iVarMax, nComps, fOneNonTriv;
184 for ( i = 0; i < nSize; i++ )
208 assert( uSupps[i] <= 0xFFFF );
209 uSuppTotal |= uSupps[i];
211 if ( uSuppTotal == 0 )
217 for ( i = 0; i < 16; i++ )
218 if ( uSuppTotal & (1 << i) )
219 if ( PrioMin > pPrio[i] )
230 for ( i = 0; i < nSize; i++ )
231 if ( uSupps[i] & (1<<iVarMax) )
233 if ( pTriv[i] || !fOneNonTriv )
237 uSuppLarge = uSupps[i];
251 for ( i = 0; i < nSize; i++ )
252 if ( !pTriv[i] && pDecision[i] == 0 && (uSupps[i] & ~uSuppLarge) == 0 )
275 If_Obj_t * pObjsNew[4][8], * pResPrev;
276 int piLitsNew[8], pDecision[8];
277 int i, k, nComps, nSize;
280 nSize = (1 << nCBars);
286 if ( p->
pPars->fVeryVerbose )
287 printf(
"Decision: " );
288 for ( i = 0; i < nSize; i++ )
292 if ( p->
pPars->fVeryVerbose )
299 piLitsNew[i] = pObj->
pFans[0];
301 piLitsNew[i] = pObj->
pFans[1];
304 piLitsNew[i] = piLits[i];
306 if ( p->
pPars->fVeryVerbose )
310 pResPrev =
Lpk_MapTreeMulti_rec( p, ppNtks, piLitsNew, piCofVar, nCBars, ppLeaves, nLeaves, pPrio );
313 for ( i = 0; i < nSize; i++ )
316 pObjsNew[nCBars][i] =
Lpk_MapTree_rec( p, ppNtks[i], ppLeaves, piLits[i], pResPrev );
317 else if ( piLits[i] == -1 )
319 else if ( piLits[i] == -2 )
322 pObjsNew[nCBars][i] = pResPrev;
326 for ( k = nCBars; k > 0; k-- )
329 for ( i = 0; i < nSize; i++ )
330 pObjsNew[k-1][i] =
If_ManCreateMux( p->
pIfMan, pObjsNew[k][2*i+0], pObjsNew[k][2*i+1], ppLeaves[piCofVar[k-1]] );
333 return pObjsNew[0][0];
353 int piCofVar[4], pPrios[16],
pFreqs[16] = {0}, piLits[16];
354 int i, k, nCBars, nSize, nMemSize;
355 unsigned * ppCofs[4][8], uSupport;
356 char pTable[16][16] = {
357 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
358 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
359 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
360 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
361 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
362 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
363 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
364 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
365 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
366 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
367 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
368 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
369 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
370 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
371 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
372 {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
374 int fVerbose = p->
pPars->fVeryVerbose;
381 ppCofs[0][0] =
ABC_ALLOC(
unsigned, 32 * nMemSize );
383 for ( i = 0; i < 4; i++ )
384 for ( k = 0; k < 8; k++ )
385 ppCofs[i][k] = ppCofs[0][0] + nMemSize * nSize++;
399 for ( k = 0; k < nCBars; k++ )
402 for ( i = 0; i < nSize; i++ )
408 nSize = (1 << nCBars);
410 for ( i = 0; i < nSize; i++ )
417 printf(
"Cof%d%d: ", nCBars, i );
423 for ( i = 0; i < nSize; i++ )
426 for ( k = 0; k < nVars; k++ )
427 if ( uSupport & (1<<k) )
432 for ( i = 0; i < nSize; i++ )
439 for ( i = 0; i < nVars; i++ )
440 pPrios[i] = pPrios[i] * 256 + (16 - pFreqs[i]) * 16 + i;
443 printf(
"After restructuring with priority:\n" );
446 for ( i = 0; i < nSize; i++ )
457 printf(
"Cof%d%d: ", nCBars, i );
462 for ( i = 0; i < nSize; i++ )
471 piLits[i] = ppNtks[i]->
Root;
484 nSize = (1 << nCBars);
485 for ( i = 0; i < nSize; i++ )
488 for ( k = nCBars-1; k >= 0; k-- )
491 for ( i = 0; i < nSize; i++ )
492 Kit_TruthMuxVar( ppCofs[k][i], ppCofs[k+1][2*i+0], ppCofs[k+1][2*i+1], nVars, piCofVar[k] );
495 printf(
"Verification failed.\n" );
499 for ( i = 0; i < 8; i++ )
void Lpk_CreateCommonOrder(char pTable[][16], int piCofVar[], int nCBars, int pPrios[], int nVars, int fVerbose)
static Kit_DsdObj_t * Kit_DsdNtkRoot(Kit_DsdNtk_t *pNtk)
static int Kit_TruthWordNum(int nVars)
unsigned Kit_DsdGetSupports(Kit_DsdNtk_t *p)
If_Obj_t * Lpk_MapTree_rec(Lpk_Man_t *p, Kit_DsdNtk_t *pNtk, If_Obj_t **ppLeaves, int iLit, If_Obj_t *pResult)
static Kit_DsdObj_t * Kit_DsdNtkObj(Kit_DsdNtk_t *pNtk, int Id)
void Kit_DsdTruth(Kit_DsdNtk_t *pNtk, unsigned *pTruthRes)
void Kit_TruthMuxVar(unsigned *pOut, unsigned *pCof0, unsigned *pCof1, int nVars, int iVar)
#define ABC_ALLOC(type, num)
#define Kit_DsdObjForEachFanin(pNtk, pObj, iLit, i)
static int Abc_LitNotCond(int Lit, int c)
Kit_DsdNtk_t * Kit_DsdDecompose(unsigned *pTruth, int nVars)
static If_Obj_t * If_Not(If_Obj_t *p)
If_Obj_t * Lpk_MapTreeMulti_rec(Lpk_Man_t *p, Kit_DsdNtk_t **ppNtks, int *piLits, int *piCofVar, int nCBars, If_Obj_t **ppLeaves, int nLeaves, int *pPrio)
If_Obj_t * If_ManCreateMux(If_Man_t *p, If_Obj_t *pFan0, If_Obj_t *pFan1, If_Obj_t *pCtrl)
void Kit_TruthCofactor0New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
static int Abc_LitIsCompl(int Lit)
void Kit_DsdPrint(FILE *pFile, Kit_DsdNtk_t *pNtk)
#define Kit_DsdNtkForEachObj(pNtk, pObj, i)
#define ABC_NAMESPACE_IMPL_END
static If_Obj_t * If_ManConst1(If_Man_t *p)
void Kit_TruthCofactor1New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
void Kit_DsdRotate(Kit_DsdNtk_t *p, int pFreqs[])
If_Obj_t * Lpk_MapTreeMulti(Lpk_Man_t *p, unsigned *pTruth, int nVars, If_Obj_t **ppLeaves)
#define ABC_NAMESPACE_IMPL_START
Kit_DsdNtk_t * Kit_DsdShrink(Kit_DsdNtk_t *p, int pPrios[])
int Lpk_FindHighest(Kit_DsdNtk_t **ppNtks, int *piLits, int nSize, int *pPrio, int *pDecision)
unsigned Kit_TruthSupport(unsigned *pTruth, int nVars)
int Kit_DsdCofactoring(unsigned *pTruth, int nVars, int *pCofVars, int nLimit, int fVerbose)
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
static int Kit_DsdLitIsLeaf(Kit_DsdNtk_t *pNtk, int Lit)
static int Abc_Lit2Var(int Lit)
#define ABC_INFINITY
MACRO DEFINITIONS ///.
void Kit_DsdNtkFree(Kit_DsdNtk_t *pNtk)
static unsigned Kit_DsdLitSupport(Kit_DsdNtk_t *pNtk, int Lit)
ABC_NAMESPACE_IMPL_START void Lpk_CreateVarOrder(Kit_DsdNtk_t *pNtk, char pTable[][16])
DECLARATIONS ///.
Kit_DsdNtk_t * Kit_DsdExpand(Kit_DsdNtk_t *p)