#include "util.h"
#include "cuddInt.h"
Go to the source code of this file.
Functions | |
DdNode * | Cudd_bddLiteralSetIntersection (DdManager *dd, DdNode *f, DdNode *g) |
DdNode * | cuddBddLiteralSetIntersectionRecur (DdManager *dd, DdNode *f, DdNode *g) |
Variables | |
static char rcsid[] | DD_UNUSED = "$Id: cuddLiteral.c,v 1.8 2004/08/13 18:04:50 fabio Exp $" |
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 114 of file cuddLiteral.c.
00118 { 00119 DdNode *res; 00120 00121 do { 00122 dd->reordered = 0; 00123 res = cuddBddLiteralSetIntersectionRecur(dd,f,g); 00124 } while (dd->reordered == 1); 00125 return(res); 00126 00127 } /* end of Cudd_bddLiteralSetIntersection */
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 149 of file cuddLiteral.c.
00153 { 00154 DdNode *res, *tmp; 00155 DdNode *F, *G; 00156 DdNode *fc, *gc; 00157 DdNode *one; 00158 DdNode *zero; 00159 unsigned int topf, topg, comple; 00160 int phasef, phaseg; 00161 00162 statLine(dd); 00163 if (f == g) return(f); 00164 00165 F = Cudd_Regular(f); 00166 G = Cudd_Regular(g); 00167 one = DD_ONE(dd); 00168 00169 /* Here f != g. If F == G, then f and g are complementary. 00170 ** Since they are two cubes, this case only occurs when f == v, 00171 ** g == v', and v is a variable or its complement. 00172 */ 00173 if (F == G) return(one); 00174 00175 zero = Cudd_Not(one); 00176 topf = cuddI(dd,F->index); 00177 topg = cuddI(dd,G->index); 00178 /* Look for a variable common to both cubes. If there are none, this 00179 ** loop will stop when the constant node is reached in both cubes. 00180 */ 00181 while (topf != topg) { 00182 if (topf < topg) { /* move down on f */ 00183 comple = f != F; 00184 f = cuddT(F); 00185 if (comple) f = Cudd_Not(f); 00186 if (f == zero) { 00187 f = cuddE(F); 00188 if (comple) f = Cudd_Not(f); 00189 } 00190 F = Cudd_Regular(f); 00191 topf = cuddI(dd,F->index); 00192 } else if (topg < topf) { 00193 comple = g != G; 00194 g = cuddT(G); 00195 if (comple) g = Cudd_Not(g); 00196 if (g == zero) { 00197 g = cuddE(G); 00198 if (comple) g = Cudd_Not(g); 00199 } 00200 G = Cudd_Regular(g); 00201 topg = cuddI(dd,G->index); 00202 } 00203 } 00204 00205 /* At this point, f == one <=> g == 1. It suffices to test one of them. */ 00206 if (f == one) return(one); 00207 00208 res = cuddCacheLookup2(dd,Cudd_bddLiteralSetIntersection,f,g); 00209 if (res != NULL) { 00210 return(res); 00211 } 00212 00213 /* Here f and g are both non constant and have the same top variable. */ 00214 comple = f != F; 00215 fc = cuddT(F); 00216 phasef = 1; 00217 if (comple) fc = Cudd_Not(fc); 00218 if (fc == zero) { 00219 fc = cuddE(F); 00220 phasef = 0; 00221 if (comple) fc = Cudd_Not(fc); 00222 } 00223 comple = g != G; 00224 gc = cuddT(G); 00225 phaseg = 1; 00226 if (comple) gc = Cudd_Not(gc); 00227 if (gc == zero) { 00228 gc = cuddE(G); 00229 phaseg = 0; 00230 if (comple) gc = Cudd_Not(gc); 00231 } 00232 00233 tmp = cuddBddLiteralSetIntersectionRecur(dd,fc,gc); 00234 if (tmp == NULL) { 00235 return(NULL); 00236 } 00237 00238 if (phasef != phaseg) { 00239 res = tmp; 00240 } else { 00241 cuddRef(tmp); 00242 if (phasef == 0) { 00243 res = cuddBddAndRecur(dd,Cudd_Not(dd->vars[F->index]),tmp); 00244 } else { 00245 res = cuddBddAndRecur(dd,dd->vars[F->index],tmp); 00246 } 00247 if (res == NULL) { 00248 Cudd_RecursiveDeref(dd,tmp); 00249 return(NULL); 00250 } 00251 cuddDeref(tmp); /* Just cuddDeref, because it is included in result */ 00252 } 00253 00254 cuddCacheInsert2(dd,Cudd_bddLiteralSetIntersection,f,g,res); 00255 00256 return(res); 00257 00258 } /* end of cuddBddLiteralSetIntersectionRecur */
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 76 of file cuddLiteral.c.