abc/src/bdd/cudd/cuddGenCof.c
/**Function********************************************************************

  Synopsis [BDD restrict according to Coudert and Madre's algorithm
  (ICCAD90).]

  Description [BDD restrict according to Coudert and Madre's algorithm
  (ICCAD90). Returns the restricted BDD if successful; otherwise NULL.
  If application of restrict results in a BDD larger than the input
  BDD, the input BDD is returned.]

  SideEffects [None]

  SeeAlso     [Cudd_bddConstrain Cudd_addRestrict]

******************************************************************************/
Function
Synopsis [BDD restrict according to Coudert and Madre's algorithm
(ICCAD90).]

Description [BDD restrict according to Coudert and Madre's algorithm
(ICCAD90). Returns the restricted BDD if successful; otherwise NULL.
If application of restrict results in a BDD larger than the input
BDD, the input BDD is returned.]




Function Synopsis [ BDD restrict according to Coudert and Madre ' s algorithm ( ICCAD90 ) . ] Description [ BDD restrict according to Coudert and Madre ' s algorithm ( ICCAD90 ) . Returns the restricted BDD if successful ; otherwise NULL . If application of restrict results in a BDD larger than the input BDD the input BDD is returned . ]
DdNode *
Cudd_bddRestrict(
  DdManager * dd,
  DdNode * f,
  DdNode * c)
{
    DdNode *suppF, *suppC, *commonSupport;
    DdNode *cplus, *res;
    int retval;
    int sizeF, sizeRes;
    if (c == Cudd_Not(DD_ONE(dd))) return(Cudd_Not(DD_ONE(dd)));
    if (Cudd_IsConstant(f)) return(f);
    if (f == c) return(DD_ONE(dd));
    if (f == Cudd_Not(c)) return(Cudd_Not(DD_ONE(dd)));
    retval = Cudd_ClassifySupport(dd,f,c,&commonSupport,&suppF,&suppC);
    if (retval == 0) {
        return(NULL);
    }
    cuddRef(commonSupport); cuddRef(suppF); cuddRef(suppC);
    Cudd_IterDerefBdd(dd,suppF);
    if (commonSupport == DD_ONE(dd)) {
        Cudd_IterDerefBdd(dd,commonSupport);
        Cudd_IterDerefBdd(dd,suppC);
        return(f);
    }
    Cudd_IterDerefBdd(dd,commonSupport);
    cplus = Cudd_bddExistAbstract(dd, c, suppC);
    if (cplus == NULL) {
        Cudd_IterDerefBdd(dd,suppC);
        return(NULL);
    }
    cuddRef(cplus);
    Cudd_IterDerefBdd(dd,suppC);
    do {
        dd->reordered = 0;
        res = cuddBddRestrictRecur(dd, f, cplus);
    } while (dd->reordered == 1);
    if (res == NULL) {
        Cudd_IterDerefBdd(dd,cplus);
        return(NULL);
    }
    cuddRef(res);
    Cudd_IterDerefBdd(dd,cplus);
    sizeF = Cudd_DagSize(f);
    sizeRes = Cudd_DagSize(res);
    if (sizeF <= sizeRes) {
        Cudd_IterDerefBdd(dd, res);
        return(f);
    } else {
        cuddDeref(res);
        return(res);
    }
}
DdNode * Cudd_bddRestrict ( DdManager * dd , DdNode * f , DdNode * c ) { DdNode * suppF , * suppC , * commonSupport ; DdNode * cplus , * res ; int retval ; int sizeF , sizeRes ; if ( c == Cudd_Not ( DD_ONE ( dd ) ) ) return ( Cudd_Not ( DD_ONE ( dd ) ) ) ; if ( Cudd_IsConstant ( f ) ) return ( f ) ; if ( f == c ) return ( DD_ONE ( dd ) ) ; if ( f == Cudd_Not ( c ) ) return ( Cudd_Not ( DD_ONE ( dd ) ) ) ; retval = Cudd_ClassifySupport ( dd , f , c , & commonSupport , & suppF , & suppC ) ; if ( retval == 0 ) { return ( NULL ) ; } cuddRef ( commonSupport ) ; cuddRef ( suppF ) ; cuddRef ( suppC ) ; Cudd_IterDerefBdd ( dd , suppF ) ; if ( commonSupport == DD_ONE ( dd ) ) { Cudd_IterDerefBdd ( dd , commonSupport ) ; Cudd_IterDerefBdd ( dd , suppC ) ; return ( f ) ; } Cudd_IterDerefBdd ( dd , commonSupport ) ; cplus = Cudd_bddExistAbstract ( dd , c , suppC ) ; if ( cplus == NULL ) { Cudd_IterDerefBdd ( dd , suppC ) ; return ( NULL ) ; } cuddRef ( cplus ) ; Cudd_IterDerefBdd ( dd , suppC ) ; do { dd -> reordered = 0 ; res = cuddBddRestrictRecur ( dd , f , cplus ) ; } while ( dd -> reordered == 1 ) ; if ( res == NULL ) { Cudd_IterDerefBdd ( dd , cplus ) ; return ( NULL ) ; } cuddRef ( res ) ; Cudd_IterDerefBdd ( dd , cplus ) ; sizeF = Cudd_DagSize ( f ) ; sizeRes = Cudd_DagSize ( res ) ; if ( sizeF <= sizeRes ) { Cudd_IterDerefBdd ( dd , res ) ; return ( f ) ; } else { cuddDeref ( res ) ; return ( res ) ; } }
Function
Synopsis [BDD restrict according to Coudert and Madre's algorithm
(ICCAD90).]
Function Synopsis [ BDD restrict according to Coudert and Madre ' s algorithm ( ICCAD90 ) . ]
/* Check terminal cases here to avoid computing supports in trivial cases.
    ** This also allows us notto check later for the case c == 0, in which
    ** there is no common support. */ /* Check if supports intersect. */ /* Abstract from c the variables that do not appear in f. */ /* Make restric safe by returning the smaller of the input and the
    ** result. */