示例#1
0
/**Function********************************************************************

  Synopsis [Computes the negative cofactor of a ZDD w.r.t. a variable.]

  Description [Computes the negative cofactor of a ZDD w.r.t. a
  variable. In terms of combinations, the result is the set of all
  combinations in which the variable is negated. Returns a pointer to
  the result if successful; NULL otherwise.]

  SideEffects [None]

  SeeAlso     [Cudd_zddSubset1]

******************************************************************************/
DdNode *
Cudd_zddSubset0(
  DdManager * dd,
  DdNode * P,
  int  var)
{
    DdNode	*r;

    do {
	dd->reordered = 0;
	r = cuddZddSubset0(dd, P, var);
    } while (dd->reordered == 1);

    return(r);

} /* end of Cudd_zddSubset0 */
示例#2
0
/**Function********************************************************************

  Synopsis    [Computes the two-way decomposition of f w.r.t. v.]

  Description []

  SideEffects [The results are returned in f1 and f0.]

  SeeAlso     [cuddZddGetCofactors3]

******************************************************************************/
int
cuddZddGetCofactors2(
  DdManager * dd,
  DdNode * f,
  int  v,
  DdNode ** f1,
  DdNode ** f0)
{
    *f1 = cuddZddSubset1(dd, f, v);
    if (*f1 == NULL)
        return(1);
    *f0 = cuddZddSubset0(dd, f, v);
    if (*f0 == NULL) {
        Cudd_RecursiveDerefZdd(dd, *f1);
        return(1);
    }
    return(0);

} /* end of cuddZddGetCofactors2 */
示例#3
0
/**
  @brief Computes the negative cofactor of a %ZDD w.r.t. a variable.

  @details In terms of combinations, the result is the set of all
  combinations in which the variable is negated.

  @return a pointer to the result if successful; NULL otherwise.

  @sideeffect None

  @see Cudd_zddSubset1

*/
DdNode *
Cudd_zddSubset0(
  DdManager * dd,
  DdNode * P,
  int  var)
{
    DdNode	*r;

    do {
	dd->reordered = 0;
	r = cuddZddSubset0(dd, P, var);
    } while (dd->reordered == 1);
    if (dd->errorCode == CUDD_TIMEOUT_EXPIRED && dd->timeoutHandler) {
        dd->timeoutHandler(dd, dd->tohArg);
    }

    return(r);

} /* end of Cudd_zddSubset0 */
示例#4
0
/**Function********************************************************************

  Synopsis    [Computes the three-way decomposition of f w.r.t. v.]

  Description [Computes the three-way decomposition of function f (represented
  by a ZDD) wit respect to variable v.  Returns 0 if successful; 1 otherwise.]

  SideEffects [The results are returned in f1, f0, and fd.]

  SeeAlso     [cuddZddGetCofactors2]

******************************************************************************/
int
cuddZddGetCofactors3(
  DdManager * dd,
  DdNode * f,
  int  v,
  DdNode ** f1,
  DdNode ** f0,
  DdNode ** fd)
{
    DdNode      *pc, *nc;
    DdNode      *zero = DD_ZERO(dd);
    int         top, hv, ht, pv, nv;
    int         level;

    top = dd->permZ[f->index];
    level = dd->permZ[v];
    hv = level >> 1;
    ht = top >> 1;

    if (hv < ht) {
        *f1 = zero;
        *f0 = zero;
        *fd = f;
    }
    else {
        pv = cuddZddGetPosVarIndex(dd, v);
        nv = cuddZddGetNegVarIndex(dd, v);

        /* not to create intermediate ZDD node */
        if (cuddZddGetPosVarLevel(dd, v) < cuddZddGetNegVarLevel(dd, v)) {
            pc = cuddZddSubset1(dd, f, pv);
            if (pc == NULL)
                return(1);
            Cudd_Ref(pc);
            nc = cuddZddSubset0(dd, f, pv);
            if (nc == NULL) {
                Cudd_RecursiveDerefZdd(dd, pc);
                return(1);
            }
            Cudd_Ref(nc);

            *f1 = cuddZddSubset0(dd, pc, nv);
            if (*f1 == NULL) {
                Cudd_RecursiveDerefZdd(dd, pc);
                Cudd_RecursiveDerefZdd(dd, nc);
                return(1);
            }
            Cudd_Ref(*f1);
            *f0 = cuddZddSubset1(dd, nc, nv);
            if (*f0 == NULL) {
                Cudd_RecursiveDerefZdd(dd, pc);
                Cudd_RecursiveDerefZdd(dd, nc);
                Cudd_RecursiveDerefZdd(dd, *f1);
                return(1);
            }
            Cudd_Ref(*f0);

            *fd = cuddZddSubset0(dd, nc, nv);
            if (*fd == NULL) {
                Cudd_RecursiveDerefZdd(dd, pc);
                Cudd_RecursiveDerefZdd(dd, nc);
                Cudd_RecursiveDerefZdd(dd, *f1);
                Cudd_RecursiveDerefZdd(dd, *f0);
                return(1);
            }
            Cudd_Ref(*fd);
        } else {
            pc = cuddZddSubset1(dd, f, nv);
            if (pc == NULL)
                return(1);
            Cudd_Ref(pc);
            nc = cuddZddSubset0(dd, f, nv);
            if (nc == NULL) {
                Cudd_RecursiveDerefZdd(dd, pc);
                return(1);
            }
            Cudd_Ref(nc);

            *f0 = cuddZddSubset0(dd, pc, pv);
            if (*f0 == NULL) {
                Cudd_RecursiveDerefZdd(dd, pc);
                Cudd_RecursiveDerefZdd(dd, nc);
                return(1);
            }
            Cudd_Ref(*f0);
            *f1 = cuddZddSubset1(dd, nc, pv);
            if (*f1 == NULL) {
                Cudd_RecursiveDerefZdd(dd, pc);
                Cudd_RecursiveDerefZdd(dd, nc);
                Cudd_RecursiveDerefZdd(dd, *f0);
                return(1);
            }
            Cudd_Ref(*f1);

            *fd = cuddZddSubset0(dd, nc, pv);
            if (*fd == NULL) {
                Cudd_RecursiveDerefZdd(dd, pc);
                Cudd_RecursiveDerefZdd(dd, nc);
                Cudd_RecursiveDerefZdd(dd, *f1);
                Cudd_RecursiveDerefZdd(dd, *f0);
                return(1);
            }
            Cudd_Ref(*fd);
        }

        Cudd_RecursiveDerefZdd(dd, pc);
        Cudd_RecursiveDerefZdd(dd, nc);
        Cudd_Deref(*f1);
        Cudd_Deref(*f0);
        Cudd_Deref(*fd);
    }
    return(0);

} /* end of cuddZddGetCofactors3 */