50 Vec_Int_t * vCover = Vec_IntAlloc( 1 << 16 );
57 Vec_IntFree( vCover );
61 fprintf( stdout,
"Converting to AIG has failed.\n" );
64 assert( Abc_NtkHasAig(pNew) );
69 Abc_Obj_t * pObj = NULL, * pFanin;
int i, k;
72 assert( Abc_NtkHasAig(pNtk) );
75 Abc_NtkCi( pNew, i )->Level = pObj->
Level;
80 if ( pObj->
Level < pFanin->Level )
81 pObj->
Level = pFanin->Level;
84 if ( (
int)pObj->
Level > Required )
86 Vec_PtrFree( vNodes );
91 Abc_NtkCi( pNew, i )->pCopy = pObj;
99 if ( pObj->
pCopy->
Level < pFanin->pCopy->Level )
106 Vec_PtrFree( vNodes );
158 p->pIfMan->pPars->pTimesArr =
ABC_ALLOC(
float, 32 );
177 vNodes = Vec_VecEntry(
p->vVisited, iNode );
178 if ( Vec_PtrSize(vNodes) == 0 )
183 pTemp = Abc_NtkObj(
p->pNtk, (
int)(ABC_PTRUINT_T)pTemp );
217 pRoot = Kit_DsdNtkRoot( pNtk );
220 if ( Abc_LitIsCompl(pNtk->
Root) )
230 pObjNew = Abc_NtkObj(
p->pNtk, pCut->
pLeaves[ Abc_Lit2Var(pRoot->
pFans[0]) ] );
231 if ( Abc_LitIsCompl(pNtk->
Root) ^ Abc_LitIsCompl(pRoot->
pFans[0]) )
240 if (
p->pIfMan == NULL )
246 for ( i = 0; i <
p->pPars->nVarsMax; i++ )
250 p->pIfMan->pPars->pTimesArr[i] = (float)pLeaf->
Level;
257 if ( pDriver == NULL )
263 p->pIfMan->pPars->fAreaOnly = 1;
266p->timeMap += Abc_Clock() - clk;
270 if (
p->pPars->fVeryVerbose )
271 printf(
" Mffc = %2d. Mapped = %2d. Gain = %3d. Depth increase = %d. SReds = %d.\n",
272 pCut->
nNodes - pCut->
nNodesDup, (
int)
p->pIfMan->AreaGlo, nGain, (
int)
p->pIfMan->RequiredGlo - (
int)
p->pObj->Level,
p->nCalledSRed );
275 if ( !(nGain > 0 || (
p->pPars->fZeroCost && nGain == 0)) )
283 p->nGainTotal += nGain;
285 if (
p->nCalledSRed )
288 nNodesBef = Abc_NtkNodeNum(
p->pNtk);
294 If_ObjSetCopy( If_ManCi(
p->pIfMan, i), pLeaf );
321 int i, k, nSuppSize, nCutNodes, RetValue;
328p->timeCuts += Abc_Clock() - clk;
331p->timeCuts += Abc_Clock() - clk;
335 if (
p->pPars->fVeryVerbose )
336 printf(
"Node %5d : Mffc size = %5d. Cuts = %5d.\n",
p->pObj->Id,
p->nMffc,
p->nEvals );
338 p->nCutsTotal +=
p->nCuts;
339 p->nCutsUseful +=
p->nEvals;
340 for ( i = 0; i <
p->nEvals; i++ )
343 pCut =
p->pCuts +
p->pEvals[i];
344 if (
p->pPars->fFirst && i == 1 )
349 for ( k = 0; k < (int)pCut->
nLeaves; k++ )
350 Abc_NtkObj(
p->pNtk, pCut->
pLeaves[k])->vFanouts.nSize++;
353 for ( k = 0; k < (int)pCut->
nLeaves; k++ )
354 Abc_NtkObj(
p->pNtk, pCut->
pLeaves[k])->vFanouts.nSize--;
364p->timeTruth += Abc_Clock() - clk;
369 if ( Kit_DsdNtkRoot(pDsdNtk)->nFans == 16 )
379 nSuppSize >= ((
int)pCut->
nNodes - (
int)pCut->
nNodesDup - 1) * (
p->pPars->nLutSize - 1) + 1 )
385 if (
p->pPars->fVeryVerbose )
388 printf(
" C%02d: L= %2d/%2d V= %2d/%d N= %d W= %4.2f ",
399p->timeEval += Abc_Clock() - clk;
421 unsigned * pTruthInv;
422 int RetValue1, RetValue2;
426 if ( RetValue1 && RetValue2 && Vec_IntSize(
p->vBddDir) > 1 && Vec_IntSize(
p->vBddInv) > 1 )
429 p->puSupps[0] =
p->puSupps[1] = 0;
446 int NodeCounts[16] = { 0, 0, 0, 0, 1, 3, 6, 14, 26, 57, 106, 230, 425, 1000000, 1000000, 1000000 };
450 int nNodesBef, nNodesAft, nCutNodes;
460p->timeCuts += Abc_Clock() - clk;
463p->timeCuts += Abc_Clock() - clk;
465 if (
p->pPars->fVeryVerbose )
466 printf(
"Node %5d : Mffc size = %5d. Cuts = %5d. Level = %2d. Req = %2d.\n",
467 p->pObj->Id,
p->nMffc,
p->nEvals,
p->pObj->Level, Required );
469 p->nCutsTotal +=
p->nCuts;
470 p->nCutsUseful +=
p->nEvals;
471 for ( i = 0; i <
p->nEvals; i++ )
474 pCut =
p->pCuts +
p->pEvals[i];
475 if (
p->pPars->fFirst && i == 1 )
482 for ( k = 0; k < (int)pCut->
nLeaves; k++ )
483 Abc_NtkObj(
p->pNtk, pCut->
pLeaves[k])->vFanouts.nSize++;
486 for ( k = 0; k < (int)pCut->
nLeaves; k++ )
487 Abc_NtkObj(
p->pNtk, pCut->
pLeaves[k])->vFanouts.nSize--;
494 Vec_PtrClear(
p->vLeaves );
495 for ( k = 0; k < (int)pCut->
nLeaves; k++ )
496 Vec_PtrPush(
p->vLeaves, Abc_NtkObj(
p->pNtk, pCut->
pLeaves[k]) );
501p->timeTruth += Abc_Clock() - clk;
504p->timeSupps += Abc_Clock() - clk;
520 if (
p->pPars->fVeryVerbose )
524 printf(
" C%02d: L= %2d/%2d V= %2d/%d N= %d W= %4.2f ",
527 printf(
"%c=%d ",
'a'+k, Abc_ObjLevel(pLeaf) );
536 nNodesBef = Abc_NtkNodeNum(
p->pNtk);
538 pObjNew =
Lpk_Decompose(
p,
p->pNtk,
p->vLeaves, pTruth,
p->puSupps,
p->pPars->nLutSize,
539 (
int)pCut->
nNodes - (
int)pCut->
nNodesDup - 1 + (
int)(
p->pPars->fZeroCost > 0), Required );
540 if ( pObjNew == NULL &&
p->pPars->nLutSize == 4 && (
int)pCut->
nNodes > NodeCounts[Vec_PtrSize(
p->vLeaves)] + !
p->pPars->fZeroCost )
542p->timeEval += Abc_Clock() - clk;
543 nNodesAft = Abc_NtkNodeNum(
p->pNtk);
548 int nGain = (int)pCut->
nNodes - (
int)pCut->
nNodesDup - (nNodesAft - nNodesBef);
550 assert( Abc_ObjLevel(pObjNew) <= Required );
561 p->nGainTotal += nGain;
563 if (
p->pPars->fVeryVerbose )
564 printf(
"Performed resynthesis: Gain = %2d. Level = %2d. Req = %2d.\n", nGain, Abc_ObjLevel(pObjNew), Required );
591 int i, Iter, nNodes, nNodesPrev;
593 assert( Abc_NtkIsLogic(pNtk) );
603 if ( pPars->nLutSize > 6 )
605 if ( pPars->nLutSize < 3 )
608 if ( pPars->nVarsShared > pPars->nLutSize - 2 )
609 pPars->nVarsShared = pPars->nLutSize - 2;
611 pPars->nVarsMax = pPars->nLutsMax * (pPars->nLutSize - 1) + 1;
612 while ( pPars->nVarsMax > 16 )
615 pPars->nVarsMax = pPars->nLutsMax * (pPars->nLutSize - 1) + 1;
618 if ( pPars->fVerbose )
620 printf(
"Resynthesis for %d %d-LUTs with %d non-MFFC LUTs, %d crossbars, and %d-input cuts.\n",
621 pPars->nLutsMax, pPars->nLutSize, pPars->nLutsOver, pPars->nVarsShared, pPars->nVarsMax );
628 fprintf( stdout,
"Converting to BDD has failed.\n" );
631 assert( Abc_NtkHasAig(pNtk) );
640 p->nNodesTotal = Abc_NtkNodeNum(pNtk);
641 p->vLevels = Vec_VecStart( pNtk->
LevelMax );
642 if (
p->pPars->fSatur )
643 p->vVisited = Vec_VecStart( 0 );
644 if ( pPars->fVerbose )
647 p->nTotalNodes = Abc_NtkNodeNum(pNtk);
659 nNodesPrev =
p->nNodesTotal;
660 for ( Iter = 1; ; Iter++ )
663 if (
p->pPars->fSatur )
664 Vec_VecExpand(
p->vVisited, Abc_NtkObjNumMax(pNtk) + 1 );
667 nNodes = Abc_NtkObjNumMax(pNtk);
668 if ( !pPars->fVeryVerbose )
675 if ( !Abc_ObjIsCo(Abc_ObjFanout0(pObj)) )
680 if ( !pPars->fVeryVerbose )
681 Extra_ProgressBarUpdate( pProgress, i, NULL );
687 if (
p->pPars->fOldAlgo )
692 if ( !pPars->fVeryVerbose )
696 Delta = 100.00 * (nNodesPrev - Abc_NtkNodeNum(pNtk)) /
p->nNodesTotal;
699 nNodesPrev = Abc_NtkNodeNum(pNtk);
700 if ( !
p->pPars->fSatur )
720 if ( pPars->fVerbose )
724 p->nTotalNodes2 = Abc_NtkNodeNum(pNtk);
725 printf(
"Node gain = %5d. (%.2f %%) ",
726 p->nTotalNodes-
p->nTotalNodes2, 100.0*(
p->nTotalNodes-
p->nTotalNodes2)/
p->nTotalNodes );
727 printf(
"Edge gain = %5d. (%.2f %%) ",
728 p->nTotalNets-
p->nTotalNets2, 100.0*(
p->nTotalNets-
p->nTotalNets2)/
p->nTotalNets );
729 printf(
"Muxes = %4d. Dsds = %4d.",
p->nMuxes,
p->nDsds );
731 printf(
"Nodes = %5d (%3d) Cuts = %5d (%4d) Changes = %5d Iter = %2d Benefit = %d.\n",
732 p->nNodesTotal,
p->nNodesOver,
p->nCutsTotal,
p->nCutsUseful,
p->nChanges, Iter,
p->nBenefited );
734 printf(
"Non-DSD:" );
735 for ( i = 3; i <= pPars->nVarsMax; i++ )
737 printf(
" %d=%d", i,
p->nBlocks[i] );
740 p->timeTotal = Abc_Clock() - clk;
741 p->timeEval =
p->timeEval -
p->timeMap;
742 p->timeOther =
p->timeTotal -
p->timeCuts -
p->timeTruth -
p->timeEval -
p->timeMap;
743 ABC_PRTP(
"Cuts ",
p->timeCuts,
p->timeTotal );
744 ABC_PRTP(
"Truth ",
p->timeTruth,
p->timeTotal );
745 ABC_PRTP(
"CSupps",
p->timeSupps,
p->timeTotal );
746 ABC_PRTP(
"Eval ",
p->timeEval,
p->timeTotal );
747 ABC_PRTP(
" MuxAn",
p->timeEvalMuxAn,
p->timeEval );
748 ABC_PRTP(
" MuxSp",
p->timeEvalMuxSp,
p->timeEval );
749 ABC_PRTP(
" DsdAn",
p->timeEvalDsdAn,
p->timeEval );
750 ABC_PRTP(
" DsdSp",
p->timeEvalDsdSp,
p->timeEval );
751 ABC_PRTP(
" Other",
p->timeEval-
p->timeEvalMuxAn-
p->timeEvalMuxSp-
p->timeEvalDsdAn-
p->timeEvalDsdSp,
p->timeEval );
753 ABC_PRTP(
"Other ",
p->timeOther,
p->timeTotal );
754 ABC_PRTP(
"TOTAL ",
p->timeTotal,
p->timeTotal );
761 printf(
"Lpk_Resynthesize: The network check has failed.\n" );
Abc_Obj_t * Abc_NodeFromIf_rec(Abc_Ntk_t *pNtkNew, If_Man_t *pIfMan, If_Obj_t *pIfObj, Vec_Int_t *vCover)
ABC_NAMESPACE_IMPL_START Abc_Ntk_t * Abc_NtkLutmin(Abc_Ntk_t *pNtkInit, int nLutSize, int fReorder, int fVerbose)
DECLARATIONS ///.
ABC_DLL int Abc_NtkSweep(Abc_Ntk_t *pNtk, int fVerbose)
struct Abc_Obj_t_ Abc_Obj_t
ABC_DLL int Abc_NtkGetFaninMax(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
ABC_DLL int Abc_ObjRequiredLevel(Abc_Obj_t *pObj)
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst0(Abc_Ntk_t *pNtk)
ABC_DLL char * Abc_SopCreateFromTruthIsop(Mem_Flex_t *pMan, int nVars, word *pTruth, Vec_Int_t *vCover)
#define Abc_ObjForEachFanin(pObj, pFanin, i)
ABC_DLL int Abc_NodeMffcLabel(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
ABC_DLL void Abc_NtkUpdate(Abc_Obj_t *pObj, Abc_Obj_t *pObjNew, Vec_Vec_t *vLevels)
struct Abc_Ntk_t_ Abc_Ntk_t
ABC_DLL void Abc_NtkStopReverseLevels(Abc_Ntk_t *pNtk)
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
ABC_DLL void Abc_NtkStartReverseLevels(Abc_Ntk_t *pNtk, int nMaxLevelIncrease)
ABC_DLL int Abc_NtkToAig(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeInv(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
ABC_DLL int Abc_NtkGetTotalFanins(Abc_Ntk_t *pNtk)
#define Abc_NtkForEachNode(pNtk, pNode, i)
ABC_DLL Abc_Ntk_t * Abc_NtkCreateWithNode(char *pSop)
#define ABC_ALLOC(type, num)
#define ABC_PRTP(a, t, T)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_DLL void * Abc_FrameReadLibLut()
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
ABC_NAMESPACE_IMPL_START typedef char ProgressBar
struct Hop_Obj_t_ Hop_Obj_t
void If_ManCleanCutData(If_Man_t *p)
If_Obj_t * If_ManCreateCo(If_Man_t *p, If_Obj_t *pDriver)
struct If_Par_t_ If_Par_t
void If_ManSetupCiCutSets(If_Man_t *p)
int If_ManPerformMappingComb(If_Man_t *p)
struct If_LibLut_t_ If_LibLut_t
void If_ManRestart(If_Man_t *p)
void If_ManSetupSetAll(If_Man_t *p, int nCrossCut)
struct If_Man_t_ If_Man_t
BASIC TYPES ///.
If_Man_t * If_ManStart(If_Par_t *pPars)
FUNCTION DEFINITIONS ///.
If_Obj_t * If_ManCreateCi(If_Man_t *p)
struct If_Obj_t_ If_Obj_t
void If_ManCleanNodeCopy(If_Man_t *p)
DECLARATIONS ///.
unsigned __int64 word
DECLARATIONS ///.
int Kit_DsdNonDsdSizeMax(Kit_DsdNtk_t *pNtk)
Kit_DsdNtk_t * Kit_DsdDecompose(unsigned *pTruth, int nVars)
void Kit_DsdPrint(FILE *pFile, Kit_DsdNtk_t *pNtk)
int Kit_CreateCloudFromTruth(CloudManager *dd, unsigned *pTruth, int nVars, Vec_Int_t *vNodes)
void Kit_TruthCofSupports(Vec_Int_t *vBddDir, Vec_Int_t *vBddInv, int nVars, Vec_Int_t *vMemory, unsigned *puSupps)
void Kit_DsdNtkFree(Kit_DsdNtk_t *pNtk)
struct Kit_DsdObj_t_ Kit_DsdObj_t
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
struct Kit_DsdNtk_t_ Kit_DsdNtk_t
Abc_Obj_t * Lpk_Decompose(Lpk_Man_t *p, Abc_Ntk_t *pNtk, Vec_Ptr_t *vLeaves, unsigned *pTruth, unsigned *puSupps, int nLutK, int AreaLim, int DelayLim)
FUNCTION DECLARATIONS ///.
int Lpk_Resynthesize(Abc_Ntk_t *pNtk, Lpk_Par_t *pPars)
MACRO DEFINITIONS ///.
int Lpk_NodeHasChanged(Lpk_Man_t *p, int iNode)
Abc_Obj_t * Abc_NtkLutMinDecompose(Abc_Ntk_t *pNtk, Vec_Ptr_t *vLeaves, word *pTruth, int nLutSize, int Required)
int Lpk_ResynthesizeNodeNew(Lpk_Man_t *p)
int Lpk_ResynthesizeNode(Lpk_Man_t *p)
void Lpk_ComputeSupports(Lpk_Man_t *p, Lpk_Cut_t *pCut, unsigned *pTruth)
int Lpk_ExploreCut(Lpk_Man_t *p, Lpk_Cut_t *pCut, Kit_DsdNtk_t *pNtk)
ABC_NAMESPACE_IMPL_START Abc_Ntk_t * Abc_NtkDecFromTruth(word *pTruth, int nVars, int nLutSize)
DECLARATIONS ///.
void Lpk_IfManStart(Lpk_Man_t *p)
int Lpk_NodeCuts(Lpk_Man_t *p)
unsigned * Lpk_CutTruth(Lpk_Man_t *p, Lpk_Cut_t *pCut, int fInv)
#define Lpk_CutForEachLeaf(pNtk, pCut, pObj, i)
MACRO DEFINITIONS ///.
Lpk_Man_t * Lpk_ManStart(Lpk_Par_t *pPars)
DECLARATIONS ///.
struct Lpk_Man_t_ Lpk_Man_t
void Lpk_ManStop(Lpk_Man_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)
struct Lpk_Cut_t_ Lpk_Cut_t
typedefABC_NAMESPACE_HEADER_START struct Lpk_Par_t_ Lpk_Par_t
INCLUDES ///.
struct Mem_Flex_t_ Mem_Flex_t
int pLeaves[LPK_SIZE_MAX]
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntryDouble(Type1, Type2, vVec, Entry1, Entry2, i)
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.