/**Function******************************************************************** Synopsis [Performs the recursive steps of Cudd_bddBoleanDiff.] Description [Performs the recursive steps of Cudd_bddBoleanDiff. Returns the BDD obtained by XORing the cofactors of f with respect to var if successful; NULL otherwise. Exploits the fact that dF/dx = dF'/dx.] SideEffects [None] SeeAlso [] ******************************************************************************/ DdNode * cuddBddBooleanDiffRecur( DdManager * manager, DdNode * f, DdNode * var) { DdNode *T, *E, *res, *res1, *res2; statLine(manager); if (cuddI(manager,f->index) > manager->perm[var->index]) { /* f does not depend on var. */ return(Cudd_Not(DD_ONE(manager))); } /* From now on, f is non-constant. */ /* If the two indices are the same, so are their levels. */ if (f->index == var->index) { res = cuddBddXorRecur(manager, cuddT(f), cuddE(f)); return(res); } /* From now on, cuddI(manager,f->index) < cuddI(manager,cube->index). */ /* Check the cache. */ res = cuddCacheLookup2(manager, cuddBddBooleanDiffRecur, f, var); if (res != NULL) { return(res); } /* Compute the cofactors of f. */ T = cuddT(f); E = cuddE(f); res1 = cuddBddBooleanDiffRecur(manager, T, var); if (res1 == NULL) return(NULL); cuddRef(res1); res2 = cuddBddBooleanDiffRecur(manager, Cudd_Regular(E), var); if (res2 == NULL) { Cudd_IterDerefBdd(manager, res1); return(NULL); } cuddRef(res2); /* ITE takes care of possible complementation of res1 and of the ** case in which res1 == res2. */ res = cuddBddIteRecur(manager, manager->vars[f->index], res1, res2); if (res == NULL) { Cudd_IterDerefBdd(manager, res1); Cudd_IterDerefBdd(manager, res2); return(NULL); } cuddDeref(res1); cuddDeref(res2); cuddCacheInsert2(manager, cuddBddBooleanDiffRecur, f, var, res); return(res); } /* end of cuddBddBooleanDiffRecur */
/** @brief Computes the boolean difference of f with respect to x. @details Computes the boolean difference of f with respect to the variable with index x. @return the %BDD of the boolean difference if successful; NULL otherwise. @sideeffect None */ DdNode * Cudd_bddBooleanDiff( DdManager * manager, DdNode * f, int x) { DdNode *res, *var; /* If the variable is not currently in the manager, f cannot ** depend on it. */ if (x >= manager->size) return(Cudd_Not(DD_ONE(manager))); var = manager->vars[x]; do { manager->reordered = 0; res = cuddBddBooleanDiffRecur(manager, Cudd_Regular(f), var); } while (manager->reordered == 1); if (manager->errorCode == CUDD_TIMEOUT_EXPIRED && manager->timeoutHandler) { manager->timeoutHandler(manager, manager->tohArg); } return(res); } /* end of Cudd_bddBooleanDiff */
/**Function******************************************************************** Synopsis [Computes the boolean difference of f with respect to x.] Description [Computes the boolean difference of f with respect to the variable with index x. Returns the BDD of the boolean difference if successful; NULL otherwise.] SideEffects [None] SeeAlso [] ******************************************************************************/ DdNode * Cudd_bddBooleanDiff( DdManager * manager, DdNode * f, int x) { DdNode *res, *var; /* If the variable is not currently in the manager, f cannot ** depend on it. */ if (x >= manager->size) return(Cudd_Not(DD_ONE(manager))); var = manager->vars[x]; do { manager->reordered = 0; res = cuddBddBooleanDiffRecur(manager, Cudd_Regular(f), var); } while (manager->reordered == 1); return(res); } /* end of Cudd_bddBooleanDiff */