SVF
Functions | Variables
cuddCof.c File Reference
#include "CUDD/util.h"
#include "CUDD/cuddInt.h"

Go to the source code of this file.

Functions

DdNodeCudd_Cofactor (DdManager *dd, DdNode *f, DdNode *g)
 
int Cudd_CheckCube (DdManager *dd, DdNode *g)
 
void cuddGetBranches (DdNode *g, DdNode **g1, DdNode **g0)
 
DdNodecuddCofactorRecur (DdManager *dd, DdNode *f, DdNode *g)
 

Variables

static char rcsid [] DD_UNUSED = "$Id: cuddCof.c,v 1.11 2012/02/05 01:07:18 fabio Exp $"
 

Function Documentation

◆ Cudd_CheckCube()

int Cudd_CheckCube ( DdManager dd,
DdNode g 
)

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

Synopsis [Checks whether g is the BDD of a cube.]

Description [Checks whether g is the BDD of a cube. Returns 1 in case of success; 0 otherwise. The constant 1 is a valid cube, but all other constant functions cause cuddCheckCube to return 0.]

SideEffects [None]

SeeAlso []

Definition at line 155 of file cuddCof.c.

158 {
159  DdNode *g1,*g0,*one,*zero;
160 
161  one = DD_ONE(dd);
162  if (g == one) return(1);
163  if (Cudd_IsConstant(g)) return(0);
164 
165  zero = Cudd_Not(one);
166  cuddGetBranches(g,&g1,&g0);
167 
168  if (g0 == zero) {
169  return(Cudd_CheckCube(dd, g1));
170  }
171  if (g1 == zero) {
172  return(Cudd_CheckCube(dd, g0));
173  }
174  return(0);
175 
176 } /* end of Cudd_CheckCube */
Definition: cudd.h:270
#define Cudd_Not(node)
Definition: cudd.h:354
#define Cudd_IsConstant(node)
Definition: cudd.h:339
void cuddGetBranches(DdNode *g, DdNode **g1, DdNode **g0)
Definition: cuddCof.c:196
static DdNode * one
Definition: cuddSat.c:105
static DdNode * zero
Definition: cuddSat.c:105
int Cudd_CheckCube(DdManager *dd, DdNode *g)
Definition: cuddCof.c:155
#define DD_ONE(dd)
Definition: cuddInt.h:864

◆ Cudd_Cofactor()

DdNode* Cudd_Cofactor ( DdManager dd,
DdNode f,
DdNode g 
)

AutomaticStart AutomaticEnd Function********************************************************************

Synopsis [Computes the cofactor of f with respect to g.]

Description [Computes the cofactor of f with respect to g; g must be the BDD or the ADD of a cube. Returns a pointer to the cofactor if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_bddConstrain Cudd_bddRestrict]

Definition at line 119 of file cuddCof.c.

123 {
124  DdNode *res,*zero;
125 
126  zero = Cudd_Not(DD_ONE(dd));
127  if (g == zero || g == DD_ZERO(dd)) {
128  (void) fprintf(dd->err,"Cudd_Cofactor: Invalid restriction 1\n");
130  return(NULL);
131  }
132  do {
133  dd->reordered = 0;
134  res = cuddCofactorRecur(dd,f,g);
135  } while (dd->reordered == 1);
136  return(res);
137 
138 } /* end of Cudd_Cofactor */
Definition: cudd.h:270
#define Cudd_Not(node)
Definition: cudd.h:354
FILE * err
Definition: cuddInt.h:424
int reordered
Definition: cuddInt.h:392
DdNode * cuddCofactorRecur(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddCof.c:226
static DdNode * zero
Definition: cuddSat.c:105
#define DD_ONE(dd)
Definition: cuddInt.h:864
Cudd_ErrorType errorCode
Definition: cuddInt.h:425
#define DD_ZERO(dd)
Definition: cuddInt.h:880

◆ cuddCofactorRecur()

DdNode* cuddCofactorRecur ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Performs the recursive step of Cudd_Cofactor.]

Description [Performs the recursive step of Cudd_Cofactor. Returns a pointer to the cofactor if successful; NULL otherwise.]

SideEffects [None]

SeeAlso [Cudd_Cofactor]

Definition at line 226 of file cuddCof.c.

