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

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START
DdNode
selectMintermsFromUniverse (DdManager *manager, int *varSeen, double n)
 
static DdNodemintermsFromUniverse (DdManager *manager, DdNode **vars, int numVars, double n, int index)
 
static double bddAnnotateMintermCount (DdManager *manager, DdNode *node, double max, st__table *table)
 
DdNodeCudd_SplitSet (DdManager *manager, DdNode *S, DdNode **xVars, int n, double m)
 
DdNodecuddSplitSetRecur (DdManager *manager, st__table *mtable, int *varSeen, DdNode *p, double n, double max, int index)
 

Function Documentation

static double bddAnnotateMintermCount ( DdManager manager,
DdNode node,
double  max,
st__table table 
)
static

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

Synopsis [Annotates every node in the BDD node with its minterm count.]

Description [Annotates every node in the BDD node with its minterm count. In this function, every node and the minterm count represented by it are stored in a hash table.]

SideEffects [Fills up 'table' with the pair <node,minterm_count>.]

Definition at line 633 of file cuddSplit.c.

638 {
639 
640  DdNode *N,*Nv,*Nnv;
641  register double min_v,min_nv;
642  register double min_N;
643  double *pmin;
644  double *dummy;
645 
646  statLine(manager);
647  N = Cudd_Regular(node);
648  if (cuddIsConstant(N)) {
649  if (node == DD_ONE(manager)) {
650  return(max);
651  } else {
652  return(0.0);
653  }
654  }
655 
656  if ( st__lookup(table, (const char *)node, (char **)&dummy)) {
657  return(*dummy);
658  }
659 
660  Nv = cuddT(N);
661  Nnv = cuddE(N);
662  if (N != node) {
663  Nv = Cudd_Not(Nv);
664  Nnv = Cudd_Not(Nnv);
665  }
666 
667  /* Recur on the two branches. */
668  min_v = bddAnnotateMintermCount(manager,Nv,max,table) / 2.0;
669  if (min_v == (double)CUDD_OUT_OF_MEM)
670  return ((double)CUDD_OUT_OF_MEM);
671  min_nv = bddAnnotateMintermCount(manager,Nnv,max,table) / 2.0;
672  if (min_nv == (double)CUDD_OUT_OF_MEM)
673  return ((double)CUDD_OUT_OF_MEM);
674  min_N = min_v + min_nv;
675 
676  pmin = ABC_ALLOC(double,1);
677  if (pmin == NULL) {
678  manager->errorCode = CUDD_MEMORY_OUT;
679  return((double)CUDD_OUT_OF_MEM);
680  }
681  *pmin = min_N;
682 
683  if ( st__insert(table,(char *)node, (char *)pmin) == st__OUT_OF_MEM) {
684  ABC_FREE(pmin);
685  return((double)CUDD_OUT_OF_MEM);
686  }
687 
688  return(min_N);
689 
690 } /* end of bddAnnotateMintermCount */
#define CUDD_OUT_OF_MEM
Definition: cudd.h:95
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int st__insert(st__table *table, const char *key, char *value)
Definition: st.c:171
#define Cudd_Regular(node)
Definition: cudd.h:397
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
#define statLine(dd)
Definition: cuddInt.h:1037
#define cuddIsConstant(node)
Definition: cuddInt.h:620
static double max
Definition: cuddSubsetHB.c:134
static double bddAnnotateMintermCount(DdManager *manager, DdNode *node, double max, st__table *table)
Definition: cuddSplit.c:633
#define cuddT(node)
Definition: cuddInt.h:636
#define st__OUT_OF_MEM
Definition: st.h:113
int st__lookup(st__table *table, const char *key, char **value)
Definition: st.c:114
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define cuddE(node)
Definition: cuddInt.h:652
#define DD_ONE(dd)
Definition: cuddInt.h:911
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode* Cudd_SplitSet ( DdManager manager,
DdNode S,
DdNode **  xVars,
int  n,
double  m 
)

AutomaticEnd Function********************************************************************

Synopsis [Returns m minterms from a BDD.]

