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

📄 cuddbddite.c

📁 主要进行大规模的电路综合
💻 C
📖 第 1 页 / 共 3 页
字号:
/**CFile***********************************************************************  FileName    [cuddBddIte.c]  PackageName [cudd]  Synopsis    [BDD ITE function and satellites.]  Description [External procedures included in this module:		<ul>                <li> Cudd_bddIte()       	        <li> Cudd_bddIteConstant()		<li> Cudd_bddIntersect()		<li> Cudd_bddAnd()		<li> Cudd_bddOr()		<li> Cudd_bddNand()		<li> Cudd_bddNor()		<li> Cudd_bddXor()		<li> Cudd_bddXnor()		<li> Cudd_bddLeq()		</ul>       Internal procedures included in this module:		<ul>		<li> cuddBddIteRecur()		<li> cuddBddIntersectRecur()		<li> cuddBddAndRecur()		<li> cuddBddXorRecur()		</ul>       Static procedures included in this module:		<ul>       	        <li> bddVarToConst()       	        <li> bddVarToCanonical()       	        <li> bddVarToCanonicalSimple()		</ul>]  SeeAlso     []  Author      [Fabio Somenzi]  Copyright   [This file was created at the University of Colorado at  Boulder.  The University of Colorado at Boulder makes no warranty  about the suitability of this software for any purpose.  It is  presented on an AS IS basis.]******************************************************************************/#include "util.h"#include "cuddInt.h"/*---------------------------------------------------------------------------*//* Constant declarations                                                     *//*---------------------------------------------------------------------------*//*---------------------------------------------------------------------------*//* Stucture declarations                                                     *//*---------------------------------------------------------------------------*//*---------------------------------------------------------------------------*//* Type declarations                                                         *//*---------------------------------------------------------------------------*//*---------------------------------------------------------------------------*//* Variable declarations                                                     *//*---------------------------------------------------------------------------*/#ifndef lintstatic char rcsid[] DD_UNUSED = "$Id: cuddBddIte.c,v 1.1.1.1 2003/02/24 22:23:51 wjiang Exp $";#endif/*---------------------------------------------------------------------------*//* Macro declarations                                                        *//*---------------------------------------------------------------------------*//**AutomaticStart*************************************************************//*---------------------------------------------------------------------------*//* Static function prototypes                                                *//*---------------------------------------------------------------------------*/static void bddVarToConst ARGS((DdNode *f, DdNode **gp, DdNode **hp, DdNode *one));static int bddVarToCanonical ARGS((DdManager *dd, DdNode **fp, DdNode **gp, DdNode **hp, unsigned int *topfp, unsigned int *topgp, unsigned int *tophp));static int bddVarToCanonicalSimple ARGS((DdManager *dd, DdNode **fp, DdNode **gp, DdNode **hp, unsigned int *topfp, unsigned int *topgp, unsigned int *tophp));/**AutomaticEnd***************************************************************//*---------------------------------------------------------------------------*//* Definition of exported functions                                          *//*---------------------------------------------------------------------------*//**Function********************************************************************  Synopsis    [Implements ITE(f,g,h).]  Description [Implements ITE(f,g,h). Returns a pointer to the  resulting BDD if successful; NULL if the intermediate result blows  up.]  SideEffects [None]  SeeAlso     [Cudd_addIte Cudd_bddIteConstant Cudd_bddIntersect]******************************************************************************/DdNode *Cudd_bddIte(  DdManager * dd,  DdNode * f,  DdNode * g,  DdNode * h){    DdNode *res;    do {	dd->reordered = 0;	res = cuddBddIteRecur(dd,f,g,h);    } while (dd->reordered == 1);    return(res);} /* end of Cudd_bddIte *//**Function********************************************************************  Synopsis    [Implements ITEconstant(f,g,h).]  Description [Implements ITEconstant(f,g,h). Returns a pointer to the  resulting BDD (which may or may not be constant) or DD_NON_CONSTANT.  No new nodes are created.]  SideEffects [None]  SeeAlso     [Cudd_bddIte Cudd_bddIntersect Cudd_bddLeq Cudd_addIteConstant]******************************************************************************/DdNode *Cudd_bddIteConstant(  DdManager * dd,  DdNode * f,  DdNode * g,  DdNode * h){    DdNode	 *r, *Fv, *Fnv, *Gv, *Gnv, *H, *Hv, *Hnv, *t, *e;    DdNode	 *one = DD_ONE(dd);    DdNode	 *zero = Cudd_Not(one);    int		 comple;    unsigned int topf, topg, toph, v;    statLine(dd);    /* Trivial cases. */    if (f == one) 			/* ITE(1,G,H) => G */	return(g);        if (f == zero)			/* ITE(0,G,H) => H */	return(h);        /* f now not a constant. */    bddVarToConst(f, &g, &h, one);	/* possibly convert g or h */					/* to constants */    if (g == h) 			/* ITE(F,G,G) => G */	return(g);    if (Cudd_IsConstant(g) && Cudd_IsConstant(h)) 	return(DD_NON_CONSTANT);	/* ITE(F,1,0) or ITE(F,0,1) */					/* => DD_NON_CONSTANT */        if (g == Cudd_Not(h))	return(DD_NON_CONSTANT);	/* ITE(F,G,G') => DD_NON_CONSTANT */					/* if F != G and F != G' */        comple = bddVarToCanonical(dd, &f, &g, &h, &topf, &topg, &toph);    /* Cache lookup. */    r = cuddConstantLookup(dd, DD_BDD_ITE_CONSTANT_TAG, f, g, h);    if (r != NULL) {	return(Cudd_NotCond(r,comple && r != DD_NON_CONSTANT));    }    v = ddMin(topg, toph);    /* ITE(F,G,H) = (v,G,H) (non constant) if F = (v,1,0), v < top(G,H). */    if (topf < v && cuddT(f) == one && cuddE(f) == zero) {	return(DD_NON_CONSTANT);    }    /* Compute cofactors. */    if (topf <= v) {	v = ddMin(topf, v);		/* v = top_var(F,G,H) */	Fv = cuddT(f); Fnv = cuddE(f);    } else {	Fv = Fnv = f;    }    if (topg == v) {	Gv = cuddT(g); Gnv = cuddE(g);    } else {	Gv = Gnv = g;    }    if (toph == v) {	H = Cudd_Regular(h);	Hv = cuddT(H); Hnv = cuddE(H);	if (Cudd_IsComplement(h)) {	    Hv = Cudd_Not(Hv);	    Hnv = Cudd_Not(Hnv);	}    } else {	Hv = Hnv = h;    }    /* Recursion. */    t = Cudd_bddIteConstant(dd, Fv, Gv, Hv);    if (t == DD_NON_CONSTANT || !Cudd_IsConstant(t)) {	cuddCacheInsert(dd, DD_BDD_ITE_CONSTANT_TAG, f, g, h, DD_NON_CONSTANT);	return(DD_NON_CONSTANT);    }    e = Cudd_bddIteConstant(dd, Fnv, Gnv, Hnv);    if (e == DD_NON_CONSTANT || !Cudd_IsConstant(e) || t != e) {	cuddCacheInsert(dd, DD_BDD_ITE_CONSTANT_TAG, f, g, h, DD_NON_CONSTANT);	return(DD_NON_CONSTANT);    }    cuddCacheInsert(dd, DD_BDD_ITE_CONSTANT_TAG, f, g, h, t);    return(Cudd_NotCond(t,comple));} /* end of Cudd_bddIteConstant *//**Function********************************************************************  Synopsis    [Returns a function included in the intersection of f and g.]  Description [Computes a function included in the intersection of f and  g. (That is, a witness that the intersection is not empty.)  Cudd_bddIntersect tries to build as few new nodes as possible. If the  only result of interest is whether f and g intersect,  Cudd_bddLeq should be used instead.]  SideEffects [None]  SeeAlso     [Cudd_bddLeq Cudd_bddIteConstant]******************************************************************************/DdNode *Cudd_bddIntersect(  DdManager * dd /* manager */,  DdNode * f /* first operand */,  DdNode * g /* second operand */){    DdNode *res;    do {	dd->reordered = 0;	res = cuddBddIntersectRecur(dd,f,g);    } while (dd->reordered == 1);    return(res);} /* end of Cudd_bddIntersect *//**Function********************************************************************  Synopsis    [Computes the conjunction of two BDDs f and g.]  Description [Computes the conjunction of two BDDs f and g. Returns a  pointer to the resulting BDD if successful; NULL if the intermediate  result blows up.]  SideEffects [None]  SeeAlso     [Cudd_bddIte Cudd_addApply Cudd_bddAndAbstract Cudd_bddIntersect  Cudd_bddOr Cudd_bddNand Cudd_bddNor Cudd_bddXor Cudd_bddXnor]******************************************************************************/DdNode *Cudd_bddAnd(  DdManager * dd,  DdNode * f,  DdNode * g){    DdNode *res;    do {	dd->reordered = 0;	res = cuddBddAndRecur(dd,f,g);    } while (dd->reordered == 1);    return(res);} /* end of Cudd_bddAnd *//**Function********************************************************************  Synopsis    [Computes the disjunction of two BDDs f and g.]  Description [Computes the disjunction of two BDDs f and g. Returns a  pointer to the resulting BDD if successful; NULL if the intermediate  result blows up.]  SideEffects [None]  SeeAlso     [Cudd_bddIte Cudd_addApply Cudd_bddAnd Cudd_bddNand Cudd_bddNor  Cudd_bddXor Cudd_bddXnor]******************************************************************************/DdNode *Cudd_bddOr(  DdManager * dd,  DdNode * f,  DdNode * g){    DdNode *res;    do {	dd->reordered = 0;	res = cuddBddAndRecur(dd,Cudd_Not(f),Cudd_Not(g));    } while (dd->reordered == 1);    res = Cudd_NotCond(res,res != NULL);    return(res);} /* end of Cudd_bddOr *//**Function********************************************************************  Synopsis    [Computes the NAND of two BDDs f and g.]  Description [Computes the NAND of two BDDs f and g. Returns a  pointer to the resulting BDD if successful; NULL if the intermediate  result blows up.]  SideEffects [None]  SeeAlso     [Cudd_bddIte Cudd_addApply Cudd_bddAnd Cudd_bddOr Cudd_bddNor  Cudd_bddXor Cudd_bddXnor]******************************************************************************/DdNode *Cudd_bddNand(  DdManager * dd,  DdNode * f,  DdNode * g){    DdNode *res;    do {	dd->reordered = 0;	res = cuddBddAndRecur(dd,f,g);    } while (dd->reordered == 1);    res = Cudd_NotCond(res,res != NULL);    return(res);} /* end of Cudd_bddNand *//**Function********************************************************************  Synopsis    [Computes the NOR of two BDDs f and g.]  Description [Computes the NOR of two BDDs f and g. Returns a  pointer to the resulting BDD if successful; NULL if the intermediate  result blows up.]  SideEffects [None]  SeeAlso     [Cudd_bddIte Cudd_addApply Cudd_bddAnd Cudd_bddOr Cudd_bddNand  Cudd_bddXor Cudd_bddXnor]******************************************************************************/DdNode *Cudd_bddNor(  DdManager * dd,  DdNode * f,  DdNode * g){    DdNode *res;    do {	dd->reordered = 0;	res = cuddBddAndRecur(dd,Cudd_Not(f),Cudd_Not(g));    } while (dd->reordered == 1);    return(res);} /* end of Cudd_bddNor *//**Function********************************************************************  Synopsis    [Computes the exclusive OR of two BDDs f and g.]  Description [Computes the exclusive OR of two BDDs f and g. Returns a  pointer to the resulting BDD if successful; NULL if the intermediate  result blows up.]  SideEffects [None]  SeeAlso     [Cudd_bddIte Cudd_addApply Cudd_bddAnd Cudd_bddOr  Cudd_bddNand Cudd_bddNor Cudd_bddXnor]******************************************************************************/DdNode *Cudd_bddXor(  DdManager * dd,  DdNode * f,  DdNode * g){    DdNode *res;    do {	dd->reordered = 0;	res = cuddBddXorRecur(dd,f,g);    } while (dd->reordered == 1);    return(res);

⌨️ 快捷键说明

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