abc/src/proof/acec/acecFadds.c
// finds a sequence of internal nodes that creates a new chain
finds a sequence of internal nodes that creates a new chain
finds a sequence of internal nodes that creates a new chain
int Gia_ManFindPath( Gia_Man_t * p, int DelayC, int nPathMin, int nPathMax, Vec_Int_t * vPath )
{
    Gia_Obj_t * pObj, * pFanin0, * pFanin1;
    int * pDelays = Vec_IntArray(p->vLevels);
    int i, iLit, iMax = Gia_ManFindChainStart( p );
    if ( iMax == -1 )
        return -1;
    Vec_IntClear( vPath );
    pObj = Gia_ManObj(p, iMax);
    assert( Gia_ObjIsAnd(pObj) );
    while ( Gia_ObjIsAnd(pObj) )
    {
        assert( !Gia_ObjIsUsed(pObj) );
        pFanin0 = Gia_ObjFanin0(pObj);
        pFanin1 = Gia_ObjFanin1(pObj);
        if ( Gia_ObjIsUsed(pFanin0) && Gia_ObjIsUsed(pFanin1) )
            break;
        if ( Gia_ObjIsUsed(pFanin0) )
        {
            Vec_IntPush( vPath, Abc_Var2Lit(Gia_ObjId(p, pObj), 1) );
            pObj = pFanin1;
        }
        else if ( Gia_ObjIsUsed(pFanin1) )
        {
            Vec_IntPush( vPath, Abc_Var2Lit(Gia_ObjId(p, pObj), 0) );
            pObj = pFanin0;
        }
        else
        {
            if ( pDelays[Gia_ObjId(p, pFanin1)] > pDelays[Gia_ObjId(p, pFanin0)] )
            {
                Vec_IntPush( vPath, Abc_Var2Lit(Gia_ObjId(p, pObj), 1) );
                pObj = pFanin1;
            }
            else
            {
                Vec_IntPush( vPath, Abc_Var2Lit(Gia_ObjId(p, pObj), 0) );
                pObj = pFanin0;
            }
        }
    }
    if ( Vec_IntSize(vPath) < nPathMin )
    {
        Gia_ManObj(p, iMax)->fPhase = 1;
        return 0;
    }
    if ( Vec_IntSize(vPath) > nPathMax )
        Vec_IntShrink( vPath, nPathMax );
    Vec_IntForEachEntry( vPath, iLit, i )
    {
        pObj = Gia_ManObj( p, Abc_Lit2Var(iLit) );
        if ( Abc_LitIsCompl(iLit) )
        {
            assert( pObj->fMark1 == 0 );
            pObj->fMark1 = 1;
            assert( Gia_ObjFanin1(pObj)->fPhase == 0 );
            Gia_ObjFanin1(pObj)->fPhase = 1;
        }
        else
        {
            assert( pObj->fMark0 == 0 );
            pObj->fMark0 = 1;
            assert( Gia_ObjFanin0(pObj)->fPhase == 0 );
            Gia_ObjFanin0(pObj)->fPhase = 1;
        }
    }
    return Vec_IntSize(vPath);
}
int Gia_ManFindPath ( Gia_Man_t * p , int DelayC , int nPathMin , int nPathMax , Vec_Int_t * vPath ) { Gia_Obj_t * pObj , * pFanin0 , * pFanin1 ; int * pDelays = Vec_IntArray ( p -> vLevels ) ; int i , iLit , iMax = Gia_ManFindChainStart ( p ) ; if ( iMax == -1 ) return -1 ; Vec_IntClear ( vPath ) ; pObj = Gia_ManObj ( p , iMax ) ; assert ( Gia_ObjIsAnd ( pObj ) ) ; while ( Gia_ObjIsAnd ( pObj ) ) { assert ( ! Gia_ObjIsUsed ( pObj ) ) ; pFanin0 = Gia_ObjFanin0 ( pObj ) ; pFanin1 = Gia_ObjFanin1 ( pObj ) ; if ( Gia_ObjIsUsed ( pFanin0 ) && Gia_ObjIsUsed ( pFanin1 ) ) break ; if ( Gia_ObjIsUsed ( pFanin0 ) ) { Vec_IntPush ( vPath , Abc_Var2Lit ( Gia_ObjId ( p , pObj ) , 1 ) ) ; pObj = pFanin1 ; } else if ( Gia_ObjIsUsed ( pFanin1 ) ) { Vec_IntPush ( vPath , Abc_Var2Lit ( Gia_ObjId ( p , pObj ) , 0 ) ) ; pObj = pFanin0 ; } else { if ( pDelays [ Gia_ObjId ( p , pFanin1 ) ] > pDelays [ Gia_ObjId ( p , pFanin0 ) ] ) { Vec_IntPush ( vPath , Abc_Var2Lit ( Gia_ObjId ( p , pObj ) , 1 ) ) ; pObj = pFanin1 ; } else { Vec_IntPush ( vPath , Abc_Var2Lit ( Gia_ObjId ( p , pObj ) , 0 ) ) ; pObj = pFanin0 ; } } } if ( Vec_IntSize ( vPath ) < nPathMin ) { Gia_ManObj ( p , iMax ) -> fPhase = 1 ; return 0 ; } if ( Vec_IntSize ( vPath ) > nPathMax ) Vec_IntShrink ( vPath , nPathMax ) ; Vec_IntForEachEntry ( vPath , iLit , i ) { pObj = Gia_ManObj ( p , Abc_Lit2Var ( iLit ) ) ; if ( Abc_LitIsCompl ( iLit ) ) { assert ( pObj -> fMark1 == 0 ) ; pObj -> fMark1 = 1 ; assert ( Gia_ObjFanin1 ( pObj ) -> fPhase == 0 ) ; Gia_ObjFanin1 ( pObj ) -> fPhase = 1 ; } else { assert ( pObj -> fMark0 == 0 ) ; pObj -> fMark0 = 1 ; assert ( Gia_ObjFanin0 ( pObj ) -> fPhase == 0 ) ; Gia_ObjFanin0 ( pObj ) -> fPhase = 1 ; } } return Vec_IntSize ( vPath ) ; }
finds a sequence of internal nodes that creates a new chain
finds a sequence of internal nodes that creates a new chain
// label nodes