1 /**CHeaderFile*****************************************************************
7 Synopsis [Functions to read in and write out BDDs, ADDs
8 and CNF formulas from and to files.]
12 Author [Gianpiero Cabodi and Stefano Quer]
15 Copyright (c) 2002 by Politecnico di Torino.
16 All Rights Reserved. This software is for educational purposes only.
17 Permission is given to academic institutions to use, copy, and modify
18 this software and its documentation provided that this introductory
19 message is not removed, that this software and its documentation is
20 used for the institutions' internal research and educational purposes,
21 and that no monies are exchanged. No guarantee is expressed or implied
22 by the distribution of this code.
23 Send bug-reports and/or questions to:
24 {gianpiero.cabodi,stefano.quer}@polito.it.
27 ******************************************************************************/
36 /*---------------------------------------------------------------------------*/
38 /*---------------------------------------------------------------------------*/
47 /*---------------------------------------------------------------------------*/
48 /* Constant declarations */
49 /*---------------------------------------------------------------------------*/
52 * Dddmp format version
55 #define DDDMP_VERSION "DDDMP-2.0"
58 * Returned values (for theorically ALL the function of the package)
61 #define DDDMP_FAILURE ((int) 0)
62 #define DDDMP_SUCCESS ((int) 1)
65 * Format modes for DD (BDD and ADD) files
68 #define DDDMP_MODE_TEXT ((int)'A')
69 #define DDDMP_MODE_BINARY ((int)'B')
70 #define DDDMP_MODE_DEFAULT ((int)'D')
72 /*---------------------------------------------------------------------------*/
73 /* Structure declarations */
74 /*---------------------------------------------------------------------------*/
76 /*---------------------------------------------------------------------------*/
77 /* Type declarations */
78 /*---------------------------------------------------------------------------*/
80 /**Enum************************************************************************
82 Synopsis [Format modes for storing CNF files]
84 Description [Type supported for storing BDDs into CNF
86 Used internally to select the proper storing format:
87 DDDMP_CNF_MODE_NODE: create a CNF temporary variables for
89 DDDMP_CNF_MODE_MAXTERM: no temporary variables
90 DDDMP_CNF_MODE_BEST: trade-off between the two previous methods
93 ******************************************************************************/
97 DDDMP_CNF_MODE_MAXTERM
,
99 } Dddmp_DecompCnfStoreType
;
101 /**Enum************************************************************************
103 Synopsis [Format modes for loading CNF files.]
105 Description [Type supported for loading CNF formulas into BDDs.
106 Used internally to select the proper returning format:
109 ******************************************************************************/
112 DDDMP_CNF_MODE_NO_CONJ
,
113 DDDMP_CNF_MODE_NO_QUANT
,
114 DDDMP_CNF_MODE_CONJ_QUANT
115 } Dddmp_DecompCnfLoadType
;
117 /**Enum************************************************************************
119 Synopsis [Type for supported decomposition types.]
121 Description [Type for supported decomposition types.
122 Used internally to select the proper type (bdd, add, ...).
123 Given externally as information fule content.
126 ******************************************************************************/
136 /**Enum************************************************************************
138 Synopsis [Type for variable extra info.]
140 Description [Type for variable extra info. Used to specify info stored
143 ******************************************************************************/
153 /**Enum************************************************************************
155 Synopsis [Type for variable matching in BDD load.]
159 ******************************************************************************/
163 DDDMP_VAR_MATCHPERMIDS
,
164 DDDMP_VAR_MATCHAUXIDS
,
165 DDDMP_VAR_MATCHNAMES
,
167 } Dddmp_VarMatchType
;
169 /**Enum************************************************************************
171 Synopsis [Type for BDD root matching in BDD load.]
175 ******************************************************************************/
178 DDDMP_ROOT_MATCHNAMES
,
180 } Dddmp_RootMatchType
;
182 typedef struct Dddmp_Hdr_s Dddmp_Hdr_t
;
184 /*---------------------------------------------------------------------------*/
185 /* Variable declarations */
186 /*---------------------------------------------------------------------------*/
188 /*---------------------------------------------------------------------------*/
189 /* Macro declarations */
190 /*---------------------------------------------------------------------------*/
192 /**Macro***********************************************************************
194 Synopsis [Checks for fatal bugs]
196 Description [Conditional safety assertion. It prints out the file
197 name and line number where the fatal error occurred.
198 Messages are printed out on stderr.
205 ******************************************************************************/
208 # define Dddmp_Assert(expr,errMsg) \
211 fprintf (stderr, "FATAL ERROR: %s\n", errMsg); \
212 fprintf (stderr, " File %s -> Line %d\n", \
213 __FILE__, __LINE__); \
215 exit (DDDMP_FAILURE); \
219 # define Dddmp_Assert(expr,errMsg) \
223 /**Macro***********************************************************************
225 Synopsis [Checks for Warnings: If expr==1 it prints out the warning
234 ******************************************************************************/
236 #define Dddmp_Warning(expr,errMsg) \
239 fprintf (stderr, "WARNING: %s\n", errMsg); \
240 fprintf (stderr, " File %s -> Line %d\n", \
241 __FILE__, __LINE__); \
246 /**Macro***********************************************************************
248 Synopsis [Checks for fatal bugs and return the DDDMP_FAILURE flag.]
256 ******************************************************************************/
258 #define Dddmp_CheckAndReturn(expr,errMsg) \
261 fprintf (stderr, "FATAL ERROR: %s\n", errMsg); \
262 fprintf (stderr, " File %s -> Line %d\n", \
263 __FILE__, __LINE__); \
265 return (DDDMP_FAILURE); \
269 /**Macro***********************************************************************
271 Synopsis [Checks for fatal bugs and go to the label to deal with
281 ******************************************************************************/
283 #define Dddmp_CheckAndGotoLabel(expr,errMsg,label) \
286 fprintf (stderr, "FATAL ERROR: %s\n", errMsg); \
287 fprintf (stderr, " File %s -> Line %d\n", \
288 __FILE__, __LINE__); \
294 /**AutomaticStart*************************************************************/
296 /*---------------------------------------------------------------------------*/
297 /* Function prototypes */
298 /*---------------------------------------------------------------------------*/
300 extern int Dddmp_Text2Bin(char *filein
, char *fileout
);
301 extern int Dddmp_Bin2Text(char *filein
, char *fileout
);
302 extern int Dddmp_cuddBddDisplayBinary(char *fileIn
, char *fileOut
);
303 extern DdNode
* Dddmp_cuddBddLoad(DdManager
*ddMgr
, Dddmp_VarMatchType varMatchMode
, char **varmatchnames
, int *varmatchauxids
, int *varcomposeids
, int mode
, char *file
, FILE *fp
);
304 extern int Dddmp_cuddBddArrayLoad(DdManager
*ddMgr
, Dddmp_RootMatchType rootMatchMode
, char **rootmatchnames
, Dddmp_VarMatchType varMatchMode
, char **varmatchnames
, int *varmatchauxids
, int *varcomposeids
, int mode
, char *file
, FILE *fp
, DdNode
***pproots
);
305 extern DdNode
* Dddmp_cuddAddLoad(DdManager
*ddMgr
, Dddmp_VarMatchType varMatchMode
, char **varmatchnames
, int *varmatchauxids
, int *varcomposeids
, int mode
, char *file
, FILE *fp
);
306 extern int Dddmp_cuddAddArrayLoad(DdManager
*ddMgr
, Dddmp_RootMatchType rootMatchMode
, char **rootmatchnames
, Dddmp_VarMatchType varMatchMode
, char **varmatchnames
, int *varmatchauxids
, int *varcomposeids
, int mode
, char *file
, FILE *fp
, DdNode
***pproots
);
307 extern int Dddmp_cuddHeaderLoad (Dddmp_DecompType
*ddType
, int *nVars
, int *nsuppvars
, char ***suppVarNames
, char ***orderedVarNames
, int **varIds
, int **composeIds
, int **auxIds
, int *nRoots
, char *file
, FILE *fp
);
308 extern int Dddmp_cuddBddLoadCnf(DdManager
*ddMgr
, Dddmp_VarMatchType varmatchmode
, char **varmatchnames
, int *varmatchauxids
, int *varcomposeids
, int mode
, char *file
, FILE *fp
, DdNode
***rootsPtrPtr
, int *nRoots
);
309 extern int Dddmp_cuddBddArrayLoadCnf(DdManager
*ddMgr
, Dddmp_RootMatchType rootmatchmode
, char **rootmatchnames
, Dddmp_VarMatchType varmatchmode
, char **varmatchnames
, int *varmatchauxids
, int *varcomposeids
, int mode
, char *file
, FILE *fp
, DdNode
***rootsPtrPtr
, int *nRoots
);
310 extern int Dddmp_cuddHeaderLoadCnf (int *nVars
, int *nsuppvars
, char ***suppVarNames
, char ***orderedVarNames
, int **varIds
, int **composeIds
, int **auxIds
, int *nRoots
, char *file
, FILE *fp
);
311 extern int Dddmp_cuddAddStore(DdManager
*ddMgr
, char *ddname
, DdNode
*f
, char **varnames
, int *auxids
, int mode
, Dddmp_VarInfoType varinfo
, char *fname
, FILE *fp
);
312 extern int Dddmp_cuddAddArrayStore(DdManager
*ddMgr
, char *ddname
, int nRoots
, DdNode
**f
, char **rootnames
, char **varnames
, int *auxids
, int mode
, Dddmp_VarInfoType varinfo
, char *fname
, FILE *fp
);
313 extern int Dddmp_cuddBddStore(DdManager
*ddMgr
, char *ddname
, DdNode
*f
, char **varnames
, int *auxids
, int mode
, Dddmp_VarInfoType varinfo
, char *fname
, FILE *fp
);
314 extern int Dddmp_cuddBddArrayStore(DdManager
*ddMgr
, char *ddname
, int nRoots
, DdNode
**f
, char **rootnames
, char **varnames
, int *auxids
, int mode
, Dddmp_VarInfoType varinfo
, char *fname
, FILE *fp
);
315 extern int Dddmp_cuddBddStoreCnf(DdManager
*ddMgr
, DdNode
*f
, Dddmp_DecompCnfStoreType mode
, int noHeader
, char **varNames
, int *bddIds
, int *bddAuxIds
, int *cnfIds
, int idInitial
, int edgeInTh
, int pathLengthTh
, char *fname
, FILE *fp
, int *clauseNPtr
, int *varNewNPtr
);
316 extern int Dddmp_cuddBddArrayStoreCnf(DdManager
*ddMgr
, DdNode
**f
, int rootN
, Dddmp_DecompCnfStoreType mode
, int noHeader
, char **varNames
, int *bddIds
, int *bddAuxIds
, int *cnfIds
, int idInitial
, int edgeInTh
, int pathLengthTh
, char *fname
, FILE *fp
, int *clauseNPtr
, int *varNewNPtr
);
317 extern int Dddmp_cuddBddStorePrefix(DdManager
*ddMgr
, int nRoots
, DdNode
*f
, char **inputNames
, char **outputNames
, char *modelName
, char *fileName
, FILE *fp
);
318 extern int Dddmp_cuddBddArrayStorePrefix(DdManager
*ddMgr
, int nroots
, DdNode
**f
, char **inputNames
, char **outputNames
, char *modelName
, char *fname
, FILE *fp
);
319 extern int Dddmp_cuddBddStoreBlif(DdManager
*ddMgr
, int nRoots
, DdNode
*f
, char **inputNames
, char **outputNames
, char *modelName
, char *fileName
, FILE *fp
);
320 extern int Dddmp_cuddBddArrayStoreBlif(DdManager
*ddMgr
, int nroots
, DdNode
**f
, char **inputNames
, char **outputNames
, char *modelName
, char *fname
, FILE *fp
);
321 extern int Dddmp_cuddBddStoreSmv(DdManager
*ddMgr
, int nRoots
, DdNode
*f
, char **inputNames
, char **outputNames
, char *modelName
, char *fileName
, FILE *fp
);
322 extern int Dddmp_cuddBddArrayStoreSmv(DdManager
*ddMgr
, int nroots
, DdNode
**f
, char **inputNames
, char **outputNames
, char *modelName
, char *fname
, FILE *fp
);
324 /**AutomaticEnd***************************************************************/