abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cuddAddFind.c File Reference
#include "misc/util/util_hack.h"
#include "cuddInt.h"

Go to the source code of this file.

Functions

static DdNodeaddDoIthBit (DdManager *dd, DdNode *f, DdNode *index)
 
DdNodeCudd_addFindMax (DdManager *dd, DdNode *f)
 
DdNodeCudd_addFindMin (DdManager *dd, DdNode *f)
 
DdNodeCudd_addIthBit (DdManager *dd, DdNode *f, int bit)
 

Variables

static
ABC_NAMESPACE_IMPL_START char
rcsid[] 
DD_UNUSED = "$Id: cuddAddFind.c,v 1.8 2004/08/13 18:04:45 fabio Exp $"
 

Function Documentation

static DdNode * addDoIthBit ( DdManager dd,
DdNode f,
DdNode index 
)
static

AutomaticStart

Function********************************************************************

Synopsis [Performs the recursive step for Cudd_addIthBit.]

Description [Performs the recursive step for Cudd_addIthBit. Returns a pointer to the BDD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 268 of file cuddAddFind.c.

272 {
273  DdNode *res, *T, *E;
274  DdNode *fv, *fvn;
275  int mask, value;
276  int v;
277 
278  statLine(dd);
279  /* Check terminal case. */
280  if (cuddIsConstant(f)) {
281  mask = 1 << ((int) cuddV(index));
282  value = (int) cuddV(f);
283  return((value & mask) == 0 ? DD_ZERO(dd) : DD_ONE(dd));
284  }
285 
286  /* Check cache. */
287  res = cuddCacheLookup2(dd,addDoIthBit,f,index);
288  if (res != NULL) return(res);
289 
290  /* Recursive step. */
291  v = f->index;
292  fv = cuddT(f); fvn = cuddE(f);
293 
294  T = addDoIthBit(dd,fv,index);
295  if (T == NULL) return(NULL);
296  cuddRef(T);
297 
298  E = addDoIthBit(dd,fvn,index);
299  if (E == NULL) {
300  Cudd_RecursiveDeref(dd, T);
301  return(NULL);
302  }
303  cuddRef(E);
304 
305  res = (T == E) ? T : cuddUniqueInter(dd,v,T,E);
306  if (res == NULL) {
307  Cudd_RecursiveDeref(dd, T);
308  Cudd_RecursiveDeref(dd, E);
309  return(NULL);
310  }
311  cuddDeref(T);
312  cuddDeref(E);
313 
314  /* Store result. */
315  cuddCacheInsert2(dd,addDoIthBit,f,index,res);
316 
317  return(res);
318 
319 } /* end of addDoIthBit */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
void cuddCacheInsert2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g, DdNode *data)
Definition: cuddCache.c:277
#define statLine(dd)
Definition: cuddInt.h:1037
#define cuddV(node)
Definition: cuddInt.h:668
DdNode * cuddCacheLookup2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:502
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
static DdNode * addDoIthBit(DdManager *dd, DdNode *f, DdNode *index)
Definition: cuddAddFind.c:268
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
int value
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
#define DD_ZERO(dd)
Definition: cuddInt.h:927
DdNode* Cudd_addFindMax ( DdManager dd,
DdNode f 
)

AutomaticEnd Function********************************************************************

Synopsis [Finds the maximum discriminant of f.]

Description [Returns a pointer to a constant ADD.]

SideEffects [None]

Definition at line 124 of file cuddAddFind.c.

127 {
128  DdNode *t, *e, *res;
129 
130  statLine(dd);
131  if (cuddIsConstant(f)) {
132  return(f);
133  }
134 
135  res = cuddCacheLookup1(dd,Cudd_addFindMax,f);
136  if (res != NULL) {
137  return(res);
138  }
139 
140  t = Cudd_addFindMax(dd,cuddT(f));
141  if (t == DD_PLUS_INFINITY(dd)) return(t);
142 
143  e = Cudd_addFindMax(dd,cuddE(f));
144 
145  res = (cuddV(t) >= cuddV(e)) ? t : e;
146 
148 
149  return(res);
150 
151 } /* end of Cudd_addFindMax */
Definition: cudd.h:278
#define statLine(dd)
Definition: cuddInt.h:1037
DdNode * Cudd_addFindMax(DdManager *dd, DdNode *f)
Definition: cuddAddFind.c:124
#define cuddV(node)
Definition: cuddInt.h:668
DdNode * cuddCacheLookup1(DdManager *table, DD_CTFP1 op, DdNode *f)
Definition: cuddCache.c:556
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
#define cuddE(node)
Definition: cuddInt.h:652
#define DD_PLUS_INFINITY(dd)
Definition: cuddInt.h:941
void cuddCacheInsert1(DdManager *table, DD_CTFP1 op, DdNode *f, DdNode *data)
Definition: cuddCache.c:323
DdNode* Cudd_addFindMin ( DdManager dd,
DdNode f 
)

