[buddy] Adding bdd_has_common_assignement
bdd_has_common_assignement determines if two bdds a and b have (at least) one common assignement. That is it will return true iff bdd_and(a, b) != bddfalse. * src/bddx.h: Here * src/bddop.c: Here
This commit is contained in:
parent
31e87aac11
commit
92239d8242
2 changed files with 43 additions and 1 deletions
|
|
@ -3586,6 +3586,44 @@ static double bdd_pathcount_rec(BDD r)
|
|||
return size;
|
||||
}
|
||||
|
||||
/*=== DECIDE IF TWO BDDS SHARE AT LEAST ONE ASSIGNEMENT ================*/
|
||||
|
||||
/*
|
||||
NAME {* bdd\_has\_common\_assignement *}
|
||||
SECTION {* info *}
|
||||
SHORT {* Decide if two bdds share an accepted assignement *}
|
||||
PROTO {* int bdd_has_common_assignement(BDD l, BDD r) *}
|
||||
DESCR {* Returns 1 iff l&r != bddfalse *}
|
||||
RETURN {* 0 or 1 *}
|
||||
*/
|
||||
int bdd_has_common_assignement(BDD left, BDD right)
|
||||
{
|
||||
// If one of them is false -> false
|
||||
if (left == 0 || right == 0)
|
||||
return 0;
|
||||
// If one of them is true and the other is not false
|
||||
// or if they are identical -> true
|
||||
if (left == 1 || right == 1 || left == right)
|
||||
return 1;
|
||||
// Now both of them are not constant
|
||||
|
||||
// Do they share the top variable?
|
||||
int vl = bddlevel2var[LEVEL(left)];
|
||||
int vr = bddlevel2var[LEVEL(right)];
|
||||
|
||||
if (vl < vr)
|
||||
// left has to "catch up"
|
||||
return bdd_has_common_assignement(LOW(left), right)
|
||||
|| bdd_has_common_assignement(HIGH(left), right);
|
||||
else if (vr < vl)
|
||||
// right has to "catch up"
|
||||
return bdd_has_common_assignement(left, LOW(right))
|
||||
|| bdd_has_common_assignement(left, HIGH(right));
|
||||
else
|
||||
// They evolve jointly
|
||||
return bdd_has_common_assignement(LOW(left), LOW(right))
|
||||
|| bdd_has_common_assignement(HIGH(left), HIGH(right));
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Other internal functions
|
||||
|
|
|
|||
|
|
@ -389,7 +389,7 @@ BUDDY_API int bdd_nodecount(BDD);
|
|||
BUDDY_API int bdd_anodecount(BDD *, int);
|
||||
BUDDY_API int* bdd_varprofile(BDD);
|
||||
BUDDY_API double bdd_pathcount(BDD);
|
||||
|
||||
BUDDY_API int bdd_has_common_assignement(BDD, BDD);
|
||||
|
||||
/* In file "bddio.c" */
|
||||
|
||||
|
|
@ -646,6 +646,7 @@ protected:
|
|||
friend int bdd_anodecountpp(const bdd *, int);
|
||||
friend int* bdd_varprofile(const bdd &);
|
||||
friend double bdd_pathcount(const bdd &);
|
||||
friend int bdd_has_common_assignement(const bdd&, const bdd&);
|
||||
|
||||
friend void bdd_fprinttable(FILE *, const bdd &);
|
||||
friend void bdd_printtable(const bdd &);
|
||||
|
|
@ -897,6 +898,9 @@ inline int* bdd_varprofile(const bdd &r)
|
|||
inline double bdd_pathcount(const bdd &r)
|
||||
{ return bdd_pathcount(r.root); }
|
||||
|
||||
inline int bdd_has_common_assignement(const bdd &l, const bdd &r)
|
||||
{ return bdd_has_common_assignement(l.root, r.root); }
|
||||
|
||||
|
||||
/* I/O extensions */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue