From feb3e7943de06c7c5ba16c53a23df00aa3c46cd0 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sat, 26 Oct 2019 16:29:05 +0300 Subject: Adding limit on the depth of recursion when counting exact area in 'amap'. --- src/map/amap/amapMatch.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) (limited to 'src/map/amap/amapMatch.c') diff --git a/src/map/amap/amapMatch.c b/src/map/amap/amapMatch.c index 2276cfc2..a8df3aeb 100644 --- a/src/map/amap/amapMatch.c +++ b/src/map/amap/amapMatch.c @@ -288,6 +288,63 @@ static inline float Amap_CutAreaDeref( Amap_Man_t * p, Amap_Mat_t * pM ) return Area; } +/**Function************************************************************* + + Synopsis [Counts area while referencing the match.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline float Amap_CutAreaRef2( Amap_Man_t * p, Amap_Mat_t * pM, Vec_Ptr_t * vTemp, int Limit ) +{ + Amap_Obj_t * pFanin; + int i, fCompl; + float Area = Amap_LibGate( p->pLib, pM->pSet->iGate )->dArea; + if ( Limit == 0 ) return Area; + Amap_MatchForEachFaninCompl( p, pM, pFanin, fCompl, i ) + { + Vec_PtrPush( vTemp, pFanin->nFouts + fCompl ); + assert( Amap_ObjRefsTotal(pFanin) >= 0 ); + if ( (int)pFanin->fPolar != fCompl && pFanin->nFouts[fCompl] == 0 ) + Area += p->fAreaInv; + if ( pFanin->nFouts[fCompl]++ + pFanin->nFouts[!fCompl] == 0 && Amap_ObjIsNode(pFanin) ) + Area += Amap_CutAreaRef2( p, &pFanin->Best, vTemp, Limit-1 ); + } + return Area; +} + +/**Function************************************************************* + + Synopsis [Derives area of the match for a non-referenced node.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline float Amap_CutAreaDerefed2( Amap_Man_t * p, Amap_Obj_t * pNode, Amap_Mat_t * pM ) +{ + int nRecurLevels = 8; + int fComplNew, i, * pInt; + float aResult; + Vec_PtrClear( p->vTempP ); + aResult = Amap_CutAreaRef2( p, pM, p->vTempP, nRecurLevels ); + //Amap_CutAreaDeref( p, pM ); + Vec_PtrForEachEntry( int *, p->vTempP, pInt, i ) + (*pInt)--; + // if node is needed in another polarity, add inverter + fComplNew = pM->pCut->fInv ^ pM->pSet->fInv; + if ( pNode->nFouts[fComplNew] == 0 && pNode->nFouts[!fComplNew] > 0 ) + aResult += p->fAreaInv; + return aResult; +} + /**Function************************************************************* Synopsis [Counts area while referencing the match.] @@ -444,7 +501,8 @@ static inline void Amap_ManMatchGetExacts( Amap_Man_t * p, Amap_Obj_t * pNode, A } pM->AveFan /= pGate->nPins; pM->Delay += 1.0; - pM->Area = Amap_CutAreaDerefed( p, pNode, pM ); + //pM->Area = Amap_CutAreaDerefed( p, pNode, pM ); + pM->Area = Amap_CutAreaDerefed2( p, pNode, pM ); } /**Function************************************************************* -- cgit v1.2.3