abc/src/aig/ivy/ivyRwrAlg.c
/**Function*************************************************************

  Synopsis    [Computing one algebraic cut.]

  Description [Returns 1 if the tree-leaves of this node where traversed 
  and found to have no external references (and have not been collected). 
  Returns 0 if the tree-leaves have external references and are collected.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [Computing one algebraic cut.]

Description [Returns 1 if the tree-leaves of this node where traversed
and found to have no external references (and have not been collected).
Returns 0 if the tree-leaves have external references and are collected.]




Function Synopsis [ Computing one algebraic cut . ] Description [ Returns 1 if the tree - leaves of this node where traversed and found to have no external references ( and have not been collected ) . Returns 0 if the tree - leaves have external references and are collected . ]
int Ivy_ManFindAlgCut_rec( Ivy_Obj_t * pObj, Ivy_Type_t Type, Vec_Ptr_t * vFront, Vec_Ptr_t * vCone )
{
    int RetValue0, RetValue1;
    Ivy_Obj_t * pObjR = Ivy_Regular(pObj);
    assert( !Ivy_ObjIsBuf(pObjR) );
    assert( Type != IVY_EXOR || !Ivy_IsComplement(pObj) );
    if ( Ivy_IsComplement(pObj) )
    { 
        if ( pObjR->fMarkA )
            return -1;
        pObjR->fMarkB = 1;
    }
    else
    { 
        if ( pObjR->fMarkB )
            return -1;
        pObjR->fMarkA = 1;
    }
    Vec_PtrPush( vCone, pObjR );
    if ( Ivy_IsComplement(pObj) || Ivy_ObjType(pObj) != Type )
    {
        if ( Ivy_ObjRefs(pObjR) == 1 )
            return 1;
        assert( Ivy_ObjRefs(pObjR) > 1 );
        Vec_PtrPush( vFront, pObj );
        return 0;
    }
    assert( !Ivy_IsComplement(pObj) );
    assert( Ivy_ObjIsNode(pObj) );
    RetValue0 = Ivy_ManFindAlgCut_rec( Ivy_ObjReal( Ivy_ObjChild0(pObj) ), Type, vFront, vCone );
    RetValue1 = Ivy_ManFindAlgCut_rec( Ivy_ObjReal( Ivy_ObjChild1(pObj) ), Type, vFront, vCone );
    if ( RetValue0 == -1 || RetValue1 == -1 )
        return -1;
    if ( RetValue0 && RetValue1 )
    {
        if ( Ivy_ObjRefs(pObj) == 1 )
            return 1;
        assert( Ivy_ObjRefs(pObj) > 1 );
        Vec_PtrPush( vFront, pObj );
        return 0;
    }
    if ( RetValue0 )
        Vec_PtrPush( vFront, Ivy_ObjReal( Ivy_ObjChild0(pObj) ) );
    if ( RetValue1 )
        Vec_PtrPush( vFront, Ivy_ObjReal( Ivy_ObjChild1(pObj) ) );
    return 0;
}
int Ivy_ManFindAlgCut_rec ( Ivy_Obj_t * pObj , Ivy_Type_t Type , Vec_Ptr_t * vFront , Vec_Ptr_t * vCone ) { int RetValue0 , RetValue1 ; Ivy_Obj_t * pObjR = Ivy_Regular ( pObj ) ; assert ( ! Ivy_ObjIsBuf ( pObjR ) ) ; assert ( Type != IVY_EXOR || ! Ivy_IsComplement ( pObj ) ) ; if ( Ivy_IsComplement ( pObj ) ) { if ( pObjR -> fMarkA ) return -1 ; pObjR -> fMarkB = 1 ; } else { if ( pObjR -> fMarkB ) return -1 ; pObjR -> fMarkA = 1 ; } Vec_PtrPush ( vCone , pObjR ) ; if ( Ivy_IsComplement ( pObj ) || Ivy_ObjType ( pObj ) != Type ) { if ( Ivy_ObjRefs ( pObjR ) == 1 ) return 1 ; assert ( Ivy_ObjRefs ( pObjR ) > 1 ) ; Vec_PtrPush ( vFront , pObj ) ; return 0 ; } assert ( ! Ivy_IsComplement ( pObj ) ) ; assert ( Ivy_ObjIsNode ( pObj ) ) ; RetValue0 = Ivy_ManFindAlgCut_rec ( Ivy_ObjReal ( Ivy_ObjChild0 ( pObj ) ) , Type , vFront , vCone ) ; RetValue1 = Ivy_ManFindAlgCut_rec ( Ivy_ObjReal ( Ivy_ObjChild1 ( pObj ) ) , Type , vFront , vCone ) ; if ( RetValue0 == -1 || RetValue1 == -1 ) return -1 ; if ( RetValue0 && RetValue1 ) { if ( Ivy_ObjRefs ( pObj ) == 1 ) return 1 ; assert ( Ivy_ObjRefs ( pObj ) > 1 ) ; Vec_PtrPush ( vFront , pObj ) ; return 0 ; } if ( RetValue0 ) Vec_PtrPush ( vFront , Ivy_ObjReal ( Ivy_ObjChild0 ( pObj ) ) ) ; if ( RetValue1 ) Vec_PtrPush ( vFront , Ivy_ObjReal ( Ivy_ObjChild1 ( pObj ) ) ) ; return 0 ; }
Function
Synopsis    [Computing one algebraic cut.]
Function Synopsis [ Computing one algebraic cut . ]
// make sure the node is not visited twice in different polarities // if complemented, mark B // if non-complicated, mark A // if the node is the end of the tree, return // branch on the node // what if buffer has more than one fanout??? // the case when both have no external references // the case when one of them has external references