/**Function************************************************************* Synopsis [Computes area of the first level.] Description [The cut need to be derefed.] SideEffects [] SeeAlso [] ***********************************************************************/ float If_CutDeref( If_Man_t * p, If_Cut_t * pCut, int nLevels ) { If_Obj_t * pLeaf; float Area; int i; Area = If_CutLutArea(p, pCut); If_CutForEachLeaf( p, pCut, pLeaf, i ) { assert( pLeaf->nRefs > 0 ); if ( --pLeaf->nRefs > 0 || !If_ObjIsAnd(pLeaf) || nLevels == 1 ) continue; Area += If_CutDeref( p, If_ObjCutBest(pLeaf), nLevels - 1 ); }
/**Function************************************************************* Synopsis [Performs area recovery for each node.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void If_ManImproveNodeExpand( If_Man_t * p, If_Obj_t * pObj, int nLimit, Vec_Ptr_t * vFront, Vec_Ptr_t * vFrontOld, Vec_Ptr_t * vVisited ) { If_Obj_t * pFanin; If_Cut_t * pCut; int CostBef, CostAft, i; float DelayOld, AreaBef, AreaAft; pCut = If_ObjCutBest(pObj); assert( pCut->Delay <= pObj->Required + p->fEpsilon ); if ( pObj->nRefs == 0 ) return; // get the delay DelayOld = pCut->Delay; // get the area AreaBef = If_CutAreaRefed( p, pCut, IF_INFINITY ); // if ( AreaBef == 1 ) // return; // the cut is non-trivial If_ManImproveNodePrepare( p, pObj, nLimit, vFront, vFrontOld, vVisited ); // iteratively modify the cut If_CutDeref( p, pCut, IF_INFINITY ); CostBef = If_ManImproveCutCost( p, vFront ); If_ManImproveNodeFaninCompact( p, pObj, nLimit, vFront, vVisited ); CostAft = If_ManImproveCutCost( p, vFront ); If_CutRef( p, pCut, IF_INFINITY ); assert( CostBef >= CostAft ); // clean up Vec_PtrForEachEntry( vVisited, pFanin, i ) pFanin->fMark = 0; // update the node If_ManImproveNodeUpdate( p, pObj, vFront ); pCut->Delay = If_CutDelay( p, pCut ); // get the new area AreaAft = If_CutAreaRefed( p, pCut, IF_INFINITY ); if ( AreaAft > AreaBef || pCut->Delay > pObj->Required + p->fEpsilon ) { If_ManImproveNodeUpdate( p, pObj, vFrontOld ); AreaAft = If_CutAreaRefed( p, pCut, IF_INFINITY ); assert( AreaAft == AreaBef ); pCut->Delay = DelayOld; } }