37#define JF_WORD_MAX ((JF_LEAF_MAX > 6) ? 1 << (JF_LEAF_MAX-6) : 1)
39#define JF_EPSILON 0.005
73static inline int Jf_ObjIsUnit(
Gia_Obj_t *
p ) {
return !
p->fMark0; }
74static inline void Jf_ObjCleanUnit(
Gia_Obj_t *
p ) {
assert(Jf_ObjIsUnit(
p));
p->fMark0 = 1; }
75static inline void Jf_ObjSetUnit(
Gia_Obj_t *
p ) {
p->fMark0 = 0; }
77static inline int Jf_ObjCutH(
Jf_Man_t *
p,
int i ) {
return Vec_IntEntry(&
p->vCuts, i); }
78static inline int * Jf_ObjCuts(
Jf_Man_t *
p,
int i ) {
return (
int *)Vec_SetEntry(&
p->pMem, Jf_ObjCutH(
p, i)); }
79static inline int * Jf_ObjCutBest(
Jf_Man_t *
p,
int i ) {
return Jf_ObjCuts(
p, i) + 1; }
80static inline int Jf_ObjArr(
Jf_Man_t *
p,
int i ) {
return Vec_IntEntry(&
p->vArr, i); }
81static inline int Jf_ObjDep(
Jf_Man_t *
p,
int i ) {
return Vec_IntEntry(&
p->vDep, i); }
82static inline float Jf_ObjFlow(
Jf_Man_t *
p,
int i ) {
return Vec_FltEntry(&
p->vFlow, i); }
83static inline float Jf_ObjRefs(
Jf_Man_t *
p,
int i ) {
return Vec_FltEntry(&
p->vRefs, i); }
85static inline int Jf_ObjLit(
int i,
int c ) {
return Abc_Var2Lit( i, c ); }
87static inline int Jf_CutSize(
int * pCut ) {
return pCut[0] & 0xF; }
88static inline int Jf_CutCost(
int * pCut ) {
return (pCut[0] >> 4) & 0xF; }
89static inline int Jf_CutFunc(
int * pCut ) {
return ((
unsigned)pCut[0] >> 8); }
90static inline int Jf_CutSetAll(
int f,
int c,
int s ) {
return (f << 8) | (c << 4) | s; }
91static inline void Jf_CutSetSize(
int * pCut,
int s ) {
assert(s>=0 && s<16); pCut[0] ^= (Jf_CutSize(pCut) ^ s); }
92static inline void Jf_CutSetCost(
int * pCut,
int c ) {
assert(c>=0 && c<16); pCut[0] ^=((Jf_CutCost(pCut) ^ c) << 4); }
93static inline void Jf_CutSetFunc(
int * pCut,
int f ) {
assert(f>=0); pCut[0] ^=((Jf_CutFunc(pCut) ^ f) << 8); }
95static inline int Jf_CutFuncClass(
int * pCut ) {
return Abc_Lit2Var(Jf_CutFunc(pCut)); }
96static inline int Jf_CutFuncCompl(
int * pCut ) {
return Abc_LitIsCompl(Jf_CutFunc(pCut)); }
97static inline int * Jf_CutLits(
int * pCut ) {
return pCut + 1; }
98static inline int Jf_CutLit(
int * pCut,
int i ) {
assert(i);
return pCut[i]; }
100static inline int Jf_CutVar(
int * pCut,
int i ) {
assert(i);
return Abc_Lit2Var(pCut[i]); }
101static inline int Jf_CutIsTriv(
int * pCut,
int i ) {
return Jf_CutSize(pCut) == 1 && Jf_CutVar(pCut, 1) == i; }
102static inline int Jf_CutCnfSizeF(
Jf_Man_t *
p,
int f ) {
return Vec_IntEntry(
p->vCnfs, f ); }
103static inline int Jf_CutCnfSize(
Jf_Man_t *
p,
int * c ) {
return Jf_CutCnfSizeF(
p, Jf_CutFuncClass(c) ); }
105static inline int Jf_ObjFunc0(
Gia_Obj_t *
p,
int * c ) {
return Abc_LitNotCond(Jf_CutFunc(c), Gia_ObjFaninC0(
p)); }
106static inline int Jf_ObjFunc1(
Gia_Obj_t *
p,
int * c ) {
return Abc_LitNotCond(Jf_CutFunc(c), Gia_ObjFaninC1(
p)); }
108#define Jf_ObjForEachCut( pList, pCut, i ) for ( i = 0, pCut = pList + 1; i < pList[0]; i++, pCut += Jf_CutSize(pCut) + 1 )
109#define Jf_CutForEachLit( pCut, Lit, i ) for ( i = 1; i <= Jf_CutSize(pCut) && (Lit = Jf_CutLit(pCut, i)); i++ )
110#define Jf_CutForEachVar( pCut, Var, i ) for ( i = 1; i <= Jf_CutSize(pCut) && (Var = Jf_CutVar(pCut, i)); i++ )
131 if ( uTruth == 0 || ~uTruth == 0 )
133 Vec_IntPush( vClas, Vec_IntSize(vLits) );
134 Vec_IntPush( vLits, Abc_LitNotCond(iLitOut, (uTruth == 0)) );
138 int i, k, c, Literal,
Cube;
139 assert( Vec_IntSize(vLeaves) > 0 );
140 for ( c = 0; c < 2; c ++ )
142 int RetValue =
Kit_TruthIsop( (
unsigned *)&uTruth, Vec_IntSize(vLeaves), vCover, 0 );
146 Vec_IntPush( vClas, Vec_IntSize(vLits) );
147 Vec_IntPush( vLits, Abc_LitNotCond(iLitOut, c) );
148 for ( k = 0; k < Vec_IntSize(vLeaves); k++ )
150 Literal = 3 & (
Cube >> (k << 1));
152 Vec_IntPush( vLits, Abc_LitNotCond(Vec_IntEntry(vLeaves, k), 0) );
153 else if ( Literal == 2 )
154 Vec_IntPush( vLits, Abc_LitNotCond(Vec_IntEntry(vLeaves, k), 1) );
155 else if ( Literal != 0 )
167 int i, Entry, * pMap, nVars = 0;
170 Vec_IntPush( vClas, Vec_IntSize(vLits) );
172 Vec_IntPush( vLits, Abc_Var2Lit(Gia_ObjId(
p, pObj), 0) );
176 Gia_ManObj(
p, Abc_Lit2Var(Entry))->fMark0 = 1;
181 pObj->
fMark0 = 0, pMap[i] = nVars++;
184 Vec_IntWriteEntry( vLits, i, Abc_Lit2LitV(pMap, Entry) );
190 pCnf->
nClauses = Vec_IntSize(vClas);
192 pCnf->
pClauses[0] = Vec_IntReleaseArray(vLits);
206 pCnf->
nVars = Gia_ManObjNum(
p);
208 pCnf->
nClauses = Vec_IntSize(vClas);
210 pCnf->
pClauses[0] = Vec_IntReleaseArray(vLits);
217 for ( i = 0; i < pCnf->
nClauses; i++ )
219 iOut = Abc_Lit2Var(pCnf->
pClauses[i][0]);
248 Gia_Obj_t * pObj, * pCtrl, * pData0, * pData1;
254 Gia_ObjRefFanin0Inc(
p, pObj );
255 if ( Gia_ObjIsBuf(pObj) )
257 Gia_ObjRefFanin1Inc(
p, pObj );
262 Gia_ObjRefDec(
p, Gia_Regular(pCtrl) );
263 if ( Gia_Regular(pData1) == Gia_Regular(pData0) )
264 Gia_ObjRefDec(
p, Gia_Regular(pData1) );
267 Gia_ObjRefFanin0Inc(
p, pObj );
276 if ( Gia_ObjRefNum(
p, Gia_ObjFanin0(pObj)) == 1 )
278 Jf_ObjSetUnit(Gia_ObjFanin0(Gia_ObjFanin0(pObj)));
279 Jf_ObjSetUnit(Gia_ObjFanin0(Gia_ObjFanin1(pObj)));
280 Jf_ObjCleanUnit(Gia_ObjFanin0(pObj)), pMan->
nCoarse++;
282 if ( Gia_ObjRefNum(
p, Gia_ObjFanin1(pObj)) == 1 )
284 Jf_ObjSetUnit(Gia_ObjFanin1(Gia_ObjFanin0(pObj)));
285 Jf_ObjSetUnit(Gia_ObjFanin1(Gia_ObjFanin1(pObj)));
286 Jf_ObjCleanUnit(Gia_ObjFanin1(pObj)), pMan->
nCoarse++;
292 for ( i = 0; i < Gia_ManObjNum(
p); i++ )
293 pRes[i] = Abc_MaxInt( 1,
p->pRefs[i] );
311 int Counts[595] = {0}, Costs[595] = {0};
312 int i, iFunc, Total = 0, CostTotal = 0, Other = 0, CostOther = 0;
313 printf(
"DSD classes that appear in more than %.1f %% of mapped nodes:\n", 0.1 *
p->pPars->nVerbLimit );
315 if ( !Gia_ObjIsBuf(pObj) && Gia_ObjRefNumId(
p->pGia, i) )
317 iFunc = Jf_CutFuncClass( Jf_ObjCutBest(
p, i) );
319 if (
p->pPars->fGenCnf )
321 Costs[iFunc] += Jf_CutCnfSizeF(
p, iFunc);
322 CostTotal += Jf_CutCnfSizeF(
p, iFunc);
327 CostTotal = Abc_MaxInt(CostTotal, 1);
328 Total = Abc_MaxInt(Total, 1);
329 for ( i = 0; i < 595; i++ )
330 if ( Counts[i] && 100.0 * Counts[i] / Total >= 0.1 *
p->pPars->nVerbLimit )
332 printf(
"%5d : ", i );
334 printf(
"%8d ", Counts[i] );
335 printf(
"%5.1f %% ", 100.0 * Counts[i] / Total );
336 printf(
"%8d ", Costs[i] );
337 printf(
"%5.1f %%", 100.0 * Costs[i] / CostTotal );
343 CostOther += Costs[i];
345 printf(
"Other : " );
346 printf(
"%-20s ",
"" );
347 printf(
"%8d ", Other );
348 printf(
"%5.1f %% ", 100.0 * Other / Total );
349 printf(
"%8d ", CostOther );
350 printf(
"%5.1f %%", 100.0 * CostOther / CostTotal );
375 p->vTtMem = Vec_MemAllocForTT( pPars->
nLutSize, 0 );
381 p->vCnfs = Vec_IntStart( 595 );
385 Vec_IntFill( &
p->vCuts, Gia_ManObjNum(pGia), 0 );
386 Vec_IntFill( &
p->vArr, Gia_ManObjNum(pGia), 0 );
387 Vec_IntFill( &
p->vDep, Gia_ManObjNum(pGia), 0 );
388 Vec_FltFill( &
p->vFlow, Gia_ManObjNum(pGia), 0 );
389 p->vRefs.nCap =
p->vRefs.nSize = Gia_ManObjNum(pGia);
391 Vec_SetAlloc_( &
p->pMem, 20 );
392 p->vTemp = Vec_IntAlloc( 1000 );
393 p->clkStart = Abc_Clock();
398 if (
p->pPars->fVerbose &&
p->pDsd )
400 if (
p->pPars->fVerbose &&
p->vTtMem )
402 printf(
"Unique truth tables = %d. Memory = %.2f MB ", Vec_MemEntryNum(
p->vTtMem), Vec_MemMemory(
p->vTtMem) / (1<<20) );
403 Abc_PrintTime( 1,
"Time", Abc_Clock() -
p->clkStart );
405 if (
p->pPars->fVeryVerbose &&
p->pPars->fCutMin &&
p->pPars->fFuncDsd )
407 if (
p->pPars->fCoarsen )
415 if (
p->pPars->fCutMin && !
p->pPars->fFuncDsd )
417 Vec_MemHashFree(
p->vTtMem );
418 Vec_MemFree(
p->vTtMem );
420 Vec_IntFreeP( &
p->vCnfs );
421 Vec_SetFree_( &
p->pMem );
422 Vec_IntFreeP( &
p->vTemp );
437static inline void Jf_CutPrint(
int * pCut )
440 printf(
"%d {", Jf_CutSize(pCut) );
441 for ( i = 1; i <= Jf_CutSize(pCut); i++ )
442 printf(
" %d", Jf_CutLit(pCut, i) );
443 printf(
" } Func = %d\n", Jf_CutFunc(pCut) );
445static inline void Jf_ObjCutPrint(
int * pCuts )
454 int * pCut = Jf_ObjCutBest(
p, Gia_ObjId(
p->pGia, pObj) );
455 printf(
"Best cut of node %d : ", Gia_ObjId(
p->pGia, pObj) );
459static inline void Jf_CutCheck(
int * pCut )
462 for ( i = 2; i <= Jf_CutSize(pCut); i++ )
463 for ( k = 1; k < i; k++ )
464 assert( Jf_CutLit(pCut, i) != Jf_CutLit(pCut, k) );
466static inline int Jf_CountBitsSimple(
unsigned n )
469 for ( i = 0; i < 32; i++ )
470 Count += ((n >> i) & 1);
473static inline int Jf_CountBits32(
unsigned i )
475 i = i - ((i >> 1) & 0x55555555);
476 i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
477 i = ((i + (i >> 4)) & 0x0F0F0F0F);
478 return (i*(0x01010101))>>24;
480static inline int Jf_CountBits(
word i )
482 i = i - ((i >> 1) & 0x5555555555555555);
483 i = (i & 0x3333333333333333) + ((i >> 2) & 0x3333333333333333);
484 i = ((i + (i >> 4)) & 0x0F0F0F0F0F0F0F0F);
485 return (i*(0x0101010101010101))>>56;
487static inline unsigned Jf_CutGetSign32(
int * pCut )
489 unsigned Sign = 0;
int i;
490 for ( i = 1; i <= Jf_CutSize(pCut); i++ )
491 Sign |= 1 << (Jf_CutVar(pCut, i) & 0x1F);
494static inline word Jf_CutGetSign(
int * pCut )
496 word Sign = 0;
int i;
497 for ( i = 1; i <= Jf_CutSize(pCut); i++ )
498 Sign |= ((
word)1) << (Jf_CutVar(pCut, i) & 0x3F);
501static inline int Jf_CutArr(
Jf_Man_t *
p,
int * pCut )
504 for ( i = 1; i <= Jf_CutSize(pCut); i++ )
505 Time = Abc_MaxInt( Time, Jf_ObjArr(
p, Jf_CutVar(pCut, i)) );
509static inline void Jf_ObjSetBestCut(
int * pCuts,
int * pCut,
Vec_Int_t * vTemp )
512 if ( ++pCuts < pCut )
514 int nBlock = pCut - pCuts;
515 int nSize = Jf_CutSize(pCut) + 1;
516 Vec_IntGrow( vTemp, nBlock );
517 memmove( Vec_IntArray(vTemp), pCuts,
sizeof(
int) * nBlock );
518 memmove( pCuts, pCut,
sizeof(
int) * nSize );
519 memmove( pCuts + nSize, Vec_IntArray(vTemp),
sizeof(
int) * nBlock );
522static inline void Jf_CutRef(
Jf_Man_t *
p,
int * pCut )
525 for ( i = 1; i <= Jf_CutSize(pCut); i++ )
526 Gia_ObjRefIncId(
p->pGia, Jf_CutVar(pCut, i) );
528static inline void Jf_CutDeref(
Jf_Man_t *
p,
int * pCut )
531 for ( i = 1; i <= Jf_CutSize(pCut); i++ )
532 Gia_ObjRefDecId(
p->pGia, Jf_CutVar(pCut, i) );
534static inline float Jf_CutFlow(
Jf_Man_t *
p,
int * pCut )
536 float Flow = 0;
int i;
537 for ( i = 1; i <= Jf_CutSize(pCut); i++ )
538 Flow += Jf_ObjFlow(
p, Jf_CutVar(pCut, i) );
554static inline int Jf_CutIsContainedOrder(
int * pBase,
int * pCut )
556 int nSizeB = Jf_CutSize(pBase);
557 int nSizeC = Jf_CutSize(pCut);
559 if ( nSizeB == nSizeC )
561 for ( i = 1; i <= nSizeB; i++ )
562 if ( pBase[i] != pCut[i] )
566 assert( nSizeB > nSizeC );
567 for ( i = k = 1; i <= nSizeB; i++ )
569 if ( pBase[i] > pCut[k] )
571 if ( pBase[i] == pCut[k] )
579static inline int Jf_CutMergeOrder(
int * pCut0,
int * pCut1,
int * pCut,
int LutSize )
581 int nSize0 = Jf_CutSize(pCut0);
582 int nSize1 = Jf_CutSize(pCut1);
583 int * pC0 = pCut0 + 1;
584 int * pC1 = pCut1 + 1;
588 if ( nSize0 == LutSize && nSize1 == LutSize )
590 for ( i = 0; i < nSize0; i++ )
592 if ( pC0[i] != pC1[i] )
601 if ( nSize0 == 0 )
goto FlushCut1;
602 if ( nSize1 == 0 )
goto FlushCut0;
605 if ( c == LutSize )
return 0;
606 if ( pC0[i] < pC1[k] )
609 if ( i >= nSize0 )
goto FlushCut1;
611 else if ( pC0[i] > pC1[k] )
614 if ( k >= nSize1 )
goto FlushCut0;
618 pC[c++] = pC0[i++]; k++;
619 if ( i >= nSize0 )
goto FlushCut1;
620 if ( k >= nSize1 )
goto FlushCut0;
625 if ( c + nSize0 > LutSize + i )
return 0;
632 if ( c + nSize1 > LutSize + k )
return 0;
650static inline int Jf_CutFindLeaf0(
int * pCut,
int iObj )
652 int i, nLits = Jf_CutSize(pCut);
653 for ( i = 1; i <= nLits; i++ )
654 if ( pCut[i] == iObj )
658static inline int Jf_CutIsContained0(
int * pBase,
int * pCut )
660 int i, nLits = Jf_CutSize(pCut);
661 for ( i = 1; i <= nLits; i++ )
662 if ( Jf_CutFindLeaf0(pBase, pCut[i]) > pBase[0] )
666static inline int Jf_CutMerge0(
int * pCut0,
int * pCut1,
int * pCut,
int LutSize )
668 int nSize0 = Jf_CutSize(pCut0);
669 int nSize1 = Jf_CutSize(pCut1), i;
671 for ( i = 1; i <= nSize1; i++ )
672 if ( Jf_CutFindLeaf0(pCut0, pCut1[i]) > nSize0 )
674 if ( pCut[0] == LutSize )
676 pCut[++pCut[0]] = pCut1[i];
678 memcpy( pCut + 1, pCut0 + 1,
sizeof(
int) * nSize0 );
693static inline int Jf_CutFindLeaf1(
int * pCut,
int iLit )
695 int i, nLits = Jf_CutSize(pCut);
696 for ( i = 1; i <= nLits; i++ )
697 if ( Abc_Lit2Var(pCut[i]) == iLit )
701static inline int Jf_CutIsContained1(
int * pBase,
int * pCut )
703 int i, nLits = Jf_CutSize(pCut);
704 for ( i = 1; i <= nLits; i++ )
705 if ( Jf_CutFindLeaf1(pBase, Abc_Lit2Var(pCut[i])) > pBase[0] )
709static inline int Jf_CutMerge1(
int * pCut0,
int * pCut1,
int * pCut,
int LutSize )
711 int nSize0 = Jf_CutSize(pCut0);
712 int nSize1 = Jf_CutSize(pCut1), i;
714 for ( i = 1; i <= nSize1; i++ )
715 if ( Jf_CutFindLeaf1(pCut0, Abc_Lit2Var(pCut1[i])) > nSize0 )
717 if ( pCut[0] == LutSize )
719 pCut[++pCut[0]] = pCut1[i];
721 memcpy( pCut + 1, pCut0 + 1,
sizeof(
int) * nSize0 );
724static inline int Jf_CutMerge2(
int * pCut0,
int * pCut1,
int * pCut,
int LutSize )
726 int ConfigMask = 0x3FFFF;
727 int nSize0 = Jf_CutSize(pCut0);
728 int nSize1 = Jf_CutSize(pCut1);
731 for ( i = 1; i <= nSize1; i++ )
733 iPlace = Jf_CutFindLeaf1(pCut0, Abc_Lit2Var(pCut1[i]));
734 if ( iPlace > nSize0 )
736 if ( pCut[0] == LutSize )
738 pCut[(iPlace = ++pCut[0])] = pCut1[i];
740 else if ( pCut0[iPlace] != pCut1[i] )
741 ConfigMask |= (1 << (iPlace+17));
742 ConfigMask ^= (((i-1) ^ 7) << (3*(iPlace-1)));
744 memcpy( pCut + 1, pCut0 + 1,
sizeof(
int) * nSize0 );
765 for ( k = 0; k < c; k++ )
766 if ( pSto[c]->pCut[0] >= pSto[k]->pCut[0] &&
767 (pSto[c]->Sign & pSto[k]->Sign) == pSto[k]->Sign &&
768 Jf_CutIsContained1(pSto[c]->pCut, pSto[k]->pCut) )
770 pSto[c]->
pCut[0] = -1;
774 for ( k = last = 0; k < c; k++ )
775 if ( !(pSto[c]->pCut[0] < pSto[k]->pCut[0] &&
776 (pSto[c]->Sign & pSto[k]->Sign) == pSto[c]->Sign &&
777 Jf_CutIsContained1(pSto[k]->pCut, pSto[c]->pCut)) )
791 if (
p->pPars->fCutMin )
793 for ( k = 0; k < c; k++ )
794 if ( pSto[c]->pCut[0] >= pSto[k]->pCut[0] &&
795 (pSto[c]->Sign & pSto[k]->Sign) == pSto[k]->Sign &&
796 Jf_CutIsContained1(pSto[c]->pCut, pSto[k]->pCut) )
801 for ( k = 0; k < c; k++ )
802 if ( pSto[c]->pCut[0] >= pSto[k]->pCut[0] &&
803 (pSto[c]->Sign & pSto[k]->Sign) == pSto[k]->Sign &&
804 Jf_CutIsContainedOrder(pSto[c]->pCut, pSto[k]->pCut) )
821static inline void Jf_ObjSortCuts(
Jf_Cut_t ** pSto,
int nSize )
824 for ( i = 0; i < nSize-1; i++ )
827 for ( j = i+1; j < nSize; j++ )
828 if ( pSto[j]->pCut[0] < pSto[best_i]->pCut[0] )
847 int i,
Var, Count = Jf_CutCost(pCut);
849 if ( !Gia_ObjRefIncId(
p->pGia,
Var) && !Jf_CutIsTriv(Jf_ObjCutBest(
p,
Var),
Var) )
855 int i,
Var, Count = Jf_CutCost(pCut);
857 if ( !Gia_ObjRefDecId(
p->pGia,
Var) && !Jf_CutIsTriv(Jf_ObjCutBest(
p,
Var),
Var) )
861static inline int Jf_CutAreaOld(
Jf_Man_t *
p,
int * pCut )
872 int i,
Var, Count = Jf_CutCost(pCut);
875 if ( !Gia_ObjRefIncId(
p->pGia,
Var) && !Jf_CutIsTriv(Jf_ObjCutBest(
p,
Var),
Var) )
877 Vec_IntPush(
p->vTemp,
Var );
883 int i,
Var, Count = (Jf_CutCost(pCut) << 4) | Jf_CutSize(pCut);
886 if ( !Gia_ObjRefIncId(
p->pGia,
Var) && !Jf_CutIsTriv(Jf_ObjCutBest(
p,
Var),
Var) )
888 Vec_IntPush(
p->vTemp,
Var );
892static inline int Jf_CutArea(
Jf_Man_t *
p,
int * pCut,
int fEdge )
895 Vec_IntClear(
p->vTemp );
901 Gia_ObjRefDecId(
p->pGia, Entry );
910 int fRecur = (!Gia_ObjRefDecId(
p->pGia,
Var) && !Jf_CutIsTriv(Jf_ObjCutBest(
p,
Var),
Var));
911 Vec_IntPush(
p->vTemp,
Var );
912 if ( Vec_IntSize(
p->vTemp) >= Limit )
919static inline int Jf_CutCheckMffc(
Jf_Man_t *
p,
int * pCut,
int Limit )
921 int RetValue, Entry, i;
922 Vec_IntClear(
p->vTemp );
925 Gia_ObjRefIncId(
p->pGia, Entry );
958static inline int Jf_ObjAddCutToStore(
Jf_Man_t *
p,
Jf_Cut_t ** pSto,
int c,
int cMax )
966 if ( c == cMax &&
p->pCutCmp(pSto[c-1], pSto[c]) <= 0 )
970 for ( iPivot = c-1; iPivot >= 0; iPivot-- )
971 if (
p->pCutCmp(pSto[iPivot], pSto[c]) < 0 )
974 if (
p->pPars->fCutMin )
976 for ( k = 0; k <= iPivot; k++ )
977 if ( pSto[c]->pCut[0] >= pSto[k]->pCut[0] &&
978 (pSto[c]->Sign & pSto[k]->Sign) == pSto[k]->Sign &&
979 Jf_CutIsContained1(pSto[c]->pCut, pSto[k]->pCut) )
984 for ( k = 0; k <= iPivot; k++ )
985 if ( pSto[c]->pCut[0] >= pSto[k]->pCut[0] &&
986 (pSto[c]->Sign & pSto[k]->Sign) == pSto[k]->Sign &&
987 Jf_CutIsContainedOrder(pSto[c]->pCut, pSto[k]->pCut) )
992 for ( ++iPivot, k = c++; k > iPivot; k-- )
994 pSto[iPivot] = pTemp;
996 if (
p->pPars->fCutMin )
998 for ( k = last = iPivot+1; k < c; k++ )
999 if ( !(pSto[iPivot]->pCut[0] <= pSto[k]->pCut[0] &&
1000 (pSto[iPivot]->Sign & pSto[k]->Sign) == pSto[iPivot]->Sign &&
1001 Jf_CutIsContained1(pSto[k]->pCut, pSto[iPivot]->pCut)) )
1010 for ( k = last = iPivot+1; k < c; k++ )
1011 if ( !(pSto[iPivot]->pCut[0] <= pSto[k]->pCut[0] &&
1012 (pSto[iPivot]->Sign & pSto[k]->Sign) == pSto[iPivot]->Sign &&
1013 Jf_CutIsContainedOrder(pSto[k]->pCut, pSto[iPivot]->pCut)) )
1022 if ( c == cMax + 1 )
1029 for ( i = 0; i < c; i++ )
1031 printf(
"Flow =%9.5f ", pSto[i]->Flow );
1032 printf(
"Time = %5d ", pSto[i]->Time );
1033 printf(
"Func = %5d ", pSto[i]->iFunc );
1035 Jf_CutPrint( pSto[i]->pCut );
1039static inline void Jf_ObjCheckPtrs(
Jf_Cut_t ** pSto,
int c )
1042 for ( i = 1; i < c; i++ )
1043 for ( k = 0; k < i; k++ )
1044 assert( pSto[k] != pSto[i] );
1046static inline void Jf_ObjCheckStore(
Jf_Man_t *
p,
Jf_Cut_t ** pSto,
int c,
int iObj )
1049 for ( i = 1; i < c; i++ )
1050 assert(
p->pCutCmp(pSto[i-1], pSto[i]) <= 0 );
1051 for ( i = 1; i < c; i++ )
1052 for ( k = 0; k < i; k++ )
1054 assert( !Jf_CutIsContained1(pSto[k]->pCut, pSto[i]->pCut) );
1055 assert( !Jf_CutIsContained1(pSto[i]->pCut, pSto[k]->pCut) );
1073 int fCompl, truthId;
1074 int LutSize =
p->pPars->nLutSize;
1075 int nWords = Abc_Truth6WordNum(
p->pPars->nLutSize);
1076 word * pTruth0 = Vec_MemReadEntry(
p->vTtMem, Abc_Lit2Var(iFuncLit0));
1077 word * pTruth1 = Vec_MemReadEntry(
p->vTtMem, Abc_Lit2Var(iFuncLit1));
1078 Abc_TtCopy( uTruth0, pTruth0,
nWords, Abc_LitIsCompl(iFuncLit0) );
1079 Abc_TtCopy( uTruth1, pTruth1,
nWords, Abc_LitIsCompl(iFuncLit1) );
1080 Abc_TtExpand( uTruth0, LutSize, pCut0 + 1, Jf_CutSize(pCut0), pCutOut + 1, Jf_CutSize(pCutOut) );
1081 Abc_TtExpand( uTruth1, LutSize, pCut1 + 1, Jf_CutSize(pCut1), pCutOut + 1, Jf_CutSize(pCutOut) );
1082 fCompl = (int)(uTruth0[0] & uTruth1[0] & 1);
1083 Abc_TtAnd( uTruth, uTruth0, uTruth1,
nWords, fCompl );
1084 pCutOut[0] = Abc_TtMinBase( uTruth, pCutOut + 1, pCutOut[0], LutSize );
1085 assert( (uTruth[0] & 1) == 0 );
1086 truthId = Vec_MemHashInsert(
p->vTtMem, uTruth);
1087 return Abc_Var2Lit( truthId, fCompl );
1103 int iObj = Gia_ObjId(
p->pGia, pObj);
1104 int pClause[3] = { 1, Jf_CutSetAll(2, 0, 1), Jf_ObjLit(iObj, 0) };
1105 assert( Gia_ObjIsCi(pObj) || Gia_ObjIsBuf(pObj) );
1106 Vec_IntWriteEntry( &
p->vCuts, iObj, Vec_SetAppend( &
p->pMem, pClause, 3 ) );
1110 int iObj = Gia_ObjId(
p->pGia, pObj );
1111 int iFanin = Gia_ObjFaninId0( pObj, iObj );
1113 assert( Gia_ObjIsBuf(pObj) );
1116 Vec_IntWriteEntry( &
p->vArr, iObj, Jf_ObjArr(
p, iFanin) );
1117 Vec_FltWriteEntry( &
p->vFlow, iObj, Jf_ObjFlow(
p, iFanin) );
1119static inline int Jf_ObjHasCutWithSize(
Jf_Cut_t ** pSto,
int c,
int nSize )
1122 for ( i = 0; i < c; i++ )
1123 if ( pSto[i]->pCut[0] <= nSize )
1129 int LutSize =
p->pPars->nLutSize;
1130 int CutNum =
p->pPars->nCutNum;
1131 int iObj = Gia_ObjId(
p->pGia, pObj);
1136 int * pCut0, * pCut1, * pCuts0, * pCuts1;
1137 int nOldSupp, Config, i, k, c = 0;
1139 for ( i = 0; i <= CutNum+1; i++ )
1140 pSto[i] = Sto + i, pSto[i]->Cost = 0, pSto[i]->iFunc = ~0;
1142 pCuts0 = Jf_ObjCuts(
p, Gia_ObjFaninId0(pObj, iObj) );
1144 Sign0[i] = Jf_CutGetSign( pCut0 );
1146 pCuts1 = Jf_ObjCuts(
p, Gia_ObjFaninId1(pObj, iObj) );
1148 Sign1[i] = Jf_CutGetSign( pCut1 );
1150 p->CutCount[0] += pCuts0[0] * pCuts1[0];
1154 if ( Jf_CountBits(Sign0[i] | Sign1[k]) > LutSize )
1157 if ( !
p->pPars->fCutMin )
1159 if ( !Jf_CutMergeOrder(pCut0, pCut1, pSto[c]->pCut, LutSize) )
1161 pSto[c]->
Sign = Sign0[i] | Sign1[k];
1163 else if (
p->pPars->fFuncDsd )
1165 if ( !(Config = Jf_CutMerge2(pCut0, pCut1, pSto[c]->pCut, LutSize)) )
1167 pSto[c]->
Sign = Sign0[i] | Sign1[k];
1168 nOldSupp = pSto[c]->
pCut[0];
1169 pSto[c]->
iFunc =
Sdm_ManComputeFunc(
p->pDsd, Jf_ObjFunc0(pObj, pCut0), Jf_ObjFunc1(pObj, pCut1), pSto[c]->pCut, Config, 0 );
1170 if ( pSto[c]->iFunc == -1 )
1172 if (
p->pPars->fGenCnf && Jf_CutCnfSizeF(
p, Abc_Lit2Var(pSto[c]->iFunc)) >= 12 )
1174 assert( pSto[c]->pCut[0] <= nOldSupp );
1175 if ( pSto[c]->pCut[0] < nOldSupp )
1176 pSto[c]->
Sign = Jf_CutGetSign( pSto[c]->pCut );
1180 if ( !Jf_CutMergeOrder(pCut0, pCut1, pSto[c]->pCut, LutSize) )
1182 pSto[c]->
Sign = Sign0[i] | Sign1[k];
1183 nOldSupp = pSto[c]->
pCut[0];
1184 pSto[c]->
iFunc =
Jf_TtComputeForCut(
p, Jf_ObjFunc0(pObj, pCut0), Jf_ObjFunc1(pObj, pCut1), pCut0, pCut1, pSto[c]->pCut );
1185 assert( pSto[c]->pCut[0] <= nOldSupp );
1186 if ( pSto[c]->pCut[0] < nOldSupp )
1187 pSto[c]->
Sign = Jf_CutGetSign( pSto[c]->pCut );
1188 if ( pSto[c]->iFunc >= (1 << 24) )
1189 printf(
"Hard limit on the number of different Boolean functions (2^23) is reached. Quitting...\n" ),
exit(1);
1192 pSto[c]->
Time =
p->pPars->fAreaOnly ? 0 : Jf_CutArr(
p, pSto[c]->pCut);
1193 pSto[c]->
Flow = Jf_CutFlow(
p, pSto[c]->pCut);
1194 c = Jf_ObjAddCutToStore(
p, pSto, c, CutNum );
1200 if ( !Jf_ObjIsUnit(pObj) && !Jf_ObjHasCutWithSize(pSto, c, 2) )
1202 assert( Jf_ObjIsUnit(Gia_ObjFanin0(pObj)) && Jf_ObjIsUnit(Gia_ObjFanin1(pObj)) );
1203 if (
p->pPars->fCutMin ) pSto[c]->
iFunc = 4;
1204 pSto[c]->
pCut[0] = 2;
1205 pSto[c]->
pCut[1] = Jf_ObjLit(Gia_ObjFaninId0(pObj, iObj), Gia_ObjFaninC0(pObj));
1206 pSto[c]->
pCut[2] = Jf_ObjLit(Gia_ObjFaninId1(pObj, iObj), Gia_ObjFaninC1(pObj));
1210 if ( Jf_ObjIsUnit(pObj) && !(
p->pPars->fCutMin && Jf_ObjHasCutWithSize(pSto, c, 1)) )
1212 if (
p->pPars->fCutMin ) pSto[c]->
iFunc = 2;
1213 pSto[c]->
pCut[0] = 1;
1214 pSto[c]->
pCut[1] = Jf_ObjLit(iObj, 0);
1221 pSto[0]->
Cost =
p->pPars->fGenCnf ? Jf_CutCnfSizeF(
p, Abc_Lit2Var(pSto[0]->iFunc)) : 1;
1222 assert( pSto[0]->Cost >= 0 );
1224 assert( pSto[0]->Flow >= 0 );
1225 Vec_IntWriteEntry( &
p->vArr, iObj, pSto[0]->
Time );
1226 Vec_FltWriteEntry( &
p->vFlow, iObj, (pSto[0]->
Flow + (fEdge ? pSto[0]->
pCut[0] : pSto[0]->
Cost)) / Jf_ObjRefs(
p, iObj) );
1228 Vec_IntClear(
p->vTemp );
1229 Vec_IntPush(
p->vTemp, c );
1230 for ( i = 0; i < c; i++ )
1232 pSto[i]->
Cost =
p->pPars->fGenCnf ? Jf_CutCnfSizeF(
p, Abc_Lit2Var(pSto[i]->iFunc)) : 1;
1233 Vec_IntPush(
p->vTemp, Jf_CutSetAll(pSto[i]->iFunc, pSto[i]->Cost, pSto[i]->pCut[0]) );
1234 for ( k = 1; k <= pSto[i]->
pCut[0]; k++ )
1235 Vec_IntPush(
p->vTemp, pSto[i]->
pCut[k] );
1237 Vec_IntWriteEntry( &
p->vCuts, iObj, Vec_SetAppend(&
p->pMem, Vec_IntArray(
p->vTemp), Vec_IntSize(
p->vTemp)) );
1238 p->CutCount[3] += c;
1243 if (
p->pPars->fVerbose )
1245 printf(
"Aig: CI = %d CO = %d AND = %d ", Gia_ManCiNum(
p->pGia), Gia_ManCoNum(
p->pGia), Gia_ManAndNum(
p->pGia) );
1246 printf(
"LutSize = %d CutMax = %d Rounds = %d\n",
p->pPars->nLutSize,
p->pPars->nCutNum,
p->pPars->nRounds );
1247 printf(
"Computing cuts...\r" );
1252 if ( Gia_ObjIsCi(pObj) || Gia_ObjIsBuf(pObj) )
1253 Jf_ObjAssignCut(
p, pObj );
1254 if ( Gia_ObjIsBuf(pObj) )
1255 Jf_ObjPropagateBuf(
p, pObj, 0 );
1256 else if ( Gia_ObjIsAnd(pObj) )
1259 if (
p->pPars->fVerbose )
1261 printf(
"CutPair = %lu ", (
long)
p->CutCount[0] );
1262 printf(
"Merge = %lu ", (
long)
p->CutCount[1] );
1263 printf(
"Eval = %lu ", (
long)
p->CutCount[2] );
1264 printf(
"Cut = %lu ", (
long)
p->CutCount[3] );
1265 Abc_PrintTime( 1,
"Time", Abc_Clock() -
p->clkStart );
1266 printf(
"Memory: " );
1268 printf(
"Man = %.2f MB ", 6.0 *
sizeof(
int) * Gia_ManObjNum(
p->pGia) / (1<<20) );
1269 printf(
"Cuts = %.2f MB", Vec_ReportMemory(&
p->pMem) / (1<<20) );
1271 printf(
" Coarse = %d (%.1f %%)",
p->nCoarse, 100.0 *
p->nCoarse / Gia_ManObjNum(
p->pGia) );
1296 if ( Gia_ObjIsBuf(pObj) )
1297 Jf_ObjPropagateBuf(
p, pObj, 0 );
1298 else if ( Gia_ObjIsAnd(pObj) && Gia_ObjRefNum(
p->pGia, pObj) > 0 )
1299 Vec_IntWriteEntry( &
p->vArr, i, Jf_CutArr(
p, Jf_ObjCutBest(
p, i)) );
1303 assert( Gia_ObjRefNum(
p->pGia, pObj) > 0 );
1304 Delay = Abc_MaxInt( Delay, Jf_ObjArr(
p, Gia_ObjId(
p->pGia, pObj)) );
1311 float nRefsNew;
int i, * pCut;
1312 float * pRefs = Vec_FltArray(&
p->vRefs);
1313 float * pFlow = Vec_FltArray(&
p->vFlow);
1314 assert(
p->pGia->pRefs != NULL );
1315 memset(
p->pGia->pRefs, 0,
sizeof(
int) * Gia_ManObjNum(
p->pGia) );
1316 p->pPars->Area =
p->pPars->Edge = 0;
1319 if ( Gia_ObjIsCo(pObj) || Gia_ObjIsBuf(pObj) )
1320 Gia_ObjRefInc(
p->pGia, Gia_ObjFanin0(pObj) );
1321 else if ( Gia_ObjIsAnd(pObj) && Gia_ObjRefNum(
p->pGia, pObj) > 0 )
1323 assert( Jf_ObjIsUnit(pObj) );
1324 pCut = Jf_ObjCutBest(
p, i);
1325 Jf_CutRef(
p, pCut );
1326 if (
p->pPars->fGenCnf )
1327 p->pPars->Clause += Jf_CutCnfSize(
p, pCut);
1328 p->pPars->Edge += Jf_CutSize(pCut);
1333 for ( i = 0; i < Gia_ManObjNum(
p->pGia); i++ )
1335 if (
p->pPars->fOptEdge )
1336 nRefsNew = Abc_MaxFloat( 1, 0.8 * pRefs[i] + 0.2 *
p->pGia->pRefs[i] );
1338 nRefsNew = Abc_MaxFloat( 1, 0.2 * pRefs[i] + 0.8 *
p->pGia->pRefs[i] );
1339 pFlow[i] = pFlow[i] * pRefs[i] / nRefsNew;
1340 pRefs[i] = nRefsNew;
1345 return p->pPars->Area;
1361 int i, iObj = Gia_ObjId(
p->pGia, pObj );
1362 int * pCuts = Jf_ObjCuts(
p, iObj );
1363 int * pCut, * pCutBest = NULL;
1368 if ( Jf_CutIsTriv(pCut, iObj) )
continue;
1369 if ( fEdge && !fEla )
1370 Jf_CutSetCost(pCut, Jf_CutSize(pCut));
1371 Area = fEla ? Jf_CutArea(
p, pCut, fEdge) : Jf_CutFlow(
p, pCut) + Jf_CutCost(pCut);
1372 if ( pCutBest == NULL || AreaBest > Area +
JF_EPSILON || (AreaBest > Area -
JF_EPSILON && TimeBest > (Time = Jf_CutArr(
p, pCut))) )
1373 pCutBest = pCut, AreaBest = Area, TimeBest = Time;
1375 Vec_IntWriteEntry( &
p->vArr, iObj, Jf_CutArr(
p, pCutBest) );
1377 Vec_FltWriteEntry( &
p->vFlow, iObj, AreaBest / Jf_ObjRefs(
p, iObj) );
1378 Jf_ObjSetBestCut( pCuts, pCutBest,
p->vTemp );
1386 if ( Gia_ObjIsBuf(pObj) )
1387 Jf_ObjPropagateBuf(
p, pObj, 0 );
1388 else if ( Gia_ObjIsAnd(pObj) && Jf_ObjIsUnit(pObj) )
1395 int i, CostBef, CostAft;
1396 p->pPars->Area =
p->pPars->Edge =
p->pPars->Clause = 0;
1398 if ( Gia_ObjIsBuf(pObj) )
1399 Jf_ObjPropagateBuf(
p, pObj, 1 );
1400 else if ( Gia_ObjIsAnd(pObj) && Gia_ObjRefNum(
p->pGia, pObj) > 0 )
1402 assert( Jf_ObjIsUnit(pObj) );
1403 if ( Jf_CutCheckMffc(
p, Jf_ObjCutBest(
p, i), 50) )
1409 assert( CostBef >= CostAft );
1411 if (
p->pPars->fGenCnf )
1412 p->pPars->Clause += Jf_CutCnfSize(
p, Jf_ObjCutBest(
p, i));
1413 p->pPars->Edge += Jf_CutSize(Jf_ObjCutBest(
p, i));
1435 Vec_Int_t * vCopies = Vec_IntStartFull( Gia_ManObjNum(
p->pGia) );
1436 Vec_Int_t * vMapping = Vec_IntStart( 2 * Gia_ManObjNum(
p->pGia) + (
int)
p->pPars->Edge + 2 * (
int)
p->pPars->Area );
1437 Vec_Int_t * vMapping2 = Vec_IntStart( (
int)
p->pPars->Edge + 2 * (
int)
p->pPars->Area + 1000 );
1438 Vec_Int_t * vCover = Vec_IntAlloc( 1 << 16 );
1439 Vec_Int_t * vLeaves = Vec_IntAlloc( 16 );
1440 Vec_Int_t * vLits = NULL, * vClas = NULL;
1441 int i, k, iLit, Class, * pCut;
1442 word uTruth = 0, * pTruth = &uTruth;
1444 if (
p->pPars->fGenCnf )
1446 vLits = Vec_IntAlloc( 1000 );
1447 vClas = Vec_IntAlloc( 1000 );
1448 Vec_IntPush( vClas, Vec_IntSize(vLits) );
1449 Vec_IntPush( vLits, 1 );
1453 pNew->
pName = Abc_UtilStrsav(
p->pGia->pName );
1454 pNew->
pSpec = Abc_UtilStrsav(
p->pGia->pSpec );
1456 Vec_IntWriteEntry( vCopies, 0, 0 );
1458 Vec_IntWriteEntry( vCopies, Gia_ObjId(
p->pGia, pObj), Gia_ManAppendCi(pNew) );
1462 if ( Gia_ObjIsBuf(pObj) || Gia_ObjRefNum(
p->pGia, pObj) == 0 )
1464 pCut = Jf_ObjCutBest(
p, i );
1466 Class = Jf_CutFuncClass( pCut );
1467 if ( Jf_CutSize(pCut) == 0 )
1470 Vec_IntWriteEntry( vCopies, i, Jf_CutFunc(pCut) );
1473 if ( Jf_CutSize(pCut) == 1 )
1476 iLit = Abc_LitNotCond( Jf_CutLit(pCut, 1) , Jf_CutFuncCompl(pCut) );
1477 iLit = Abc_Lit2LitL( Vec_IntArray(vCopies), iLit );
1478 Vec_IntWriteEntry( vCopies, i, iLit );
1481 if (
p->pPars->fFuncDsd )
1484 pTruth = Vec_MemReadEntry(
p->vTtMem, Class);
1487 Vec_IntClear( vLeaves );
1489 Vec_IntPush( vLeaves, Abc_Lit2LitL(Vec_IntArray(vCopies), iLit) );
1491 iLit =
Kit_TruthToGia( pNew, (
unsigned *)pTruth, Vec_IntSize(vLeaves), vCover, vLeaves, 0 );
1492 if (
p->pPars->fGenCnf )
1493 Jf_ManGenCnf( uTruth, iLit, vLeaves, vLits, vClas, vCover );
1494 iLit = Abc_LitNotCond( iLit, Jf_CutFuncCompl(pCut) );
1495 Vec_IntWriteEntry( vCopies, i, iLit );
1497 Vec_IntSetEntry( vMapping, Abc_Lit2Var(iLit), Vec_IntSize(vMapping2) );
1498 Vec_IntPush( vMapping2, Vec_IntSize(vLeaves) );
1500 Vec_IntPush( vMapping2, Abc_Lit2Var(iLit) );
1501 Vec_IntPush( vMapping2, Abc_Lit2Var(Vec_IntEntry(vCopies, i)) );
1505 if (
p->pPars->fGenCnf )
1506 Vec_IntClear( vLeaves );
1507 iLit = Vec_IntEntry( vCopies, Gia_ObjFaninId0p(
p->pGia, pObj) );
1508 if (
p->pPars->fGenCnf )
1509 Vec_IntPush( vLeaves, Abc_LitNotCond(iLit, Gia_ObjFaninC0(pObj)) );
1510 iLit = Gia_ManAppendCo( pNew, Abc_LitNotCond(iLit, Gia_ObjFaninC0(pObj)) );
1511 if (
p->pPars->fGenCnf )
1514 Vec_IntFree( vCopies );
1515 Vec_IntFree( vCover );
1516 Vec_IntFree( vLeaves );
1518 if ( Vec_IntSize(vMapping) > Gia_ManObjNum(pNew) )
1519 Vec_IntShrink( vMapping, Gia_ManObjNum(pNew) );
1521 Vec_IntFillExtra( vMapping, Gia_ManObjNum(pNew), 0 );
1522 assert( Vec_IntSize(vMapping) == Gia_ManObjNum(pNew) );
1525 Vec_IntAddToEntry( vMapping, i, Gia_ManObjNum(pNew) );
1526 Vec_IntAppend( vMapping, vMapping2 );
1527 Vec_IntFree( vMapping2 );
1533 if (
p->pPars->fGenCnf )
1535 if (
p->pPars->fCnfObjIds )
1540 Vec_IntFreeP( &vLits );
1541 Vec_IntFreeP( &vClas );
1550 vMapping = Vec_IntAlloc( Gia_ManObjNum(
p->pGia) + (
int)
p->pPars->Edge + (
int)
p->pPars->Area * 2 );
1551 Vec_IntFill( vMapping, Gia_ManObjNum(
p->pGia), 0 );
1554 if ( Gia_ObjIsBuf(pObj) || Gia_ObjRefNum(
p->pGia, pObj) == 0 )
1556 pCut = Jf_ObjCutBest(
p, i );
1557 Vec_IntWriteEntry( vMapping, i, Vec_IntSize(vMapping) );
1558 assert( !
p->pPars->fCutMin || Jf_CutSize(pCut) <= 6 );
1559 Vec_IntPush( vMapping, Jf_CutSize(pCut) );
1560 for ( k = 1; k <= Jf_CutSize(pCut); k++ )
1561 Vec_IntPush( vMapping, Jf_CutVar(pCut, k) );
1562 Vec_IntPush( vMapping, i );
1564 assert( Vec_IntCap(vMapping) == 16 || Vec_IntSize(vMapping) == Vec_IntCap(vMapping) );
1565 p->pGia->vMapping = vMapping;
1584 Vec_Int_t * vCopies = Vec_IntStartFull( Gia_ManObjNum(
p->pGia) );
1585 Vec_Int_t * vCover = Vec_IntAlloc( 1 << 16 );
1586 Vec_Int_t * vLeaves = Vec_IntAlloc( 16 );
1587 int i, k, iLit, Class, * pCut;
1588 int nWords = Abc_Truth6WordNum(
p->pPars->nLutSize);
1592 pNew->
pName = Abc_UtilStrsav(
p->pGia->pName );
1593 pNew->
pSpec = Abc_UtilStrsav(
p->pGia->pSpec );
1594 pNew->
vLevels = Vec_IntStart( 6*Gia_ManObjNum(
p->pGia)/5 + 100 );
1596 Vec_IntWriteEntry( vCopies, 0, 0 );
1598 Vec_IntWriteEntry( vCopies, Gia_ObjId(
p->pGia, pObj), Gia_ManAppendCi(pNew) );
1600 if ( !
p->pPars->fCutMin )
1605 if ( Gia_ObjIsBuf(pObj) || Gia_ObjRefNum(
p->pGia, pObj) == 0 )
1607 pCut = Jf_ObjCutBest(
p, i );
1610 if (
p->pPars->fCutMin )
1612 Class = Jf_CutFuncClass( pCut );
1613 if ( Jf_CutSize(pCut) == 0 )
1616 Vec_IntWriteEntry( vCopies, i, Jf_CutFunc(pCut) );
1619 if ( Jf_CutSize(pCut) == 1 )
1622 iLit = Abc_LitNotCond( Jf_CutLit(pCut, 1) , Jf_CutFuncCompl(pCut) );
1623 iLit = Abc_Lit2LitL( Vec_IntArray(vCopies), iLit );
1624 Vec_IntWriteEntry( vCopies, i, iLit );
1627 if (
p->pPars->fFuncDsd )
1630 Abc_TtCopy( (pTruth = Truth), Vec_MemReadEntry(
p->vTtMem, Class),
nWords, 0 );
1635 Vec_IntClear( vLeaves );
1637 Vec_IntPush( vLeaves, Abc_Lit2Var(iLit) );
1641 Vec_IntClear( vLeaves );
1643 Vec_IntPush( vLeaves, Abc_Lit2LitL(Vec_IntArray(vCopies), iLit) );
1646 iLit = Abc_LitNotCond( iLit, (
p->pPars->fCutMin && Jf_CutFuncCompl(pCut)) );
1647 Vec_IntWriteEntry( vCopies, i, iLit );
1651 iLit = Vec_IntEntry( vCopies, Gia_ObjFaninId0p(
p->pGia, pObj) );
1652 Gia_ManAppendCo( pNew, Abc_LitNotCond(iLit, Gia_ObjFaninC0(pObj)) );
1654 if ( !
p->pPars->fCutMin )
1656 Vec_IntFree( vCopies );
1657 Vec_IntFree( vLeaves );
1658 Vec_IntFree( vCover );
1663 if ( !
p->pPars->fCutMin )
1704 if ( !
p->pPars->fVerbose )
1706 printf(
"%s : ", pTitle );
1707 printf(
"Level =%6lu ", (
long)
p->pPars->Delay );
1708 printf(
"Area =%9lu ", (
long)
p->pPars->Area );
1709 printf(
"Edge =%9lu ", (
long)
p->pPars->Edge );
1710 if (
p->pPars->fGenCnf )
1711 printf(
"Cnf =%9lu ", (
long)
p->pPars->Clause );
1712 Abc_PrintTime( 1,
"Time", Abc_Clock() -
p->clkStart );
1719 assert( !Gia_ManBufNum(pGia) );
1729 for ( i = 0; i < pPars->
nRounds; i++ )
1731 if ( !
p->pPars->fGenCnf )
1738 if (
p->pPars->fVeryVerbose &&
p->pPars->fCutMin && !
p->pPars->fFuncDsd )
1739 Vec_MemDumpTruthTables(
p->vTtMem, Gia_ManName(
p->pGia),
p->pPars->nLutSize );
1740 if (
p->pPars->fPureAig )
1742 else if (
p->pPars->fCutMin )
1778 printf(
"CNF stats: Vars = %6d. Clauses = %7d. Literals = %8d. ", pCnf->
nVars, pCnf->
nClauses, pCnf->
nLiterals );
1779 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
1793 for ( i = 0; i < pCnf->
nVars; i++ )
#define ABC_SWAP(Type, a, b)
#define ABC_FALLOC(type, num)
#define ABC_ALLOC(type, num)
#define ABC_INFINITY
MACRO DEFINITIONS ///.
#define ABC_CALLOC(type, num)
#define ABC_CONST(number)
PARAMETERS ///.
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
struct Cnf_Dat_t_ Cnf_Dat_t
void Cnf_DataFree(Cnf_Dat_t *p)
void Cnf_DataWriteIntoFile(Cnf_Dat_t *p, char *pFileName, int fReadable, Vec_Int_t *vForAlls, Vec_Int_t *vExists)
int Dsm_ManTruthToGia(void *p, word *pTruth, Vec_Int_t *vLeaves, Vec_Int_t *vCover)
Gia_Man_t * Jf_ManDeriveMappingGia(Jf_Man_t *p)
void Jf_ManSetDefaultPars(Jf_Par_t *pPars)
#define Jf_ObjForEachCut(pList, pCut, i)
int Jf_CutDeref_rec(Jf_Man_t *p, int *pCut)
Gia_Man_t * Jf_ManDeriveGia(Jf_Man_t *p)
int Jf_ObjCutFilterBoth(Jf_Man_t *p, Jf_Cut_t **pSto, int c)
void Jf_ManGenCnf(word uTruth, int iLitOut, Vec_Int_t *vLeaves, Vec_Int_t *vLits, Vec_Int_t *vClas, Vec_Int_t *vCover)
FUNCTION DEFINITIONS ///.
int Jf_TtComputeForCut(Jf_Man_t *p, int iFuncLit0, int iFuncLit1, int *pCut0, int *pCut1, int *pCutOut)
Cnf_Dat_t * Jf_ManCreateCnfRemap(Gia_Man_t *p, Vec_Int_t *vLits, Vec_Int_t *vClas, int fAddOrCla)
void Jf_ObjComputeCuts(Jf_Man_t *p, Gia_Obj_t *pObj, int fEdge)
void Jf_ManPrintStats(Jf_Man_t *p, char *pTitle)
float * Jf_ManInitRefs(Jf_Man_t *pMan)
struct Jf_Man_t_ Jf_Man_t
Jf_Man_t * Jf_ManAlloc(Gia_Man_t *pGia, Jf_Par_t *pPars)
int Jf_ManComputeRefs(Jf_Man_t *p)
void Jf_ManProfileClasses(Jf_Man_t *p)
#define Jf_CutForEachLit(pCut, Lit, i)
void Jf_ManDumpCnf(Gia_Man_t *p, char *pFileName, int fVerbose)
int Jf_CutAreaRef_rec(Jf_Man_t *p, int *pCut)
int Jf_ObjCutFilter(Jf_Man_t *p, Jf_Cut_t **pSto, int c)
Gia_Man_t * Jf_ManPerformMapping(Gia_Man_t *pGia, Jf_Par_t *pPars)
#define Jf_CutForEachVar(pCut, Var, i)
void Jf_ManDeriveMapping(Jf_Man_t *p)
int Jf_CutAreaRefEdge_rec(Jf_Man_t *p, int *pCut)
int Jf_CutCheckMffc_rec(Jf_Man_t *p, int *pCut, int Limit)
void Jf_ManComputeCuts(Jf_Man_t *p, int fEdge)
struct Jf_Cut_t_ Jf_Cut_t
void Jf_ManTestCnf(Gia_Man_t *p)
int Jf_ManComputeDelay(Jf_Man_t *p, int fEval)
float Jf_CutCompareArea(Jf_Cut_t *pOld, Jf_Cut_t *pNew)
float Jf_CutCompareDelay(Jf_Cut_t *pOld, Jf_Cut_t *pNew)
int Kit_TruthToGia(Gia_Man_t *pMan, unsigned *pTruth, int nVars, Vec_Int_t *vMemory, Vec_Int_t *vLeaves, int fHash)
DECLARATIONS ///.
Gia_Man_t * Jf_ManDeriveCnfMiter(Gia_Man_t *p, int fVerbose)
void Jf_ObjComputeBestCut(Jf_Man_t *p, Gia_Obj_t *pObj, int fEdge, int fEla)
#define JF_LEAF_MAX
DECLARATIONS ///.
int Jf_CutRef_rec(Jf_Man_t *p, int *pCut)
void Jf_ManPropagateEla(Jf_Man_t *p, int fEdge)
Gia_Man_t * Jf_ManDeriveCnf(Gia_Man_t *p, int fCnfObjIds)
Cnf_Dat_t * Jf_ManCreateCnf(Gia_Man_t *p, Vec_Int_t *vLits, Vec_Int_t *vClas)
void Jf_ManPropagateFlow(Jf_Man_t *p, int fEdge)
void Jf_ManFree(Jf_Man_t *p)
void Gia_ManStop(Gia_Man_t *p)
word * Gia_ObjComputeTruthTableCut(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vLeaves)
void Gia_ManHashStart(Gia_Man_t *p)
double Gia_ManMemory(Gia_Man_t *p)
Gia_Obj_t * Gia_ObjRecognizeMux(Gia_Obj_t *pNode, Gia_Obj_t **ppNodeT, Gia_Obj_t **ppNodeE)
#define Gia_ManForEachPo(p, pObj, i)
#define Gia_ManForEachAnd(p, pObj, i)
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
#define Gia_ManForEachObjReverse(p, pObj, i)
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
struct Gia_Obj_t_ Gia_Obj_t
int Gia_ObjIsMuxType(Gia_Obj_t *pNode)
struct Gia_Man_t_ Gia_Man_t
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
void Gia_ManCleanMark0(Gia_Man_t *p)
void Gia_ObjComputeTruthTableStart(Gia_Man_t *p, int nVarsMax)
void Gia_ObjComputeTruthTableStop(Gia_Man_t *p)
struct Jf_Par_t_ Jf_Par_t
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
#define Gia_ManForEachCo(p, pObj, i)
#define Gia_ManForEachCi(p, pObj, i)
void Gia_ManHashStop(Gia_Man_t *p)
void Gia_ManPrintCone(Gia_Man_t *p, Gia_Obj_t *pObj, int *pLeaves, int nLeaves, Vec_Int_t *vNodes)
#define Gia_ManForEachCoDriver(p, pObj, i)
unsigned __int64 word
DECLARATIONS ///.
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
float(* pCutCmp)(Jf_Cut_t *, Jf_Cut_t *)
typedefABC_NAMESPACE_IMPL_START struct Vec_Mem_t_ Vec_Mem_t
DECLARATIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Flt_t_ Vec_Flt_t
INCLUDES ///.
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Set_t_ Vec_Set_t
INCLUDES ///.