Description [Returns m minterms from a BDD whose support has n variables at most. The procedure tries to create as few extra nodes as possible. The function represented by S depends on at most n of the variables in xVars. Returns a BDD with m minterms of the on-set of S if successful; NULL otherwise.]

SideEffects [None]

SeeAlso []

Definition at line 128 of file cuddSplit.c.

134 {
135  DdNode *result;
136  DdNode *zero, *one;
137  double max, num;
138  st__table *mtable;
139  int *varSeen;
140  int i,index, size;
141 
142  size = manager->size;
143  one = DD_ONE(manager);
144  zero = Cudd_Not(one);
145 
146  /* Trivial cases. */
147  if (m == 0.0) {
148  return(zero);
149  }
150  if (S == zero) {
151  return(NULL);
152  }
153 
154  max = pow(2.0,(double)n);
155  if (m > max)
156  return(NULL);
157 
158  do {
159  manager->reordered = 0;
160  /* varSeen is used to mark the variables that are encountered
161  ** while traversing the BDD S.
162  */
163  varSeen = ABC_ALLOC(int, size);
164  if (varSeen == NULL) {
165  manager->errorCode = CUDD_MEMORY_OUT;
166  return(NULL);
167  }
168  for (i = 0; i < size; i++) {
169  varSeen[i] = -1;
170  }
171  for (i = 0; i < n; i++) {
172  index = (xVars[i])->index;
173  varSeen[manager->invperm[index]] = 0;
174  }
175 
176  if (S == one) {
177  if (m == max) {
178  ABC_FREE(varSeen);
179  return(S);
180  }
181  result = selectMintermsFromUniverse(manager,varSeen,m);
182  if (result)
183  cuddRef(result);
184  ABC_FREE(varSeen);
185  } else {
187  if (mtable == NULL) {
188  (void) fprintf(manager->out,
189  "Cudd_SplitSet: out-of-memory.\n");
190  ABC_FREE(varSeen);
191  manager->errorCode = CUDD_MEMORY_OUT;
192  return(NULL);
193  }
194  /* The nodes of BDD S are annotated by the number of minterms
195  ** in their onset. The node and the number of minterms in its
196  ** onset are stored in mtable.
197  */
198  num = bddAnnotateMintermCount(manager,S,max,mtable);
199  if (m == num) {
200  st__foreach(mtable,cuddStCountfree,NIL(char));
201  st__free_table(mtable);
202  ABC_FREE(varSeen);
203  return(S);
204  }
205 
206  result = cuddSplitSetRecur(manager,mtable,varSeen,S,m,max,0);
207  if (result)
208  cuddRef(result);
209  st__foreach(mtable,cuddStCountfree,NULL);
210  st__free_table(mtable);
211  ABC_FREE(varSeen);
212  }
213  } while (manager->reordered == 1);
214 
215  cuddDeref(result);
216  return(result);
217 
218 } /* end of Cudd_SplitSet */
void st__free_table(st__table *table)
Definition: st.c:81
#define cuddRef(n)
Definition: cuddInt.h:584
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int size
Definition: cuddInt.h:361
enum st__retval cuddStCountfree(char *key, char *value, char *arg)
Definition: cuddUtil.c:2895
int st__ptrcmp(const char *, const char *)
Definition: st.c:480
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
#define NIL(type)
Definition: avl.h:25
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
int reordered
Definition: cuddInt.h:409
static DdNode * one
Definition: cuddDecomp.c:112
FILE * out
Definition: cuddInt.h:441
Definition: st.h:52
static double max
Definition: cuddSubsetHB.c:134
static double bddAnnotateMintermCount(DdManager *manager, DdNode *node, double max, st__table *table)
Definition: cuddSplit.c:633
static int size
Definition: cuddSign.c:86
int st__foreach(st__table *table, enum st__retval(*func)(char *, char *, char *), char *arg)
Definition: st.c:421
#define ABC_FREE(obj)
Definition: abc_global.h:232
int * invperm
Definition: cuddInt.h:388
static int result
Definition: cuddGenetic.c:125
static ABC_NAMESPACE_IMPL_START DdNode * selectMintermsFromUniverse(DdManager *manager, int *varSeen, double n)
Definition: cuddSplit.c:499
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * cuddSplitSetRecur(DdManager *manager, st__table *mtable, int *varSeen, DdNode *p, double n, double max, int index)
Definition: cuddSplit.c:247
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int st__ptrhash(const char *, int)
Definition: st.c:468
static DdNode * zero
Definition: cuddApa.c:100
DdNode* cuddSplitSetRecur ( DdManager manager,
st__table mtable,
int *  varSeen,
DdNode p,
double  n,
double  max,
int  index 
)

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