230 {
231  DdNode *one,*zero,*F,*G,*g1,*g0,*f1,*f0,*t,*e,*r;
232  unsigned int topf,topg;
233  int comple;
234 
235  statLine(dd);
236  F = Cudd_Regular(f);
237  if (cuddIsConstant(F)) return(f);
238 
239  one = DD_ONE(dd);
240 
241  /* The invariant g != 0 is true on entry to this procedure and is
242  ** recursively maintained by it. Therefore it suffices to test g
243  ** against one to make sure it is not constant.
244  */
245  if (g == one) return(f);
246  /* From now on, f and g are known not to be constants. */
247 
248  comple = f != F;
249  r = cuddCacheLookup2(dd,Cudd_Cofactor,F,g);
250  if (r != NULL) {
251  return(Cudd_NotCond(r,comple));
252  }
253 
254  topf = dd->perm[F->index];
255  G = Cudd_Regular(g);
256  topg = dd->perm[G->index];
257 
258  /* We take the cofactors of F because we are going to rely on
259  ** the fact that the cofactors of the complement are the complements
260  ** of the cofactors to better utilize the cache. Variable comple
261  ** remembers whether we have to complement the result or not.
262  */
263  if (topf <= topg) {
264  f1 = cuddT(F); f0 = cuddE(F);
265  } else {
266  f1 = f0 = F;
267  }
268  if (topg <= topf) {
269  g1 = cuddT(G); g0 = cuddE(G);
270  if (g != G) { g1 = Cudd_Not(g1); g0 = Cudd_Not(g0); }
271  } else {
272  g1 = g0 = g;
273  }
274 
275  zero = Cudd_Not(one);
276  if (topf >= topg) {
277  if (g0 == zero || g0 == DD_ZERO(dd)) {
278  r = cuddCofactorRecur(dd, f1, g1);
279  } else if (g1 == zero || g1 == DD_ZERO(dd)) {
280  r = cuddCofactorRecur(dd, f0, g0);
281  } else {
282  (void) fprintf(dd->out,
283  "Cudd_Cofactor: Invalid restriction 2\n");
285  return(NULL);
286  }
287  if (r == NULL) return(NULL);
288  } else /* if (topf < topg) */ {
289  t = cuddCofactorRecur(dd, f1, g);
290  if (t == NULL) return(NULL);
291  cuddRef(t);
292  e = cuddCofactorRecur(dd, f0, g);
293  if (e == NULL) {
294  Cudd_RecursiveDeref(dd, t);
295  return(NULL);
296  }
297  cuddRef(e);
298 
299  if (t == e) {
300  r = t;
301  } else if (Cudd_IsComplement(t)) {
302  r = cuddUniqueInter(dd,(int)F->index,Cudd_Not(t),Cudd_Not(e));
303  if (r != NULL)
304  r = Cudd_Not(r);
305  } else {
306  r = cuddUniqueInter(dd,(int)F->index,t,e);
307  }
308  if (r == NULL) {
309  Cudd_RecursiveDeref(dd ,e);
310  Cudd_RecursiveDeref(dd ,t);
311  return(NULL);
312  }
313  cuddDeref(t);
314  cuddDeref(e);
315  }
316 
318 
319  return(Cudd_NotCond(r,comple));
320 
321 } /* end of cuddCofactorRecur */
#define cuddRef(n)
Definition: cuddInt.h:557
#define cuddDeref(n)
Definition: cuddInt.h:577
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:150
Definition: cudd.h:270
#define Cudd_Not(node)
Definition: cudd.h:354
DdNode * cuddCacheLookup2(DdManager *table, DdNode *(*)(DdManager *, DdNode *, DdNode *), DdNode *f, DdNode *g)
#define Cudd_Regular(node)
Definition: cudd.h:384
DdNode * Cudd_Cofactor(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddCof.c:119
#define statLine(dd)
Definition: cuddInt.h:990
static DdNode * one
Definition: cuddSat.c:105
#define Cudd_IsComplement(node)
Definition: cudd.h:412
FILE * out
Definition: cuddInt.h:423
#define cuddIsConstant(node)
Definition: cuddInt.h:593
#define cuddT(node)
Definition: cuddInt.h:609
DdNode * cuddCofactorRecur(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddCof.c:226
void cuddCacheInsert2(DdManager *table, DdNode *(*)(DdManager *, DdNode *, DdNode *), DdNode *f, DdNode *g, DdNode *data)
DdHalfWord index
Definition: cudd.h:271
static DdNode * zero
Definition: cuddSat.c:105
#define cuddE(node)
Definition: cuddInt.h:625
#define Cudd_NotCond(node, c)
Definition: cudd.h:370
#define DD_ONE(dd)
Definition: cuddInt.h:864
int * perm
Definition: cuddInt.h:369
Cudd_ErrorType errorCode
Definition: cuddInt.h:425
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1137
#define DD_ZERO(dd)
Definition: cuddInt.h:880

◆ cuddGetBranches()

void cuddGetBranches ( DdNode g,
DdNode **  g1,
DdNode **  g0 
)

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

Synopsis [Computes the children of g.]

Description []

SideEffects [None]

SeeAlso []

Definition at line 196 of file cuddCof.c.

200 {
201  DdNode *G = Cudd_Regular(g);
202 
203  *g1 = cuddT(G);
204  *g0 = cuddE(G);
205  if (Cudd_IsComplement(g)) {
206  *g1 = Cudd_Not(*g1);
207  *g0 = Cudd_Not(*g0);
208  }
209 
210 } /* end of cuddGetBranches */
Definition: cudd.h:270
#define Cudd_Not(node)
Definition: cudd.h:354
#define Cudd_Regular(node)
Definition: cudd.h:384
#define Cudd_IsComplement(node)
Definition: cudd.h:412
#define cuddT(node)
Definition: cuddInt.h:609
#define cuddE(node)
Definition: cuddInt.h:625

Variable Documentation

◆ DD_UNUSED

char rcsid [] DD_UNUSED = "$Id: cuddCof.c,v 1.11 2012/02/05 01:07:18 fabio Exp $"
static

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

FileName [cuddCof.c]

PackageName [cudd]

Synopsis [Cofactoring functions.]

Description [External procedures included in this module:

Internal procedures included in this module:

]

SeeAlso []

Author [Fabio Somenzi]

Copyright [Copyright (c) 1995-2012, 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 82 of file cuddCof.c.