src/bdd/cudd/cuddLiteral.c File Reference

#include "util_hack.h"
#include "cuddInt.h"
Include dependency graph for cuddLiteral.c:

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 char rcsid[] DD_UNUSED = "$Id: cuddLiteral.c,v 1.1.1.1 2003/02/24 22:23:52 wjiang 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 87 of file cuddLiteral.c.

00091 {
00092     DdNode *res;
00093 
00094     do {
00095         dd->reordered = 0;
00096         res = cuddBddLiteralSetIntersectionRecur(dd,f,g);
00097     } while (dd->reordered == 1);
00098     return(res);
00099 
00100 } /* end of Cudd_bddLiteralSetIntersection */

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

00126 {
00127     DdNode *res, *tmp;
00128     DdNode *F, *G;
00129     DdNode *fc, *gc;
00130     DdNode *one;
00131     DdNode *zero;
00132     unsigned int topf, topg, comple;
00133     int phasef, phaseg;
00134 
00135     statLine(dd);
00136     if (f == g) return(f);
00137 
00138     F = Cudd_Regular(f);
00139     G = Cudd_Regular(g);
00140     one = DD_ONE(dd);
00141 
00142     /* Here f != g. If F == G, then f and g are complementary.
00143     ** Since they are two cubes, this case only occurs when f == v,
00144     ** g == v', and v is a variable or its complement.
00145     */
00146     if (F == G) return(one);
00147 
00148     zero = Cudd_Not(one);
00149     topf = cuddI(dd,F->index);
00150     topg = cuddI(dd,G->index);
00151     /* Look for a variable common to both cubes. If there are none, this
00152     ** loop will stop when the constant node is reached in both cubes.
00153     */
00154     while (topf != topg) {
00155         if (topf < topg) {      /* move down on f */
00156             comple = f != F;
00157             f = cuddT(F);
00158             if (comple) f = Cudd_Not(f);
00159             if (f == zero) {
00160                 f = cuddE(F);
00161                 if (comple) f = Cudd_Not(f);
00162             }
00163             F = Cudd_Regular(f);
00164             topf = cuddI(dd,F->index);
00165         } else if (topg < topf) {
00166             comple = g != G;
00167             g = cuddT(G);
00168             if (comple) g = Cudd_Not(g);
00169             if (g == zero) {
00170                 g = cuddE(G);
00171                 if (comple) g = Cudd_Not(g);
00172             }
00173             G = Cudd_Regular(g);
00174             topg = cuddI(dd,G->index);
00175         }
00176     }
00177 
00178     /* At this point, f == one <=> g == 1. It suffices to test one of them. */
00179     if (f == one) return(one);
00180 
00181     res = cuddCacheLookup2(dd,Cudd_bddLiteralSetIntersection,f,g);
00182     if (res != NULL) {
00183         return(res);
00184     }
00185 
00186     /* Here f and g are both non constant and have the same top variable. */
00187     comple = f != F;
00188     fc = cuddT(F);
00189     phasef = 1;
00190     if (comple) fc = Cudd_Not(fc);
00191     if (fc == zero) {
00192         fc = cuddE(F);
00193         phasef = 0;
00194         if (comple) fc = Cudd_Not(fc);
00195     }
00196     comple = g != G;
00197     gc = cuddT(G);
00198     phaseg = 1;
00199     if (comple) gc = Cudd_Not(gc);
00200     if (gc == zero) {
00201         gc = cuddE(G);
00202         phaseg = 0;
00203         if (comple) gc = Cudd_Not(gc);
00204     }
00205 
00206     tmp = cuddBddLiteralSetIntersectionRecur(dd,fc,gc);
00207     if (tmp == NULL) {
00208         return(NULL);
00209     }
00210 
00211     if (phasef != phaseg) {
00212         res = tmp;
00213     } else {
00214         cuddRef(tmp);
00215         if (phasef == 0) {
00216             res = cuddBddAndRecur(dd,Cudd_Not(dd->vars[F->index]),tmp);
00217         } else {
00218             res = cuddBddAndRecur(dd,dd->vars[F->index],tmp);
00219         }
00220         if (res == NULL) {
00221             Cudd_RecursiveDeref(dd,tmp);
00222             return(NULL);
00223         }
00224         cuddDeref(tmp); /* Just cuddDeref, because it is included in result */
00225     }
00226 
00227     cuddCacheInsert2(dd,Cudd_bddLiteralSetIntersection,f,g,res);
00228 
00229     return(res);
00230 
00231 } /* end of cuddBddLiteralSetIntersectionRecur */


Variable Documentation

char rcsid [] DD_UNUSED = "$Id: cuddLiteral.c,v 1.1.1.1 2003/02/24 22:23:52 wjiang 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 [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.]

Definition at line 49 of file cuddLiteral.c.


Generated on Tue Jan 5 12:18:55 2010 for abc70930 by  doxygen 1.6.1