Synopsis [Implements the recursive step of Cudd_SplitSet.]

Description [Implements the recursive step of Cudd_SplitSet. The procedure recursively traverses the BDD and checks to see if any node satisfies the minterm requirements as specified by 'n'. At any node X, n is compared to the number of minterms in the onset of X's children. If either of the child nodes have exactly n minterms, then that node is returned; else, if n is greater than the onset of one of the child nodes, that node is retained and the difference in the number of minterms is extracted from the other child. In case n minterms can be extracted from constant 1, the algorithm returns the result with at most log(n) nodes.]

SideEffects [The array 'varSeen' is updated at every recursive call to set the variables traversed by the procedure.]

SeeAlso []

Definition at line 247 of file cuddSplit.c.

255 {
256  DdNode *one, *zero, *N, *Nv;
257  DdNode *Nnv, *q, *r, *v;
258  DdNode *result;
259  double *dummy, numT, numE;
260  int variable, positive;
261 
262  statLine(manager);
263  one = DD_ONE(manager);
264  zero = Cudd_Not(one);
265 
266  /* If p is constant, extract n minterms from constant 1. The procedure by
267  ** construction guarantees that minterms will not be extracted from
268  ** constant 0.
269  */
270  if (Cudd_IsConstant(p)) {
271  q = selectMintermsFromUniverse(manager,varSeen,n);
272  return(q);
273  }
274 
275  N = Cudd_Regular(p);
276 
277  /* Set variable as seen. */
278  variable = N->index;
279  varSeen[manager->invperm[variable]] = -1;
280 
281  Nv = cuddT(N);
282  Nnv = cuddE(N);
283  if (Cudd_IsComplement(p)) {
284  Nv = Cudd_Not(Nv);
285  Nnv = Cudd_Not(Nnv);
286  }
287 
288  /* If both the children of 'p' are constants, extract n minterms from a
289  ** constant node.
290  */
291  if (Cudd_IsConstant(Nv) && Cudd_IsConstant(Nnv)) {
292  q = selectMintermsFromUniverse(manager,varSeen,n);
293  if (q == NULL) {
294  return(NULL);
295  }
296  cuddRef(q);
297  r = cuddBddAndRecur(manager,p,q);
298  if (r == NULL) {
299  Cudd_RecursiveDeref(manager,q);
300  return(NULL);
301  }
302  cuddRef(r);
303  Cudd_RecursiveDeref(manager,q);
304  cuddDeref(r);
305  return(r);
306  }
307 
308  /* Lookup the # of minterms in the onset of the node from the table. */
309  if (!Cudd_IsConstant(Nv)) {
310  if (! st__lookup(mtable, (const char *)Nv, (char **)&dummy)) return(NULL);
311  numT = *dummy/(2*(1<<index));
312  } else if (Nv == one) {
313  numT = max/(2*(1<<index));
314  } else {
315  numT = 0;
316  }
317 
318  if (!Cudd_IsConstant(Nnv)) {
319  if (! st__lookup(mtable, (const char *)Nnv, (char **)&dummy)) return(NULL);
320  numE = *dummy/(2*(1<<index));
321  } else if (Nnv == one) {
322  numE = max/(2*(1<<index));
323  } else {
324  numE = 0;
325  }
326 
327  v = cuddUniqueInter(manager,variable,one,zero);
328  cuddRef(v);
329 
330  /* If perfect match. */
331  if (numT == n) {
332  q = cuddBddAndRecur(manager,v,Nv);
333  if (q == NULL) {
334  Cudd_RecursiveDeref(manager,v);
335  return(NULL);
336  }
337  cuddRef(q);
338  Cudd_RecursiveDeref(manager,v);
339  cuddDeref(q);
340  return(q);
341  }
342  if (numE == n) {
343  q = cuddBddAndRecur(manager,Cudd_Not(v),Nnv);
344  if (q == NULL) {
345  Cudd_RecursiveDeref(manager,v);
346  return(NULL);
347  }
348  cuddRef(q);
349  Cudd_RecursiveDeref(manager,v);
350  cuddDeref(q);
351  return(q);
352  }
353  /* If n is greater than numT, extract the difference from the ELSE child
354  ** and retain the function represented by the THEN branch.
355  */
356  if (numT < n) {
357  q = cuddSplitSetRecur(manager,mtable,varSeen,
358  Nnv,(n-numT),max,index+1);
359  if (q == NULL) {
360  Cudd_RecursiveDeref(manager,v);
361  return(NULL);
362  }
363  cuddRef(q);
364  r = cuddBddIteRecur(manager,v,Nv,q);
365  if (r == NULL) {
366  Cudd_RecursiveDeref(manager,q);
367  Cudd_RecursiveDeref(manager,v);
368  return(NULL);
369  }
370  cuddRef(r);
371  Cudd_RecursiveDeref(manager,q);
372  Cudd_RecursiveDeref(manager,v);
373  cuddDeref(r);
374  return(r);
375  }
376  /* If n is greater than numE, extract the difference from the THEN child
377  ** and retain the function represented by the ELSE branch.
378  */
379  if (numE < n) {
380  q = cuddSplitSetRecur(manager,mtable,varSeen,
381  Nv, (n-numE),max,index+1);
382  if (q == NULL) {
383  Cudd_RecursiveDeref(manager,v);
384  return(NULL);
385  }
386  cuddRef(q);
387  r = cuddBddIteRecur(manager,v,q,Nnv);
388  if (r == NULL) {
389  Cudd_RecursiveDeref(manager,q);
390  Cudd_RecursiveDeref(manager,v);
391  return(NULL);
392  }
393  cuddRef(r);
394  Cudd_RecursiveDeref(manager,q);
395  Cudd_RecursiveDeref(manager,v);
396  cuddDeref(r);
397  return(r);
398  }
399 
400  /* None of the above cases; (n < numT and n < numE) and either of
401  ** the Nv, Nnv or both are not constants. If possible extract the
402  ** required minterms the constant branch.
403  */
404  if (Cudd_IsConstant(Nv) && !Cudd_IsConstant(Nnv)) {
405  q = selectMintermsFromUniverse(manager,varSeen,n);
406  if (q == NULL) {
407  Cudd_RecursiveDeref(manager,v);
408  return(NULL);
409  }
410  cuddRef(q);
411  result = cuddBddAndRecur(manager,v,q);
412  if (result == NULL) {
413  Cudd_RecursiveDeref(manager,q);
414  Cudd_RecursiveDeref(manager,v);
415  return(NULL);
416  }
417  cuddRef(result);
418  Cudd_RecursiveDeref(manager,q);
419  Cudd_RecursiveDeref(manager,v);
420  cuddDeref(result);
421  return(result);
422  } else if (!Cudd_IsConstant(Nv) && Cudd_IsConstant(Nnv)) {
423  q = selectMintermsFromUniverse(manager,varSeen,n);
424  if (q == NULL) {
425  Cudd_RecursiveDeref(manager,v);
426  return(NULL);
427  }
428  cuddRef(q);
429  result = cuddBddAndRecur(manager,Cudd_Not(v),q);
430  if (result == NULL) {
431  Cudd_RecursiveDeref(manager,q);
432  Cudd_RecursiveDeref(manager,v);
433  return(NULL);
434  }
435  cuddRef(result);
436  Cudd_RecursiveDeref(manager,q);
437  Cudd_RecursiveDeref(manager,v);
438  cuddDeref(result);
439  return(result);
440  }
441 
442  /* Both Nv and Nnv are not constants. So choose the one which
443  ** has fewer minterms in its onset.
444  */
445  positive = 0;
446  if (numT < numE) {
447  q = cuddSplitSetRecur(manager,mtable,varSeen,
448  Nv,n,max,index+1);
449  positive = 1;
450  } else {
451  q = cuddSplitSetRecur(manager,mtable,varSeen,
452  Nnv,n,max,index+1);
453  }
454 
455  if (q == NULL) {
456  Cudd_RecursiveDeref(manager,v);
457  return(NULL);
458  }
459  cuddRef(q);
460 
461  if (positive) {
462  result = cuddBddAndRecur(manager,v,q);
463  } else {
464  result = cuddBddAndRecur(manager,Cudd_Not(v),q);
465  }
466  if (result == NULL) {
467  Cudd_RecursiveDeref(manager,q);
468  Cudd_RecursiveDeref(manager,v);
469  return(NULL);
470  }
471  cuddRef(result);
472  Cudd_RecursiveDeref(manager,q);
473  Cudd_RecursiveDeref(manager,v);
474  cuddDeref(result);
475 
476  return(result);
477 
478 } /* end of cuddSplitSetRecur */
#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
#define Cudd_Not(node)
Definition: cudd.h:367
#define Cudd_IsConstant(node)
Definition: cudd.h:352
int * variable
#define Cudd_Regular(node)
Definition: cudd.h:397
#define statLine(dd)
Definition: cuddInt.h:1037
#define Cudd_IsComplement(node)
Definition: cudd.h:425
static DdNode * one
Definition: cuddDecomp.c:112
static double max
Definition: cuddSubsetHB.c:134
#define cuddT(node)
Definition: cuddInt.h:636
int st__lookup(st__table *table, const char *key, char **value)
Definition: st.c:114
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
int * invperm
Definition: cuddInt.h:388
static int result
Definition: cuddGenetic.c:125
static ABC_NAMESPACE_IMPL_START DdNode * selectMintermsFromUniverse(DdManager *manager, int *varSeen, double n)
Definition: cuddSplit.c:499
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * cuddBddAndRecur(DdManager *manager, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:886
DdNode * cuddSplitSetRecur(DdManager *manager, st__table *mtable, int *varSeen, DdNode *p, double n, double max, int index)
Definition: cuddSplit.c:247
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
static DdNode * zero
Definition: cuddApa.c:100
DdNode * cuddBddIteRecur(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddBddIte.c:633
static DdNode * mintermsFromUniverse ( DdManager manager,
DdNode **  vars,
int  numVars,
double  n,
int  index 
)
static

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

Synopsis [Recursive procedure to extract n mintems from constant 1.]

Description [Recursive procedure to extract n mintems from constant 1.]

SideEffects [None]

Definition at line 562 of file cuddSplit.c.

568 {
569  DdNode *one, *zero;
570  DdNode *q, *result;
571  double max, max2;
572 
573  statLine(manager);
574  one = DD_ONE(manager);
575  zero = Cudd_Not(one);
576 
577  max = pow(2.0, (double)numVars);
578  max2 = max / 2.0;
579 
580  if (n == max)
581  return(one);
582  if (n == 0.0)
583  return(zero);
584  /* if n == 2^(numVars-1), return a single variable */
585  if (n == max2)
586  return vars[index];
587  else if (n > max2) {
588  /* When n > 2^(numVars-1), a single variable vars[index]
589  ** contains 2^(numVars-1) minterms. The rest are extracted
590  ** from a constant with 1 less variable.
591  */
592  q = mintermsFromUniverse(manager,vars,numVars-1,(n-max2),index+1);
593  if (q == NULL)
594  return(NULL);
595  cuddRef(q);
596  result = cuddBddIteRecur(manager,vars[index],one,q);
597  } else {
598  /* When n < 2^(numVars-1), a literal of variable vars[index]
599  ** is selected. The required n minterms are extracted from a
600  ** constant with 1 less variable.
601  */
602  q = mintermsFromUniverse(manager,vars,numVars-1,n,index+1);
603  if (q == NULL)
604  return(NULL);
605  cuddRef(q);
606  result = cuddBddAndRecur(manager,vars[index],q);
607  }
608 
609  if (result == NULL) {
610  Cudd_RecursiveDeref(manager,q);
611  return(NULL);
612  }
613  cuddRef(result);
614  Cudd_RecursiveDeref(manager,q);
615  cuddDeref(result);
616  return(result);
617 
618 } /* end of mintermsFromUniverse */
#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
#define Cudd_Not(node)
Definition: cudd.h:367
#define statLine(dd)
Definition: cuddInt.h:1037
static DdNode * one
Definition: cuddDecomp.c:112
static double max
Definition: cuddSubsetHB.c:134
static int result
Definition: cuddGenetic.c:125
#define DD_ONE(dd)
Definition: cuddInt.h:911
DdNode * cuddBddAndRecur(DdManager *manager, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:886
static DdNode * mintermsFromUniverse(DdManager *manager, DdNode **vars, int numVars, double n, int index)
Definition: cuddSplit.c:562
static DdNode * zero
Definition: cuddApa.c:100
DdNode * cuddBddIteRecur(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddBddIte.c:633
static DdNode * selectMintermsFromUniverse ( DdManager manager,
int *  varSeen,
double  n 
)
static

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

FileName [cuddSplit.c]

PackageName [cudd]

Synopsis [Returns a subset of minterms from a boolean function.]

Description [External functions included in this modoule:

Internal functions included in this module:

  • cuddSplitSetRecur() </u> Static functions included in this module:

    ]

    SeeAlso []

    Author [Balakrishna Kumthekar]

    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.]AutomaticStart

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

    Synopsis [This function prepares an array of variables which have not been encountered so far when traversing the procedure cuddSplitSetRecur.]

    Description [This function prepares an array of variables which have not been encountered so far when traversing the procedure cuddSplitSetRecur. This array is then used to extract the required number of minterms from a constant

    1. The algorithm guarantees that the size of BDD will be utmost (n).]

    SideEffects [None]

Definition at line 499 of file cuddSplit.c.

503 {
504  int numVars;
505  int i, size, j;
506  DdNode *one, *zero, *result;
507  DdNode **vars;
508 
509  numVars = 0;
510  size = manager->size;
511  one = DD_ONE(manager);
512  zero = Cudd_Not(one);
513 
514  /* Count the number of variables not encountered so far in procedure
515  ** cuddSplitSetRecur.
516  */
517  for (i = size-1; i >= 0; i--) {
518  if(varSeen[i] == 0)
519  numVars++;
520  }
521  vars = ABC_ALLOC(DdNode *, numVars);
522  if (!vars) {
523  manager->errorCode = CUDD_MEMORY_OUT;
524  return(NULL);
525  }
526 
527  j = 0;
528  for (i = size-1; i >= 0; i--) {
529  if(varSeen[i] == 0) {
530  vars[j] = cuddUniqueInter(manager,manager->perm[i],one,zero);
531  cuddRef(vars[j]);
532  j++;
533  }
534  }
535 
536  /* Compute a function which has n minterms and depends on at most
537  ** numVars variables.
538  */
539  result = mintermsFromUniverse(manager,vars,numVars,n, 0);
540  if (result)
541  cuddRef(result);
542 
543  for (i = 0; i < numVars; i++)
544  Cudd_RecursiveDeref(manager,vars[i]);
545  ABC_FREE(vars);
546 
547  return(result);
548 
549 } /* end of selectMintermsFromUniverse */
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
int size
Definition: cuddInt.h:361
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static DdNode * one
Definition: cuddDecomp.c:112
static int size
Definition: cuddSign.c:86
#define ABC_FREE(obj)
Definition: abc_global.h:232
static int result
Definition: cuddGenetic.c:125
#define DD_ONE(dd)
Definition: cuddInt.h:911
int * perm
Definition: cuddInt.h:386
static DdNode * mintermsFromUniverse(DdManager *manager, DdNode **vars, int numVars, double n, int index)
Definition: cuddSplit.c:562
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
static DdNode * zero
Definition: cuddApa.c:100