50 memcpy( pNew, pCut, (
size_t)nBytes );
108 Delay = Abc_MaxInt( Delay, Amap_ObjFanin0(
p,pObj)->Best.Delay );
149 int i, iFanin, fComplFanin;
151 if ( pObj->
nFouts[fCompl]++ + pObj->
nFouts[!fCompl] > 0 )
153 if ( Amap_ObjIsPi(pObj) || Amap_ObjIsConst1(pObj) )
155 pGate = Amap_LibGate(
p->pLib, pM->
pSet->
iGate );
158 for ( i = 0; i < (int)pGate->
nPins; i++ )
160 iFanin = Abc_Lit2Var( pM->
pSet->
Ins[i] );
161 pFanin = Amap_ManObj(
p, Abc_Lit2Var(pM->
pCut->
Fans[iFanin]) );
162 fComplFanin = Abc_LitIsCompl( pM->
pSet->
Ins[i] ) ^ Abc_LitIsCompl( pM->
pCut->
Fans[iFanin] );
224 if ( pM0->
Delay < pM1->
Delay -
p->pPars->fEpsilon )
226 if ( pM0->
Delay > pM1->
Delay +
p->pPars->fEpsilon )
230 if ( pM0->
Area < pM1->
Area -
p->pPars->fEpsilon )
232 if ( pM0->
Area > pM1->
Area +
p->pPars->fEpsilon )
245 if ( pM0->
Area < pM1->
Area -
p->pPars->fEpsilon )
247 if ( pM0->
Area > pM1->
Area +
p->pPars->fEpsilon )
257 if ( pM0->
Delay < pM1->
Delay -
p->pPars->fEpsilon )
259 if ( pM0->
Delay > pM1->
Delay +
p->pPars->fEpsilon )
279 float Area = Amap_LibGate(
p->pLib, pM->
pSet->
iGate )->dArea;
282 assert( Amap_ObjRefsTotal(pFanin) > 0 );
283 if ( (
int)pFanin->
fPolar != fCompl && pFanin->
nFouts[fCompl] == 1 )
285 if ( --pFanin->
nFouts[fCompl] + pFanin->
nFouts[!fCompl] == 0 && Amap_ObjIsNode(pFanin) )
286 Area += Amap_CutAreaDeref(
p, &pFanin->
Best );
306 float Area = Amap_LibGate(
p->pLib, pM->
pSet->
iGate )->dArea;
307 if ( Limit == 0 )
return Area;
310 Vec_PtrPush( vTemp, pFanin->
nFouts + fCompl );
311 assert( Amap_ObjRefsTotal(pFanin) >= 0 );
312 if ( (
int)pFanin->
fPolar != fCompl && pFanin->
nFouts[fCompl] == 0 )
314 if ( pFanin->
nFouts[fCompl]++ + pFanin->
nFouts[!fCompl] == 0 && Amap_ObjIsNode(pFanin) )
315 Area += Amap_CutAreaRef2(
p, &pFanin->
Best, vTemp, Limit-1 );
333 int nRecurLevels = 8;
334 int fComplNew, i, * pInt;
336 Vec_PtrClear(
p->vTempP );
337 aResult = Amap_CutAreaRef2(
p, pM,
p->vTempP, nRecurLevels );
343 if ( pNode->
nFouts[fComplNew] == 0 && pNode->
nFouts[!fComplNew] > 0 )
344 aResult +=
p->fAreaInv;
363 float Area = Amap_LibGate(
p->pLib, pM->
pSet->
iGate )->dArea;
366 assert( Amap_ObjRefsTotal(pFanin) >= 0 );
367 if ( (
int)pFanin->
fPolar != fCompl && pFanin->
nFouts[fCompl] == 0 )
369 if ( pFanin->
nFouts[fCompl]++ + pFanin->
nFouts[!fCompl] == 0 && Amap_ObjIsNode(pFanin) )
370 Area += Amap_CutAreaRef(
p, &pFanin->
Best );
388 float aResult, aResult2;
390 aResult2 = Amap_CutAreaRef(
p, pM );
391 aResult = Amap_CutAreaDeref(
p, pM );
392 assert( aResult > aResult2 -
p->fEpsilonInternal );
393 assert( aResult < aResult2 + p->fEpsilonInternal );
396 if ( pNode->
nFouts[fComplNew] == 0 && pNode->
nFouts[!fComplNew] > 0 )
397 aResult +=
p->fAreaInv;
414 float aResult, aResult2;
415 if ( Amap_ObjRefsTotal(pNode) == 0 )
417 aResult2 = Amap_CutAreaRef(
p, &pNode->
Best );
418 aResult = Amap_CutAreaDeref(
p, &pNode->
Best );
419 assert( aResult > aResult2 -
p->fEpsilonInternal );
420 assert( aResult < aResult2 + p->fEpsilonInternal );
424 aResult = Amap_CutAreaDeref(
p, &pNode->
Best );
425 aResult2 = Amap_CutAreaRef(
p, &pNode->
Best );
426 assert( aResult > aResult2 -
p->fEpsilonInternal );
427 assert( aResult < aResult2 + p->fEpsilonInternal );
449 pGate = Amap_LibGate(
p->pLib, pM->
pSet->
iGate );
457 pMFanin = &pFanin->
Best;
459 pM->
AveFan += Amap_ObjRefsTotal(pFanin);
464 AddOn = Amap_ObjRefsTotal(pFanin) == 0 ? pMFanin->
Area : pMFanin->
Area / pFanin->
EstRefs;
465 if ( pM->
Area >= (
float)1e32 || AddOn >= (
float)1e32 )
466 pM->
Area = (float)1e32;
491 pGate = Amap_LibGate(
p->pLib, pM->
pSet->
iGate );
498 pMFanin = &pFanin->
Best;
500 pM->
AveFan += Amap_ObjRefsTotal(pFanin);
505 pM->
Area = Amap_CutAreaDerefed2(
p, pNode, pM );
522 int fVeryVerbose = fVerbose;
525 Amap_Mat_t * pMBestA = &MA, * pMBestD = &MD, * pMThis = &
M, * pMBest;
532 pNode->
EstRefs = (float)((2.0 * pNode->
EstRefs + Amap_ObjRefsTotal(pNode)) / 3.0);
535 if ( fRefs && Amap_ObjRefsTotal(pNode) > 0 )
536 Amap_CutAreaDeref(
p, &pNode->
Best );
539 printf(
"\nNode %d (%d)\n", pNode->
Id, pNode->
Level );
541 pMBestA->
pCut = pMBestD->pCut = NULL;
544 if ( pCut->
iMat == 0 )
546 pNod = Amap_LibNod(
p->pLib, pCut->
iMat );
549 Amap_ManMatchStart( pMThis, pCut, pSet );
551 Amap_ManMatchGetFlows(
p, pMThis );
553 Amap_ManMatchGetExacts(
p, pNode, pMThis );
554 if ( pMBestD->pCut == NULL || Amap_CutCompareDelay(
p, pMBestD, pMThis) == 1 )
556 if ( pMBestA->
pCut == NULL || Amap_CutCompareArea(
p, pMBestA, pMThis) == 1 )
561 printf(
"Cut %2d (%d) : ", i, pCut->
nFans );
562 printf(
"Gate %10s ", Amap_LibGate(
p->pLib, pMThis->pSet->iGate)->pName );
563 printf(
"%s ", pMThis->pSet->fInv ?
"inv" :
" " );
564 printf(
"Delay %5.2f ", pMThis->Delay );
565 printf(
"Area %5.2f ", pMThis->Area );
571 if ( Abc_AbsFloat(pMBestA->
Area - pMBestD->Area) / pMBestD->Area >=
p->pPars->fADratio * Abc_AbsFloat(pMBestA->
Delay - pMBestD->Delay) / pMBestA->
Delay )
578 printf(
"BEST MATCHA: " );
579 printf(
"Gate %10s ", Amap_LibGate(
p->pLib, pMBestA->
pSet->
iGate)->pName );
580 printf(
"%s ", pMBestA->
pSet->
fInv ?
"inv" :
" " );
581 printf(
"Delay %5.2f ", pMBestA->
Delay );
582 printf(
"Area %5.2f ", pMBestA->
Area );
585 printf(
"BEST MATCHD: " );
586 printf(
"Gate %10s ", Amap_LibGate(
p->pLib, pMBestD->pSet->iGate)->pName );
587 printf(
"%s ", pMBestD->pSet->fInv ?
"inv" :
" " );
588 printf(
"Delay %5.2f ", pMBestD->Delay );
589 printf(
"Area %5.2f ", pMBestD->Area );
592 printf(
"BEST MATCH : " );
593 printf(
"Gate %10s ", Amap_LibGate(
p->pLib, pMBest->pSet->iGate)->pName );
594 printf(
"%s ", pMBest->pSet->fInv ?
"inv" :
" " );
595 printf(
"Delay %5.2f ", pMBest->Delay );
596 printf(
"Area %5.2f ", pMBest->Area );
600 pNode->
fPolar = pMBest->pCut->fInv ^ pMBest->pSet->fInv;
601 pNode->
Best = *pMBest;
603 if ( fRefs && Amap_ObjRefsTotal(pNode) > 0 )
604 Amap_CutAreaRef(
p, &pNode->
Best );
625 pMemOld =
p->pMemCutBest;
633if (
p->pPars->fVerbose )
635 printf(
"Area =%9.2f. Gate =%9.2f. Inv =%9.2f. (%6d.) Delay =%6.2f. ",
636 Area + nInvs *
p->fAreaInv,
637 Area, nInvs *
p->fAreaInv, nInvs,
639ABC_PRT(
"Time ", Abc_Clock() - clk );
661 for ( i = 0; i <
p->pPars->nIterFlow; i++ )
663 for ( i = 0; i <
p->pPars->nIterArea; i++ )
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
void Aig_MmFlexStop(Aig_MmFlex_t *p, int fVerbose)
char * Aig_MmFlexEntryFetch(Aig_MmFlex_t *p, int nBytes)
struct Aig_MmFlex_t_ Aig_MmFlex_t
Aig_MmFlex_t * Aig_MmFlexStart()
struct Amap_Obj_t_ Amap_Obj_t
#define Amap_NodeForEachCut(pNode, pCut, i)
#define Amap_MatchForEachFaninCompl(p, pM, pFanin, fCompl, i)
struct Amap_Man_t_ Amap_Man_t
#define Amap_ManForEachObj(p, pObj, i)
#define Amap_ManForEachNode(p, pObj, i)
struct Amap_Set_t_ Amap_Set_t
void Amap_ManMerge(Amap_Man_t *p)
struct Amap_Gat_t_ Amap_Gat_t
#define Amap_LibNodeForEachSet(pNod, pSet)
struct Amap_Mat_t_ Amap_Mat_t
struct Amap_Nod_t_ Amap_Nod_t
struct Amap_Cut_t_ Amap_Cut_t
#define Amap_ManForEachPo(p, pObj, i)
#define Amap_MatchForEachFanin(p, pM, pFanin, i)
void Amap_ManMatchNode(Amap_Man_t *p, Amap_Obj_t *pNode, int fFlow, int fRefs)
void Amap_ManMatch(Amap_Man_t *p, int fFlow, int fRefs)
float Amap_ManComputeMapping_rec(Amap_Man_t *p, Amap_Obj_t *pObj, int fCompl)
float Amap_ManMaxDelay(Amap_Man_t *p)
void Amap_ManCleanData(Amap_Man_t *p)
ABC_NAMESPACE_IMPL_START Amap_Cut_t * Amap_ManDupCut(Amap_Man_t *p, Amap_Cut_t *pCut)
DECLARATIONS ///.
float Amap_ManComputeMapping(Amap_Man_t *p)
int Amap_ManCountInverters(Amap_Man_t *p)
void Amap_ManMap(Amap_Man_t *p)
void Amap_ManCleanRefs(Amap_Man_t *p)
word M(word f1, word f2, int n)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.