⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cuddsat.c

📁 主要进行大规模的电路综合
💻 C
📖 第 1 页 / 共 3 页
字号:
  Synopsis    [Determines whether a BDD is positive unate in a  variable.]  Description [Determines whether the function represented by BDD f is  positive unate (monotonic decreasing) in variable i. It is based on  Cudd_Decreasing and the fact that f is monotonic increasing in i if  and only if its complement is monotonic decreasing in i.]  SideEffects [None]  SeeAlso     [Cudd_Decreasing]******************************************************************************/DdNode *Cudd_Increasing(  DdManager * dd,  DdNode * f,  int  i){    return(Cudd_Decreasing(dd,Cudd_Not(f),i));} /* end of Cudd_Increasing *//**Function********************************************************************  Synopsis    [Tells whether F and G are identical wherever D is 0.]  Description [Tells whether F and G are identical wherever D is 0.  F  and G are either two ADDs or two BDDs.  D is either a 0-1 ADD or a  BDD.  The function returns 1 if F and G are equivalent, and 0  otherwise.  No new nodes are created.]  SideEffects [None]  SeeAlso     [Cudd_bddLeqUnless]******************************************************************************/intCudd_EquivDC(  DdManager * dd,  DdNode * F,  DdNode * G,  DdNode * D){    DdNode *tmp, *One, *Gr, *Dr;    DdNode *Fv, *Fvn, *Gv, *Gvn, *Dv, *Dvn;    int res;    unsigned int flevel, glevel, dlevel, top;    One = DD_ONE(dd);    statLine(dd);    /* Check terminal cases. */    if (D == One || F == G) return(1);    if (D == Cudd_Not(One) || D == DD_ZERO(dd) || F == Cudd_Not(G)) return(0);    /* From now on, D is non-constant. */    /* Normalize call to increase cache efficiency. */    if (F > G) {	tmp = F;	F = G;	G = tmp;    }    if (Cudd_IsComplement(F)) {	F = Cudd_Not(F);	G = Cudd_Not(G);    }    /* From now on, F is regular. */    /* Check cache. */    tmp = cuddCacheLookup(dd,DD_EQUIV_DC_TAG,F,G,D);    if (tmp != NULL) return(tmp == One);    /* Find splitting variable. */    flevel = cuddI(dd,F->index);    Gr = Cudd_Regular(G);    glevel = cuddI(dd,Gr->index);    top = ddMin(flevel,glevel);    Dr = Cudd_Regular(D);    dlevel = dd->perm[Dr->index];    top = ddMin(top,dlevel);    /* Compute cofactors. */    if (top == flevel) {	Fv = cuddT(F);	Fvn = cuddE(F);    } else {	Fv = Fvn = F;    }    if (top == glevel) {	Gv = cuddT(Gr);	Gvn = cuddE(Gr);	if (G != Gr) {	    Gv = Cudd_Not(Gv);	    Gvn = Cudd_Not(Gvn);	}    } else {	Gv = Gvn = G;    }    if (top == dlevel) {	Dv = cuddT(Dr);	Dvn = cuddE(Dr);	if (D != Dr) {	    Dv = Cudd_Not(Dv);	    Dvn = Cudd_Not(Dvn);	}    } else {	Dv = Dvn = D;    }    /* Solve recursively. */    res = Cudd_EquivDC(dd,Fv,Gv,Dv);    if (res != 0) {	res = Cudd_EquivDC(dd,Fvn,Gvn,Dvn);    }    cuddCacheInsert(dd,DD_EQUIV_DC_TAG,F,G,D,(res) ? One : Cudd_Not(One));    return(res);} /* end of Cudd_EquivDC *//**Function********************************************************************  Synopsis    [Tells whether f is less than of equal to G unless D is 1.]  Description [Tells whether f is less than of equal to G unless D is  1.  f, g, and D are BDDs.  The function returns 1 if f is less than  of equal to G, and 0 otherwise.  No new nodes are created.]  SideEffects [None]  SeeAlso     [Cudd_EquivDC Cudd_bddLeq Cudd_bddIteConstant]******************************************************************************/intCudd_bddLeqUnless(  DdManager *dd,  DdNode *f,  DdNode *g,  DdNode *D){    DdNode *tmp, *One, *F, *G;    DdNode *Ft, *Fe, *Gt, *Ge, *Dt, *De;    int res;    unsigned int flevel, glevel, dlevel, top;    statLine(dd);    One = DD_ONE(dd);    /* Check terminal cases. */    if (f == g || g == One || f == Cudd_Not(One) || D == One ||	D == f || D == Cudd_Not(g)) return(1);    /* Check for two-operand cases. */    if (D == Cudd_Not(One) || D == g || D == Cudd_Not(f))	return(Cudd_bddLeq(dd,f,g));    if (g == Cudd_Not(One) || g == Cudd_Not(f)) return(Cudd_bddLeq(dd,f,D));    if (f == One) return(Cudd_bddLeq(dd,Cudd_Not(g),D));    /* From now on, f, g, and D are non-constant, distinct, and    ** non-complementary. */    /* Normalize call to increase cache efficiency.  We rely on the    ** fact that f <= g unless D is equivalent to not(g) <= not(f)    ** unless D and to f <= D unless g.  We make sure that D is    ** regular, and that at most one of f and g is complemented.  We also    ** ensure that when two operands can be swapped, the one with the    ** lowest address comes first. */    if (Cudd_IsComplement(D)) {	if (Cudd_IsComplement(g)) {	    /* Special case: if f is regular and g is complemented,	    ** f(1,...,1) = 1 > 0 = g(1,...,1).  If D(1,...,1) = 0, return 0.	    */	    if (!Cudd_IsComplement(f)) return(0);	    /* !g <= D unless !f  or  !D <= g unless !f */	    tmp = D;	    D = Cudd_Not(f);	    if (g < tmp) {		f = Cudd_Not(g);		g = tmp;	    } else {		f = Cudd_Not(tmp);	    }	} else {	    if (Cudd_IsComplement(f)) {		/* !D <= !f unless g  or  !D <= g unless !f */		tmp = f;		f = Cudd_Not(D);		if (tmp < g) {		    D = g;		    g = Cudd_Not(tmp);		} else {		    D = Cudd_Not(tmp);		}	    } else {		/* f <= D unless g  or  !D <= !f unless g */		tmp = D;		D = g;		if (tmp < f) {		    g = Cudd_Not(f);		    f = Cudd_Not(tmp);		} else {		    g = tmp;		}	    }	}    } else {	if (Cudd_IsComplement(g)) {	    if (Cudd_IsComplement(f)) {		/* !g <= !f unless D  or  !g <= D unless !f */		tmp = f;		f = Cudd_Not(g);		if (D < tmp) {		    g = D;		    D = Cudd_Not(tmp);		} else {		    g = Cudd_Not(tmp);		}	    } else {		/* f <= g unless D  or  !g <= !f unless D */		if (g < f) {		    tmp = g;		    g = Cudd_Not(f);		    f = Cudd_Not(tmp);		}	    }	} else {	    /* f <= g unless D  or  f <= D unless g */	    if (D < g) {		tmp = D;		D = g;		g = tmp;	    }	}    }    /* From now on, D is regular. */    /* Check cache. */    tmp = cuddCacheLookup(dd,DD_BDD_LEQ_UNLESS_TAG,f,g,D);    if (tmp != NULL) return(tmp == One);    /* Find splitting variable. */    F = Cudd_Regular(f);    flevel = dd->perm[F->index];    G = Cudd_Regular(g);    glevel = dd->perm[G->index];    top = ddMin(flevel,glevel);    dlevel = dd->perm[D->index];    top = ddMin(top,dlevel);    /* Compute cofactors. */    if (top == flevel) {	Ft = cuddT(F);	Fe = cuddE(F);	if (F != f) {	    Ft = Cudd_Not(Ft);	    Fe = Cudd_Not(Fe);	}    } else {	Ft = Fe = f;    }    if (top == glevel) {	Gt = cuddT(G);	Ge = cuddE(G);	if (G != g) {	    Gt = Cudd_Not(Gt);	    Ge = Cudd_Not(Ge);	}    } else {	Gt = Ge = g;    }    if (top == dlevel) {	Dt = cuddT(D);	De = cuddE(D);    } else {	Dt = De = D;    }    /* Solve recursively. */    res = Cudd_bddLeqUnless(dd,Ft,Gt,Dt);    if (res != 0) {	res = Cudd_bddLeqUnless(dd,Fe,Ge,De);    }    cuddCacheInsert(dd,DD_BDD_LEQ_UNLESS_TAG,f,g,D,Cudd_NotCond(One,!res));    return(res);} /* end of Cudd_bddLeqUnless *//**Function********************************************************************  Synopsis    [Compares two ADDs for equality within tolerance.]  Description [Compares two ADDs for equality within tolerance. Two  ADDs are reported to be equal if the maximum difference between them  (the sup norm of their difference) is less than or equal to the  tolerance parameter. Returns 1 if the two ADDs are equal (within  tolerance); 0 otherwise. If parameter <code>pr</code> is positive  the first failure is reported to the standard output.]  SideEffects [None]  SeeAlso     []******************************************************************************/intCudd_EqualSupNorm(  DdManager * dd /* manager */,  DdNode * f /* first ADD */,  DdNode * g /* second ADD */,  CUDD_VALUE_TYPE  tolerance /* maximum allowed difference */,  int  pr /* verbosity level */){    DdNode *fv, *fvn, *gv, *gvn, *r;    unsigned int topf, topg;    statLine(dd);    /* Check terminal cases. */    if (f == g) return(1);    if (Cudd_IsConstant(f) && Cudd_IsConstant(g)) {	if (ddEqualVal(cuddV(f),cuddV(g),tolerance)) {	    return(1);	} else {	    if (pr>0) {		(void) fprintf(dd->out,"Offending nodes:\n");#if SIZEOF_VOID_P == 8		(void) fprintf(dd->out,			       "f: address = %lx\t value = %40.30f\n",			       (unsigned long) f, cuddV(f));		(void) fprintf(dd->out,			       "g: address = %lx\t value = %40.30f\n",			       (unsigned long) g, cuddV(g));#else		(void) fprintf(dd->out,			       "f: address = %x\t value = %40.30f\n",			       (unsigned) f, cuddV(f));		(void) fprintf(dd->out,			       "g: address = %x\t value = %40.30f\n",			       (unsigned) g, cuddV(g));#endif	    }	    return(0);	}    }    /* We only insert the result in the cache if the comparison is    ** successful. Therefore, if we hit we return 1. */    r = cuddCacheLookup2(dd,(DdNode * (*)(DdManager *, DdNode *, DdNode *))Cudd_EqualSupNorm,f,g);    if (r != NULL) {	return(1);    }    /* Compute the cofactors and solve the recursive subproblems. */    topf = cuddI(dd,f->index);    topg = cuddI(dd,g->index);    if (topf <= topg) {fv = cuddT(f); fvn = cuddE(f);} else {fv = fvn = f;}    if (topg <= topf) {gv = cuddT(g); gvn = cuddE(g);} else {gv = gvn = g;}    if (!Cudd_EqualSupNorm(dd,fv,gv,tolerance,pr)) return(0);    if (!Cudd_EqualSupNorm(dd,fvn,gvn,tolerance,pr)) return(0);    cuddCacheInsert2(dd,(DdNode * (*)(DdManager *, DdNode *, DdNode *))Cudd_EqualSupNorm,f,g,DD_ONE(dd));    return(1);} /* end of Cudd_EqualSupNorm *//**Function********************************************************************  Synopsis    [Expands cube to a prime implicant of f.]  Description [Expands cube to a prime implicant of f. Returns the prime  if successful; NULL otherwise.  In particular, NULL is returned if cube  is not a real cube or is not an implicant of f.]  SideEffects [None]  SeeAlso     []******************************************************************************/DdNode *Cudd_bddMakePrime(  DdManager *dd /* manager */,  DdNode *cube /* cube to be expanded */,  DdNode *f /* function of which the cube is to be made a prime */){    DdNode *res;    if (!Cudd_bddLeq(dd,cube,f)) return(NULL);    do {	dd->reordered = 0;	res = cuddBddMakePrime(dd,cube,f);    } while (dd->reordered == 1);    return(res);} /* end of Cudd_bddMakePrime *//*---------------------------------------------------------------------------*//* Definition of internal functions                                          *//*---------------------------------------------------------------------------*//**Function********************************************************************  Synopsis    [Performs the recursive step of Cudd_bddMakePrime.]  Description [Performs the recursive step of Cudd_bddMakePrime.  Returns the prime if successful; NULL otherwise.]  SideEffects [None]  SeeAlso     []******************************************************************************/DdNode *cuddBddMakePrime(  DdManager *dd /* manager */,  DdNode *cube /* cube to be expanded */,  DdNode *f /* function of which the cube is to be made a prime */){    DdNode *scan;    DdNode *t, *e;    DdNode *res = cube;    DdNode *zero = Cudd_Not(DD_ONE(dd));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -