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

Go to the source code of this file.

Functions

static int cuddZddDagInt (DdNode *n, st__table *tab)
 
int Cudd_zddDagSize (DdNode *p_node)
 
double Cudd_zddCountMinterm (DdManager *zdd, DdNode *node, int path)
 
void Cudd_zddPrintSubtable (DdManager *table)
 

Variables

static
ABC_NAMESPACE_IMPL_START char
rcsid[] 
DD_UNUSED = "$Id: cuddZddMisc.c,v 1.16 2009/02/20 02:14:58 fabio Exp $"
 

Function Documentation

double Cudd_zddCountMinterm ( DdManager zdd,
DdNode node,
int  path 
)

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

Synopsis [Counts the number of minterms of a ZDD.]

Description [Counts the number of minterms of the ZDD rooted at node. This procedure takes a parameter path that specifies how many variables are in the support of the function. If the procedure runs out of memory, it returns (double) CUDD_OUT_OF_MEM.]

SideEffects [None]

SeeAlso [Cudd_zddCountDouble]

Definition at line 158 of file cuddZddMisc.c.

162 {
163  double dc_var, minterms;
164 
165  dc_var = (double)((double)(zdd->sizeZ) - (double)path);
166  minterms = Cudd_zddCountDouble(zdd, node) / pow(2.0, dc_var);
167  return(minterms);
168 
169 } /* end of Cudd_zddCountMinterm */
int sizeZ
Definition: cuddInt.h:362
double Cudd_zddCountDouble(DdManager *zdd, DdNode *P)
Definition: cuddZddCount.c:176
pset minterms()
int Cudd_zddDagSize ( DdNode p_node)

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

Synopsis [Counts the number of nodes in a ZDD.]

Description [Counts the number of nodes in a ZDD. This function duplicates Cudd_DagSize and is only retained for compatibility.]

SideEffects [None]

SeeAlso [Cudd_DagSize]

Definition at line 127 of file cuddZddMisc.c.

129 {
130 
131  int i;
132  st__table *table;
133 
135  i = cuddZddDagInt(p_node, table);
136  st__free_table(table);
137  return(i);
138 
139 } /* end of Cudd_zddDagSize */
void st__free_table(st__table *table)
Definition: st.c:81
int st__ptrcmp(const char *, const char *)
Definition: st.c:480
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
Definition: st.h:52
static int cuddZddDagInt(DdNode *n, st__table *tab)
Definition: cuddZddMisc.c:265
int st__ptrhash(const char *, int)
Definition: st.c:468
void Cudd_zddPrintSubtable ( DdManager table)

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

Synopsis [Prints the ZDD table.]

Description [Prints the ZDD table for debugging purposes.]

SideEffects [None]

SeeAlso []

Definition at line 184 of file cuddZddMisc.c.

186 {
187  int i, j;
188  DdNode *z1, *z1_next, *base;
189  DdSubtable *ZSubTable;
190 
191  base = table->one;
192  for (i = table->sizeZ - 1; i >= 0; i--) {
193  ZSubTable = &(table->subtableZ[i]);
194  printf("subtable[%d]:\n", i);
195  for (j = ZSubTable->slots - 1; j >= 0; j--) {
196  z1 = ZSubTable->nodelist[j];
197  while (z1 != NIL(DdNode)) {
198  (void) fprintf(table->out,
199 #if SIZEOF_VOID_P == 8
200  "ID = 0x%lx\tindex = %u\tr = %u\t",
201  (ptruint) z1 / (ptruint) sizeof(DdNode),
202  z1->index, z1->ref);
203 #else
204  "ID = 0x%x\tindex = %hu\tr = %hu\t",
205  (ptruint) z1 / (ptruint) sizeof(DdNode),
206  z1->index, z1->ref);
207 #endif
208  z1_next = cuddT(z1);
209  if (Cudd_IsConstant(z1_next)) {
210  (void) fprintf(table->out, "T = %d\t\t",
211  (z1_next == base));
212  }
213  else {
214 #if SIZEOF_VOID_P == 8
215  (void) fprintf(table->out, "T = 0x%lx\t",
216  (ptruint) z1_next / (ptruint) sizeof(DdNode));
217 #else
218  (void) fprintf(table->out, "T = 0x%x\t",
219  (ptruint) z1_next / (ptruint) sizeof(DdNode));
220 #endif
221  }
222  z1_next = cuddE(z1);
223  if (Cudd_IsConstant(z1_next)) {
224  (void) fprintf(table->out, "E = %d\n",
225  (z1_next == base));
226  }
227  else {
228 #if SIZEOF_VOID_P == 8
229  (void) fprintf(table->out, "E = 0x%lx\n",
230  (ptruint) z1_next / (ptruint) sizeof(DdNode));
231 #else
232  (void) fprintf(table->out, "E = 0x%x\n",
233  (ptruint) z1_next / (ptruint) sizeof(DdNode));
234 #endif
235  }
236 
237  z1_next = z1->next;
238  z1 = z1_next;
239  }
240  }
241  }
242  putchar('\n');
243 
244 } /* Cudd_zddPrintSubtable */
DdHalfWord ref
Definition: cudd.h:280
Definition: cudd.h:278
#define z1
Definition: extraBdd.h:78
#define Cudd_IsConstant(node)
Definition: cudd.h:352
#define NIL(type)
Definition: avl.h:25
struct DdNode DdNode
Definition: cudd.h:270
ABC_PTRUINT_T ptruint
Definition: cuddInt.h:261
#define SIZEOF_VOID_P
Definition: cudd.h:78
FILE * out
Definition: cuddInt.h:441
DdNode * next
Definition: cudd.h:281
DdNode ** nodelist
Definition: cuddInt.h:327
#define cuddT(node)
Definition: cuddInt.h:636
int sizeZ
Definition: cuddInt.h:362
DdHalfWord index
Definition: cudd.h:279
unsigned int slots
Definition: cuddInt.h:329
DdNode * one
Definition: cuddInt.h:345
#define cuddE(node)
Definition: cuddInt.h:652
DdSubtable * subtableZ
Definition: cuddInt.h:366
static int cuddZddDagInt ( DdNode n,
st__table tab 
)
static

AutomaticStart

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

Synopsis [Performs the recursive step of Cudd_zddDagSize.]

Description [Performs the recursive step of Cudd_zddDagSize. Does not check for out-of-memory conditions.]

SideEffects [None]

SeeAlso []

Definition at line 265 of file cuddZddMisc.c.

268 {
269  if (n == NIL(DdNode))
270  return(0);
271 
272  if ( st__is_member(tab, (char *)n) == 1)
273  return(0);
274 
275  if (Cudd_IsConstant(n))
276  return(0);
277 
278  (void) st__insert(tab, (char *)n, NIL(char));
279  return(1 + cuddZddDagInt(cuddT(n), tab) +
280  cuddZddDagInt(cuddE(n), tab));
281 
282 } /* cuddZddDagInt */
Definition: cudd.h:278
int st__insert(st__table *table, const char *key, char *value)
Definition: st.c:171
#define Cudd_IsConstant(node)
Definition: cudd.h:352
#define st__is_member(table, key)
Definition: st.h:70
#define NIL(type)
Definition: avl.h:25
static int cuddZddDagInt(DdNode *n, st__table *tab)
Definition: cuddZddMisc.c:265
#define cuddT(node)
Definition: cuddInt.h:636
#define cuddE(node)
Definition: cuddInt.h:652

Variable Documentation

ABC_NAMESPACE_IMPL_START char rcsid [] DD_UNUSED = "$Id: cuddZddMisc.c,v 1.16 2009/02/20 02:14:58 fabio Exp $"
static

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

FileName [cuddZddMisc.c]

PackageName [cudd]

Synopsis [Miscellaneous utility functions for ZDDs.]

Description [External procedures included in this module:

Internal procedures included in this module:

Static procedures included in this module:

]

SeeAlso []

Author [Hyong-Kyoon Shin, In-Ho Moon]

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 90 of file cuddZddMisc.c.