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

Go to the source code of this file.

Functions

DdNodeCudd_bddLiteralSetIntersection (DdManager *dd, DdNode *f, DdNode *g)
 
DdNodecuddBddLiteralSetIntersectionRecur (DdManager *dd, DdNode *f, DdNode *g)
 

Variables

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

Function Documentation

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

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

Synopsis [Computes the intesection of two sets of literals represented as BDDs.]

Description [Computes the intesection of two sets of literals represented as BDDs. Each set is represented as a cube of the literals in the set. The empty set is represented by the constant 1. No variable can be simultaneously present in both phases in a set. Returns a pointer to the BDD representing the intersected sets, if successful; NULL otherwise.]

SideEffects [None]

Definition at line 118 of file cuddLiteral.c.

122 {
123  DdNode *res;
124 
125  do {
126  dd->reordered = 0;
128  } while (dd->reordered == 1);
129  return(res);
130 
131 } /* end of Cudd_bddLiteralSetIntersection */
Definition: cudd.h:278
DdNode * cuddBddLiteralSetIntersectionRecur(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddLiteral.c:153
int reordered
Definition: cuddInt.h:409
DdNode* cuddBddLiteralSetIntersectionRecur ( DdManager dd,
DdNode f,
DdNode g 
)

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

Synopsis [Performs the recursive step of Cudd_bddLiteralSetIntersection.]

Description [Performs the recursive step of Cudd_bddLiteralSetIntersection. Scans the cubes for common variables, and checks whether they agree in phase. Returns a pointer to the resulting cube if successful; NULL otherwise.]

SideEffects [None]

Definition at line 153 of file cuddLiteral.c.

157 {
158  DdNode *res, *tmp;
159  DdNode *F, *G;
160  DdNode *fc, *gc;
161  DdNode *one;
162  DdNode *zero;
163  unsigned int topf, topg, comple;
164  int phasef, phaseg;
165 
166  statLine(dd);
167  if (f == g) return(f);
168 
169  F = Cudd_Regular(f);
170  G = Cudd_Regular(g);
171  one = DD_ONE(dd);
172 
173  /* Here f != g. If F == G, then f and g are complementary.
174  ** Since they are two cubes, this case only occurs when f == v,
175  ** g == v', and v is a variable or its complement.
176  */
177  if (F == G) return(one);
178 
179  zero = Cudd_Not(one);
180  topf = cuddI(dd,F->index);
181  topg = cuddI(dd,G->index);
182  /* Look for a variable common to both cubes. If there are none, this
183  ** loop will stop when the constant node is reached in both cubes.
184  */
185  while (topf != topg) {
186  if (topf < topg) { /* move down on f */
187  comple = f != F;
188  f = cuddT(F);
189  if (comple) f = Cudd_Not(f);
190  if (f == zero) {
191  f = cuddE(F);
192  if (comple) f = Cudd_Not(f);
193  }
194  F = Cudd_Regular(f);
195  topf = cuddI(dd,F->index);
196  } else if (topg < topf) {
197  comple = g != G;
198  g = cuddT(G);
199  if (comple) g = Cudd_Not(g);
200  if (g == zero) {
201  g = cuddE(G);
202  if (comple) g = Cudd_Not(g);
203  }
204  G = Cudd_Regular(g);
205  topg = cuddI(dd,G->index);
206  }
207  }
208 
209  /* At this point, f == one <=> g == 1. It suffices to test one of them. */
210  if (f == one) return(one);
211 
213  if (res != NULL) {
214  return(res);
215  }
216 
217  /* Here f and g are both non constant and have the same top variable. */
218  comple = f != F;
219  fc = cuddT(F);
220  phasef = 1;
221  if (comple) fc = Cudd_Not(fc);
222  if (fc == zero) {
223  fc = cuddE(F);
224  phasef = 0;
225  if (comple) fc = Cudd_Not(fc);
226  }
227  comple = g != G;
228  gc = cuddT(G);
229  phaseg = 1;
230  if (comple) gc = Cudd_Not(gc);
231  if (gc == zero) {
232  gc = cuddE(G);
233  phaseg = 0;
234  if (comple) gc = Cudd_Not(gc);
235  }
236 
237  tmp = cuddBddLiteralSetIntersectionRecur(dd,fc,gc);
238  if (tmp == NULL) {
239  return(NULL);
240  }
241 
242  if (phasef != phaseg) {
243  res = tmp;
244  } else {
245  cuddRef(tmp);
246  if (phasef == 0) {
247  res = cuddBddAndRecur(dd,Cudd_Not(dd->vars[F->index]),tmp);
248  } else {
249  res = cuddBddAndRecur(dd,dd->vars[F->index],tmp);
250  }
251  if (res == NULL) {
252  Cudd_RecursiveDeref(dd,tmp);
253  return(NULL);
254  }
255  cuddDeref(tmp); /* Just cuddDeref, because it is included in result */
256  }
257 
259 
260  return(res);
261 
262 } /* end of cuddBddLiteralSetIntersectionRecur */
#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 * cuddBddLiteralSetIntersectionRecur(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddLiteral.c:153
#define Cudd_Not(node)
Definition: cudd.h:367
void cuddCacheInsert2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g, DdNode *data)
Definition: cuddCache.c:277
#define Cudd_Regular(node)
Definition: cudd.h:397
#define statLine(dd)
Definition: cuddInt.h:1037
DdNode * cuddCacheLookup2(DdManager *table, DD_CTFP op, DdNode *f, DdNode *g)
Definition: cuddCache.c:502
static DdNode * one
Definition: cuddDecomp.c:112
#define cuddT(node)
Definition: cuddInt.h:636
#define cuddI(dd, index)
Definition: cuddInt.h:686
DdHalfWord index
Definition: cudd.h:279
DdNode ** vars
Definition: cuddInt.h:390
#define cuddE(node)
Definition: cuddInt.h:652
DdNode * Cudd_bddLiteralSetIntersection(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddLiteral.c:118
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * cuddBddAndRecur(DdManager *manager, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:886
static DdNode * zero
Definition: cuddApa.c:100

Variable Documentation

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

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

FileName [cuddLiteral.c]

PackageName [cudd]

Synopsis [Functions for manipulation of literal sets represented by BDDs.]

Description [External procedures included in this file:

Internal procedures included in this file:

]

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 80 of file cuddLiteral.c.