本文整理汇总了C++中cuddE函数的典型用法代码示例。如果您正苦于以下问题:C++ cuddE函数的具体用法?C++ cuddE怎么用?C++ cuddE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cuddE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cuddAddComposeRecur
/**Function********************************************************************
Synopsis [Performs the recursive step of Cudd_addCompose.]
Description [Performs the recursive step of Cudd_addCompose.
Returns the composed BDD if successful; NULL otherwise.]
SideEffects [None]
SeeAlso [Cudd_addCompose]
******************************************************************************/
DdNode *
cuddAddComposeRecur(
DdManager * dd,
DdNode * f,
DdNode * g,
DdNode * proj)
{
DdNode *f1, *f0, *g1, *g0, *r, *t, *e;
unsigned int v, topf, topg, topindex;
statLine(dd);
v = dd->perm[proj->index];
topf = cuddI(dd,f->index);
/* Terminal case. Subsumes the test for constant f. */
if (topf > v) return(f);
/* Check cache. */
r = cuddCacheLookup(dd,DD_ADD_COMPOSE_RECUR_TAG,f,g,proj);
if (r != NULL) {
return(r);
}
if (topf == v) {
/* Compose. */
f1 = cuddT(f);
f0 = cuddE(f);
r = cuddAddIteRecur(dd, g, f1, f0);
if (r == NULL) return(NULL);
} else {
/* Compute cofactors of f and g. Remember the index of the top
** variable.
*/
topg = cuddI(dd,g->index);
if (topf > topg) {
topindex = g->index;
f1 = f0 = f;
} else {
topindex = f->index;
f1 = cuddT(f);
f0 = cuddE(f);
}
if (topg > topf) {
g1 = g0 = g;
} else {
g1 = cuddT(g);
g0 = cuddE(g);
}
/* Recursive step. */
t = cuddAddComposeRecur(dd, f1, g1, proj);
if (t == NULL) return(NULL);
cuddRef(t);
e = cuddAddComposeRecur(dd, f0, g0, proj);
if (e == NULL) {
Cudd_RecursiveDeref(dd, t);
return(NULL);
}
cuddRef(e);
if (t == e) {
r = t;
} else {
r = cuddUniqueInter(dd, (int) topindex, t, e);
if (r == NULL) {
Cudd_RecursiveDeref(dd, t);
Cudd_RecursiveDeref(dd, e);
return(NULL);
}
}
cuddDeref(t);
cuddDeref(e);
}
cuddCacheInsert(dd,DD_ADD_COMPOSE_RECUR_TAG,f,g,proj,r);
return(r);
} /* end of cuddAddComposeRecur */
示例2: addMMRecur
//.........这里部分代码省略.........
for (i = 0; i < dd->size; i++) {
if (vars[i]) {
if (dd->perm[i] > topP && (unsigned) dd->perm[i] < topV) {
scale *= 2;
}
}
}
if (scale > 1.0) {
cuddRef(res);
add_scale = cuddUniqueConst(dd,(CUDD_VALUE_TYPE)scale);
if (add_scale == NULL) {
Cudd_RecursiveDeref(dd, res);
return(NULL);
}
cuddRef(add_scale);
scaled = cuddAddApplyRecur(dd,Cudd_addTimes,res,add_scale);
if (scaled == NULL) {
Cudd_RecursiveDeref(dd, add_scale);
Cudd_RecursiveDeref(dd, res);
return(NULL);
}
cuddRef(scaled);
Cudd_RecursiveDeref(dd, add_scale);
Cudd_RecursiveDeref(dd, res);
res = scaled;
cuddDeref(res);
}
return(res);
}
/* compute the cofactors */
if (topV == topA) {
At = cuddT(A);
Ae = cuddE(A);
} else {
At = Ae = A;
}
if (topV == topB) {
Bt = cuddT(B);
Be = cuddE(B);
} else {
Bt = Be = B;
}
t = addMMRecur(dd, At, Bt, (int)topV, vars);
if (t == NULL) return(NULL);
cuddRef(t);
e = addMMRecur(dd, Ae, Be, (int)topV, vars);
if (e == NULL) {
Cudd_RecursiveDeref(dd, t);
return(NULL);
}
cuddRef(e);
index = dd->invperm[topV];
if (vars[index] == 0) {
/* We have split on either the rows of A or the columns
** of B. We just need to connect the two subresults,
** which correspond to two submatrices of the result.
*/
res = (t == e) ? t : cuddUniqueInter(dd,index,t,e);
if (res == NULL) {
Cudd_RecursiveDeref(dd, t);
Cudd_RecursiveDeref(dd, e);
return(NULL);
}
示例3: cuddAddOuterSumRecur
/**Function********************************************************************
Synopsis [Performs the recursive step of Cudd_addOuterSum.]
Description [Performs the recursive step of Cudd_addOuterSum.
Returns a pointer to the result if successful; NULL otherwise.]
SideEffects [None]
SeeAlso []
******************************************************************************/
static DdNode *
cuddAddOuterSumRecur(
DdManager *dd,
DdNode *M,
DdNode *r,
DdNode *c)
{
DdNode *P, *R, *Mt, *Me, *rt, *re, *ct, *ce, *Rt, *Re;
int topM, topc, topr;
int v, index;
statLine(dd);
/* Check special cases. */
if (r == DD_PLUS_INFINITY(dd) || c == DD_PLUS_INFINITY(dd)) return(M);
if (cuddIsConstant(c) && cuddIsConstant(r)) {
R = cuddUniqueConst(dd,Cudd_V(c)+Cudd_V(r));
cuddRef(R);
if (cuddIsConstant(M)) {
if (cuddV(R) <= cuddV(M)) {
cuddDeref(R);
return(R);
} else {
Cudd_RecursiveDeref(dd,R);
return(M);
}
} else {
P = Cudd_addApply(dd,Cudd_addMinimum,R,M);
cuddRef(P);
Cudd_RecursiveDeref(dd,R);
cuddDeref(P);
return(P);
}
}
/* Check the cache. */
R = cuddCacheLookup(dd,DD_ADD_OUT_SUM_TAG,M,r,c);
if (R != NULL) return(R);
topM = cuddI(dd,M->index); topr = cuddI(dd,r->index);
topc = cuddI(dd,c->index);
v = ddMin(topM,ddMin(topr,topc));
/* Compute cofactors. */
if (topM == v) { Mt = cuddT(M); Me = cuddE(M); } else { Mt = Me = M; }
if (topr == v) { rt = cuddT(r); re = cuddE(r); } else { rt = re = r; }
if (topc == v) { ct = cuddT(c); ce = cuddE(c); } else { ct = ce = c; }
/* Recursively solve. */
Rt = cuddAddOuterSumRecur(dd,Mt,rt,ct);
if (Rt == NULL) return(NULL);
cuddRef(Rt);
Re = cuddAddOuterSumRecur(dd,Me,re,ce);
if (Re == NULL) {
Cudd_RecursiveDeref(dd, Rt);
return(NULL);
}
cuddRef(Re);
index = dd->invperm[v];
R = (Rt == Re) ? Rt : cuddUniqueInter(dd,index,Rt,Re);
if (R == NULL) {
Cudd_RecursiveDeref(dd, Rt);
Cudd_RecursiveDeref(dd, Re);
return(NULL);
}
cuddDeref(Rt);
cuddDeref(Re);
/* Store the result in the cache. */
cuddCacheInsert(dd,DD_ADD_OUT_SUM_TAG,M,r,c,R);
return(R);
} /* end of cuddAddOuterSumRecur */
示例4: Cudd_DelayedDerefBdd
/**Function********************************************************************
Synopsis [Decreases the reference count of BDD node n.]
Description [Enqueues node n for later dereferencing. If the queue
is full decreases the reference count of the oldest node N to make
room for n. If N dies, recursively decreases the reference counts of
its children. It is used to dispose of a BDD that is currently not
needed, but may be useful again in the near future. The dereferencing
proper is done as in Cudd_IterDerefBdd.]
SideEffects [None]
SeeAlso [Cudd_RecursiveDeref Cudd_IterDerefBdd]
******************************************************************************/
void
Cudd_DelayedDerefBdd(
DdManager * table,
DdNode * n)
{
DdNode *N;
int ord;
DdNodePtr *stack;
int SP;
unsigned int live = table->keys - table->dead;
if (live > table->peakLiveNodes) {
table->peakLiveNodes = live;
}
n = Cudd_Regular(n);
#ifdef DD_DEBUG
assert(n->ref != 0);
#endif
#ifdef DD_NO_DEATH_ROW
N = n;
#else
if (cuddIsConstant(n) || n->ref > 1) {
#ifdef DD_DEBUG
assert(n->ref != 1 && (!cuddIsConstant(n) || n == DD_ONE(table)));
#endif
cuddSatDec(n->ref);
return;
}
N = table->deathRow[table->nextDead];
if (N != NULL) {
#endif
#ifdef DD_DEBUG
assert(!Cudd_IsComplement(N));
#endif
stack = table->stack;
SP = 1;
do {
#ifdef DD_DEBUG
assert(N->ref != 0);
#endif
if (N->ref == 1) {
N->ref = 0;
table->dead++;
#ifdef DD_STATS
table->nodesDropped++;
#endif
ord = table->perm[N->index];
stack[SP++] = Cudd_Regular(cuddE(N));
table->subtables[ord].dead++;
N = cuddT(N);
} else {
cuddSatDec(N->ref);
N = stack[--SP];
}
} while (SP != 0);
#ifndef DD_NO_DEATH_ROW
}
table->deathRow[table->nextDead] = n;
/* Udate insertion point. */
table->nextDead++;
table->nextDead &= table->deadMask;
#if 0
if (table->nextDead == table->deathRowDepth) {
if (table->deathRowDepth < table->looseUpTo / 2) {
extern void (*MMoutOfMemory)(long);
void (*saveHandler)(long) = MMoutOfMemory;
DdNodePtr *newRow;
MMoutOfMemory = Cudd_OutOfMem;
newRow = REALLOC(DdNodePtr,table->deathRow,2*table->deathRowDepth);
MMoutOfMemory = saveHandler;
if (newRow == NULL) {
table->nextDead = 0;
} else {
int i;
table->memused += table->deathRowDepth;
i = table->deathRowDepth;
table->deathRowDepth <<= 1;
for (; i < table->deathRowDepth; i++) {
newRow[i] = NULL;
//.........这里部分代码省略.........
示例5: zddReorderPostprocess
/**Function********************************************************************
Synopsis [Shrinks almost empty ZDD subtables at the end of reordering
to guarantee that they have a reasonable load factor.]
Description [Shrinks almost empty subtables at the end of reordering to
guarantee that they have a reasonable load factor. However, if there many
nodes are being reclaimed, then no resizing occurs. Returns 1 in case of
success; 0 otherwise.]
SideEffects [None]
******************************************************************************/
static int
zddReorderPostprocess(
DdManager * table)
{
int i, j, posn;
DdNodePtr *nodelist, *oldnodelist;
DdNode *node, *next;
unsigned int slots, oldslots;
extern DD_OOMFP MMoutOfMemory;
DD_OOMFP saveHandler;
#ifdef DD_VERBOSE
(void) fflush(table->out);
#endif
/* If we have very many reclaimed nodes, we do not want to shrink
** the subtables, because this will lead to more garbage
** collections. More garbage collections mean shorter mean life for
** nodes with zero reference count; hence lower probability of finding
** a result in the cache.
*/
if (table->reclaimed > table->allocated * 0.5) return(1);
/* Resize subtables. */
for (i = 0; i < table->sizeZ; i++) {
int shift;
oldslots = table->subtableZ[i].slots;
if (oldslots < table->subtableZ[i].keys * DD_MAX_SUBTABLE_SPARSITY ||
oldslots <= table->initSlots) continue;
oldnodelist = table->subtableZ[i].nodelist;
slots = oldslots >> 1;
saveHandler = MMoutOfMemory;
MMoutOfMemory = Cudd_OutOfMem;
nodelist = ALLOC(DdNodePtr, slots);
MMoutOfMemory = saveHandler;
if (nodelist == NULL) {
return(1);
}
table->subtableZ[i].nodelist = nodelist;
table->subtableZ[i].slots = slots;
table->subtableZ[i].shift++;
table->subtableZ[i].maxKeys = slots * DD_MAX_SUBTABLE_DENSITY;
#ifdef DD_VERBOSE
(void) fprintf(table->err,
"shrunk layer %d (%d keys) from %d to %d slots\n",
i, table->subtableZ[i].keys, oldslots, slots);
#endif
for (j = 0; (unsigned) j < slots; j++) {
nodelist[j] = NULL;
}
shift = table->subtableZ[i].shift;
for (j = 0; (unsigned) j < oldslots; j++) {
node = oldnodelist[j];
while (node != NULL) {
next = node->next;
posn = ddHash(cuddT(node), cuddE(node), shift);
node->next = nodelist[posn];
nodelist[posn] = node;
node = next;
}
}
FREE(oldnodelist);
table->memused += (slots - oldslots) * sizeof(DdNode *);
table->slots += slots - oldslots;
table->minDead = (unsigned) (table->gcFrac * (double) table->slots);
table->cacheSlack = (int) ddMin(table->maxCacheHard,
DD_MAX_CACHE_TO_SLOTS_RATIO*table->slots) -
2 * (int) table->cacheSlots;
}
/* We don't look at the constant subtable, because it is not
** affected by reordering.
*/
return(1);
} /* end of zddReorderPostprocess */
示例6: extraTransferPermuteRecurTime
/**Function********************************************************************
Synopsis [Performs the recursive step of Extra_TransferPermute.]
Description [Performs the recursive step of Extra_TransferPermute.
Returns a pointer to the result if successful; NULL otherwise.]
SideEffects [None]
SeeAlso [extraTransferPermuteTime]
******************************************************************************/
static DdNode *
extraTransferPermuteRecurTime(
DdManager * ddS,
DdManager * ddD,
DdNode * f,
st_table * table,
int * Permute,
int TimeOut )
{
DdNode *ft, *fe, *t, *e, *var, *res;
DdNode *one, *zero;
int index;
int comple = 0;
statLine( ddD );
one = DD_ONE( ddD );
comple = Cudd_IsComplement( f );
/* Trivial cases. */
if ( Cudd_IsConstant( f ) )
return ( Cudd_NotCond( one, comple ) );
/* Make canonical to increase the utilization of the cache. */
f = Cudd_NotCond( f, comple );
/* Now f is a regular pointer to a non-constant node. */
/* Check the cache. */
if ( st_lookup( table, ( char * ) f, ( char ** ) &res ) )
return ( Cudd_NotCond( res, comple ) );
if ( TimeOut && TimeOut < clock() )
return NULL;
/* Recursive step. */
if ( Permute )
index = Permute[f->index];
else
index = f->index;
ft = cuddT( f );
fe = cuddE( f );
t = extraTransferPermuteRecurTime( ddS, ddD, ft, table, Permute, TimeOut );
if ( t == NULL )
{
return ( NULL );
}
cuddRef( t );
e = extraTransferPermuteRecurTime( ddS, ddD, fe, table, Permute, TimeOut );
if ( e == NULL )
{
Cudd_RecursiveDeref( ddD, t );
return ( NULL );
}
cuddRef( e );
zero = Cudd_Not(ddD->one);
var = cuddUniqueInter( ddD, index, one, zero );
if ( var == NULL )
{
Cudd_RecursiveDeref( ddD, t );
Cudd_RecursiveDeref( ddD, e );
return ( NULL );
}
res = cuddBddIteRecur( ddD, var, t, e );
if ( res == NULL )
{
Cudd_RecursiveDeref( ddD, t );
Cudd_RecursiveDeref( ddD, e );
return ( NULL );
}
cuddRef( res );
Cudd_RecursiveDeref( ddD, t );
Cudd_RecursiveDeref( ddD, e );
if ( st_add_direct( table, ( char * ) f, ( char * ) res ) ==
ST_OUT_OF_MEM )
{
Cudd_RecursiveDeref( ddD, res );
return ( NULL );
}
return ( Cudd_NotCond( res, comple ) );
} /* end of extraTransferPermuteRecurTime */
示例7: cuddauxAddConstrainRecur
/**Function********************************************************************
Synopsis [Performs the recursive step of Cuddaux_addConstrain.]
Description [Performs the recursive step of Cuddaux_addConstrain.
Returns a pointer to the result if successful; NULL otherwise.]
SideEffects [None]
SeeAlso [Cuddaux_addConstrain]
******************************************************************************/
DdNode *
cuddauxAddConstrainRecur(
DdManager * dd,
DdNode * f,
DdNode * c)
{
DdNode *Fv, *Fnv, *Cv, *Cnv, *t, *e, *res;
DdNode *one, *zero;
unsigned int topf, topc;
int index;
one = DD_ONE(dd);
zero = Cudd_Not(one);
/* Trivial cases. */
if (c == one) return(f);
if (c == zero){
fprintf(stderr,"CuddauxAddConstrainRecur: warning: false careset\n");
return(DD_BACKGROUND(dd));
}
if (Cudd_IsConstant(f)) return(f);
/* Now f and c are non-constant. */
/* Check the cache. */
res = cuddCacheLookup2(dd, Cuddaux_addConstrain, f, c);
if (res != NULL) {
return(res);
}
/* Recursive step. */
topf = dd->perm[f->index];
topc = dd->perm[Cudd_Regular(c)->index];
if (topf <= topc) {
index = f->index;
Fv = cuddT(f); Fnv = cuddE(f);
} else {
index = Cudd_Regular(c)->index;
Fv = Fnv = f;
}
if (topc <= topf) {
Cv = Cudd_T(c); Cnv = Cudd_E(c);
if (Cudd_IsComplement(c)) {
Cv = Cudd_Not(Cv); Cnv = Cudd_Not(Cnv);
}
} else {
Cv = Cnv = c;
}
if (!Cudd_IsConstant(Cv)) {
t = cuddauxAddConstrainRecur(dd, Fv, Cv);
if (t == NULL)
return(NULL);
}
else if (Cv == one) {
t = Fv;
}
else { /* Cv == zero: return Fnv @ Cnv */
if (Cnv == one) {
res = Fnv;
}
else {
res = cuddauxAddConstrainRecur(dd, Fnv, Cnv);
if (res == NULL)
return(NULL);
}
return(res);
}
cuddRef(t);
if (!Cudd_IsConstant(Cnv)) {
e = cuddauxAddConstrainRecur(dd, Fnv, Cnv);
if (e == NULL) {
Cudd_RecursiveDeref(dd, t);
return(NULL);
}
}
else if (Cnv == one) {
e = Fnv;
}
else { /* Cnv == zero: return Fv @ Cv previously computed */
cuddDeref(t);
return(t);
}
cuddRef(e);
res = (t == e) ? t : cuddUniqueInter(dd, index, t, e);
if (res == NULL) {
//.........这里部分代码省略.........
示例8: Extra_bddSpaceFromFunctionPos
/**Function*************************************************************
Synopsis [Performs the recursive step of Extra_bddSpaceFromFunctionPos().]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
DdNode * extraBddSpaceFromFunctionNeg( DdManager * dd, DdNode * bF )
{
DdNode * bRes, * bFR;
statLine( dd );
bFR = Cudd_Regular(bF);
if ( cuddIsConstant(bFR) )
return b0;
if ( (bRes = cuddCacheLookup1(dd, extraBddSpaceFromFunctionNeg, bF)) )
return bRes;
else
{
DdNode * bF0, * bF1;
DdNode * bPos0, * bPos1;
DdNode * bNeg0, * bNeg1;
DdNode * bRes0, * bRes1;
if ( bFR != bF ) // bF is complemented
{
bF0 = Cudd_Not( cuddE(bFR) );
bF1 = Cudd_Not( cuddT(bFR) );
}
else
{
bF0 = cuddE(bFR);
bF1 = cuddT(bFR);
}
bPos0 = extraBddSpaceFromFunctionNeg( dd, bF0 );
if ( bPos0 == NULL )
return NULL;
cuddRef( bPos0 );
bPos1 = extraBddSpaceFromFunctionNeg( dd, bF1 );
if ( bPos1 == NULL )
{
Cudd_RecursiveDeref( dd, bPos0 );
return NULL;
}
cuddRef( bPos1 );
bRes0 = cuddBddAndRecur( dd, bPos0, bPos1 );
if ( bRes0 == NULL )
{
Cudd_RecursiveDeref( dd, bPos0 );
Cudd_RecursiveDeref( dd, bPos1 );
return NULL;
}
cuddRef( bRes0 );
Cudd_RecursiveDeref( dd, bPos0 );
Cudd_RecursiveDeref( dd, bPos1 );
bNeg0 = extraBddSpaceFromFunctionPos( dd, bF0 );
if ( bNeg0 == NULL )
{
Cudd_RecursiveDeref( dd, bRes0 );
return NULL;
}
cuddRef( bNeg0 );
bNeg1 = extraBddSpaceFromFunctionPos( dd, bF1 );
if ( bNeg1 == NULL )
{
Cudd_RecursiveDeref( dd, bRes0 );
Cudd_RecursiveDeref( dd, bNeg0 );
return NULL;
}
cuddRef( bNeg1 );
bRes1 = cuddBddAndRecur( dd, bNeg0, bNeg1 );
if ( bRes1 == NULL )
{
Cudd_RecursiveDeref( dd, bRes0 );
Cudd_RecursiveDeref( dd, bNeg0 );
Cudd_RecursiveDeref( dd, bNeg1 );
return NULL;
}
cuddRef( bRes1 );
Cudd_RecursiveDeref( dd, bNeg0 );
Cudd_RecursiveDeref( dd, bNeg1 );
// consider the case when Res0 and Res1 are the same node
if ( bRes0 == bRes1 )
bRes = bRes1;
// consider the case when Res1 is complemented
//.........这里部分代码省略.........
示例9: cuddAddApplyRecur
/**Function********************************************************************
Synopsis [Performs the recursive step of Cudd_addApply.]
Description [Performs the recursive step of Cudd_addApply. Returns a
pointer to the result if successful; NULL otherwise.]
SideEffects [None]
SeeAlso []
******************************************************************************/
DdNode *
cuddAddApplyRecur(
DdManager * dd,
DdNode * (*op)(DdManager *, DdNode **, DdNode **),
DdNode * f,
DdNode * g)
{
DdNode *res,
*fv, *fvn, *gv, *gvn,
*T, *E;
unsigned int ford, gord;
unsigned int index;
DdNode *(*cacheOp)(DdManager *, DdNode *, DdNode *);
/* Check terminal cases. Op may swap f and g to increase the
* cache hit ratio.
*/
res = (*op)(dd,&f,&g);
if (res != NULL) return(res);
/* Check cache */
cacheOp = (DdNode *(*)(DdManager *, DdNode *, DdNode *)) op;
res = cuddCacheLookup2(dd,cacheOp,f,g);
if (res != NULL) return(res);
/* Recursive Step */
ford = cuddI(dd,f->index);
gord = cuddI(dd,g->index);
if (ford <= gord) {
index = f->index;
fv = cuddT(f);
fvn = cuddE(f);
} else {
index = g->index;
fv = fvn = f;
}
if (gord <= ford) {
gv = cuddT(g);
gvn = cuddE(g);
} else {
gv = gvn = g;
}
T = cuddAddApplyRecur(dd,op,fv,gv);
if (T == NULL) return(NULL);
cuddRef(T);
E = cuddAddApplyRecur(dd,op,fvn,gvn);
if (E == NULL) {
Cudd_RecursiveDeref(dd,T);
return(NULL);
}
cuddRef(E);
res = (T == E) ? T : cuddUniqueInter(dd,(int)index,T,E);
if (res == NULL) {
Cudd_RecursiveDeref(dd, T);
Cudd_RecursiveDeref(dd, E);
return(NULL);
}
cuddDeref(T);
cuddDeref(E);
/* Store result */
cuddCacheInsert2(dd,cacheOp,f,g,res);
return(res);
} /* end of cuddAddApplyRecur */
示例10: extraBddSpaceFromFunction
/**Function********************************************************************
Synopsis [Performs the recursive steps of Extra_bddSpaceFromFunction.]
Description []
SideEffects []
SeeAlso []
******************************************************************************/
DdNode * extraBddSpaceFromFunction( DdManager * dd, DdNode * bF, DdNode * bG )
{
DdNode * bRes;
DdNode * bFR, * bGR;
bFR = Cudd_Regular( bF );
bGR = Cudd_Regular( bG );
if ( cuddIsConstant(bFR) )
{
if ( bF == bG )
return b1;
else
return b0;
}
if ( cuddIsConstant(bGR) )
return b0;
// both bFunc and bCore are not constants
// the operation is commutative - normalize the problem
if ( (unsigned)(ABC_PTRUINT_T)bF > (unsigned)(ABC_PTRUINT_T)bG )
return extraBddSpaceFromFunction(dd, bG, bF);
if ( (bRes = cuddCacheLookup2(dd, extraBddSpaceFromFunction, bF, bG)) )
return bRes;
else
{
DdNode * bF0, * bF1;
DdNode * bG0, * bG1;
DdNode * bTemp1, * bTemp2;
DdNode * bRes0, * bRes1;
int LevelF, LevelG;
int index;
LevelF = dd->perm[bFR->index];
LevelG = dd->perm[bGR->index];
if ( LevelF <= LevelG )
{
index = dd->invperm[LevelF];
if ( bFR != bF )
{
bF0 = Cudd_Not( cuddE(bFR) );
bF1 = Cudd_Not( cuddT(bFR) );
}
else
{
bF0 = cuddE(bFR);
bF1 = cuddT(bFR);
}
}
else
{
index = dd->invperm[LevelG];
bF0 = bF1 = bF;
}
if ( LevelG <= LevelF )
{
if ( bGR != bG )
{
bG0 = Cudd_Not( cuddE(bGR) );
bG1 = Cudd_Not( cuddT(bGR) );
}
else
{
bG0 = cuddE(bGR);
bG1 = cuddT(bGR);
}
}
else
bG0 = bG1 = bG;
bTemp1 = extraBddSpaceFromFunction( dd, bF0, bG0 );
if ( bTemp1 == NULL )
return NULL;
cuddRef( bTemp1 );
bTemp2 = extraBddSpaceFromFunction( dd, bF1, bG1 );
if ( bTemp2 == NULL )
{
Cudd_RecursiveDeref( dd, bTemp1 );
return NULL;
}
cuddRef( bTemp2 );
bRes0 = cuddBddAndRecur( dd, bTemp1, bTemp2 );
if ( bRes0 == NULL )
{
//.........这里部分代码省略.........
示例11: Extra_bddSpaceEquationsNev
/**Function*************************************************************
Synopsis [Performs the recursive step of Extra_bddSpaceEquationsNev().]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
DdNode * extraBddSpaceEquationsNeg( DdManager * dd, DdNode * bF )
{
DdNode * zRes;
statLine( dd );
if ( bF == b0 )
return z1;
if ( bF == b1 )
return z0;
if ( (zRes = cuddCacheLookup1Zdd(dd, extraBddSpaceEquationsNeg, bF)) )
return zRes;
else
{
DdNode * bFR, * bF0, * bF1;
DdNode * zPos0, * zPos1, * zNeg1;
DdNode * zRes, * zRes0, * zRes1;
bFR = Cudd_Regular(bF);
if ( bFR != bF ) // bF is complemented
{
bF0 = Cudd_Not( cuddE(bFR) );
bF1 = Cudd_Not( cuddT(bFR) );
}
else
{
bF0 = cuddE(bFR);
bF1 = cuddT(bFR);
}
if ( bF0 == b0 )
{
zRes = extraBddSpaceEquationsNeg( dd, bF1 );
if ( zRes == NULL )
return NULL;
}
else if ( bF1 == b0 )
{
zRes0 = extraBddSpaceEquationsNeg( dd, bF0 );
if ( zRes0 == NULL )
return NULL;
cuddRef( zRes0 );
// add the current element to the set
zRes = cuddZddGetNode( dd, 2*bFR->index, z1, zRes0 );
if ( zRes == NULL )
{
Cudd_RecursiveDerefZdd(dd, zRes0);
return NULL;
}
cuddDeref( zRes0 );
}
else
{
zPos0 = extraBddSpaceEquationsNeg( dd, bF0 );
if ( zPos0 == NULL )
return NULL;
cuddRef( zPos0 );
zPos1 = extraBddSpaceEquationsNeg( dd, bF1 );
if ( zPos1 == NULL )
{
Cudd_RecursiveDerefZdd(dd, zPos0);
return NULL;
}
cuddRef( zPos1 );
zNeg1 = extraBddSpaceEquationsPos( dd, bF1 );
if ( zNeg1 == NULL )
{
Cudd_RecursiveDerefZdd(dd, zPos0);
Cudd_RecursiveDerefZdd(dd, zPos1);
return NULL;
}
cuddRef( zNeg1 );
zRes0 = cuddZddIntersect( dd, zPos0, zPos1 );
if ( zRes0 == NULL )
{
Cudd_RecursiveDerefZdd(dd, zNeg1);
Cudd_RecursiveDerefZdd(dd, zPos0);
Cudd_RecursiveDerefZdd(dd, zPos1);
return NULL;
}
cuddRef( zRes0 );
zRes1 = cuddZddIntersect( dd, zPos0, zNeg1 );
if ( zRes1 == NULL )
//.........这里部分代码省略.........
示例12: zp2
/**Function********************************************************************
Synopsis [Performs the recursive step of cuddZddP.]
Description [Performs the recursive step of cuddZddP. Returns 1 in
case of success; 0 otherwise.]
SideEffects [None]
SeeAlso []
******************************************************************************/
static int
zp2(
DdManager * zdd,
DdNode * f,
st_table * t)
{
DdNode *n;
int T, E;
DdNode *base = DD_ONE(zdd);
if (f == NULL)
return(0);
if (Cudd_IsConstant(f)) {
(void)fprintf(zdd->out, "ID = %d\n", (f == base));
return(1);
}
if (st_is_member(t, (char *)f) == 1)
return(1);
if (st_insert(t, (char *) f, NULL) == ST_OUT_OF_MEM)
return(0);
#if SIZEOF_VOID_P == 8
(void) fprintf(zdd->out, "ID = 0x%lx\tindex = %d\tr = %d\t",
(unsigned long)f / (unsigned long) sizeof(DdNode), f->index, f->ref);
#else
(void) fprintf(zdd->out, "ID = 0x%x\tindex = %d\tr = %d\t",
(unsigned)f / (unsigned) sizeof(DdNode), f->index, f->ref);
#endif
n = cuddT(f);
if (Cudd_IsConstant(n)) {
(void) fprintf(zdd->out, "T = %d\t\t", (n == base));
T = 1;
} else {
#if SIZEOF_VOID_P == 8
(void) fprintf(zdd->out, "T = 0x%lx\t", (unsigned long) n /
(unsigned long) sizeof(DdNode));
#else
(void) fprintf(zdd->out, "T = 0x%x\t", (unsigned) n / (unsigned) sizeof(DdNode));
#endif
T = 0;
}
n = cuddE(f);
if (Cudd_IsConstant(n)) {
(void) fprintf(zdd->out, "E = %d\n", (n == base));
E = 1;
} else {
#if SIZEOF_VOID_P == 8
(void) fprintf(zdd->out, "E = 0x%lx\n", (unsigned long) n /
(unsigned long) sizeof(DdNode));
#else
(void) fprintf(zdd->out, "E = 0x%x\n", (unsigned) n / (unsigned) sizeof(DdNode));
#endif
E = 0;
}
if (E == 0)
if (zp2(zdd, cuddE(f), t) == 0) return(0);
if (T == 0)
if (zp2(zdd, cuddT(f), t) == 0) return(0);
return(1);
} /* end of zp2 */
示例13: otherwise
//.........这里部分代码省略.........
retval = fprintf(fp,"\"%lx\";\n", (mask & (long) scan) / sizeof(DdNode));
if (retval == EOF) goto failure;
}
scan = scan->next;
}
}
retval = fprintf(fp,"}\n");
if (retval == EOF) goto failure;
}
}
/* All constants have the same rank. */
retval = fprintf(fp,
"{ rank = same; \"CONST NODES\";\n{ node [shape = box]; ");
if (retval == EOF) goto failure;
nodelist = dd->constants.nodelist;
slots = dd->constants.slots;
for (j = 0; j < slots; j++) {
scan = nodelist[j];
while (scan != NULL) {
if (st_is_member(visited,(char *) scan)) {
retval = fprintf(fp,"\"%lx\";\n", (mask & (long) scan) / sizeof(DdNode));
if (retval == EOF) goto failure;
}
scan = scan->next;
}
}
retval = fprintf(fp,"}\n}\n");
if (retval == EOF) goto failure;
/* Write edge info. */
/* Edges from the output nodes. */
for (i = 0; i < n; i++) {
if (onames == NULL) {
retval = fprintf(fp,"\"F%d\"", i);
} else {
retval = fprintf(fp,"\" %s \"", onames[i]);
}
if (retval == EOF) goto failure;
retval = fprintf(fp," -> \"%lx\" [style = solid];\n",
(mask & (long) f[i]) / sizeof(DdNode));
if (retval == EOF) goto failure;
}
/* Edges from internal nodes. */
for (i = 0; i < nvars; i++) {
if (sorted[dd->invpermZ[i]]) {
nodelist = dd->subtableZ[i].nodelist;
slots = dd->subtableZ[i].slots;
for (j = 0; j < slots; j++) {
scan = nodelist[j];
while (scan != NULL) {
if (st_is_member(visited,(char *) scan)) {
retval = fprintf(fp,
"\"%lx\" -> \"%lx\";\n",
(mask & (long) scan) / sizeof(DdNode),
(mask & (long) cuddT(scan)) / sizeof(DdNode));
if (retval == EOF) goto failure;
retval = fprintf(fp,
"\"%lx\" -> \"%lx\" [style = dashed];\n",
(mask & (long) scan) / sizeof(DdNode),
(mask & (long) cuddE(scan)) / sizeof(DdNode));
if (retval == EOF) goto failure;
}
scan = scan->next;
}
}
}
}
/* Write constant labels. */
nodelist = dd->constants.nodelist;
slots = dd->constants.slots;
for (j = 0; j < slots; j++) {
scan = nodelist[j];
while (scan != NULL) {
if (st_is_member(visited,(char *) scan)) {
retval = fprintf(fp,"\"%lx\" [label = \"%g\"];\n",
(mask & (long) scan) / sizeof(DdNode), cuddV(scan));
if (retval == EOF) goto failure;
}
scan = scan->next;
}
}
/* Write trailer and return. */
retval = fprintf(fp,"}\n");
if (retval == EOF) goto failure;
st_free_table(visited);
FREE(sorted);
return(1);
failure:
if (sorted != NULL) FREE(sorted);
if (support != NULL) Cudd_RecursiveDeref(dd,support);
if (visited != NULL) st_free_table(visited);
return(0);
} /* end of Cudd_zddDumpBlif */
示例14: cuddBddAndRecurTime
/**Function********************************************************************
Synopsis [Implements the recursive step of Cudd_bddAnd.]
Description [Implements the recursive step of Cudd_bddAnd by taking
the conjunction of two BDDs. Returns a pointer to the result is
successful; NULL otherwise.]
SideEffects [None]
SeeAlso [Cudd_bddAnd]
******************************************************************************/
DdNode *
cuddBddAndRecurTime(
DdManager * manager,
DdNode * f,
DdNode * g,
int * pRecCalls,
int TimeOut)
{
DdNode *F, *fv, *fnv, *G, *gv, *gnv;
DdNode *one, *r, *t, *e;
unsigned int topf, topg, index;
statLine(manager);
one = DD_ONE(manager);
/* Terminal cases. */
F = Cudd_Regular(f);
G = Cudd_Regular(g);
if (F == G) {
if (f == g) return(f);
else return(Cudd_Not(one));
}
if (F == one) {
if (f == one) return(g);
else return(f);
}
if (G == one) {
if (g == one) return(f);
else return(g);
}
/* At this point f and g are not constant. */
if (f > g) { /* Try to increase cache efficiency. */
DdNode *tmp = f;
f = g;
g = tmp;
F = Cudd_Regular(f);
G = Cudd_Regular(g);
}
/* Check cache. */
if (F->ref != 1 || G->ref != 1) {
r = cuddCacheLookup2(manager, Cudd_bddAnd, f, g);
if (r != NULL) return(r);
}
// if ( TimeOut && ((*pRecCalls)++ % CHECK_FACTOR) == 0 && TimeOut < clock() )
if ( TimeOut && TimeOut < clock() )
return NULL;
/* Here we can skip the use of cuddI, because the operands are known
** to be non-constant.
*/
topf = manager->perm[F->index];
topg = manager->perm[G->index];
/* Compute cofactors. */
if (topf <= topg) {
index = F->index;
fv = cuddT(F);
fnv = cuddE(F);
if (Cudd_IsComplement(f)) {
fv = Cudd_Not(fv);
fnv = Cudd_Not(fnv);
}
} else {
index = G->index;
fv = fnv = f;
}
if (topg <= topf) {
gv = cuddT(G);
gnv = cuddE(G);
if (Cudd_IsComplement(g)) {
gv = Cudd_Not(gv);
gnv = Cudd_Not(gnv);
}
} else {
gv = gnv = g;
}
t = cuddBddAndRecurTime(manager, fv, gv, pRecCalls, TimeOut);
if (t == NULL) return(NULL);
cuddRef(t);
e = cuddBddAndRecurTime(manager, fnv, gnv, pRecCalls, TimeOut);
if (e == NULL) {
//.........这里部分代码省略.........
示例15: cuddBddXorRecur
/**Function********************************************************************
Synopsis [Implements the recursive step of Cudd_bddXor.]
Description [Implements the recursive step of Cudd_bddXor by taking
the exclusive OR of two BDDs. Returns a pointer to the result is
successful; NULL otherwise.]
SideEffects [None]
SeeAlso [Cudd_bddXor]
******************************************************************************/
DdNode *
cuddBddXorRecur(
DdManager * manager,
DdNode * f,
DdNode * g)
{
DdNode *fv, *fnv, *G, *gv, *gnv;
DdNode *one, *zero, *r, *t, *e;
unsigned int topf, topg, index;
statLine(manager);
one = DD_ONE(manager);
zero = Cudd_Not(one);
/* Terminal cases. */
if (f == g) return(zero);
if (f == Cudd_Not(g)) return(one);
if (f > g) { /* Try to increase cache efficiency and simplify tests. */
DdNode *tmp = f;
f = g;
g = tmp;
}
if (g == zero) return(f);
if (g == one) return(Cudd_Not(f));
if (Cudd_IsComplement(f)) {
f = Cudd_Not(f);
g = Cudd_Not(g);
}
/* Now the first argument is regular. */
if (f == one) return(Cudd_Not(g));
/* At this point f and g are not constant. */
/* Check cache. */
r = cuddCacheLookup2(manager, Cudd_bddXor, f, g);
if (r != NULL) return(r);
/* Here we can skip the use of cuddI, because the operands are known
** to be non-constant.
*/
topf = manager->perm[f->index];
G = Cudd_Regular(g);
topg = manager->perm[G->index];
/* Compute cofactors. */
if (topf <= topg) {
index = f->index;
fv = cuddT(f);
fnv = cuddE(f);
} else {
index = G->index;
fv = fnv = f;
}
if (topg <= topf) {
gv = cuddT(G);
gnv = cuddE(G);
if (Cudd_IsComplement(g)) {
gv = Cudd_Not(gv);
gnv = Cudd_Not(gnv);
}
} else {
gv = gnv = g;
}
t = cuddBddXorRecur(manager, fv, gv);
if (t == NULL) return(NULL);
cuddRef(t);
e = cuddBddXorRecur(manager, fnv, gnv);
if (e == NULL) {
Cudd_IterDerefBdd(manager, t);
return(NULL);
}
cuddRef(e);
if (t == e) {
r = t;
} else {
if (Cudd_IsComplement(t)) {
r = cuddUniqueInter(manager,(int)index,Cudd_Not(t),Cudd_Not(e));
if (r == NULL) {
Cudd_IterDerefBdd(manager, t);
Cudd_IterDerefBdd(manager, e);
return(NULL);
}
r = Cudd_Not(r);
//.........这里部分代码省略.........