49 int i,
Var, VarBest, nSuppSize0, nSuppSize1;
50 int nSuppTotalMin = -1;
58 if ( (uNonDecSupp & (1 <<
Var)) == 0 )
62 for ( i = 0; i < nTruths; i++ )
66 nSuppSize0 = Kit_WordCountOnes(
p->puSupps[2*
Var+0] );
67 nSuppSize1 = Kit_WordCountOnes(
p->puSupps[2*
Var+1] );
76 nSuppMaxCur = Abc_MaxInt( nSuppMaxCur, nSuppSize0 );
77 nSuppMaxCur = Abc_MaxInt( nSuppMaxCur, nSuppSize1 );
78 nSuppTotalCur += nSuppSize0 + nSuppSize1;
80 if ( VarBest == -1 || nSuppMaxMin > nSuppMaxCur ||
81 (nSuppMaxMin == nSuppMaxCur && nSuppTotalMin > nSuppTotalCur) )
84 nSuppMaxMin = nSuppMaxCur;
85 nSuppTotalMin = nSuppTotalCur;
89 for ( i = 0; i < nTruths; i++ )
110 unsigned i, iLitFanin, uSupport, uSuppCur;
113 pObj = Kit_DsdNtkObj(
p, Abc_Lit2Var(iLit) );
115 return (1 << Abc_Lit2Var(iLit));
118 unsigned uSupps[16], Limit, s;
123 uSupport |= uSupps[i];
126 Limit = (1 << pObj->
nFans) - 1;
127 for ( s = 1; s < Limit; s++ )
130 for ( i = 0; i < pObj->
nFans; i++ )
132 uSuppCur |= uSupps[i];
133 if ( Kit_WordCountOnes(uSuppCur) <= nSizeMax )
134 Vec_IntPush( vSets, uSuppCur );
144 uSupport |= uSuppCur;
145 if ( Kit_WordCountOnes(uSuppCur) <= nSizeMax )
146 Vec_IntPush( vSets, uSuppCur );
165 unsigned uSupport, Entry;
168 vSets = Vec_IntAlloc( 100 );
169 Vec_IntPush( vSets, 0 );
174 uSupport = ( 1 << Abc_Lit2Var(Kit_DsdNtkRoot(
p)->pFans[0]) );
175 if ( Kit_WordCountOnes(uSupport) <= nSizeMax )
176 Vec_IntPush( vSets, uSupport );
180 assert( (uSupport & 0xFFFF0000) == 0 );
182 if ( Kit_WordCountOnes(uSupport) <= nSizeMax )
183 Vec_IntPush( vSets, uSupport );
188 Vec_IntWriteEntry( vSets, i, Entry | ((uSupport & ~Entry) << 16) );
204static void Lpk_PrintSetOne(
int uSupport )
207 for ( k = 0; k < 16; k++ )
208 if ( uSupport & (1<<k) )
209 printf(
"%c",
'a'+k );
223static void Lpk_PrintSets(
Vec_Int_t * vSets )
227 printf(
"Subsets(%d): ", Vec_IntSize(vSets) );
231 Lpk_PrintSetOne( uSupport );
250 int Entry0, Entry1, Entry;
252 vSets = Vec_IntAlloc( 100 );
256 Entry = Entry0 | Entry1;
257 if ( (Entry & (Entry >> 16)) )
259 if ( Kit_WordCountOnes(Entry & 0xffff) <= nSizeMax )
260 Vec_IntPush( vSets, Entry );
280 int i, nVarsBS, nVarsRem, Delay, Area;
286 if ( (uBoundSet & 0xFFFF) == 0 )
288 if ( (uBoundSet & uNonDecSupp) == 0 )
290 if ( (uBoundSet & uLateArrSupp) )
294Lpk_PrintSetOne( uBoundSet & 0xFFFF );
299 assert( (uBoundSet & (uBoundSet >> 16)) == 0 );
300 nVarsBS = Kit_WordCountOnes( uBoundSet & 0xFFFF );
303 assert( nVarsBS <= (
int)
p->nLutK - nCofDepth );
304 nVarsRem =
p->nVars - nVarsBS + 1;
305 Area = 1 + Lpk_LutNumLuts( nVarsRem,
p->nLutK );
308printf(
"area = %d limit = %d delay = %d limit = %d\n", Area, (
int)
p->nAreaLim, Delay, (
int)
p->nDelayLim );
309 if ( Area > (
int)
p->nAreaLim || Delay > (
int)
p->nDelayLim )
314 pRes->
BSVars = (uBoundSet & 0xFFFF);
325printf(
"Found bound set " );
326Lpk_PrintSetOne( pRes->
BSVars );
330printf(
"Did not find boundsets.\n" );
354 unsigned i, uLateArrSupp = 0;
356 if (
p->pDelays[i] > (
int)
p->nDelayLim - 2 )
357 uLateArrSupp |= (1 << i);
376 unsigned uNonDecSupp, uLateArrSupp;
377 int i, k, nNonDecSize, nNonDecSizeMax;
378 assert( nCofDepth >= 1 && nCofDepth <= 3 );
379 assert( nCofDepth < (
int)
p->nLutK - 1 );
384 uNonDecSupp =
p->uSupp;
385 for ( i = 0; i < (1<<(nCofDepth-1)); i++ )
388 if ( nNonDecSizeMax < nNonDecSize )
390 nNonDecSizeMax = nNonDecSize;
393 else if ( nNonDecSizeMax == nNonDecSize )
400 if ( (uNonDecSupp & ~uLateArrSupp) == 0 )
407 pCofVars[nCofDepth-1] =
Lpk_FunComputeMinSuppSizeVar(
p, ppTruths[nCofDepth-1], 1<<(nCofDepth-1), ppTruths[nCofDepth], uNonDecSupp & ~uLateArrSupp );
410 for ( i = 0; i < (1<<nCofDepth); i++ )
421 for ( i = nCofDepth - 1; i >= 0; i-- )
422 for ( k = 0; k < (1<<i); k++ )
423 pvBSets[i][k] =
Lpk_MergeBoundSets( pvBSets[i+1][2*k+0], pvBSets[i+1][2*k+1],
p->nLutK - nCofDepth );
427 for ( i = nCofDepth; i >= 0; i-- )
428 for ( k = 0; k < (1<<i); k++ )
429 Vec_IntFree( pvBSets[i][k] );
435 for ( i = 0; i < nCofDepth; i++ )
458 int fUseBackLooking = 1;
466 assert( nShared >= 0 && nShared <= 3 );
467 assert(
p->uSupp == Kit_BitMask(
p->nVars) );
471 if ( pMan->
pPars->fVerbose )
475 Vec_IntFree( vBSets );
478 if ( pRes0->
nBSVars == (
int)
p->nLutK )
479 { pRes = pRes0;
goto finish; }
480 if ( pRes0->
nBSVars == (
int)
p->nLutK - 1 )
481 { pRes = pRes0;
goto finish; }
486 Kit_TruthCopy( pMan->
ppTruths[0][0], Lpk_FunTruth(
p, 0 ),
p->nVars );
492 if ( pRes1->
nBSVars == (
int)
p->nLutK - 1 )
493 { pRes = pRes1;
goto finish; }
494 if ( pRes0->
nBSVars == (
int)
p->nLutK - 2 )
495 { pRes = pRes0;
goto finish; }
496 if ( pRes1->
nBSVars == (
int)
p->nLutK - 2 )
497 { pRes = pRes1;
goto finish; }
507 if ( pRes2->
nBSVars == (
int)
p->nLutK - 2 )
508 { pRes = pRes2;
goto finish; }
509 if ( fUseBackLooking )
511 if ( pRes0->
nBSVars == (
int)
p->nLutK - 3 )
512 { pRes = pRes0;
goto finish; }
513 if ( pRes1->
nBSVars == (
int)
p->nLutK - 3 )
514 { pRes = pRes1;
goto finish; }
516 if ( pRes2->
nBSVars == (
int)
p->nLutK - 3 )
517 { pRes = pRes2;
goto finish; }
529 if ( pRes3->
nBSVars == (
int)
p->nLutK - 3 )
530 { pRes = pRes3;
goto finish; }
531 if ( fUseBackLooking )
533 if ( pRes0->
nBSVars == (
int)
p->nLutK - 4 )
534 { pRes = pRes0;
goto finish; }
535 if ( pRes1->
nBSVars == (
int)
p->nLutK - 4 )
536 { pRes = pRes1;
goto finish; }
537 if ( pRes2->
nBSVars == (
int)
p->nLutK - 4 )
538 { pRes = pRes2;
goto finish; }
540 if ( pRes3->
nBSVars == (
int)
p->nLutK - 4 )
541 { pRes = pRes3;
goto finish; }
546 for ( i = 0; i < (1<<nShared); i++ )
568 int i, k, iVacVar, nCofs;
570 Kit_TruthCopy( pMan->
ppTruths[0][0], Lpk_FunTruth(
p, 0),
p->nVars );
572 iVacVar = Kit_WordFindFirstBit( uBoundSet );
574 for ( i = 0; i < nCofVars; i++ )
575 for ( k = 0; k < (1<<i); k++ )
581 nCofs = (1<<nCofVars);
582 for ( k = 0; k < nCofs; k++ )
589 for ( i = nCofVars; i >= 1; i-- )
590 for ( k = 0; k < (1<<i); k++ )
596 Kit_TruthCopy( Lpk_FunTruth(
p, 0), pMan->
ppTruths[1][0],
p->nVars );
598 p->pFanins[iVacVar] = pNew->
Id;
607 p->nAreaLim =
p->nAreaLim - 1;
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
int Kit_DsdNonDsdSizeMax(Kit_DsdNtk_t *pNtk)
void Kit_DsdPrint(FILE *pFile, Kit_DsdNtk_t *pNtk)
unsigned Kit_TruthSupport(unsigned *pTruth, int nVars)
void Kit_TruthMuxVar(unsigned *pOut, unsigned *pCof0, unsigned *pCof1, int nVars, int iVar)
Kit_DsdNtk_t * Kit_DsdDecomposeExpand(unsigned *pTruth, int nVars)
void Kit_TruthCofactor1New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
void Kit_TruthCofactor0New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
void Kit_DsdNtkFree(Kit_DsdNtk_t *pNtk)
struct Kit_DsdObj_t_ Kit_DsdObj_t
int Kit_TruthSupportSize(unsigned *pTruth, int nVars)
void Kit_DsdTruthPartialTwo(Kit_DsdMan_t *p, Kit_DsdNtk_t *pNtk, unsigned uSupp, int iVar, unsigned *pTruthCo, unsigned *pTruthDec)
#define Kit_DsdObjForEachFanin(pNtk, pObj, iLit, i)
unsigned Kit_DsdNonDsdSupports(Kit_DsdNtk_t *pNtk)
struct Kit_DsdNtk_t_ Kit_DsdNtk_t
ABC_NAMESPACE_IMPL_START int Lpk_FunComputeMinSuppSizeVar(Lpk_Fun_t *p, unsigned **ppTruths, int nTruths, unsigned **ppCofs, unsigned uNonDecSupp)
DECLARATIONS ///.
Vec_Int_t * Lpk_ComputeBoundSets(Kit_DsdNtk_t *p, int nSizeMax)
unsigned Lpk_ComputeBoundSets_rec(Kit_DsdNtk_t *p, int iLit, Vec_Int_t *vSets, int nSizeMax)
Lpk_Res_t * Lpk_DsdAnalize(Lpk_Man_t *pMan, Lpk_Fun_t *p, int nShared)
unsigned Lpk_DsdLateArriving(Lpk_Fun_t *p)
int Lpk_DsdAnalizeOne(Lpk_Fun_t *p, unsigned *ppTruths[5][16], Kit_DsdNtk_t *pNtks[], char pCofVars[], int nCofDepth, Lpk_Res_t *pRes)
Vec_Int_t * Lpk_MergeBoundSets(Vec_Int_t *vSets0, Vec_Int_t *vSets1, int nSizeMax)
Lpk_Fun_t * Lpk_DsdSplit(Lpk_Man_t *pMan, Lpk_Fun_t *p, char *pCofVars, int nCofVars, unsigned uBoundSet)
void Lpk_FunCompareBoundSets(Lpk_Fun_t *p, Vec_Int_t *vBSets, int nCofDepth, unsigned uNonDecSupp, unsigned uLateArrSupp, Lpk_Res_t *pRes)
Lpk_Fun_t * Lpk_FunDup(Lpk_Fun_t *p, unsigned *pTruth)
int Lpk_SuppDelay(unsigned uSupp, int *pDelays)
int Lpk_FunSuppMinimize(Lpk_Fun_t *p)
#define Lpk_SuppForEachVar(Supp, Var)
struct Lpk_Fun_t_ Lpk_Fun_t
struct Lpk_Man_t_ Lpk_Man_t
struct Lpk_Res_t_ Lpk_Res_t
unsigned * ppTruths[5][16]
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.