Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

cuddBdd.h

Go to the documentation of this file.
00001 
00037 #ifndef _BDD
00038 #define _BDD
00039 
00040 /*---------------------------------------------------------------------------*/
00041 /* Nested includes                                                           */
00042 /*---------------------------------------------------------------------------*/
00043 
00044 #include "var_set.h"
00045 
00046 /*---------------------------------------------------------------------------*/
00047 /* Constant declarations                                                     */
00048 /*---------------------------------------------------------------------------*/
00049 
00050 
00051 /*---------------------------------------------------------------------------*/
00052 /* Stucture declarations                                                     */
00053 /*---------------------------------------------------------------------------*/
00054 
00055 #define boolean   int
00056 /*
00057  *    foreach macro in the most misesque tradition
00058  *    bdd_gen_free always returns 0
00059  *
00060  *    CAUTION: in the context of the port to the CUDD package, it is assumed that
00061  *    dynamic reordering will not occur while there are open generators.  It is 
00062  *    the user's responsibility to make sure dynamic reordering doesn't occur.
00063  *    As long as new nodes are not created during generation, and you don't 
00064  *    explicitly call dynamic reordering, you should be okay.
00065  */
00066 
00067 /*
00068  *    foreach_bdd_cube(fn, gen, cube)
00069  *    bdd_t *fn;
00070  *    bdd_gen *gen;
00071  *    array_t *cube;  - return
00072  *
00073  *    foreach_bdd_cube(fn, gen, cube) {
00074  *        ...
00075  *    }
00076  */
00077 #define foreach_bdd_cube(fn, gen, cube)\
00078   for((gen) = bdd_first_cube(fn, &cube);\
00079       bdd_is_gen_empty(gen) ? bdd_gen_free(gen) : TRUE;\
00080       (void) bdd_next_cube(gen, &cube))
00081 
00082 /*
00083  *    foreach_bdd_node(fn, gen, node)
00084  *    bdd_t *fn;
00085  *    bdd_gen *gen;
00086  *    bdd_node *node; - return
00087  */
00088 #define foreach_bdd_node(fn, gen, node)\
00089   for((gen) = bdd_first_node(fn, &node);\
00090       bdd_is_gen_empty(gen) ? bdd_gen_free(gen) : TRUE;\
00091       (void) bdd_next_node(gen, &node))
00092 
00093 /*
00094  * Default settings.
00095  */
00096 #define BDD_NO_LIMIT                      ((1<<30)-2)
00097 #define BDD_DFLT_ITE_ON                   TRUE
00098 #define BDD_DFLT_ITE_RESIZE_AT            75
00099 #define BDD_DFLT_ITE_MAX_SIZE             1000000
00100 #define BDD_DFLT_ITE_CONST_ON             TRUE
00101 #define BDD_DFLT_ITE_CONST_RESIZE_AT      75
00102 #define BDD_DFLT_ITE_CONST_MAX_SIZE       1000000
00103 #define BDD_DFLT_ADHOC_ON                 TRUE
00104 #define BDD_DFLT_ADHOC_RESIZE_AT          0
00105 #define BDD_DFLT_ADHOC_MAX_SIZE           10000000
00106 #define BDD_DFLT_GARB_COLLECT_ON          TRUE
00107 #define BDD_DFLT_DAEMON                   NIL(void)
00108 #define BDD_DFLT_MEMORY_LIMIT             BDD_NO_LIMIT   
00109 #define BDD_DFLT_NODE_RATIO               2.0
00110 #define BDD_DFLT_INIT_BLOCKS              10
00111 
00112 
00113 /*---------------------------------------------------------------------------*/
00114 /* Type declarations                                                         */
00115 /*---------------------------------------------------------------------------*/
00116 
00117 typedef struct DdManager bdd_manager;         /* referenced via a pointer only */
00118 typedef unsigned int bdd_variableId;    /* the id of the variable in a bdd node */
00119 typedef struct DdNode bdd_node;                 /* referenced via a pointer only */
00120 typedef int bdd_literal;                  /* integers in the set { 0, 1, 2 } */
00121 
00122 /* This is to avoid problems with the mnemosyne library, which redefines
00123 ** free.
00124 */
00125 #ifdef MNEMOSYNE
00126 #undef free
00127 #endif
00128 
00129 typedef struct bdd_t {
00130     boolean free;                         /* TRUE if this is free, FALSE otherwise ... */
00131     bdd_node *node;                             /* ptr to the top node of the function */
00132     bdd_manager *mgr;                           /* the manager */
00133 } bdd_t;  
00134 
00135 /* 
00136  * Initialization data structure.   Not supported in CMU package.
00137  */
00138 typedef struct bdd_mgr_init {
00139     struct {
00140         boolean on;                   /* TRUE/FALSE: is the cache on */
00141         unsigned int resize_at;       /* percentage at which to resize (e.g. 85% is 85); doesn't apply to adhoc */
00142         unsigned int max_size;        /* max allowable number of buckets; for adhoc, max allowable number of entries */
00143     } ITE_cache,
00144       ITE_const_cache,
00145       adhoc_cache;
00146     struct {
00147       boolean on;                     /* TRUE/FALSE: is the garbage collector on */
00148     } garbage_collector;
00149     struct {
00150       void (*daemon)();               /* used for callback when memory limit exceeded */
00151       unsigned int limit;             /* upper bound on memory allocated by the manager; in megabytes */
00152     } memory;
00153     struct {
00154       float ratio;                    /* allocate new bdd_nodes to achieve ratio of used to unused nodes */
00155       unsigned int init_blocks;       /* number of bdd_nodeBlocks initially allocated */
00156     } nodes;
00157 } bdd_mgr_init;
00158 
00159 /*
00160  * Match types for BDD minimization.
00161  */
00162 typedef enum {
00163     BDD_MIN_TSM,    /* two-side match */
00164     BDD_MIN_OSM,    /* one-side match */
00165     BDD_MIN_OSDM    /* one-side DC match */
00166 } bdd_min_match_type_t;
00167 
00168 /*
00169  * Statistics and Other Queries
00170  */
00171 typedef struct bdd_cache_stats {
00172     unsigned int hits;
00173     unsigned int misses;
00174     unsigned int collisions;
00175     unsigned int inserts;
00176 } bdd_cache_stats;
00177 
00178 typedef struct bdd_stats {
00179     struct {
00180   bdd_cache_stats hashtable;   /* the unique table; collisions and inserts fields not used */ 
00181   bdd_cache_stats itetable;
00182   bdd_cache_stats consttable;
00183   bdd_cache_stats adhoc;
00184     } cache;    /* various cache statistics */
00185     struct {
00186   unsigned int calls;
00187   struct {
00188       unsigned int trivial;
00189       unsigned int cached;
00190       unsigned int full;
00191   } returns;
00192     } ITE_ops,
00193       ITE_constant_ops,
00194       adhoc_ops;
00195     struct {
00196   unsigned int total;
00197     } blocks;   /* bdd_nodeBlock count */
00198     struct {
00199   unsigned int used;
00200   unsigned int unused;
00201   unsigned int total;
00202         unsigned int peak;
00203     } nodes;    /* bdd_node count */
00204     struct {
00205   unsigned int used;
00206   unsigned int unused;
00207   unsigned int total;
00208         unsigned int blocks; 
00209     } extptrs;    /* bdd_t count */
00210     struct {
00211   unsigned int times;     /* the number of times the garbage-collector has run */
00212         unsigned int nodes_collected; /* cumulative number of nodes collected over life of manager */
00213         long runtime;           /* cumulative CPU time spent garbage collecting */
00214     } gc;
00215     struct {
00216         int first_sbrk;         /* value of sbrk at start of manager; used to analyze memory usage */
00217         int last_sbrk;          /* value of last sbrk (see "man sbrk") fetched; used to analyze memory usage */
00218         unsigned int manager;
00219   unsigned int nodes;
00220   unsigned int hashtable;
00221   unsigned int ext_ptrs;
00222   unsigned int ITE_cache;
00223   unsigned int ITE_const_cache;
00224   unsigned int adhoc_cache;
00225   unsigned int total;
00226     } memory;           /* memory usage */
00227 } bdd_stats;
00228 
00229 /*
00230  * Traversal of BDD Formulas
00231  */
00232 
00233 typedef struct bdd_gen bdd_gen;
00234 
00235 /*
00236  *    These are the hooks for stuff that uses bdd's
00237  *
00238  *    There are three hooks, and users may use them in whatever
00239  *    way they wish; these hooks are guaranteed to never be used
00240  *    by the bdd package.
00241  */
00242 typedef struct bdd_external_hooks {
00243     char *network;
00244     char *mdd;
00245     char *undef1;
00246 } bdd_external_hooks;
00247 
00248 /*
00249  * Dynamic reordering.
00250  */
00251 typedef enum {
00252     BDD_REORDER_SIFT,
00253     BDD_REORDER_WINDOW,
00254     BDD_REORDER_NONE,
00255     BDD_REORDER_SAME,
00256     BDD_REORDER_RANDOM,
00257     BDD_REORDER_RANDOM_PIVOT,
00258     BDD_REORDER_SIFT_CONVERGE,
00259     BDD_REORDER_SYMM_SIFT,
00260     BDD_REORDER_SYMM_SIFT_CONV,
00261     BDD_REORDER_WINDOW2,
00262     BDD_REORDER_WINDOW3,
00263     BDD_REORDER_WINDOW4,
00264     BDD_REORDER_WINDOW2_CONV,
00265     BDD_REORDER_WINDOW3_CONV,
00266     BDD_REORDER_WINDOW4_CONV,
00267     BDD_REORDER_GROUP_SIFT,
00268     BDD_REORDER_GROUP_SIFT_CONV,
00269     BDD_REORDER_ANNEALING,
00270     BDD_REORDER_GENETIC
00271 } bdd_reorder_type_t;
00272 
00273 
00274 /*---------------------------------------------------------------------------*/
00275 /* Variable declarations                                                     */
00276 /*---------------------------------------------------------------------------*/
00277 
00278 
00279 /*---------------------------------------------------------------------------*/
00280 /* Macro declarations                                                        */
00281 /*---------------------------------------------------------------------------*/
00282 
00283 /*
00284  * BDD Manager Allocation And Destruction
00285  */
00286 EXTERN void bdd_end ARGS((bdd_manager *));
00287 EXTERN void bdd_register_daemon ARGS((bdd_manager *, void (*daemon)()));
00288 EXTERN void bdd_set_mgr_init_dflts ARGS((bdd_mgr_init *));
00289 EXTERN bdd_manager *bdd_start ARGS((int));
00290 EXTERN bdd_manager *bdd_start_with_params ARGS((int, bdd_mgr_init *));
00291 
00292 /*
00293  * BDD Variable Allocation
00294  */
00295 EXTERN bdd_t *bdd_create_variable ARGS((bdd_manager *));    
00296 EXTERN bdd_t *bdd_get_variable ARGS((bdd_manager *, bdd_variableId)); 
00297 
00298 /*
00299  * BDD Formula Management
00300  */
00301 EXTERN bdd_t *bdd_dup ARGS((bdd_t *));
00302 EXTERN void bdd_free ARGS((bdd_t *));
00303 
00304 /* 
00305  * Operations on BDD Formulas
00306  */
00307 EXTERN bdd_t *bdd_and ARGS((bdd_t *, bdd_t *, boolean, boolean));
00308 EXTERN bdd_t *bdd_and_smooth ARGS((bdd_t *, bdd_t *, array_t *));
00309 EXTERN bdd_t *bdd_between ARGS((bdd_t *, bdd_t *));
00310 EXTERN bdd_t *bdd_cofactor ARGS((bdd_t *, bdd_t *));
00311 EXTERN bdd_t *bdd_compose ARGS((bdd_t *, bdd_t *, bdd_t *));
00312 EXTERN bdd_t *bdd_consensus ARGS((bdd_t *, array_t *));
00313 EXTERN bdd_t *bdd_cproject ARGS((bdd_t *, array_t *));
00314 EXTERN bdd_t *bdd_else ARGS((bdd_t *));
00315 EXTERN bdd_t *bdd_ite ARGS((bdd_t *, bdd_t *, bdd_t *, boolean, boolean, boolean));
00316 EXTERN bdd_t *bdd_minimize ARGS((bdd_t *, bdd_t *));
00317 EXTERN bdd_t *bdd_minimize_with_params ARGS((bdd_t *, bdd_t *, bdd_min_match_type_t, boolean, boolean, boolean));
00318 EXTERN bdd_t *bdd_not ARGS((bdd_t *));
00319 EXTERN bdd_t *bdd_one ARGS((bdd_manager *));
00320 EXTERN bdd_t *bdd_or ARGS((bdd_t *, bdd_t *, boolean, boolean));
00321 EXTERN bdd_t *bdd_smooth ARGS((bdd_t *, array_t *));
00322 EXTERN bdd_t *bdd_substitute ARGS((bdd_t *, array_t *, array_t *));
00323 EXTERN bdd_t *bdd_then ARGS((bdd_t *));
00324 EXTERN bdd_t *bdd_top_var ARGS((bdd_t *));
00325 EXTERN bdd_t *bdd_xnor ARGS((bdd_t *, bdd_t *));
00326 EXTERN bdd_t *bdd_xor ARGS((bdd_t *, bdd_t *));
00327 EXTERN bdd_t *bdd_zero ARGS((bdd_manager *));
00328 
00329 /*
00330  * Queries about BDD Formulas
00331  */
00332 EXTERN boolean bdd_equal ARGS((bdd_t *, bdd_t *));
00333 EXTERN boolean bdd_is_cube ARGS((bdd_t *));
00334 EXTERN boolean bdd_is_tautology ARGS((bdd_t *, boolean));
00335 EXTERN boolean bdd_leq ARGS((bdd_t *, bdd_t *, boolean, boolean));
00336 
00337 EXTERN double bdd_count_onset ARGS((bdd_t *, array_t *));
00338 EXTERN bdd_manager *bdd_get_manager ARGS((bdd_t *));
00339 EXTERN bdd_node *bdd_get_node ARGS((bdd_t *, boolean *));
00340 EXTERN void bdd_get_stats ARGS((bdd_manager *, bdd_stats *));
00341 EXTERN var_set_t *bdd_get_support ARGS((bdd_t *));
00342 EXTERN array_t *bdd_get_varids ARGS((array_t *));
00343 EXTERN unsigned int bdd_num_vars ARGS((bdd_manager *));
00344 EXTERN void bdd_print ARGS((bdd_t *));
00345 EXTERN void bdd_print_stats ARGS((bdd_stats, FILE *));
00346 EXTERN int bdd_size ARGS((bdd_t *));
00347 EXTERN bdd_variableId bdd_top_var_id ARGS((bdd_t *));
00348 EXTERN bdd_t *bdd_create_variable_after ARGS((bdd_manager *, bdd_variableId));
00349 EXTERN bdd_variableId bdd_get_id_from_level ARGS((bdd_manager *, long));
00350 EXTERN long bdd_top_var_level ARGS((bdd_manager *, bdd_t *));
00351 
00352 EXTERN int bdd_gen_free ARGS((bdd_gen *));
00353 
00354 /*
00355  * These are NOT to be used directly; only indirectly in the macros.
00356  */
00357 EXTERN bdd_gen *bdd_first_cube ARGS((bdd_t *, array_t **));
00358 EXTERN boolean bdd_next_cube ARGS((bdd_gen *, array_t **));
00359 EXTERN bdd_gen *bdd_first_node ARGS((bdd_t *, bdd_node **));
00360 EXTERN boolean bdd_next_node ARGS((bdd_gen *, bdd_node **));
00361 EXTERN boolean bdd_is_gen_empty ARGS((bdd_gen *));
00362 
00363 /* 
00364  * Miscellaneous
00365  */
00366 EXTERN void bdd_set_gc_mode ARGS((bdd_manager *, boolean));
00367 
00368 EXTERN bdd_external_hooks *bdd_get_external_hooks ARGS((bdd_manager *));
00369 
00370 EXTERN void bdd_dynamic_reordering ARGS((bdd_manager *, bdd_reorder_type_t));
00371 
00372 EXTERN int bdd_read_reordering_flag ARGS((bdd_manager *));
00373 
00374 #endif /* _BDD */

Generated on Fri Jan 14 08:28:58 2005 for SystemC2.1beta11(excludingMSLib)(IncludingSCV)\nProvidedby:www.openverificationfoundation.org by doxygen1.2.18