/**Function************************************************************* Synopsis [Pushing the flow through the top part of the node.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Nwk_ManPushBackwardTop_rec( Nwk_Obj_t * pObj, Nwk_Obj_t * pPred ) { Nwk_Obj_t * pNext; int i; if ( Nwk_ObjVisitedTop(pObj) ) return 0; Nwk_ObjSetVisitedTop(pObj); // check if this is the sink if ( Nwk_ObjIsSink(pObj) ) return 1; // try to push through the fanins Nwk_ObjForEachFanin( pObj, pNext, i ) if ( Nwk_ManPushBackwardBot_rec( pNext, pPred ) ) return 1; // try to push through the fanouts Nwk_ObjForEachFanout( pObj, pNext, i ) if ( !Nwk_ObjIsCo(pObj) && Nwk_ManPushBackwardTop_rec( pNext, pPred ) ) return 1; // redirect the flow if ( Nwk_ObjHasFlow(pObj) ) if ( Nwk_ObjPred(pObj) && Nwk_ManPushBackwardBot_rec( pObj, Nwk_ObjPred(pObj) ) ) { Nwk_ObjClearFlow( pObj ); return Nwk_ObjSetPred( pObj, NULL ); } return 0; }
/**Function************************************************************* Synopsis [Transfers fanout from the old node to the new node.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Nwk_ObjTransferFanout( Nwk_Obj_t * pNodeFrom, Nwk_Obj_t * pNodeTo ) { Vec_Ptr_t * vFanouts = pNodeFrom->pMan->vTemp; Nwk_Obj_t * pTemp; int nFanoutsOld, i; assert( !Nwk_ObjIsCo(pNodeFrom) && !Nwk_ObjIsCo(pNodeTo) ); assert( pNodeFrom->pMan == pNodeTo->pMan ); assert( pNodeFrom != pNodeTo ); assert( Nwk_ObjFanoutNum(pNodeFrom) > 0 ); // get the fanouts of the old node nFanoutsOld = Nwk_ObjFanoutNum(pNodeTo); Nwk_ObjCollectFanouts( pNodeFrom, vFanouts ); // patch the fanin of each of them Vec_PtrForEachEntry( Nwk_Obj_t *, vFanouts, pTemp, i ) Nwk_ObjPatchFanin( pTemp, pNodeFrom, pNodeTo ); assert( Nwk_ObjFanoutNum(pNodeFrom) == 0 ); assert( Nwk_ObjFanoutNum(pNodeTo) == nFanoutsOld + Vec_PtrSize(vFanouts) ); }