143#define SFM_MASK_INPUT 2
144#define SFM_MASK_FANIN 4
145#define SFM_MASK_MFFC 8
146#define SFM_MASK_PIVOT 16
149static inline word Sfm_DecObjSim(
Sfm_Dec_t *
p,
Abc_Obj_t * pObj ) {
return Vec_WrdEntry(&
p->vObjSims, Abc_ObjId(pObj)); }
150static inline word Sfm_DecObjSim2(
Sfm_Dec_t *
p,
Abc_Obj_t * pObj ) {
return Vec_WrdEntry(&
p->vObjSims2, Abc_ObjId(pObj)); }
213 p->timeStart = Abc_Clock();
221p->timeLib = Abc_Clock();
223p->timeLib = Abc_Clock() -
p->timeLib;
228 if (
p->pMit == NULL )
236 assert( Abc_NtkIsMappedLogic(pNtk) );
244 p->pTtElems[i] =
p->TtElems[i];
255 printf(
"Level count mismatch at node %d.\n", i );
263 Vec_IntErase( &
p->vGateSizes );
264 Vec_WrdErase( &
p->vGateFuncs );
265 Vec_WecErase( &
p->vGateCnfs );
266 Vec_PtrErase( &
p->vGateHands );
268 Vec_IntErase( &
p->vObjRoots );
269 Vec_IntErase( &
p->vObjGates );
270 Vec_WecErase( &
p->vObjFanins );
271 Vec_IntErase( &
p->vObjMap );
272 Vec_IntErase( &
p->vObjDec );
273 Vec_IntErase( &
p->vObjMffc );
274 Vec_IntErase( &
p->vObjInMffc );
275 Vec_WrdErase( &
p->vObjSims );
276 Vec_WrdErase( &
p->vObjSims2 );
277 Vec_PtrErase( &
p->vMatchGates );
278 Vec_PtrErase( &
p->vMatchFans );
281 Vec_WecErase( &
p->vClauses );
282 Vec_IntErase( &
p->vImpls[0] );
283 Vec_IntErase( &
p->vImpls[1] );
284 Vec_WrdErase( &
p->vSets[0] );
285 Vec_WrdErase( &
p->vSets[1] );
287 Vec_IntErase( &
p->vNewNodes );
288 Vec_IntErase( &
p->vGateTfi );
289 Vec_IntErase( &
p->vGateTfo );
290 Vec_IntErase( &
p->vGateCut );
291 Vec_IntErase( &
p->vGateTemp );
292 Vec_IntErase( &
p->vGateMffc );
293 Vec_IntErase( &
p->vCands );
314 assert( Abc_ObjFaninNum(pObj) <= 6 );
316 uFanins[i] = Sfm_DecObjSim(
p, pFanin );
317 return Exp_Truth6( Abc_ObjFaninNum(pObj), vExpr, uFanins );
326 uFanins[i] = Sfm_DecObjSim2(
p, pFanin );
328 uFanins[i] = Sfm_DecObjSim(
p, pFanin );
329 return Exp_Truth6( Abc_ObjFaninNum(pObj), vExpr, uFanins );
331static inline void Sfm_NtkSimulate(
Abc_Ntk_t * pNtk )
335 Sfm_Dec_t *
p = Sfm_DecMan( Abc_NtkPi(pNtk, 0) );
336 Vec_WrdFill( &
p->vObjSims, 2*Abc_NtkObjNumMax(pNtk), 0 );
337 Vec_WrdFill( &
p->vObjSims2, 2*Abc_NtkObjNumMax(pNtk), 0 );
342 Vec_WrdWriteEntry( &
p->vObjSims, Abc_ObjId(pObj), (uTemp =
Gia_ManRandomW(0)) );
350 Vec_WrdWriteEntry( &
p->vObjSims, Abc_ObjId(pObj), (uTemp = Sfm_ObjSimulate(pObj)) );
355 Vec_PtrFree( vNodes );
357static inline void Sfm_ObjSimulateNode(
Abc_Obj_t * pObj )
360 if ( !
p->pPars->fUseSim )
362 Vec_WrdWriteEntry( &
p->vObjSims, Abc_ObjId(pObj), Sfm_ObjSimulate(pObj) );
364 Vec_WrdWriteEntry( &
p->vObjSims2, Abc_ObjId(pObj), Sfm_ObjSimulate2(pObj) );
366static inline void Sfm_ObjFlipNode(
Abc_Obj_t * pObj )
369 if ( !
p->pPars->fUseSim )
371 Vec_WrdWriteEntry( &
p->vObjSims2, Abc_ObjId(pObj), ~Sfm_DecObjSim(
p, pObj) );
375 Sfm_Dec_t *
p = Sfm_DecMan( Abc_NtkPi(pNtk, 0) );
377 if ( !
p->pPars->fUseSim )
380 Res |= Sfm_DecObjSim(
p, pObj) ^ Sfm_DecObjSim2(
p, pObj);
383static inline void Sfm_ObjSetupSimInfo(
Abc_Obj_t * pObj )
386 p->nPats[0] =
p->nPats[1] = 0;
387 p->nPatWords[0] =
p->nPatWords[1] = 0;
391 p->nDivWords = Abc_Bit6WordNum( 4 *
p->nDivs );
392 if (
p->nDivWordsAlloc <
p->nDivWords )
394 p->nDivWordsAlloc = Abc_MaxInt( 16,
p->nDivWords );
398 memset(
p->pDivWords[0], 0,
sizeof(
word) *
p->nDivWords );
400 if (
p->pPars->fUseSim &&
p->uCareSet != 0 )
402 word uCareSet =
p->uCareSet;
403 word uValues = Sfm_DecObjSim(
p, pObj);
404 int c, d, i, Indexes[2][64];
408 for ( i = 0; i < 64; i++ )
409 if ( (uCareSet >> i) & 1 )
411 c = !((uValues >> i) & 1);
412 Indexes[c][
p->nPats[c]++] = i;
414 for ( c = 0; c < 2; c++ )
415 p->nPatWords[c] = 1 + (
p->nPats[c] >> 6);
417 for ( d = 0; d <
p->nDivs; d++ )
419 word uSim = Vec_WrdEntry( &
p->vObjSims, Vec_IntEntry(&
p->vObjMap, d) );
420 for ( c = 0; c < 2; c++ )
421 for ( i = 0; i <
p->nPats[c]; i++ )
422 if ( (uSim >> Indexes[c][i]) & 1 )
423 Abc_TtSetBit( Sfm_DecDivPats(
p, d, c), i );
428static inline void Sfm_ObjSetdownSimInfo(
Abc_Obj_t * pObj )
432 int c, d;
word uSim, uSims[2], uMask;
433 if ( !
p->pPars->fUseSim )
435 for ( d = 0; d <
p->nDivs; d++ )
437 uSim = Vec_WrdEntry( &
p->vObjSims, Vec_IntEntry(&
p->vObjMap, d) );
438 for ( c = 0; c < 2; c++ )
440 uMask = Abc_Tt6Mask( Abc_MinInt(
p->nPats[c], nPatKeep) );
441 uSims[c] = (Sfm_DecDivPats(
p, d, c)[0] & uMask) | (uSim & ~uMask);
444 uSim = (uSims[0] & 0xFFFFFFFF) | (uSims[1] << 32);
445 Vec_WrdWriteEntry( &
p->vObjSims, Vec_IntEntry(&
p->vObjMap, d), uSim );
485 int i, k, Gate, iObj, RetValue;
486 int nTfiSize =
p->iTarget + 1;
487 int nWinSize = Vec_IntSize(&
p->vObjGates);
488 int nSatVars = 2 * nWinSize - nTfiSize;
489 assert( nWinSize == Vec_IntSize(&
p->vObjGates) );
490 assert(
p->iTarget < nWinSize );
500 vLevel = Vec_WecEntry( &
p->vObjFanins, i );
501 Vec_IntPush( vLevel, i );
503 Vec_IntPop( vLevel );
507 if ( Vec_IntSize(vClause) == 0 )
509 RetValue =
sat_solver_addclause(
p->pSat, Vec_IntArray(vClause), Vec_IntArray(vClause) + Vec_IntSize(vClause) );
518 vLevel = Vec_WecEntry( &
p->vObjFanins, i );
519 Vec_IntClear( vFaninVars );
521 Vec_IntPush( vFaninVars, iObj <= p->iTarget ? iObj : iObj + nWinSize - nTfiSize );
522 Vec_IntPush( vFaninVars, i + nWinSize - nTfiSize );
528 if ( Vec_IntSize(vClause) == 0 )
530 RetValue =
sat_solver_addclause(
p->pSat, Vec_IntArray(vClause), Vec_IntArray(vClause) + Vec_IntSize(vClause) );
535 if ( nTfiSize < nWinSize )
538 Vec_IntClear( vFaninVars );
541 Vec_IntPush( vFaninVars, Abc_Var2Lit(nSatVars, 0) );
550 else assert( Vec_IntSize(vRoots) == 1 );
569 word * pPats = Sfm_DecDivPats(
p, Abc_Lit2Var(iLit), !c );
570 return Abc_TtCountOnesVecMask( pPats, pMask,
p->nPatWords[!c], Abc_LitIsCompl(iLit) );
575 for ( c = 0; c < 2; c++ )
577 Vec_Int_t * vLevel = Vec_WecEntry( &
p->vObjFanins,
p->iTarget );
578 printf(
"%s-SET of object %d (divs = %d) with gate \"%s\" and fanins: ",
579 c ?
"OFF":
"ON",
p->iTarget,
p->nDivs,
582 printf(
"%d ", Entry );
585 printf(
"Implications: " );
587 printf(
"%s%d(%d) ", Abc_LitIsCompl(Entry)?
"!":
"", Abc_Lit2Var(Entry),
Sfm_DecFindCost(
p, c, Entry, Masks[!c]) );
590 for ( i = 0; i <
p->nDivs; i++ )
591 printf(
"%d", (i / 10) % 10 );
594 for ( i = 0; i <
p->nDivs; i++ )
595 printf(
"%d", i % 10 );
597 for ( k = 0; k <
p->nPats[c]; k++ )
599 printf(
"%2d : ", k );
600 for ( i = 0; i <
p->nDivs; i++ )
601 printf(
"%d", Abc_TtGetBit(Sfm_DecDivPats(
p, i, c), k) );
622 for ( c = 0; c < 2; c++ )
624 word * pPats = Sfm_DecDivPats(
p, d, c );
625 int Num = Abc_TtCountOnesVec( Masks[c],
p->nPatWords[c] );
626 Counts[c][1] = Abc_TtCountOnesVecMask( pPats, Masks[c],
p->nPatWords[c], 0 );
627 Counts[c][0] = Num - Counts[c][1];
628 assert( Counts[c][0] >= 0 && Counts[c][1] >= 0 );
636 for ( d = 0; d <
p->nDivs; d++ )
639 if ( (Counts[0][0] < Counts[0][1]) == (Counts[1][0] < Counts[1][1]) )
641 Cost = Abc_MinInt(Counts[0][0], Counts[0][1]) + Abc_MinInt(Counts[1][0], Counts[1][1]);
642 if ( CostBest > Cost )
653 for ( c = 0; c < 2; c++ )
657 if ( Vec_IntSize(&
p->vImpls[c]) > 1 && Vec_IntFind(&
p->vObjDec, Abc_Lit2Var(iLit)) >= 0 )
660 if ( CostMin > Cost )
663 Var = Abc_Lit2Var(iLit);
684 int i, nAreaMffc = 0;
696 if ( --pFanin->
vFanouts.nSize == 0 && !Abc_ObjIsCi(pFanin) )
707 if ( pFanin->
vFanouts.nSize++ == 0 && !Abc_ObjIsCi(pFanin) )
711 Vec_IntPush( vMffc, Abc_ObjId(pObj) );
719 assert( Abc_ObjIsNode(pPivot) );
721 Vec_IntClear( vMffc );
734 Vec_IntClear( vCut );
735 for ( i = 0; i < nNodes; i++ )
736 Vec_IntPush( vCut, Vec_IntEntry(vMap, pNodes[i]) );
742 int i, Handle, fNeedInv = 0, Gain = 0;
745 if ( !Abc_ObjIsNode(pFanout) )
762 pGateNew = (
Mio_Gate_t *)Vec_PtrEntry( &
p->vGateHands, Handle );
768 *pfNeedInv = fNeedInv;
788 int nWords0 = Abc_TtWordNum(nSupp0);
791 if ( nSupp0 == nSupp1 && !
memcmp(pSupp0, pSupp1,
sizeof(
int)*nSupp0) && !
memcmp(pTruth0, pTruth1,
sizeof(
word)*nWords0) )
793 memcpy( pSupp, pSupp0,
sizeof(
int)*nSupp0 );
794 memcpy( pTruth, pTruth0,
sizeof(
word)*nWords0 );
795 Abc_TtStretch6( pTruth, nSupp0,
p->pPars->nVarMax );
799 Vec_IntTwoMerge2Int( &vVec0, &vVec1, &vVec );
800 Vec_IntPushOrder( &vVec,
Var );
801 nSupp = Vec_IntSize( &vVec );
802 if ( nSupp >
p->pPars->nVarMax )
805 Abc_TtStretch6( pTruth0, nSupp0, nSupp );
806 Abc_TtStretch6( pTruth1, nSupp1, nSupp );
807 Abc_TtExpand( pTruth0, nSupp, pSupp0, nSupp0, pSupp, nSupp );
808 Abc_TtExpand( pTruth1, nSupp, pSupp1, nSupp1, pSupp, nSupp );
810 iSuppVar = Vec_IntFind( &vVec,
Var );
811 Abc_TtMux( pTruth,
p->pTtElems[iSuppVar], pTruth1, pTruth0, Abc_TtWordNum(nSupp) );
812 Abc_TtStretch6( pTruth, nSupp,
p->pPars->nVarMax );
817 int nBTLimit =
p->pPars->nBTLimit;
819 int c, i, d, iLit, status,
Var = -1;
820 word * pDivWords =
p->pDivWords[nAssump];
823 if (
p->pPars->fVeryVerbose )
825 printf(
"\nObject %d\n",
p->iTarget );
826 printf(
"Divs = %d. Nodes = %d. Mffc = %d. Mffc area = %.2f. ",
p->nDivs, Vec_IntSize(&
p->vObjGates),
p->nMffc, Scl_Int2Flt(
p->AreaMffc) );
827 printf(
"Pat0 = %d. Pat1 = %d. ",
p->nPats[0],
p->nPats[1] );
831 printf(
"Cofactor: " );
832 for ( i = 0; i < nAssump; i++ )
833 printf(
" %s%d", Abc_LitIsCompl(pAssump[i])?
"!":
"", Abc_Lit2Var(pAssump[i]) );
838 for ( c = 0; c < 2; c++ )
840 if ( !Abc_TtIsConst0(Masks[c],
p->nPatWords[c]) )
843 pAssump[nAssump] = Abc_Var2Lit(
p->iTarget, c );
845 status =
sat_solver_solve(
p->pSat, pAssump, pAssump + nAssump + 1, nBTLimit, 0, 0, 0 );
854 p->timeSatUnsat += Abc_Clock() - clk;
855 Abc_TtConst( pTruth, Abc_TtWordNum(
p->pPars->nVarMax), c );
856 if (
p->pPars->fVeryVerbose )
857 printf(
"Found constant %d.\n", c );
862 p->timeSatSat += Abc_Clock() - clk;
868 for ( i = 0; i <
p->nDivs; i++ )
869 if ( sat_solver_var_value(
p->pSat, i) )
870 Abc_TtSetBit( Sfm_DecDivPats(
p, i, c),
p->nPats[c] );
871 p->nPatWords[c] = 1 + (
p->nPats[c] >> 6);
872 Abc_TtSetBit( Masks[c],
p->nPats[c]++ );
875 if (
p->iUseThis != -1 )
883 Vec_IntClear( &
p->vImpls[0] );
884 Vec_IntClear( &
p->vImpls[1] );
885 for ( d = 0; d <
p->nDivs; d++ )
887 int Impls[2] = {-1, -1};
888 for ( c = 0; c < 2; c++ )
890 word * pPats = Sfm_DecDivPats(
p, d, c );
891 int fHas0s = Abc_TtIntersect( pPats, Masks[c],
p->nPatWords[c], 1 );
892 int fHas1s = Abc_TtIntersect( pPats, Masks[c],
p->nPatWords[c], 0 );
893 if ( fHas0s && fHas1s )
895 pAssump[nAssump] = Abc_Var2Lit(
p->iTarget, c );
896 pAssump[nAssump+1] = Abc_Var2Lit( d, fHas1s );
898 if ( Abc_TtGetBit( pDivWords, 4*d+2*c+fHas1s ) )
906 status =
sat_solver_solve(
p->pSat, pAssump, pAssump + nAssump + 2, nBTLimit, 0, 0, 0 );
916 p->timeSatUnsat += Abc_Clock() - clk;
917 Impls[c] = Abc_LitNot(pAssump[nAssump+1]);
918 Vec_IntPush( &
p->vImpls[c], Abc_LitNot(pAssump[nAssump+1]) );
919 Abc_TtSetBit( pDivWords, 4*d+2*c+fHas1s );
924 p->timeSatSat += Abc_Clock() - clk;
931 for ( i = 0; i <
p->nDivs; i++ )
932 if ( sat_solver_var_value(
p->pSat, i) )
933 Abc_TtSetBit( Sfm_DecDivPats(
p, i, c),
p->nPats[c] );
934 p->nPatWords[c] = 1 + (
p->nPats[c] >> 6);
935 Abc_TtSetBit( Masks[c],
p->nPats[c]++ );
937 if ( Impls[0] == -1 || Impls[1] == -1 )
939 if ( Impls[0] == Impls[1] )
941 Vec_IntPop( &
p->vImpls[0] );
942 Vec_IntPop( &
p->vImpls[1] );
945 assert( Abc_Lit2Var(Impls[0]) == Abc_Lit2Var(Impls[1]) );
947 Abc_TtUnit( pTruth, Abc_TtWordNum(
p->pPars->nVarMax), Abc_LitIsCompl(Impls[0]) );
948 pSupp[0] = Abc_Lit2Var(Impls[0]);
949 if (
p->pPars->fVeryVerbose )
950 printf(
"Found variable %s%d.\n", Abc_LitIsCompl(Impls[0]) ?
"!":
"", pSupp[0] );
953 if ( nSuppAdd >
p->pPars->nVarMax - 2 )
955 if (
p->pPars->fVeryVerbose )
956 printf(
"The number of assumption is more than MFFC size.\n" );
960 if (
p->pPars->fUseAndOr )
961 for ( c = 0; c < 2; c++ )
963 if ( Vec_IntSize(&
p->vImpls[!c]) < 2 )
966 pAssump[nAssump] = Abc_Var2Lit(
p->iTarget, c );
969 pAssump[nAssump+1+i] = iLit;
971 status =
sat_solver_solve(
p->pSat, pAssump, pAssump + nAssump+1+i, nBTLimit, 0, 0, 0 );
979 int * pFinal, nFinal = sat_solver_final(
p->pSat, &pFinal );
981 p->timeSatUnsat += Abc_Clock() - clk;
982 if ( nFinal + nSuppAdd > 6 )
985 for ( i = d = 0; i < nFinal; i++ )
986 if ( Vec_IntFind(&
p->vImpls[!c], Abc_LitNot(pFinal[i])) >= 0 )
987 pSupp[d++] = Abc_LitNot(pFinal[i]);
994 for ( i = 0; i < nFinal; i++ )
996 *pTruth &= Abc_LitIsCompl(pSupp[i]) ? ~s_Truths6[i] : s_Truths6[i];
997 pSupp[i] = Abc_Lit2Var(pSupp[i]);
1003 for ( i = 0; i < nFinal; i++ )
1005 *pTruth |= Abc_LitIsCompl(pSupp[i]) ? s_Truths6[i] : ~s_Truths6[i];
1006 pSupp[i] = Abc_Lit2Var(pSupp[i]);
1009 Abc_TtStretch6( pTruth, nFinal,
p->pPars->nVarMax );
1011 if (
p->pPars->fVeryVerbose )
1012 printf(
"Found %d-input AND/OR gate.\n", nFinal );
1017 p->timeSatSat += Abc_Clock() - clk;
1023 for ( i = 0; i <
p->nDivs; i++ )
1024 if ( sat_solver_var_value(
p->pSat, i) )
1025 Abc_TtSetBit( Sfm_DecDivPats(
p, i, c),
p->nPats[c] );
1026 p->nPatWords[c] = 1 + (
p->nPats[c] >> 6);
1027 Abc_TtSetBit( Masks[c],
p->nPats[c]++ );
1054 if (
Var == -1 && fCofactor )
1058 if ( Vec_IntFind(&
p->vObjDec,
Var) == -1 )
1066 if (
p->pPars->fVeryVerbose )
1069 printf(
"Best var %d\n",
Var );
1078 Vec_IntPush( &
p->vObjDec,
Var );
1079 for ( i = 0; i < 2; i++ )
1081 for ( c = 0; c < 2; c++ )
1083 Abc_TtAndSharp( MasksNext[c], Masks[c], Sfm_DecDivPats(
p,
Var, c),
p->nPatWords[c], !i );
1085 MasksNext[c][w] = 0;
1087 pAssump[nAssump] = Abc_Var2Lit(
Var, !i );
1088 memcpy(
p->pDivWords[nAssump+1],
p->pDivWords[nAssump],
sizeof(
word) *
p->nDivWords );
1089 nSupp[i] =
Sfm_DecPeformDec_rec(
p, uTruth[i], Supp[i], pAssump, nAssump+1, MasksNext, fCofactor, (i ? nSupp[0] : 0) + nSuppAdd + 1 );
1090 if ( nSupp[i] == -2 )
1094 return Sfm_DecCombineDec(
p, uTruth[0], uTruth[1], Supp[0], Supp[1], nSupp[0], nSupp[1], pTruth, pSupp,
Var );
1103 int fVeryVerbose =
p->pPars->fPrintDecs ||
p->pPars->fVeryVerbose;
1104 int nDecs = Abc_MaxInt(
p->pPars->nDecMax, 1);
1106 int i, RetValue, Prev = 0, iBest = -1, AreaThis, AreaNew;
1107 int GainThis, GainBest = -1, iLibObj, iLibObjBest = -1;
1108 assert(
p->pPars->fArea == 1 );
1112 printf(
"\nNode %4d : MFFC %2d\n",
p->iTarget,
p->nMffc );
1114 Sfm_ObjSetupSimInfo( pObj );
1115 Vec_IntClear( &
p->vObjDec );
1116 for ( i = 0; i < nDecs; i++ )
1119 if ( Vec_IntSize(&
p->vObjDec) > Prev )
1120 Vec_IntShrink( &
p->vObjDec, Prev );
1121 Prev = Vec_IntSize(&
p->vObjDec) + 1;
1126 if ( nSupp[i] == -2 )
1129 printf(
"Dec %d: Pat0 = %2d Pat1 = %2d NO DEC.\n", i,
p->nPats[0],
p->nPats[1] );
1133 printf(
"Dec %d: Pat0 = %2d Pat1 = %2d Supp = %d ", i,
p->nPats[0],
p->nPats[1], nSupp[i] );
1138 p->nSuppVars = nSupp[i];
1141 assert( nSupp[i] <=
p->pPars->nVarMax );
1142 p->nLuckySizes[nSupp[i]]++;
1144 p->nLuckyGates[RetValue]++;
1149 p->nSuppVars = nSupp[i];
1163 if ( AreaNew == -1 )
1170 assert(
p->AreaMffc <= AreaThis );
1171 if (
p->pPars->fZeroCost ? (AreaNew > AreaThis) : (AreaNew >= AreaThis) )
1174 GainThis = AreaThis - AreaNew;
1176 if ( GainBest < GainThis )
1178 GainBest = GainThis;
1179 iLibObjBest = iLibObj;
1183 Sfm_ObjSetdownSimInfo( pObj );
1187 printf(
"Best : NO DEC.\n" );
1193 printf(
"Best %d: %d ", iBest, nSupp[iBest] );
1197 assert( iLibObjBest >= 0 );
1199 assert( nSupp[iBest] <=
p->pPars->nVarMax );
1200 p->nLuckySizes[nSupp[iBest]]++;
1202 p->nLuckyGates[RetValue]++;
1210 int fVeryVerbose =
p->pPars->fPrintDecs ||
p->pPars->fVeryVerbose;
1211 int nDecs = Abc_MaxInt(
p->pPars->nDecMax, 1);
1212 int i, k, DelayOrig = 0, DelayMin, GainMax, AreaMffc, nMatches, iBest = -1, RetValue, Prev = 0;
1213 Mio_Gate_t * pGate1Best = NULL, * pGate2Best = NULL;
1214 char * pFans1Best = NULL, * pFans2Best = NULL;
1215 assert(
p->pPars->fArea == 0 );
1219 printf(
"\nNode %4d : MFFC %2d\n",
p->iTarget,
p->nMffc );
1222 Sfm_ObjSetupSimInfo( pObj );
1223 Vec_IntClear( &
p->vObjDec );
1224 for ( i = 0; i < nDecs; i++ )
1227 DelayMin = DelayOrig = Sfm_ManReadObjDelay(
p, Abc_ObjId(pObj) );
1229 if ( Vec_IntSize(&
p->vObjDec) > Prev )
1230 Vec_IntShrink( &
p->vObjDec, Prev );
1231 Prev = Vec_IntSize(&
p->vObjDec) + 1;
1236 if ( nSupp[i] == -2 )
1239 printf(
"Dec %d: Pat0 = %2d Pat1 = %2d NO DEC.\n", i,
p->nPats[0],
p->nPats[1] );
1243 printf(
"Dec %d: Pat0 = %2d Pat1 = %2d Supp = %d ", i,
p->nPats[0],
p->nPats[1], nSupp[i] );
1246 if (
p->pTim && nSupp[i] == 1 && uTruth[i][0] ==
ABC_CONST(0x5555555555555555) && DelayMin <= p->DelayInv + Sfm_ManReadObjDelay(
p, Vec_IntEntry(&
p->vObjMap, pSupp[i][0])) )
1249 printf(
"Dec %d: Pat0 = %2d Pat1 = %2d NO DEC.\n", i,
p->nPats[0],
p->nPats[1] );
1252 if (
p->pMit && nSupp[i] == 1 && uTruth[i][0] ==
ABC_CONST(0x5555555555555555) )
1255 printf(
"Dec %d: Pat0 = %2d Pat1 = %2d NO DEC.\n", i,
p->nPats[0],
p->nPats[1] );
1260 p->nSuppVars = nSupp[i];
1263 assert( nSupp[i] <=
p->pPars->nVarMax );
1264 p->nLuckySizes[nSupp[i]]++;
1266 p->nLuckyGates[RetValue]++;
1275 p->nSuppVars = nSupp[i];
1278 for ( k = 0; k < nMatches; k++ )
1284 char * pFans1 = (
char *)Vec_PtrEntry( &
p->vMatchFans, 2*k+0 );
1285 char * pFans2 = (
char *)Vec_PtrEntry( &
p->vMatchFans, 2*k+1 );
1286 Vec_Int_t vFanins = { nSupp[i], nSupp[i], pSupp[i] };
1292 int Gain =
Sfm_MitEvalRemapping(
p->pMit, &
p->vGateMffc, pObj, &vFanins, &
p->vObjMap, pGate1, pFans1, pGate2, pFans2 );
1293 if (
p->pPars->DelAreaRatio && AreaNew > AreaMffc && (Gain / (AreaNew - AreaMffc)) <
p->pPars->DelAreaRatio )
1295 if ( GainMax < Gain )
1298 pGate1Best = pGate1;
1299 pGate2Best = pGate2;
1300 pFans1Best = pFans1;
1301 pFans2Best = pFans2;
1308 if (
p->pPars->DelAreaRatio && AreaNew > AreaMffc && (Delay / (AreaNew - AreaMffc)) <
p->pPars->DelAreaRatio )
1310 if ( DelayMin > Delay )
1313 pGate1Best = pGate1;
1314 pGate2Best = pGate2;
1315 pFans1Best = pFans1;
1316 pFans2Best = pFans2;
1320 p->timeEval += Abc_Clock() - clk;
1324 Sfm_ObjSetdownSimInfo( pObj );
1328 printf(
"Best : NO DEC.\n" );
1333 printf(
"Best %d: %d ", iBest, nSupp[iBest] );
1336 RetValue =
Sfm_LibImplementGatesDelay(
p->pLib, pSupp[iBest], pGate1Best, pGate2Best, pFans1Best, pFans2Best, &
p->vObjGates, &
p->vObjFanins );
1337 assert( nSupp[iBest] <=
p->pPars->nVarMax );
1338 p->nLuckySizes[nSupp[iBest]]++;
1340 p->nLuckyGates[RetValue]++;
1341 p->DelayMin = DelayMin;
1360 if ( LevelNew == Abc_ObjLevel(pObj) && Abc_ObjIsNode(pObj) && Abc_ObjFaninNum(pObj) > 0 )
1362 pObj->
Level = LevelNew;
1363 if ( !Abc_ObjIsCo(pObj) )
1382 if ( pObj == pPivot )
1384 if ( Abc_NodeIsTravIdCurrent( pObj ) )
1386 Abc_NodeSetTravIdCurrent( pObj );
1387 if ( Abc_ObjIsCi(pObj) )
1389 assert( Abc_ObjIsNode(pObj) );
1398 if ( Abc_NodeIsTravIdCurrent( pObj ) )
1400 Abc_NodeSetTravIdCurrent( pObj );
1401 if ( Abc_ObjIsCo(pObj) || Abc_ObjLevel(pObj) > nLevelMax )
1403 assert( Abc_ObjIsNode( pObj ) );
1404 if ( Abc_ObjFanoutNum(pObj) <= nFanoutMax )
1407 if ( Abc_ObjIsCo(pFanout) || Abc_ObjLevel(pFanout) > nLevelMax )
1409 if ( i == Abc_ObjFanoutNum(pObj) )
1413 Vec_IntPush( vTfo, Abc_ObjId(pObj) );
1419 if ( Abc_NodeIsTravIdCurrent( pObj ) )
1421 Abc_NodeSetTravIdCurrent( pObj );
1422 if ( Abc_ObjIsCi(pObj) || (Abc_ObjLevel(pObj) < nLevelMin && Abc_ObjFaninNum(pObj) > 0) )
1424 Vec_IntPush( vTfi, Abc_ObjId(pObj) );
1425 return (pObj->
iTemp = CiLabel);
1427 assert( Abc_ObjIsNode(pObj) );
1428 pObj->
iTemp = Abc_ObjFaninNum(pObj) ? 0 : CiLabel;
1431 Vec_IntPush( vTfi, Abc_ObjId(pObj) );
1432 Sfm_ObjSimulateNode( pObj );
1438 printf(
"%d:%d(%d) ", Vec_IntSize(vMap), Abc_ObjId(pObj), pObj->
iTemp );
1441 Vec_IntPush( vMap, Abc_ObjId(pObj) );
1444static inline int Sfm_DecNodeIsMffc(
Abc_Obj_t *
p,
int nLevelMin )
1446 return Abc_ObjIsNode(
p) && Abc_ObjFanoutNum(
p) == 1 && Abc_NodeIsTravIdCurrent(
p) && (Abc_ObjLevel(
p) >= nLevelMin || Abc_ObjFaninNum(
p) == 0);
1458 Abc_Obj_t * pFanin, * pFanin2, * pFanin3, * pObj;
int i, k, n;
1460 Vec_IntFill( vMffc, 1, Abc_ObjId(pPivot) );
1466 Vec_IntClear(vInMffc);
1468 if ( Sfm_DecNodeIsMffcInput2(pFanin, nLevelMin, pMit, pPivot) )
1469 Vec_IntPushUnique( vInMffc, Abc_ObjId(pFanin) );
1472 if ( Sfm_DecNodeIsMffcInput2(pFanin2, nLevelMin, pMit, pPivot) )
1473 Vec_IntPushUnique( vInMffc, Abc_ObjId(pFanin2) );
1477 if ( Sfm_DecNodeIsMffcInput2(pFanin3, nLevelMin, pMit, pPivot) )
1478 Vec_IntPushUnique( vInMffc, Abc_ObjId(pFanin3) );
1480 else if ( pTim != NULL )
1485 Vec_IntClear(vInMffc);
1487 if ( Sfm_DecNodeIsMffcInput(pFanin, nLevelMin, pTim, pPivot) )
1488 Vec_IntPushUnique( vInMffc, Abc_ObjId(pFanin) );
1491 if ( Sfm_DecNodeIsMffcInput(pFanin2, nLevelMin, pTim, pPivot) )
1492 Vec_IntPushUnique( vInMffc, Abc_ObjId(pFanin2) );
1496 if ( Sfm_DecNodeIsMffcInput(pFanin3, nLevelMin, pTim, pPivot) )
1497 Vec_IntPushUnique( vInMffc, Abc_ObjId(pFanin3) );
1516 if ( Sfm_DecNodeIsMffc(pFanin, nLevelMin) && Vec_IntSize(vMffc) < nMffcMax )
1517 Vec_IntPushUnique( vMffc, Abc_ObjId(pFanin) );
1519 if ( Sfm_DecNodeIsMffc(pFanin, nLevelMin) && Vec_IntSize(vMffc) < nMffcMax )
1521 if ( Sfm_DecNodeIsMffc(pFanin2, nLevelMin) && Vec_IntSize(vMffc) < nMffcMax )
1522 Vec_IntPushUnique( vMffc, Abc_ObjId(pFanin2) );
1524 if ( Sfm_DecNodeIsMffc(pFanin, nLevelMin) && Vec_IntSize(vMffc) < nMffcMax )
1526 if ( Sfm_DecNodeIsMffc(pFanin2, nLevelMin) && Vec_IntSize(vMffc) < nMffcMax )
1528 if ( Sfm_DecNodeIsMffc(pFanin3, nLevelMin) && Vec_IntSize(vMffc) < nMffcMax )
1529 Vec_IntPushUnique( vMffc, Abc_ObjId(pFanin3) );
1531 assert( Vec_IntSize(vMffc) <= nMffcMax );
1536 Vec_IntClear(vInMffc);
1540 Vec_IntPushUnique( vInMffc, Abc_ObjId(pFanin) );
1565int Sfm_DecExtract(
Abc_Ntk_t * pNtk,
Sfm_Par_t * pPars,
Abc_Obj_t * pPivot,
Vec_Int_t * vRoots,
Vec_Int_t * vGates,
Vec_Wec_t * vFanins,
Vec_Int_t * vMap,
Vec_Int_t * vTfi,
Vec_Int_t * vTfo,
Vec_Int_t * vMffc,
Vec_Int_t * vInMffc,
Sfm_Tim_t * pTim,
Sfm_Mit_t * pMit )
1567 int fVeryVerbose = 0;
1572 int i, k, nTfiSize, nDivs = -1;
1573 assert( Abc_ObjIsNode(pPivot) );
1575printf(
"\n\nTarget %d\n", Abc_ObjId(pPivot) );
1577 Vec_IntClear( vTfo );
1578 Abc_NtkIncrementTravId( pNtk );
1585 Vec_IntClear( vRoots );
1587 if ( pObj->
iTemp != Abc_ObjFanoutNum(pObj) )
1588 Vec_IntPush( vRoots, Abc_ObjId(pObj) );
1589 assert( Vec_IntSize(vRoots) > 0 );
1591 Vec_IntClear( vTfi );
1592 Abc_NtkIncrementTravId( pNtk );
1594 nTfiSize = Vec_IntSize(vTfi);
1595 Sfm_ObjFlipNode( pPivot );
1600printf(
"Mffc size = %d. Mffc area = %.2f. InMffc size = %d.\n", Vec_IntSize(vMffc), Scl_Int2Flt(
Sfm_DecMffcArea(pNtk, vMffc)), Vec_IntSize(vInMffc) );
1612printf(
"\nDivs:\n" );
1613 Vec_IntClear( vMap );
1614 Vec_IntClear( vGates );
1617 Sfm_DecAddNode( pObj, vMap, vGates, Abc_ObjIsCi(pObj) || (Abc_ObjLevel(pObj) < nLevelMin && Abc_ObjFaninNum(pObj) > 0), fVeryVerbose );
1618 nDivs = Vec_IntSize(vMap);
1621printf(
"\nSides:\n" );
1628 int nDivsNew, nOldSize = Vec_IntSize(vMap);
1629 Vec_IntClear( vTfo );
1630 Vec_IntAppend( vTfo, vMap );
1633 Vec_IntClear( vMap );
1634 Vec_IntClear( vGates );
1637 assert( nOldSize == Vec_IntSize(vMap) );
1643 int nDivsNew, nOldSize = Vec_IntSize(vMap);
1644 Vec_IntClear( vTfo );
1645 Vec_IntAppend( vTfo, vMap );
1648 Vec_IntClear( vMap );
1649 Vec_IntClear( vGates );
1652 assert( nOldSize == Vec_IntSize(vMap) );
1658printf(
"\nTFO:\n" );
1662 assert( Vec_IntSize(vMap) == Vec_IntSize(vGates) );
1666 Vec_WecClear( vFanins );
1670 vLevel = Vec_WecPushLevel( vFanins );
1671 if ( Vec_IntEntry(vGates, i) >= 0 )
1673 Vec_IntPush( vLevel, pFanin->
iTemp );
1676 Sfm_DecMan(pPivot)->uCareSet = Sfm_ObjFindCareSet(pPivot->
pNtk, vRoots);
1684 Vec_IntWriteEntry( vRoots, i, pObj->
iTemp );
1687 Vec_IntWriteEntry( vInMffc, i, pObj->
iTemp );
1701Abc_Obj_t *
Sfm_DecInsert(
Abc_Ntk_t * pNtk,
Abc_Obj_t * pPivot,
int Limit,
Vec_Int_t * vGates,
Vec_Wec_t * vFanins,
Vec_Int_t * vMap,
Vec_Ptr_t * vGateHandles,
int GateBuf,
int GateInv,
Vec_Wrd_t * vFuncs,
Vec_Int_t * vNewNodes,
Sfm_Mit_t * pMit )
1705 int i, k, iObj, Gate;
1707 Vec_IntClear( vNewNodes );
1709 assert( Limit < Vec_IntSize(vGates) );
1710 assert( Limit == Vec_IntSize(vMap) );
1711 if ( Limit + 1 == Vec_IntSize(vGates) )
1713 Gate = Vec_IntEntryLast(vGates);
1714 if ( Gate == GateBuf )
1716 iObj = Vec_WecEntryEntry( vFanins, Limit, 0 );
1717 pObjNew = Abc_NtkObj( pNtk, Vec_IntEntry(vMap, iObj) );
1727 Vec_IntPush( vNewNodes, Abc_ObjId(pObjNew) );
1730 else if ( vNewNodes == NULL && Gate == GateInv )
1738 if ( i == Abc_ObjFanoutNum(pPivot) )
1745 assert( iGateNew >= 0 && iGateNew != iGate && iFaninNew >= 0 );
1746 pFanout->
pData = Vec_PtrEntry( vGateHandles, iGateNew );
1749 if ( iFanin != iFaninNew )
1751 int * pArray = Vec_IntArray( &pFanout->
vFanins );
1752 ABC_SWAP(
int, pArray[iFanin], pArray[iFaninNew] );
1755 iObj = Vec_WecEntryEntry( vFanins, Limit, 0 );
1756 pObjNew = Abc_NtkObj( pNtk, Vec_IntEntry(vMap, iObj) );
1768 vLevel = Vec_WecEntry( vFanins, i );
1769 pObjNew = Abc_NtkCreateNode( pNtk );
1771 Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtk, Vec_IntEntry(vMap, iObj)) );
1772 pObjNew->
pData = Vec_PtrEntry( vGateHandles, Gate );
1774 Vec_IntPush( vMap, Abc_ObjId(pObjNew) );
1776 Vec_IntPush( vNewNodes, Abc_ObjId(pObjNew) );
1794 printf(
"Node = %d. Try = %d. Change = %d. Const0 = %d. Const1 = %d. Buf = %d. Inv = %d. Gate = %d. AndOr = %d. Effort = %d. NoDec = %d.\n",
1795 p->nTotalNodesBeg,
p->nNodesTried,
p->nNodesChanged,
p->nNodesConst0,
p->nNodesConst1,
p->nNodesBuf,
p->nNodesInv,
p->nNodesResyn,
p->nNodesAndOr,
p->nEfforts,
p->nNoDecs );
1796 printf(
"MaxDiv = %d. MaxWin = %d. AveDiv = %d. AveWin = %d. Calls = %d. (Sat = %d. Unsat = %d.) Over = %d. T/O = %d.\n",
1797 p->nMaxDivs,
p->nMaxWin, (
int)(
p->nAllDivs/Abc_MaxInt(1,
p->nNodesTried)), (
int)(
p->nAllWin/Abc_MaxInt(1,
p->nNodesTried)),
p->nSatCalls,
p->nSatCallsSat,
p->nSatCallsUnsat,
p->nSatCallsOver,
p->nTimeOuts );
1799 p->timeTotal = Abc_Clock() -
p->timeStart;
1800 p->timeOther =
p->timeTotal -
p->timeLib -
p->timeWin -
p->timeCnf -
p->timeSat -
p->timeTime;
1802 ABC_PRTP(
"Lib ",
p->timeLib ,
p->timeTotal );
1803 ABC_PRTP(
"Win ",
p->timeWin ,
p->timeTotal );
1804 ABC_PRTP(
"Cnf ",
p->timeCnf ,
p->timeTotal );
1805 ABC_PRTP(
"Sat ",
p->timeSat-
p->timeEval,
p->timeTotal );
1806 ABC_PRTP(
" Sat ",
p->timeSatSat,
p->timeTotal );
1807 ABC_PRTP(
" Unsat",
p->timeSatUnsat,
p->timeTotal );
1808 ABC_PRTP(
"Eval ",
p->timeEval ,
p->timeTotal );
1809 ABC_PRTP(
"Timing",
p->timeTime ,
p->timeTotal );
1810 ABC_PRTP(
"Other ",
p->timeOther,
p->timeTotal );
1811 ABC_PRTP(
"ALL ",
p->timeTotal,
p->timeTotal );
1813 printf(
"Cone sizes: " );
1815 if (
p->nLuckySizes[i] )
1816 printf(
"%d=%d ", i,
p->nLuckySizes[i] );
1819 printf(
"Gate sizes: " );
1821 if (
p->nLuckyGates[i] )
1822 printf(
"%d=%d ", i,
p->nLuckyGates[i] );
1825 printf(
"Reduction: " );
1826 printf(
"Nodes %6d out of %6d (%6.2f %%) ",
p->nTotalNodesBeg-
p->nTotalNodesEnd,
p->nTotalNodesBeg, 100.0*(
p->nTotalNodesBeg-
p->nTotalNodesEnd)/Abc_MaxInt(1,
p->nTotalNodesBeg) );
1827 printf(
"Edges %6d out of %6d (%6.2f %%) ",
p->nTotalEdgesBeg-
p->nTotalEdgesEnd,
p->nTotalEdgesBeg, 100.0*(
p->nTotalEdgesBeg-
p->nTotalEdgesEnd)/Abc_MaxInt(1,
p->nTotalEdgesBeg) );
1832 int Gate, nGates = Vec_IntSize(&
p->vObjGates);
1833 if ( nGates == Limit )
1835 Gate = Vec_IntEntryLast(&
p->vObjGates);
1836 if ( nGates > Limit + 1 )
1838 else if ( Gate ==
p->GateConst0 )
1840 else if ( Gate ==
p->GateConst1 )
1842 else if ( Gate ==
p->GateBuffer )
1844 else if ( Gate ==
p->GateInvert )
1867 int Limit, RetValue;
1876 p->nDivs =
Sfm_DecExtract( pNtk, pPars, pObj, &
p->vObjRoots, &
p->vObjGates, &
p->vObjFanins, &
p->vObjMap, &
p->vGateTfi, &
p->vGateTfo, &
p->vObjMffc, &
p->vObjInMffc, NULL, NULL );
1877p->timeWin += Abc_Clock() - clk;
1880 p->nMffc = Vec_IntSize(&
p->vObjMffc);
1882 p->nMaxDivs = Abc_MaxInt(
p->nMaxDivs,
p->nDivs );
1883 p->nAllDivs +=
p->nDivs;
1884 p->iTarget = pObj->
iTemp;
1885 Limit = Vec_IntSize( &
p->vObjGates );
1886 p->nMaxWin = Abc_MaxInt(
p->nMaxWin, Limit );
1887 p->nAllWin += Limit;
1890p->timeCnf += Abc_Clock() - clk;
1910 if (
p->pPars->fVerbose )
1919 if (
p->pPars->fVeryVerbose )
1921p->timeSat += Abc_Clock() - clk;
1926 return Sfm_DecInsert( pNtk, pObj, Limit, &
p->vObjGates, &
p->vObjFanins, &
p->vObjMap, &
p->vGateHands,
p->GateBuffer,
p->GateInvert, &
p->vGateFuncs, NULL,
p->pMit );
1931 int i, nStop = Abc_NtkObjNumMax(
p->pNtk);
1934 if ( i >= nStop || (
p->pPars->nNodesMax && i >
p->pPars->nNodesMax) )
1942 int i, k, nStop = Abc_NtkObjNumMax(
p->pNtk);
1943 Vec_Ptr_t * vFront = Vec_PtrAlloc( 1000 );
1948 if ( Abc_ObjIsNode(Abc_ObjFanin0(pObj)) && !Abc_ObjFanin0(pObj)->fMarkB )
1950 Abc_ObjFanin0(pObj)->fMarkB = 1;
1951 Vec_PtrPush( vFront, Abc_ObjFanin0(pObj) );
1956 if ( Abc_ObjIsNone(pObj) )
1959 if ( pObjNew != NULL )
1961 if ( !Abc_ObjIsNode(pObjNew) || Abc_ObjFaninNum(pObjNew) == 0 || pObjNew->
fMarkB )
1963 if ( (
int)Abc_ObjId(pObjNew) < nStop )
1966 Vec_PtrPush( vFront, pObjNew );
1973 if ( Abc_ObjIsNode(pFanin) && Abc_ObjFaninNum(pObjNew) > 0 && !pFanin->
fMarkB )
1976 Vec_PtrPush( vFront, pFanin );
1981 Vec_PtrFree( vFront );
1992 int i = 0, Limit, RetValue;
1995 Vec_IntFill( &
p->vCands, 1, pPars->
iNodeOne );
2003 int OldId = Abc_ObjId(pObj);
2004 int DelayOld = Sfm_ManReadObjDelay(
p, OldId);
2008 p->nDivs =
Sfm_DecExtract( pNtk, pPars, pObj, &
p->vObjRoots, &
p->vObjGates, &
p->vObjFanins, &
p->vObjMap, &
p->vGateTfi, &
p->vGateTfo, &
p->vObjMffc, &
p->vObjInMffc,
p->pTim,
p->pMit );
2009p->timeWin += Abc_Clock() - clk;
2015 p->nMffc = Vec_IntSize(&
p->vObjMffc);
2017 p->nMaxDivs = Abc_MaxInt(
p->nMaxDivs,
p->nDivs );
2018 p->nAllDivs +=
p->nDivs;
2019 p->iTarget = pObj->
iTemp;
2020 Limit = Vec_IntSize( &
p->vObjGates );
2021 p->nMaxWin = Abc_MaxInt(
p->nMaxWin, Limit );
2022 p->nAllWin += Limit;
2025p->timeCnf += Abc_Clock() - clk;
2048 if (
p->pPars->fVerbose )
2057 if (
p->pPars->fVeryVerbose )
2059p->timeSat += Abc_Clock() - clk;
2065 assert( Vec_IntSize(&
p->vObjGates) - Limit > 0 );
2066 assert( Vec_IntSize(&
p->vObjGates) - Limit <= 2 );
2071 Sfm_DecInsert( pNtk, pObj, Limit, &
p->vObjGates, &
p->vObjFanins, &
p->vObjMap, &
p->vGateHands,
p->GateBuffer,
p->GateInvert, &
p->vGateFuncs, &
p->vNewNodes,
p->pMit );
2079p->timeTime += Abc_Clock() - clk;
2080 pObjNew = Abc_NtkObj( pNtk, Abc_NtkObjNumMax(pNtk)-1 );
2081 assert(
p->pMit ||
p->DelayMin == 0 ||
p->DelayMin == Sfm_ManReadObjDelay(
p, Abc_ObjId(pObjNew)) );
2084 printf(
"Node %5d %5d : I =%3d. Cand = %5d (%6.2f %%) Old =%8.2f. New =%8.2f. Final =%8.2f. WNS =%8.2f.\n",
2085 OldId, Abc_NtkObjNumMax(
p->pNtk), i, Vec_IntSize(&
p->vCands), 100.0 * Vec_IntSize(&
p->vCands) / Abc_NtkNodeNum(
p->pNtk),
2086 Scl_Int2Flt(DelayOld), Scl_Int2Flt(Sfm_ManReadObjDelay(
p, Abc_ObjId(pObjNew))),
2087 Scl_Int2Flt(Sfm_ManReadNtkDelay(
p)), Scl_Int2Flt(Sfm_ManReadNtkMinSlack(
p)) );
2100 printf(
"Remapping parameters: " );
2106 printf(
"FanMax = %d. ", pPars->
nFanoutMax );
2110 printf(
"Confl = %d. ", pPars->
nBTLimit );
2112 printf(
"MffcMin = %d. ", pPars->
nMffcMin );
2114 printf(
"MffcMax = %d. ", pPars->
nMffcMax );
2116 printf(
"DecMax = %d. ", pPars->
nDecMax );
2118 printf(
"Pivot = %d. ", pPars->
iNodeOne );
2119 if ( !pPars->
fArea )
2120 printf(
"Win = %d. ", pPars->
nTimeWin );
2121 if ( !pPars->
fArea )
2122 printf(
"Delta = %.2f ps. ", Scl_Int2Flt(
p->DeltaCrit) );
2124 printf(
"0-cost = %s. ", pPars->
fZeroCost ?
"yes" :
"no" );
2125 printf(
"Effort = %s. ", pPars->
fMoreEffort ?
"yes" :
"no" );
2126 printf(
"Sim = %s. ", pPars->
fUseSim ?
"yes" :
"no" );
2131 if (
p->pPars->fUseSim )
2132 Sfm_NtkSimulate( pNtk );
2134 if ( pPars->
fVerbose )
p->nTotalNodesBeg = Abc_NtkNodeNum(pNtk);
2147 if ( pPars->
fVerbose )
p->nTotalNodesEnd = Abc_NtkNodeNum(pNtk);
struct Abc_Obj_t_ Abc_Obj_t
#define Abc_NtkForEachCo(pNtk, pCo, i)
ABC_DLL void Abc_NtkCleanMarkABC(Abc_Ntk_t *pNtk)
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
#define Abc_ObjForEachFanin(pObj, pFanin, i)
#define Abc_ObjForEachFanout(pObj, pFanout, i)
ABC_DLL void Abc_ObjPrint(FILE *pFile, Abc_Obj_t *pObj)
ABC_DLL int Abc_NodeMffcLabel(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
struct Abc_Ntk_t_ Abc_Ntk_t
ABC_DLL void Abc_ObjReplace(Abc_Obj_t *pObjOld, Abc_Obj_t *pObjNew)
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
#define Abc_NtkForEachCi(pNtk, pCi, i)
#define Abc_NtkForEachObjVecStart(vIds, pNtk, pObj, i, Start)
ABC_DLL int Abc_ObjLevelNew(Abc_Obj_t *pObj)
#define Abc_NtkForEachObjVec(vIds, pNtk, pObj, i)
ABC_DLL int Abc_NtkGetTotalFanins(Abc_Ntk_t *pNtk)
ABC_DLL int Abc_NodeFindFanin(Abc_Obj_t *pNode, Abc_Obj_t *pFanin)
#define Abc_NtkForEachNode(pNtk, pNode, i)
#define ABC_SWAP(Type, a, b)
#define ABC_PRTP(a, t, T)
#define ABC_REALLOC(type, obj, 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
ABC_DLL void * Abc_FrameReadLibScl()
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
struct Vec_Str_t_ Vec_Str_t
#define sat_solver_addclause
#define sat_solver_add_xor
ABC_NAMESPACE_IMPL_START pcube * cofactor(IN pcube *T, IN register pcube c)
void Dau_DsdPrintFromTruth(word *pTruth, int nVarsInit)
word Gia_ManRandomW(int fReset)
unsigned __int64 word
DECLARATIONS ///.
float Mio_LibraryReadDelayInvMax(Mio_Library_t *pLib)
Mio_Gate_t * Mio_LibraryReadConst0(Mio_Library_t *pLib)
int Mio_GateReadPinNum(Mio_Gate_t *pGate)
double Mio_GateReadArea(Mio_Gate_t *pGate)
struct Mio_LibraryStruct_t_ Mio_Library_t
Vec_Int_t * Mio_GateReadExpr(Mio_Gate_t *pGate)
int Mio_GateIsInv(Mio_Gate_t *pGate)
int Mio_GateReadValue(Mio_Gate_t *pGate)
char * Mio_GateReadName(Mio_Gate_t *pGate)
Mio_Gate_t * Mio_LibraryReadConst1(Mio_Library_t *pLib)
Mio_Gate_t * Mio_LibraryReadInv(Mio_Library_t *pLib)
struct Mio_GateStruct_t_ Mio_Gate_t
Mio_Gate_t * Mio_LibraryReadBuf(Mio_Library_t *pLib)
double Mio_GateReadDelayMax(Mio_Gate_t *pGate)
sat_solver * sat_solver_new(void)
int sat_solver_simplify(sat_solver *s)
void sat_solver_restart(sat_solver *s)
void sat_solver_setnvars(sat_solver *s, int n)
int sat_solver_nvars(sat_solver *s)
void sat_solver_delete(sat_solver *s)
Scl_Con_t * Scl_ConReadMan()
void Abc_NtkChangePerform(Abc_Ntk_t *pNtk, int fVerbose)
void Sfm_TranslateCnf(Vec_Wec_t *vRes, Vec_Str_t *vCnf, Vec_Int_t *vFaninMap, int iPivotVar)
int Sfm_DecMffcArea(Abc_Ntk_t *pNtk, Vec_Int_t *vMffc)
void Sfm_DecStop(Sfm_Dec_t *p)
void Abc_NtkCountStats(Sfm_Dec_t *p, int Limit)
void Sfm_ParSetDefault3(Sfm_Par_t *pPars)
FUNCTION DEFINITIONS ///.
int Sfm_DecComputeFlipInvGain(Sfm_Dec_t *p, Abc_Obj_t *pPivot, int *pfNeedInv)
int Abc_NtkDfsOne_rec(Abc_Obj_t *pObj, Vec_Int_t *vTfi, int nLevelMin, int CiLabel)
void Sfm_DecPrintStats(Sfm_Dec_t *p)
void Abc_NtkDfsReverseOne_rec(Abc_Obj_t *pObj, Vec_Int_t *vTfo, int nLevelMax, int nFanoutMax)
int Sfm_DecPeformDec2(Sfm_Dec_t *p, Abc_Obj_t *pObj)
int Sfm_MffcDeref_rec(Abc_Obj_t *pObj)
int Sfm_DecPeformDec_rec(Sfm_Dec_t *p, word *pTruth, int *pSupp, int *pAssump, int nAssump, word Masks[2][SFM_SIM_WORDS], int fCofactor, int nSuppAdd)
typedefABC_NAMESPACE_IMPL_START struct Sfm_Dec_t_ Sfm_Dec_t
DECLARATIONS ///.
int Sfm_DecMffcAreaReal(Abc_Obj_t *pPivot, Vec_Int_t *vCut, Vec_Int_t *vMffc)
void Sfm_DecVarCost(Sfm_Dec_t *p, word Masks[2][SFM_SIM_WORDS], int d, int Counts[2][2])
void Abc_NtkAreaOpt(Sfm_Dec_t *p)
void Sfm_DecMarkMffc(Abc_Obj_t *pPivot, int nLevelMin, int nMffcMax, int fVeryVerbose, Vec_Int_t *vMffc, Vec_Int_t *vInMffc, Sfm_Tim_t *pTim, Sfm_Mit_t *pMit)
void Abc_NtkUpdateIncLevel_rec(Abc_Obj_t *pObj)
void Abc_NtkPerformMfs3(Abc_Ntk_t *pNtk, Sfm_Par_t *pPars)
void Sfm_DecPrepareVec(Vec_Int_t *vMap, int *pNodes, int nNodes, Vec_Int_t *vCut)
void Abc_NtkDelayOpt(Sfm_Dec_t *p)
int Sfm_DecPeformDec3(Sfm_Dec_t *p, Abc_Obj_t *pObj)
Sfm_Dec_t * Sfm_DecStart(Sfm_Par_t *pPars, Mio_Library_t *pLib, Abc_Ntk_t *pNtk)
int Sfm_DecPrepareSolver(Sfm_Dec_t *p)
Abc_Obj_t * Abc_NtkAreaOptOne(Sfm_Dec_t *p, int i)
int Sfm_MffcRef_rec(Abc_Obj_t *pObj, Vec_Int_t *vMffc)
int Abc_NtkDfsCheck_rec(Abc_Obj_t *pObj, Abc_Obj_t *pPivot)
int Sfm_DecFindBestVar(Sfm_Dec_t *p, word Masks[2][SFM_SIM_WORDS])
int Sfm_DecFindBestVar2(Sfm_Dec_t *p, word Masks[2][SFM_SIM_WORDS])
void Sfm_DecPrint(Sfm_Dec_t *p, word Masks[2][SFM_SIM_WORDS])
void Sfm_DecAddNode(Abc_Obj_t *pObj, Vec_Int_t *vMap, Vec_Int_t *vGates, int fSkip, int fVeryVerbose)
int Sfm_DecFindCost(Sfm_Dec_t *p, int c, int iLit, word *pMask)
int Sfm_DecCombineDec(Sfm_Dec_t *p, word *pTruth0, word *pTruth1, int *pSupp0, int *pSupp1, int nSupp0, int nSupp1, word *pTruth, int *pSupp, int Var)
Abc_Obj_t * Sfm_DecInsert(Abc_Ntk_t *pNtk, Abc_Obj_t *pPivot, int Limit, Vec_Int_t *vGates, Vec_Wec_t *vFanins, Vec_Int_t *vMap, Vec_Ptr_t *vGateHandles, int GateBuf, int GateInv, Vec_Wrd_t *vFuncs, Vec_Int_t *vNewNodes, Sfm_Mit_t *pMit)
int Sfm_DecExtract(Abc_Ntk_t *pNtk, Sfm_Par_t *pPars, Abc_Obj_t *pPivot, Vec_Int_t *vRoots, Vec_Int_t *vGates, Vec_Wec_t *vFanins, Vec_Int_t *vMap, Vec_Int_t *vTfi, Vec_Int_t *vTfo, Vec_Int_t *vMffc, Vec_Int_t *vInMffc, Sfm_Tim_t *pTim, Sfm_Mit_t *pMit)
void Abc_NtkAreaOpt2(Sfm_Dec_t *p)
int Sfm_TimSortArrayByArrival(Sfm_Tim_t *p, Vec_Int_t *vNodes, int iPivot)
void Sfm_MitTimingGrow(Sfm_Mit_t *p)
int Sfm_LibImplementGatesArea(Sfm_Lib_t *p, int *pFanins, int nFanins, int iObj, Vec_Int_t *vGates, Vec_Wec_t *vFanins)
void Sfm_MitUpdateTiming(Sfm_Mit_t *p, Vec_Int_t *vTimeNodes)
void Sfm_MitTransferLoad(Sfm_Mit_t *p, Abc_Obj_t *pNew, Abc_Obj_t *pOld)
void Sfm_LibPrint(Sfm_Lib_t *p)
void Sfm_MitStop(Sfm_Mit_t *p)
struct Sfm_Tim_t_ Sfm_Tim_t
Sfm_Tim_t * Sfm_TimStart(Mio_Library_t *pLib, Scl_Con_t *pExt, Abc_Ntk_t *pNtk, int DeltaCrit)
struct Sfm_Mit_t_ Sfm_Mit_t
int Sfm_MitReadNtkDelay(Sfm_Mit_t *p)
int Sfm_TimReadObjDelay(Sfm_Tim_t *p, int iObj)
int Sfm_TimNodeIsNonCritical(Sfm_Tim_t *p, Abc_Obj_t *pPivot, Abc_Obj_t *pNode)
void Sfm_MitUpdateLoad(Sfm_Mit_t *p, Vec_Int_t *vTimeNodes, int fAdd)
int Sfm_MitReadObjDelay(Sfm_Mit_t *p, int iObj)
Sfm_Lib_t * Sfm_LibPrepare(int nVars, int fTwo, int fDelay, int fVerbose, int fLibVerbose)
int Sfm_LibFindComplInputGate(Vec_Wrd_t *vFuncs, int iGate, int nFanins, int iFanin, int *piFaninNew)
void Sfm_LibStop(Sfm_Lib_t *p)
int Sfm_TimReadNtkDelay(Sfm_Tim_t *p)
void Sfm_TimUpdateTiming(Sfm_Tim_t *p, Vec_Int_t *vTimeNodes)
int Sfm_MitPriorityNodes(Sfm_Mit_t *p, Vec_Int_t *vCands, int Window)
void Sfm_TimStop(Sfm_Tim_t *p)
int Sfm_LibImplementGatesDelay(Sfm_Lib_t *p, int *pFanins, Mio_Gate_t *pGateB, Mio_Gate_t *pGateT, char *pFansB, char *pFansT, Vec_Int_t *vGates, Vec_Wec_t *vFanins)
int Sfm_LibFindDelayMatches(Sfm_Lib_t *p, word *pTruth, int *pFanins, int nFanins, Vec_Ptr_t *vGates, Vec_Ptr_t *vFans)
struct Sfm_Lib_t_ Sfm_Lib_t
int Sfm_LibImplementSimple(Sfm_Lib_t *p, word *pTruth, int *pFanins, int nFanins, Vec_Int_t *vGates, Vec_Wec_t *vFanins)
int Sfm_MitSortArrayByArrival(Sfm_Mit_t *p, Vec_Int_t *vNodes, int iPivot)
int Sfm_MitNodeIsNonCritical(Sfm_Mit_t *p, Abc_Obj_t *pPivot, Abc_Obj_t *pNode)
int Sfm_LibFindAreaMatch(Sfm_Lib_t *p, word *pTruth, int nFanins, int *piObj)
int Sfm_MitReadNtkMinSlack(Sfm_Mit_t *p)
int Sfm_TimEvalRemapping(Sfm_Tim_t *p, Vec_Int_t *vFanins, Vec_Int_t *vMap, Mio_Gate_t *pGate1, char *pFans1, Mio_Gate_t *pGate2, char *pFans2)
int Sfm_MitEvalRemapping(Sfm_Mit_t *p, Vec_Int_t *vMffc, Abc_Obj_t *pObj, Vec_Int_t *vFanins, Vec_Int_t *vMap, Mio_Gate_t *pGate1, char *pFans1, Mio_Gate_t *pGate2, char *pFans2)
int Sfm_TimPriorityNodes(Sfm_Tim_t *p, Vec_Int_t *vCands, int Window)
Sfm_Mit_t * Sfm_MitStart(Mio_Library_t *pLib, SC_Lib *pScl, Scl_Con_t *pExt, Abc_Ntk_t *pNtk, int DeltaCrit)
FUNCTION DEFINITIONS ///.
void Sfm_LibPreprocess(Mio_Library_t *pLib, Vec_Int_t *vGateSizes, Vec_Wrd_t *vGateFuncs, Vec_Wec_t *vGateCnfs, Vec_Ptr_t *vGateHands)
struct Sfm_Par_t_ Sfm_Par_t
word TtElems[SFM_SUPP_MAX][SFM_WORD_MAX]
word * pTtElems[SFM_SUPP_MAX]
word * pDivWords[SFM_SUPP_MAX]
int nLuckySizes[SFM_SUPP_MAX+1]
int nLuckyGates[SFM_SUPP_MAX+1]
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
#define Vec_IntForEachEntryReverse(vVec, pEntry, i)
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.