/* NAME {* bdd\_high *} SECTION {* info *} SHORT {* gets the true branch of a bdd *} PROTO {* BDD bdd_high(BDD r) *} DESCR {* Gets the true branch of the bdd {\tt r}. *} RETURN {* The bdd of the true branch *} ALSO {* bdd\_low *} */ BDD bdd_high(BDD root) { BUDDY_PROLOGUE; ADD_ARG1(T_BDD,root); CHECK(root); if (root < 2) RETURN_BDD(bdd_error(BDD_ILLBDD)); RETURN_BDD(HIGH(root)); }
/* NAME {* bdd\_nithvar *} SECTION {* kernel *} SHORT {* returns a bdd representing the negation of the I'th variable *} PROTO {* BDD bdd_nithvar(int var) *} DESCR {* This function is used to get a bdd representing the negation of the I'th variable (one node with the childs false and true). The requested variable must be in the range define by {\tt bdd\_setvarnum} starting with 0 being the first. For ease of use then the bdd returned from {\tt bdd\_nithvar} does not have to be referenced counted with a call to {\tt bdd\_addref}. *} RETURN {* The negated I'th variable on succes, otherwise the constant false bdd *} ALSO {* bdd\_setvarnum, bdd\_ithvar, bddtrue, bddfalse *} */ BDD bdd_nithvar(int var) { int res; BUDDY_PROLOGUE; ADD_ARG1(T_INT,var); if (var < 0 || var >= bddvarnum) { bdd_error(BDD_VAR); RETURN_BDD(bddfalse); } res = bddvarset[var*2+1]; RETURN_BDD(res); }
/* NAME {* bdd\_addref *} SECTION {* kernel *} SHORT {* increases the reference count on a node *} PROTO {* BDD bdd_addref(BDD r) *} DESCR {* Reference counting is done on externaly referenced nodes only and the count for a specific node {\tt r} can and must be increased using this function to avoid loosing the node in the next garbage collection. *} ALSO {* bdd\_delref *} RETURN {* The BDD node {\tt r}. *} */ BDD bdd_addref(BDD root) { BUDDY_PROLOGUE; ADD_ARG1(T_BDD,root); if (root < 2 || !bddrunning) RETURN_BDD(root); if (root >= bddnodesize) RETURN_BDD(bdd_error(BDD_ILLBDD)); if (LOW(root) == INVALID_BDD) RETURN_BDD(bdd_error(BDD_ILLBDD)); INCREF(root); RETURN_BDD(root); }
bdd cmu_bdd_implies(cmu_bdd_manager bddm, bdd f, bdd g) { if (bdd_check_arguments(2, f, g)) { FIREWALL(bddm); RETURN_BDD(cmu_bdd_intersects_step(bddm, f, BDD_NOT(g))); } return ((bdd)0); }
bdd cmu_bdd_ite(cmu_bdd_manager bddm, bdd f, bdd g, bdd h) { if (bdd_check_arguments(3, f, g, h)) { FIREWALL(bddm); RETURN_BDD(cmu_bdd_ite_step(bddm, f, g, h)); } return ((bdd)0); }
/* NAME {* bdd\_delref *} SECTION {* kernel *} SHORT {* decreases the reference count on a node *} PROTO {* BDD bdd_delref(BDD r) *} DESCR {* Reference counting is done on externaly referenced nodes only and the count for a specific node {\tt r} can and must be decreased using this function to make it possible to reclaim the node in the next garbage collection. *} ALSO {* bdd\_addref *} RETURN {* The BDD node {\tt r}. *} */ BDD bdd_delref(BDD root) { BUDDY_PROLOGUE; ADD_ARG1(T_BDD,root); if (root < 2 || !bddrunning) RETURN_BDD(root); if (root >= bddnodesize) RETURN_BDD(bdd_error(BDD_ILLBDD)); if (LOW(root) == INVALID_BDD) RETURN_BDD(bdd_error(BDD_ILLBDD)); /* if the following line is present, fails there much earlier */ if (!HASREF(root)) bdd_error(BDD_BREAK); /* distinctive */ DECREF(root); if(!HASREF(root)) trace_del_bdd(T_BDD,(void *)root); RETURN_BDD(root); }
bdd cmu_bdd_if(cmu_bdd_manager bddm, bdd f) { if (bdd_check_arguments(1, f)) { BDD_SETUP(f); if (BDD_IS_CONST(f)) { cmu_bdd_warning("cmu_bdd_if: argument is a constant"); return (f); } FIREWALL(bddm); RETURN_BDD(BDD_IF(bddm, f)); } return (f); }
/* NAME {* bdd\_makeset *} SECTION {* kernel *} SHORT {* builds a BDD variable set from an integer array *} PROTO {* BDD bdd_makeset(int *v, int n) *} DESCR {* Reads a set of variable numbers from the integer array {\tt v} which must hold exactly {\tt n} integers and then builds a BDD representing the variable set. The BDD variable set is represented as the conjunction of all the variables in their positive form and may just as well be made that way by the user. The user should keep a reference to the returned BDD instead of building it every time the set is needed. *} ALSO {* bdd\_scanset *} RETURN {* A BDD variable set. *} */ BDD bdd_makeset(int *varset, int varnum) { int v, res=1; BUDDY_PROLOGUE; ADD_ARG2(T_INT_PTR,varset,varnum); ADD_ARG1(T_INT,varnum); for (v=varnum-1 ; v>=0 ; v--) { BDD tmp; bdd_addref(res); tmp = bdd_apply(res, bdd_ithvar(varset[v]), bddop_and); bdd_delref(res); res = tmp; } RETURN_BDD(res); }
/* NAME {* bdd\_false *} SECTION {* kernel *} SHORT {* returns the constant false bdd *} PROTO {* BDD bdd_false(void) *} DESCR {* This function returns the constant false bdd and can freely be used together with the {\tt bddtrue} and {\tt bddfalse} constants. *} RETURN {* The constant false bdd *} ALSO {* bdd\_true, bddtrue, bddfalse *} */ BDD bdd_false(void) { BUDDY_PROLOGUE; RETURN_BDD(0); }
/* NAME {* bdd\_true *} SECTION {* kernel *} SHORT {* returns the constant true bdd *} PROTO {* BDD bdd_true(void) *} DESCR {* This function returns the constant true bdd and can freely be used together with the {\tt bddtrue} and {\tt bddfalse} constants. *} RETURN {* The constant true bdd *} ALSO {* bdd\_false, bddtrue, bddfalse *} */ BDD bdd_true(void) { BUDDY_PROLOGUE; RETURN_BDD(1); }