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

📄 cuddbridge.c

📁 主要进行大规模的电路综合
💻 C
📖 第 1 页 / 共 2 页
字号:
/**CFile***********************************************************************  FileName    [cuddBridge.c]  PackageName [cudd]  Synopsis    [Translation from BDD to ADD and vice versa and transfer between  different managers.]  Description [External procedures included in this file:	    <ul>	    <li> Cudd_addBddThreshold()	    <li> Cudd_addBddStrictThreshold()	    <li> Cudd_addBddInterval()	    <li> Cudd_addBddIthBit()	    <li> Cudd_BddToAdd()	    <li> Cudd_addBddPattern()	    <li> Cudd_bddTransfer()	    </ul>	Internal procedures included in this file:	    <ul>	    <li> cuddBddTransfer()	    <li> cuddAddBddDoPattern()	    </ul>	Static procedures included in this file:	    <ul>	    <li> addBddDoThreshold()	    <li> addBddDoStrictThreshold()	    <li> addBddDoInterval()	    <li> addBddDoIthBit()	    <li> ddBddToAddRecur()	    <li> cuddBddTransferRecur()	    </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: cuddBridge.c,v 1.1.1.1 2003/02/24 22:23:51 wjiang Exp $";#endif/*---------------------------------------------------------------------------*//* Macro declarations                                                        *//*---------------------------------------------------------------------------*//**AutomaticStart*************************************************************//*---------------------------------------------------------------------------*//* Static function prototypes                                                *//*---------------------------------------------------------------------------*/static DdNode * addBddDoThreshold ARGS((DdManager *dd, DdNode *f, DdNode *val));static DdNode * addBddDoStrictThreshold ARGS((DdManager *dd, DdNode *f, DdNode *val));static DdNode * addBddDoInterval ARGS((DdManager *dd, DdNode *f, DdNode *l, DdNode *u));static DdNode * addBddDoIthBit ARGS((DdManager *dd, DdNode *f, DdNode *index));static DdNode * ddBddToAddRecur ARGS((DdManager *dd, DdNode *B));static DdNode * cuddBddTransferRecur ARGS((DdManager *ddS, DdManager *ddD, DdNode *f, st_table *table));/**AutomaticEnd***************************************************************//*---------------------------------------------------------------------------*//* Definition of exported functions                                          *//*---------------------------------------------------------------------------*//**Function********************************************************************  Synopsis    [Converts an ADD to a BDD.]  Description [Converts an ADD to a BDD by replacing all  discriminants greater than or equal to value with 1, and all other  discriminants with 0. Returns a pointer to the resulting BDD if  successful; NULL otherwise.]  SideEffects [None]  SeeAlso     [Cudd_addBddInterval Cudd_addBddPattern Cudd_BddToAdd  Cudd_addBddStrictThreshold]******************************************************************************/DdNode *Cudd_addBddThreshold(  DdManager * dd,  DdNode * f,  CUDD_VALUE_TYPE  value){    DdNode *res;    DdNode *val;        val = cuddUniqueConst(dd,value);    if (val == NULL) return(NULL);    cuddRef(val);    do {	dd->reordered = 0;	res = addBddDoThreshold(dd, f, val);    } while (dd->reordered == 1);    if (res == NULL) {	Cudd_RecursiveDeref(dd, val);	return(NULL);    }    cuddRef(res);    Cudd_RecursiveDeref(dd, val);    cuddDeref(res);    return(res);} /* end of Cudd_addBddThreshold *//**Function********************************************************************  Synopsis    [Converts an ADD to a BDD.]  Description [Converts an ADD to a BDD by replacing all  discriminants STRICTLY greater than value with 1, and all other  discriminants with 0. Returns a pointer to the resulting BDD if  successful; NULL otherwise.]  SideEffects [None]  SeeAlso     [Cudd_addBddInterval Cudd_addBddPattern Cudd_BddToAdd   Cudd_addBddThreshold]******************************************************************************/DdNode *Cudd_addBddStrictThreshold(  DdManager * dd,  DdNode * f,  CUDD_VALUE_TYPE  value){    DdNode *res;    DdNode *val;        val = cuddUniqueConst(dd,value);    if (val == NULL) return(NULL);    cuddRef(val);    do {	dd->reordered = 0;	res = addBddDoStrictThreshold(dd, f, val);    } while (dd->reordered == 1);    if (res == NULL) {	Cudd_RecursiveDeref(dd, val);	return(NULL);    }    cuddRef(res);    Cudd_RecursiveDeref(dd, val);    cuddDeref(res);    return(res);} /* end of Cudd_addBddStrictThreshold *//**Function********************************************************************  Synopsis    [Converts an ADD to a BDD.]  Description [Converts an ADD to a BDD by replacing all  discriminants greater than or equal to lower and less than or equal to  upper with 1, and all other discriminants with 0. Returns a pointer to  the resulting BDD if successful; NULL otherwise.]  SideEffects [None]  SeeAlso     [Cudd_addBddThreshold Cudd_addBddStrictThreshold   Cudd_addBddPattern Cudd_BddToAdd]******************************************************************************/DdNode *Cudd_addBddInterval(  DdManager * dd,  DdNode * f,  CUDD_VALUE_TYPE  lower,  CUDD_VALUE_TYPE  upper){    DdNode *res;    DdNode *l;    DdNode *u;        /* Create constant nodes for the interval bounds, so that we can use    ** the global cache.    */    l = cuddUniqueConst(dd,lower);    if (l == NULL) return(NULL);    cuddRef(l);    u = cuddUniqueConst(dd,upper);    if (u == NULL) {	Cudd_RecursiveDeref(dd,l);	return(NULL);    }    cuddRef(u);    do {	dd->reordered = 0;	res = addBddDoInterval(dd, f, l, u);    } while (dd->reordered == 1);    if (res == NULL) {	Cudd_RecursiveDeref(dd, l);	Cudd_RecursiveDeref(dd, u);	return(NULL);    }    cuddRef(res);    Cudd_RecursiveDeref(dd, l);    Cudd_RecursiveDeref(dd, u);    cuddDeref(res);    return(res);} /* end of Cudd_addBddInterval *//**Function********************************************************************  Synopsis    [Converts an ADD to a BDD by extracting the i-th bit from  the leaves.]  Description [Converts an ADD to a BDD by replacing all  discriminants whose i-th bit is equal to 1 with 1, and all other  discriminants with 0. The i-th bit refers to the integer  representation of the leaf value. If the value is has a fractional  part, it is ignored. Repeated calls to this procedure allow one to  transform an integer-valued ADD into an array of BDDs, one for each  bit of the leaf values. Returns a pointer to the resulting BDD if  successful; NULL otherwise.]  SideEffects [None]  SeeAlso     [Cudd_addBddInterval Cudd_addBddPattern Cudd_BddToAdd]******************************************************************************/DdNode *Cudd_addBddIthBit(  DdManager * dd,  DdNode * f,  int  bit){    DdNode *res;    DdNode *index;        index = cuddUniqueConst(dd,(CUDD_VALUE_TYPE) bit);    if (index == NULL) return(NULL);    cuddRef(index);    do {	dd->reordered = 0;	res = addBddDoIthBit(dd, f, index);    } while (dd->reordered == 1);    if (res == NULL) {	Cudd_RecursiveDeref(dd, index);	return(NULL);    }    cuddRef(res);    Cudd_RecursiveDeref(dd, index);    cuddDeref(res);    return(res);} /* end of Cudd_addBddIthBit *//**Function********************************************************************  Synopsis    [Converts a BDD to a 0-1 ADD.]  Description [Converts a BDD to a 0-1 ADD. Returns a pointer to the  resulting ADD if successful; NULL otherwise.]  SideEffects [None]  SeeAlso     [Cudd_addBddPattern Cudd_addBddThreshold Cudd_addBddInterval  Cudd_addBddStrictThreshold]******************************************************************************/DdNode *Cudd_BddToAdd(  DdManager * dd,  DdNode * B){    DdNode *res;    do {	dd->reordered = 0;	res = ddBddToAddRecur(dd, B);    } while (dd->reordered ==1);    return(res);} /* end of Cudd_BddToAdd *//**Function********************************************************************  Synopsis    [Converts an ADD to a BDD.]  Description [Converts an ADD to a BDD by replacing all  discriminants different from 0 with 1. Returns a pointer to the  resulting BDD if successful; NULL otherwise.]  SideEffects [None]  SeeAlso     [Cudd_BddToAdd Cudd_addBddThreshold Cudd_addBddInterval  Cudd_addBddStrictThreshold]******************************************************************************/DdNode *Cudd_addBddPattern(  DdManager * dd,  DdNode * f){    DdNode *res;        do {	dd->reordered = 0;	res = cuddAddBddDoPattern(dd, f);    } while (dd->reordered == 1);    return(res);} /* end of Cudd_addBddPattern *//**Function********************************************************************  Synopsis    [Convert a BDD from a manager to another one.]  Description [Convert a BDD from a manager to another one. The orders of the  variables in the two managers may be different. Returns a  pointer to the BDD in the destination manager if successful; NULL  otherwise.]  SideEffects [None]  SeeAlso     []******************************************************************************/DdNode *Cudd_bddTransfer(  DdManager * ddSource,  DdManager * ddDestination,  DdNode * f){    DdNode *res;    do {	ddDestination->reordered = 0;	res = cuddBddTransfer(ddSource, ddDestination, f);    } while (ddDestination->reordered == 1);    return(res);} /* end of Cudd_bddTransfer *//*---------------------------------------------------------------------------*//* Definition of internal functions                                          *//*---------------------------------------------------------------------------*//**Function********************************************************************  Synopsis    [Convert a BDD from a manager to another one.]  Description [Convert a BDD from a manager to another one. Returns a  pointer to the BDD in the destination manager if successful; NULL  otherwise.]  SideEffects [None]  SeeAlso     [Cudd_bddTransfer]******************************************************************************/DdNode *cuddBddTransfer(  DdManager * ddS,  DdManager * ddD,  DdNode * f){    DdNode *res;    st_table *table = NULL;    st_generator *gen = NULL;    DdNode *key, *value;    table = st_init_table(st_ptrcmp,st_ptrhash);    if (table == NULL) goto failure;    res = cuddBddTransferRecur(ddS, ddD, f, table);    if (res != NULL) cuddRef(res);    /* Dereference all elements in the table and dispose of the table.    ** This must be done also if res is NULL to avoid leaks in case of    ** reordering. */    gen = st_init_gen(table);    if (gen == NULL) goto failure;    while (st_gen(gen, (char **) &key, (char **) &value)) {	Cudd_RecursiveDeref(ddD, value);    }    st_free_gen(gen); gen = NULL;    st_free_table(table); table = NULL;    if (res != NULL) cuddDeref(res);    return(res);failure:    if (table != NULL) st_free_table(table);    if (gen != NULL) st_free_gen(gen);    return(NULL);} /* end of cuddBddTransfer *//**Function********************************************************************  Synopsis    [Performs the recursive step for Cudd_addBddPattern.]  Description [Performs the recursive step for Cudd_addBddPattern. Returns a  pointer to the resulting BDD if successful; NULL otherwise.]  SideEffects [None]  SeeAlso     []******************************************************************************/DdNode *cuddAddBddDoPattern(  DdManager * dd,  DdNode * f){    DdNode *res, *T, *E;    DdNode *fv, *fvn;    int v;    statLine(dd);    /* Check terminal case. */    if (cuddIsConstant(f)) {	return(Cudd_NotCond(DD_ONE(dd),f == DD_ZERO(dd)));    }    /* Check cache. */    res = cuddCacheLookup1(dd,Cudd_addBddPattern,f);    if (res != NULL) return(res);    /* Recursive step. */    v = f->index;    fv = cuddT(f); fvn = cuddE(f);    T = cuddAddBddDoPattern(dd,fv);    if (T == NULL) return(NULL);    cuddRef(T);    E = cuddAddBddDoPattern(dd,fvn);    if (E == NULL) {	Cudd_RecursiveDeref(dd, T);	return(NULL);    }    cuddRef(E);    if (Cudd_IsComplement(T)) {	res = (T == E) ? Cudd_Not(T) : cuddUniqueInter(dd,v,Cudd_Not(T),Cudd_Not(E));	if (res == NULL) {	    Cudd_RecursiveDeref(dd, T);	    Cudd_RecursiveDeref(dd, E);	    return(NULL);

⌨️ 快捷键说明

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