48 int hHandle = Mmr_StepFetch(
p->pManCuts, Mpm_CutWordNum(nLeaves) );
49 *ppCut = (
Mpm_Cut_t *)Mmr_StepEntry(
p->pManCuts, hHandle );
52 (*ppCut)->fUseless = 0;
56static inline int Mpm_CutCreateZero(
Mpm_Man_t *
p )
59 int hCut = Mpm_CutAlloc(
p, 0, &pCut );
63static inline int Mpm_CutCreateUnit(
Mpm_Man_t *
p,
int Id )
66 int hCut = Mpm_CutAlloc(
p, 1, &pCut );
67 pCut->
iFunc = Abc_Var2Lit(
p->funcVar0, 0 );
68 pCut->
pLeaves[0] = Abc_Var2Lit( Id, 0 );
73 int hCutNew = Mpm_CutAlloc(
p, pUni->
nLeaves, ppCut );
74 (*ppCut)->iFunc = pUni->
iFunc;
75 (*ppCut)->fCompl = pUni->
fCompl;
77 (*ppCut)->nLeaves = pUni->
nLeaves;
84 int hCutNew = Mpm_CutAlloc(
p, pCut->
nLeaves, &pCutNew );
85 pCutNew->
iFunc = Abc_LitNotCond( pCut->
iFunc, fCompl );
94 int hCut, iList = 0, * pList = &iList;
97 *pList = Mpm_CutDup(
p, pCut, fCompl );
98 pList = &Mpm_CutFetch(
p, *pList )->hNext;
106 printf(
"%d : { ", pCut->
nLeaves );
107 for ( i = 0; i < (int)pCut->
nLeaves; i++ )
108 printf(
"%d ", pCut->
pLeaves[i] );
111static inline void Mpm_CutPrintAll(
Mpm_Man_t *
p )
114 for ( i = 0; i <
p->nCutStore; i++ )
116 printf(
"%2d : ", i );
120static inline int Mpm_CutFindLeaf(
Mpm_Cut_t * pNew,
int iObj )
123 for ( i = 0; i < (int)pNew->
nLeaves; i++ )
124 if ( Abc_Lit2Var(pNew->
pLeaves[i]) == iObj )
131 for ( i = 0; i < (int)pCut->
nLeaves; i++ )
132 if ( Mpm_CutFindLeaf( pBase, Abc_Lit2Var(pCut->
pLeaves[i]) ) == (
int)pBase->
nLeaves )
150 if (
p->pPars->fMap4Cnf )
152 if (
p->pPars->fMap4Aig )
154 if (
p->pPars->fMap4Gates )
156 return p->pLibLut->pLutAreas[pCut->
nLeaves];
163 uSign |= ((
word)1 << (iLeaf & 0x3F));
168 int * pmTimes = Vec_IntArray( &
p->vTimes );
169 int * pDelays =
p->pLibLut->pLutDelays[pCut->
nLeaves];
170 int i, iLeaf, ArrTime = 0;
172 ArrTime = Abc_MaxInt( ArrTime, pmTimes[iLeaf] + pDelays[i] );
177 int * pMigRefs = Vec_IntArray( &
p->vMigRefs );
178 int * pMapRefs = Vec_IntArray( &
p->vMapRefs );
179 int * pEstRefs = Vec_IntArray( &
p->vEstRefs );
180 int * pmArea = Vec_IntArray( &
p->vAreas );
181 int * pmEdge = Vec_IntArray( &
p->vEdges );
185 pUnit->
mTime = ArrTime;
186 pUnit->
mArea = Mpm_CutGetArea(
p, pCut );
193 if (
p->fMainRun && pMapRefs[iLeaf] == 0 )
195 pUnit->
mArea += pmArea[iLeaf];
196 pUnit->
mEdge += pmEdge[iLeaf];
200 assert( pEstRefs[iLeaf] > 0 );
203 pUnit->
mAveRefs +=
p->fMainRun ? pMapRefs[iLeaf] : pMigRefs[iLeaf];
205 pUnit->
uSign |= ((
word)1 << (iLeaf & 0x3F));
227 int fEnableContainment = 1;
235 pUnitNew = Mpm_CutSetupInfo(
p, pCut, ArrTime );
237p->timeEval += Abc_Clock() - clk;
240 if (
p->nCutStore == 0 )
242 p->pCutStore[
p->nCutStore++] = pUnitNew;
243 Vec_PtrPop( &
p->vFreeUnits );
247 if (
p->nCutStore ==
p->nNumCuts-1 &&
p->pCutCmp(pUnitNew,
p->pCutStore[
p->nCutStore-1]) > 0 )
251 assert(
p->nCutStore <=
p->nNumCuts );
252 for ( iPivot =
p->nCutStore - 1; iPivot >= 0; iPivot-- )
253 if (
p->pCutCmp(pUnitNew,
p->pCutStore[iPivot]) > 0 )
256 if ( fEnableContainment )
262 for ( k = 0; k <= iPivot; k++ )
264 pUnit =
p->pCutStore[k];
267 Mpm_CutIsContained(
p, &pUnitNew->
pCut, &pUnit->
pCut) )
270p->timeCompare += Abc_Clock() - clk;
278 if (
p->pCutStore[0]->pCut.fUseless && !pUnitNew->
pCut.
fUseless )
283 Vec_PtrPop( &
p->vFreeUnits );
287 for ( k =
p->nCutStore++; k > iPivot; k-- )
288 p->pCutStore[k] =
p->pCutStore[k-1];
289 p->pCutStore[iPivot] = pUnitNew;
291 if ( fEnableContainment )
294 for ( k = last = iPivot+1; k <
p->nCutStore; k++ )
296 pUnit =
p->pCutStore[k];
299 Mpm_CutIsContained(
p, &pUnit->
pCut, &pUnitNew->
pCut) )
301 Vec_PtrPush( &
p->vFreeUnits, pUnit );
304 p->pCutStore[last++] =
p->pCutStore[k];
308p->timeCompare += Abc_Clock() - clk;
313 if (
p->nCutStore ==
p->nNumCuts )
314 Vec_PtrPush( &
p->vFreeUnits,
p->pCutStore[--
p->nCutStore] );
315 assert(
p->nCutStore <
p->nNumCuts );
338 if (
p->pPars->fUseDsd )
340 for ( c = 1; c < 3; c++ )
342 pTemp = (c == 1) ? pCut1 : pCut2;
345 p->uPermMask[c] = 0x3FFFF;
346 p->uComplMask[c] = 0;
347 for ( i = 0; i < (int)pTemp->
nLeaves; i++ )
349 iPlace = Mpm_CutFindLeaf( pCut, Abc_Lit2Var(pTemp->
pLeaves[i]) );
350 if ( iPlace == (
int)pCut->
nLeaves )
352 if ( (
int)pCut->
nLeaves ==
p->nLutSize )
356 p->uPermMask[c] ^= (((i & 7) ^ 7) << (3*iPlace));
358 p->uComplMask[c] |= (1 << iPlace);
364 for ( c = 1; c < 3; c++ )
366 pTemp = (c == 1) ? pCut1 : pCut2;
369 for ( i = 0; i < (int)pTemp->
nLeaves; i++ )
371 iPlace = Mpm_CutFindLeaf( pCut, Abc_Lit2Var(pTemp->
pLeaves[i]) );
372 if ( iPlace == (
int)pCut->
nLeaves )
374 if ( (
int)pCut->
nLeaves ==
p->nLutSize )
397 if (
p->pPars->fUseTruth )
411 pCut = Mpm_ManMergeCuts(
p, pCut0, pCut1, pCut2 );
413p->timeMerge += clock() - clk;
417 if (
p->pPars->fUseTruth )
418 Mpm_CutComputeTruth(
p, pCut, pCut0, pCut1, pCut2, Mig_ObjFaninC0(pObj), Mig_ObjFaninC1(pObj), Mig_ObjFaninC2(pObj), Mig_ObjNodeType(pObj) );
419 else if (
p->pPars->fUseDsd )
421 if ( !
Mpm_CutComputeDsd6(
p, pCut, pCut0, pCut1, pCut2, Mig_ObjFaninC0(pObj), Mig_ObjFaninC1(pObj), Mig_ObjFaninC2(pObj), Mig_ObjNodeType(pObj) ) )
427 pCut = Mpm_ManMergeCuts(
p, pCut1, pCut0, pCut2 );
429p->timeMerge += clock() - clk;
433 if (
p->pPars->fUseTruth )
434 Mpm_CutComputeTruth(
p, pCut, pCut1, pCut0, pCut2, Mig_ObjFaninC1(pObj), Mig_ObjFaninC0(pObj), 1 ^ Mig_ObjFaninC2(pObj), Mig_ObjNodeType(pObj) );
435 else if (
p->pPars->fUseDsd )
437 if ( !
Mpm_CutComputeDsd6(
p, pCut, pCut1, pCut0, pCut2, Mig_ObjFaninC1(pObj), Mig_ObjFaninC0(pObj), 1 ^ Mig_ObjFaninC2(pObj), Mig_ObjNodeType(pObj) ) )
445 ArrTime = Mpm_CutGetArrTime(
p, pCut );
447p->timeEval += clock() - clk;
449 if (
p->fMainRun && ArrTime > Required )
457p->timeStore += Abc_Clock() - clk;
494 Mmr_StepRecycle(
p->pManCuts, hCut );
495 Mpm_ObjSetCutList(
p, pObj, 0 );
502 if ( Mig_ObjIsNode(pFanin) && Mig_ObjMigRefDec(
p, pFanin) == 0 )
503 Mpm_ObjRecycleCuts(
p, pFanin );
504 pFanin = Mig_ObjSibl(pObj);
505 if ( pFanin && Mig_ObjMigRefDec(
p, pFanin) == 0 )
506 Mpm_ObjRecycleCuts(
p, pFanin );
507 if ( Mig_ObjMigRefNum(
p, pObj) == 0 )
508 Mpm_ObjRecycleCuts(
p, pObj );
516 p->pCuts[i][nCuts] = pCut;
517 p->pSigns[i][nCuts++] = Mpm_CutGetSign( pCut );
526 Mpm_ObjCollectFaninsAndSigns(
p, pFanin, i );
532 int hCut, hNext, ArrTime;
533 int fCompl = Mig_ObjPhase(pRoot) ^ Mig_ObjPhase(pObj);
536 if ( Abc_Lit2Var(pCut->
pLeaves[0]) == Mig_ObjId(pObj) )
538 ArrTime = Mpm_CutGetArrTime(
p, pCut );
539 if ( ArrTime > ReqTime )
542 pCut = Mpm_ManMergeCuts(
p, pCut, NULL, NULL );
551 int i, *pList = Mpm_ObjCutListP(
p, pObj );
552 assert(
p->nCutStore > 0 &&
p->nCutStore <=
p->nNumCuts );
555 for ( i = 0; i <
p->nCutStore; i++ )
557 pUnit =
p->pCutStore[i];
558 *pList = Mpm_CutCreate(
p, &pUnit->
pCut, &pCut );
559 pList = &pCut->
hNext;
560 Vec_PtrPush( &
p->vFreeUnits, pUnit );
562 assert( Vec_PtrSize(&
p->vFreeUnits) ==
p->nNumCuts + 1 );
563 if (
p->nCutStore == 1 && pCut->
nLeaves < 2 )
566 *pList = Mpm_CutCreateUnit(
p, Mig_ObjId(pObj) );
583 int Required = Mpm_ObjRequired(
p, pObj );
584 int hCutBest = Mpm_ObjCutBest(
p, pObj );
590 assert( Vec_PtrSize( &
p->vFreeUnits ) ==
p->nNumCuts + 1 );
591 assert( Mpm_ObjCutList(
p, pObj) == 0 );
595 Mpm_Cut_t * pCut = Mpm_ObjCutBestP(
p, pObj );
596 int Times = Mpm_CutGetArrTime(
p, pCut );
598 if ( Times > Required )
599 printf(
"Arrival time (%d) exceeds required time (%d) at object %d.\n", Times, Required, Mig_ObjId(pObj) );
603 Mpm_ObjSetTime(
p, pObj, Times );
606 if ( Mig_ManChoiceNum(
p->pMig) && Mig_ObjSiblId(pObj) )
612 Mpm_ObjPrepareFanins(
p, pObj );
613 if ( Mig_ObjIsNode2(pObj) )
616 for ( c0 = 0; c0 <
p->nCuts[0] && (pCut0 =
p->pCuts[0][c0]); c0++ )
617 for ( c1 = 0; c1 <
p->nCuts[1] && (pCut1 =
p->pCuts[1][c1]); c1++ )
618 if ( Abc_TtCountOnes(
p->pSigns[0][c0] |
p->pSigns[1][c1]) <=
p->nLutSize )
619 if ( !Mpm_ManExploreNewCut(
p, pObj, pCut0, pCut1, NULL, Required ) )
622 else if ( Mig_ObjIsNode3(pObj) )
625 for ( c0 = 0; c0 <
p->nCuts[0] && (pCut0 =
p->pCuts[0][c0]); c0++ )
626 for ( c1 = 0; c1 <
p->nCuts[1] && (pCut1 =
p->pCuts[1][c1]); c1++ )
627 for ( c2 = 0; c2 <
p->nCuts[2] && (pCut2 =
p->pCuts[2][c2]); c2++ )
628 if ( Abc_TtCountOnes(
p->pSigns[0][c0] |
p->pSigns[1][c1] |
p->pSigns[2][c2]) <=
p->nLutSize )
629 if ( !Mpm_ManExploreNewCut(
p, pObj, pCut0, pCut1, pCut2, Required ) )
634p->timeDerive += Abc_Clock() - clk;
640 if (
p->pCutStore[0]->mTime <= Required )
644 Mmr_StepRecycle(
p->pManCuts, hCutBest );
645 hCutBest = Mpm_CutCreate(
p, &
p->pCutStore[0]->pCut, &pCut );
646 Mpm_ObjSetCutBest(
p, pObj, hCutBest );
647 Mpm_ObjSetTime(
p, pObj,
p->pCutStore[0]->mTime );
648 Mpm_ObjSetArea(
p, pObj,
p->pCutStore[0]->mArea );
649 Mpm_ObjSetEdge(
p, pObj,
p->pCutStore[0]->mEdge );
656 Mpm_ObjDerefFaninCuts(
p, pObj );
672static inline int Mpm_ManFindArrivalMax(
Mpm_Man_t *
p )
674 int * pmTimes = Vec_IntArray( &
p->vTimes );
678 ArrMax = Abc_MaxInt( ArrMax, pmTimes[ Mig_ObjFaninId0(pObj) ] );
681static inline void Mpm_ManFinalizeRound(
Mpm_Man_t *
p )
683 int * pMapRefs = Vec_IntArray( &
p->vMapRefs );
684 int * pRequired = Vec_IntArray( &
p->vRequireds );
691 p->GloRequired = Mpm_ManFindArrivalMax(
p);
692 if (
p->pPars->DelayTarget != -1 )
693 p->GloRequired = Abc_MaxInt(
p->GloRequired,
p->pPars->DelayTarget );
694 Mpm_ManCleanMapRefs(
p );
695 Mpm_ManCleanRequired(
p );
698 if ( Mig_ObjIsCo(pObj) )
700 pRequired[Mig_ObjFaninId0(pObj)] =
p->GloRequired;
701 pMapRefs [Mig_ObjFaninId0(pObj)]++;
703 else if ( Mig_ObjIsNode(pObj) )
705 int Required = pRequired[Mig_ObjId(pObj)];
707 if ( pMapRefs[Mig_ObjId(pObj)] > 0 )
709 pCut = Mpm_ObjCutBestP(
p, pObj );
710 pDelays =
p->pLibLut->pLutDelays[pCut->
nLeaves];
713 pRequired[iLeaf] = Abc_MinInt( pRequired[iLeaf], Required - pDelays[i] );
716 p->GloArea += Mpm_CutGetArea(
p, pCut );
720 else if ( Mig_ObjIsBuf(pObj) )
726static inline void Mpm_ManComputeEstRefs(
Mpm_Man_t *
p )
728 int * pMapRefs = Vec_IntArray( &
p->vMapRefs );
729 int * pEstRefs = Vec_IntArray( &
p->vEstRefs );
733 for ( i = 0; i < Mig_ManObjNum(
p->pMig); i++ )
734 pEstRefs[i] = (1 * pEstRefs[i] +
MPM_UNIT_REFS * pMapRefs[i]) / 2;
800 hCut = Mpm_CutCreateUnit(
p, Mig_ObjId(pObj) );
801 Mpm_ObjSetCutBest(
p, pObj, hCut );
802 Mpm_ObjSetCutList(
p, pObj, hCut );
813 assert( Vec_IntSize(&
p->vMigRefs) == Vec_IntSize(&
p->pMig->vRefs) );
814 memcpy( Vec_IntArray(&
p->vMigRefs), Vec_IntArray(&
p->pMig->vRefs),
sizeof(
int) * Mig_ManObjNum(
p->pMig) );
816 Mig_ObjMigRefDec(
p, Mig_ObjFanin0(pObj) );
821 assert( Mig_ManCandNum(
p->pMig) ==
p->pManCuts->nEntries );
822 Mpm_ManFinalizeRound(
p );
824 if (
p->pPars->fVerbose )
826 printf(
"Del =%5d. Ar =%8d. Edge =%8d. Cut =%10d. Max =%8d. Tru =%8d. Small =%6d. ",
827 p->GloRequired, (
int)
p->GloArea, (
int)
p->GloEdge,
828 p->nCutsMerged,
p->pManCuts->nEntriesMax,
829 p->vTtMem ?
p->vTtMem->nEntries : 0,
p->nSmallSupp );
830 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
835 if (
p->pPars->fMap4Cnf )
844 if (
p->pPars->fOneRound )
856 Mpm_ManComputeEstRefs(
p );
860 Mpm_ManComputeEstRefs(
p );
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
unsigned __int64 word
DECLARATIONS ///.
int Mpm_CutComputeDsd6(Mpm_Man_t *p, Mpm_Cut_t *pCut, Mpm_Cut_t *pCut0, Mpm_Cut_t *pCut1, Mpm_Cut_t *pCutC, int fCompl0, int fCompl1, int fComplC, int Type)
struct Mpm_Uni_t_ Mpm_Uni_t
int Mpm_CutComputeTruth(Mpm_Man_t *p, Mpm_Cut_t *pCut, Mpm_Cut_t *pCut0, Mpm_Cut_t *pCut1, Mpm_Cut_t *pCutC, int fCompl0, int fCompl1, int fComplC, int Type)
struct Mpm_Man_t_ Mpm_Man_t
#define Mpm_ObjForEachCutSafe(p, pObj, hCut, pCut, hNext)
#define Mpm_CutForEachLeafId(pCut, iLeafId, i)
struct Mpm_Cut_t_ Mpm_Cut_t
BASIC TYPES ///.
#define Mpm_ObjForEachCut(p, pObj, hCut, pCut)
void Mpm_ObjAddChoiceCutsToStore(Mpm_Man_t *p, Mig_Obj_t *pRoot, Mig_Obj_t *pObj, int ReqTime)
int Mpm_ObjAddCutToStore(Mpm_Man_t *p, Mpm_Cut_t *pCut, int ArrTime)
void Mpm_ManPerformRound(Mpm_Man_t *p)
int Mpm_CutCompareDelay2(Mpm_Uni_t *pOld, Mpm_Uni_t *pNew)
int Mpm_ManDeriveCuts(Mpm_Man_t *p, Mig_Obj_t *pObj)
void Mpm_ObjTranslateCutsFromStore(Mpm_Man_t *p, Mig_Obj_t *pObj)
void Mpm_CutPrint(Mpm_Cut_t *pCut)
int Mpm_CutCompareDelay(Mpm_Uni_t *pOld, Mpm_Uni_t *pNew)
void Mpm_ManPerform(Mpm_Man_t *p)
void Mpm_ManPrepare(Mpm_Man_t *p)
int Mpm_CutCompareArea(Mpm_Uni_t *pOld, Mpm_Uni_t *pNew)
int Mpm_CutCompareArea2(Mpm_Uni_t *pOld, Mpm_Uni_t *pNew)
#define Mig_ManForEachObjReverse(p, pObj)
struct Mig_Obj_t_ Mig_Obj_t
#define Mig_ObjForEachFanin(p, pFanin, i)
#define Mig_ManForEachNode(p, pObj)
#define Mig_ManForEachCand(p, pObj)
#define Mig_ManForEachCi(p, pObj, i)
#define Mig_ManForEachCo(p, pObj, i)