Function********************************************************************

Synopsis [Finds the minimum discriminant of f.]

Description [Returns a pointer to a constant ADD.]

SideEffects [None]

Definition at line 164 of file cuddAddFind.c.

167 {
168  DdNode *t, *e, *res;
169 
170  statLine(dd);
171  if (cuddIsConstant(f)) {
172  return(f);
173  }
174 
175  res = cuddCacheLookup1(dd,Cudd_addFindMin,f);
176  if (res != NULL) {
177  return(res);
178  }
179 
180  t = Cudd_addFindMin(dd,cuddT(f));
181  if (t == DD_MINUS_INFINITY(dd)) return(t);
182 
183  e = Cudd_addFindMin(dd,cuddE(f));
184 
185  res = (cuddV(t) <= cuddV(e)) ? t : e;
186 
188 
189  return(res);
190 
191 } /* end of Cudd_addFindMin */
Definition: cudd.h:278
DdNode * Cudd_addFindMin(DdManager *dd, DdNode *f)
Definition: cuddAddFind.c:164
#define statLine(dd)
Definition: cuddInt.h:1037
#define DD_MINUS_INFINITY(dd)
Definition: cuddInt.h:955
#define cuddV(node)
Definition: cuddInt.h:668
DdNode * cuddCacheLookup1(DdManager *table, DD_CTFP1 op, DdNode *f)
Definition: cuddCache.c:556
#define cuddIsConstant(node)
Definition: cuddInt.h:620
#define cuddT(node)
Definition: cuddInt.h:636
#define cuddE(node)
Definition: cuddInt.h:652
void cuddCacheInsert1(DdManager *table, DD_CTFP1 op, DdNode *f, DdNode *data)
Definition: cuddCache.c:323
DdNode* Cudd_addIthBit ( DdManager dd,
DdNode f,
int  bit 
)

Function********************************************************************

Synopsis [Extracts the i-th bit from an ADD.]

Description [Produces an ADD from another ADD 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 ADDs, one for each bit of the leaf values. Returns a pointer to the resulting ADD if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_addBddIthBit]

Definition at line 213 of file cuddAddFind.c.

217 {
218  DdNode *res;
219  DdNode *index;
220 
221  /* Use a constant node to remember the bit, so that we can use the
222  ** global cache.
223  */
224  index = cuddUniqueConst(dd,(CUDD_VALUE_TYPE) bit);
225  if (index == NULL) return(NULL);
226  cuddRef(index);
227 
228  do {
229  dd->reordered = 0;
230  res = addDoIthBit(dd, f, index);
231  } while (dd->reordered == 1);
232 
233  if (res == NULL) {
234  Cudd_RecursiveDeref(dd, index);
235  return(NULL);
236  }
237  cuddRef(res);
238  Cudd_RecursiveDeref(dd, index);
239  cuddDeref(res);
240  return(res);
241 
242 } /* end of Cudd_addIthBit */
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
int reordered
Definition: cuddInt.h:409
static DdNode * addDoIthBit(DdManager *dd, DdNode *f, DdNode *index)
Definition: cuddAddFind.c:268
#define CUDD_VALUE_TYPE
Definition: cudd.h:94

Variable Documentation

ABC_NAMESPACE_IMPL_START char rcsid [] DD_UNUSED = "$Id: cuddAddFind.c,v 1.8 2004/08/13 18:04:45 fabio Exp $"
static

CFile***********************************************************************

FileName [cuddAddFind.c]

PackageName [cudd]

Synopsis [Functions to find maximum and minimum in an ADD and to extract the i-th bit.]

Description [External procedures included in this module:

Static functions included in this module:

]

Author [Fabio Somenzi]

Copyright [Copyright (c) 1995-2004, Regents of the University of Colorado

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

Neither the name of the University of Colorado nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.]

Definition at line 84 of file cuddAddFind.c.