#include "cuPortInt.h"
Go to the source code of this file.
Data Structures | |
struct | cu_bdd_gen |
Functions | |
bdd_gen_status | bdd_gen_read_status (bdd_gen *gen) |
bdd_gen * | bdd_first_disjoint_cube (bdd_t *fn, array_t **cube) |
boolean | bdd_next_disjoint_cube (bdd_gen *gen_, array_t **cube) |
bdd_gen * | bdd_first_cube (bdd_t *fn, array_t **cube) |
boolean | bdd_next_cube (bdd_gen *gen_, array_t **cube) |
bdd_gen * | bdd_first_node (bdd_t *fn, bdd_node **node) |
boolean | bdd_next_node (bdd_gen *gen, bdd_node **node) |
int | bdd_gen_free (bdd_gen *gen_) |
Variables | |
static char rcsid[] | UNUSED = "$Id: cuPortIter.c,v 1.13 2004/08/13 18:39:31 fabio Exp $" |
Function********************************************************************
Synopsis [Returns the first cube of the function. A generator is also returned, which will iterate over the rest.]
Description [Defines an iterator on the onset of a BDD. Two routines are provided: bdd_first_cube, which extracts one cube from a BDD and returns a bdd_gen structure containing the information necessary to continue the enumeration; and bdd_next_cube, which returns 1 if another cube was found, and 0 otherwise. A cube is represented as an array of bdd_literal (which are integers in {0, 1, 2}), where 0 represents negated literal, 1 for literal, and 2 for don't care. Returns a prime and irredundant cover. A third routine is there to clean up.]
SideEffects []
SeeAlso [bdd_next_cube bdd_gen_free]
Definition at line 239 of file cuPortIter.c.
00240 { 00241 DdManager *manager; 00242 cu_bdd_gen *gen; 00243 int i; 00244 int *icube; 00245 00246 /* Make sure we receive a valid bdd_t. (So to speak.) */ 00247 assert(fn != 0); 00248 00249 manager = (DdManager *)fn->mgr; 00250 00251 /* Initialize the generator. */ 00252 gen = ALLOC(cu_bdd_gen,1); 00253 if (gen == NULL) { 00254 return(NIL(bdd_gen)); 00255 } 00256 gen->manager = manager; 00257 00258 gen->cube = array_alloc(bdd_literal, manager->size); 00259 if (gen->cube == NULL) { 00260 fail("Bdd Package: Out of memory in bdd_first_cube"); 00261 } 00262 00263 gen->ddGen = Cudd_FirstPrime(manager,(DdNode *)fn->node, 00264 (DdNode *)fn->node,&icube); 00265 if (gen->ddGen == NULL) { 00266 fail("Cudd Package: Out of memory in bdd_first_cube"); 00267 } 00268 00269 if (!Cudd_IsGenEmpty(gen->ddGen)) { 00270 /* Copy icube to the array_t cube. */ 00271 for (i = 0; i < manager->size; i++) { 00272 int myconst = icube[i]; 00273 array_insert(bdd_literal, gen->cube, i, myconst); 00274 } 00275 *cube = gen->cube; 00276 } 00277 00278 return(gen); 00279 00280 } /* end of bdd_first_cube */
Function********************************************************************
Synopsis [Returns the first disjoint cube of the function. A generator is also returned, which will iterate over the rest.]
Description [Defines an iterator on the onset of a BDD. Two routines are provided: bdd_first_cube, which extracts one cube from a BDD and returns a bdd_gen structure containing the information necessary to continue the enumeration; and bdd_next_disjoint_cube, which returns 1 if another cube was found, and 0 otherwise. A cube is represented as an array of bdd_literal (which are integers in {0, 1, 2}), where 0 represents negated literal, 1 for literal, and 2 for don't care. Returns a disjoint cover. A third routine is there to clean up.]
SideEffects []
SeeAlso [bdd_next_cube bdd_gen_free]
Definition at line 138 of file cuPortIter.c.
00139 { 00140 DdManager *manager; 00141 cu_bdd_gen *gen; 00142 int i; 00143 int *icube; 00144 CUDD_VALUE_TYPE value; 00145 00146 /* Make sure we receive a valid bdd_t. (So to speak.) */ 00147 assert(fn != 0); 00148 00149 manager = (DdManager *)fn->mgr; 00150 00151 /* Initialize the generator. */ 00152 gen = ALLOC(cu_bdd_gen,1); 00153 if (gen == NULL) { 00154 return(NIL(bdd_gen)); 00155 } 00156 gen->manager = manager; 00157 00158 gen->cube = array_alloc(bdd_literal, manager->size); 00159 if (gen->cube == NULL) { 00160 fail("Bdd Package: Out of memory in bdd_first_cube"); 00161 } 00162 00163 gen->ddGen = Cudd_FirstCube(manager,(DdNode *)fn->node,&icube,&value); 00164 if (gen->ddGen == NULL) { 00165 fail("Cudd Package: Out of memory in bdd_first_cube"); 00166 } 00167 00168 if (!Cudd_IsGenEmpty(gen->ddGen)) { 00169 /* Copy icube to the array_t cube. */ 00170 for (i = 0; i < manager->size; i++) { 00171 int myconst = icube[i]; 00172 array_insert(bdd_literal, gen->cube, i, myconst); 00173 } 00174 *cube = gen->cube; 00175 } 00176 00177 return(gen); 00178 00179 } /* end of bdd_first_disjoint_cube */
Function********************************************************************
Synopsis [Gets the first node in the BDD and returns a generator.]
SideEffects []
SeeAlso [bdd_next_node]
Definition at line 328 of file cuPortIter.c.
00329 { 00330 bdd_manager *manager; 00331 cu_bdd_gen *gen; 00332 00333 /* Make sure we receive a valid bdd_t. (So to speak.) */ 00334 assert(fn != 0); 00335 00336 manager = fn->mgr; 00337 00338 /* Initialize the generator. */ 00339 gen = ALLOC(cu_bdd_gen,1); 00340 if (gen == NULL) return(NULL); 00341 gen->manager = (DdManager *) manager; 00342 gen->cube = NULL; 00343 00344 gen->ddGen = Cudd_FirstNode((DdManager *)manager,(DdNode *)fn->node, 00345 (DdNode **)node); 00346 if (gen->ddGen == NULL) { 00347 fail("Cudd Package: Out of memory in bdd_first_node"); 00348 } 00349 00350 return(gen); 00351 00352 } /* end of bdd_first_node */
int bdd_gen_free | ( | bdd_gen * | gen_ | ) |
Function********************************************************************
Synopsis [Frees up the space used by the generator. Returns an int so that it is easier to fit in a foreach macro. Returns 0 (to make it easy to put in expressions).]
SideEffects []
SeeAlso []
Definition at line 385 of file cuPortIter.c.
00386 { 00387 cu_bdd_gen *gen; 00388 00389 gen = (cu_bdd_gen *)gen_; 00390 if (gen->cube != NULL) array_free(gen->cube); 00391 Cudd_GenFree(gen->ddGen); 00392 FREE(gen); 00393 return(0); 00394 00395 } /* end of bdd_gen_free */
bdd_gen_status bdd_gen_read_status | ( | bdd_gen * | gen | ) |
AutomaticStart AutomaticEnd Function********************************************************************
Synopsis [Returns the status of a bdd generator.]
SideEffects []
SeeAlso [bdd_first_cube bdd_next_cube bdd_gen_free]
Definition at line 106 of file cuPortIter.c.
00107 { 00108 if (Cudd_IsGenEmpty(((cu_bdd_gen *)gen)->ddGen)) { 00109 return bdd_EMPTY; 00110 } 00111 else { 00112 return bdd_NONEMPTY; 00113 } 00114 00115 } /* end of bdd_gen_read_status */
Function********************************************************************
Synopsis [Gets the next cube on the generator. Returns {TRUE, FALSE} when {more, no more}.]
SideEffects []
SeeAlso [bdd_first_prime bdd_gen_free]
Definition at line 294 of file cuPortIter.c.
00295 { 00296 cu_bdd_gen *gen; 00297 int retval; 00298 int *icube; 00299 int i; 00300 00301 gen = (cu_bdd_gen *)gen_; 00302 00303 retval = Cudd_NextPrime(gen->ddGen,&icube); 00304 if (!Cudd_IsGenEmpty(gen->ddGen)) { 00305 /* Copy icube to the array_t cube. */ 00306 for (i = 0; i < gen->manager->size; i++) { 00307 int myconst = icube[i]; 00308 array_insert(bdd_literal, gen->cube, i, myconst); 00309 } 00310 *cube = gen->cube; 00311 } 00312 00313 return(retval); 00314 00315 } /* end of bdd_next_cube */
Function********************************************************************
Synopsis [Gets the next cube on the generator. Returns {TRUE, FALSE} when {more, no more}.]
SideEffects []
SeeAlso [bdd_first_cube bdd_gen_free]
Definition at line 193 of file cuPortIter.c.
00194 { 00195 cu_bdd_gen *gen; 00196 int retval; 00197 int *icube; 00198 CUDD_VALUE_TYPE value; 00199 int i; 00200 00201 gen = (cu_bdd_gen *)gen_; 00202 00203 retval = Cudd_NextCube(gen->ddGen,&icube,&value); 00204 if (!Cudd_IsGenEmpty(gen->ddGen)) { 00205 /* Copy icube to the array_t cube. */ 00206 for (i = 0; i < gen->manager->size; i++) { 00207 int myconst = icube[i]; 00208 array_insert(bdd_literal, gen->cube, i, myconst); 00209 } 00210 *cube = gen->cube; 00211 } 00212 00213 return(retval); 00214 00215 } /* end of bdd_next_disjoint_cube */
Function********************************************************************
Synopsis [Gets the next node in the BDD. Returns {TRUE, FALSE} when {more, no more}.]
SideEffects []
SeeAlso [bdd_first_node]
Definition at line 366 of file cuPortIter.c.
00367 { 00368 return(Cudd_NextNode(((cu_bdd_gen *)gen)->ddGen,(DdNode **)node)); 00369 00370 } /* end of bdd_next_node */
char rcsid [] UNUSED = "$Id: cuPortIter.c,v 1.13 2004/08/13 18:39:31 fabio Exp $" [static] |
CFile***********************************************************************
FileName [cuPortIter.c]
PackageName [cu_port]
Synopsis [Port routines for CU package.]
Description [optional]
SeeAlso [optional]
Author [Abelardo Pardo <abel@vlsi.colorado.edu> ]
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 52 of file cuPortIter.c.