1 | /**CHeaderFile***************************************************************** |
---|
2 | |
---|
3 | FileName [cal.h] |
---|
4 | |
---|
5 | PackageName [cal] |
---|
6 | |
---|
7 | Synopsis [Header CAL file for exported data structures and functions.] |
---|
8 | |
---|
9 | Description [] |
---|
10 | |
---|
11 | SeeAlso [optional] |
---|
12 | |
---|
13 | Author [Rajeev K. Ranjan (rajeev@eecs.berkeley.edu) |
---|
14 | Jagesh V. Sanghavi (sanghavi@eecs.berkeley.edu)] |
---|
15 | |
---|
16 | Copyright [Copyright (c) 1994-1996 The Regents of the Univ. of California. |
---|
17 | All rights reserved. |
---|
18 | |
---|
19 | Permission is hereby granted, without written agreement and without license |
---|
20 | or royalty fees, to use, copy, modify, and distribute this software and its |
---|
21 | documentation for any purpose, provided that the above copyright notice and |
---|
22 | the following two paragraphs appear in all copies of this software. |
---|
23 | |
---|
24 | IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR |
---|
25 | DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT |
---|
26 | OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF |
---|
27 | CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
28 | |
---|
29 | THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, |
---|
30 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
---|
31 | FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN |
---|
32 | "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE |
---|
33 | MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.] |
---|
34 | |
---|
35 | Revision [$Id: cal.h,v 1.8 2002/09/08 21:22:16 fabio Exp $] |
---|
36 | |
---|
37 | ******************************************************************************/ |
---|
38 | |
---|
39 | #ifndef _CAL |
---|
40 | #define _CAL |
---|
41 | #include <stdio.h> |
---|
42 | #include <stdlib.h> |
---|
43 | #include <string.h> |
---|
44 | #if HAVE_SYS_TYPES_H |
---|
45 | # include <sys/types.h> |
---|
46 | #endif |
---|
47 | #if HAVE_SYS_TIME_H |
---|
48 | # include <sys/time.h> |
---|
49 | #endif |
---|
50 | #if HAVE_SYS_RESOURCE_H |
---|
51 | # include <sys/resource.h> |
---|
52 | #endif |
---|
53 | #if HAVE_UNISTD_H |
---|
54 | # include <unistd.h> |
---|
55 | #endif |
---|
56 | #if HAVE_TIME_H |
---|
57 | # include <time.h> |
---|
58 | #endif |
---|
59 | |
---|
60 | #include <assert.h> |
---|
61 | #include <math.h> |
---|
62 | |
---|
63 | #include "calMem.h" |
---|
64 | /*---------------------------------------------------------------------------*/ |
---|
65 | /* Constant declarations */ |
---|
66 | /*---------------------------------------------------------------------------*/ |
---|
67 | |
---|
68 | #ifndef EXTERN |
---|
69 | # ifdef __cplusplus |
---|
70 | # define EXTERN extern "C" |
---|
71 | # else |
---|
72 | # define EXTERN extern |
---|
73 | # endif |
---|
74 | #endif |
---|
75 | |
---|
76 | #define CAL_BDD_TYPE_NONTERMINAL 0 |
---|
77 | #define CAL_BDD_TYPE_ZERO 1 |
---|
78 | #define CAL_BDD_TYPE_ONE 2 |
---|
79 | #define CAL_BDD_TYPE_POSVAR 3 |
---|
80 | #define CAL_BDD_TYPE_NEGVAR 4 |
---|
81 | #define CAL_BDD_TYPE_OVERFLOW 5 |
---|
82 | #define CAL_BDD_TYPE_CONSTANT 6 |
---|
83 | |
---|
84 | #define CAL_BDD_UNDUMP_FORMAT 1 |
---|
85 | #define CAL_BDD_UNDUMP_OVERFLOW 2 |
---|
86 | #define CAL_BDD_UNDUMP_IOERROR 3 |
---|
87 | #define CAL_BDD_UNDUMP_EOF 4 |
---|
88 | |
---|
89 | #define CAL_REORDER_NONE 0 |
---|
90 | #define CAL_REORDER_SIFT 1 |
---|
91 | #define CAL_REORDER_WINDOW 2 |
---|
92 | #define CAL_REORDER_METHOD_BF 0 |
---|
93 | #define CAL_REORDER_METHOD_DF 1 |
---|
94 | |
---|
95 | /*---------------------------------------------------------------------------*/ |
---|
96 | /* Type declarations */ |
---|
97 | /*---------------------------------------------------------------------------*/ |
---|
98 | typedef struct Cal_BddManagerStruct *Cal_BddManager; |
---|
99 | typedef struct Cal_BddManagerStruct Cal_BddManager_t; |
---|
100 | typedef struct CalBddNodeStruct *Cal_Bdd; |
---|
101 | typedef unsigned short int Cal_BddId_t; |
---|
102 | typedef unsigned short int Cal_BddIndex_t; |
---|
103 | typedef char * (*Cal_VarNamingFn_t)(Cal_BddManager, Cal_Bdd, Cal_Pointer_t); |
---|
104 | typedef char * (*Cal_TerminalIdFn_t)(Cal_BddManager, Cal_Address_t, Cal_Address_t, Cal_Pointer_t); |
---|
105 | typedef struct Cal_BlockStruct *Cal_Block; |
---|
106 | |
---|
107 | /*---------------------------------------------------------------------------*/ |
---|
108 | /* Stucture declarations */ |
---|
109 | /*---------------------------------------------------------------------------*/ |
---|
110 | enum Cal_BddOpEnum {CAL_AND, CAL_OR, CAL_XOR}; |
---|
111 | typedef enum Cal_BddOpEnum Cal_BddOp_t; |
---|
112 | |
---|
113 | |
---|
114 | /*---------------------------------------------------------------------------*/ |
---|
115 | /* Variable declarations */ |
---|
116 | /*---------------------------------------------------------------------------*/ |
---|
117 | |
---|
118 | /*---------------------------------------------------------------------------*/ |
---|
119 | /* Macro declarations */ |
---|
120 | /*---------------------------------------------------------------------------*/ |
---|
121 | #define Cal_BddNamingFnNone ((char *(*)(Cal_BddManager, Cal_Bdd, Cal_Pointer_t))0) |
---|
122 | #define Cal_BddTerminalIdFnNone ((char *(*)(Cal_BddManager, Cal_Address_t, Cal_Address_t, Cal_Pointer_t))0) |
---|
123 | #ifdef _CAL_DEBUG_ |
---|
124 | #define Cal_Assert(valid) assert(valid) |
---|
125 | #else |
---|
126 | #define Cal_Assert(ignore) ((void)0) |
---|
127 | #endif |
---|
128 | |
---|
129 | |
---|
130 | |
---|
131 | /**AutomaticStart*************************************************************/ |
---|
132 | |
---|
133 | /*---------------------------------------------------------------------------*/ |
---|
134 | /* Function prototypes */ |
---|
135 | /*---------------------------------------------------------------------------*/ |
---|
136 | |
---|
137 | EXTERN int Cal_BddIsEqual(Cal_BddManager bddManager, Cal_Bdd userBdd1, Cal_Bdd userBdd2); |
---|
138 | EXTERN int Cal_BddIsBddOne(Cal_BddManager bddManager, Cal_Bdd userBdd); |
---|
139 | EXTERN int Cal_BddIsBddZero(Cal_BddManager bddManager, Cal_Bdd userBdd); |
---|
140 | EXTERN int Cal_BddIsBddNull(Cal_BddManager bddManager, Cal_Bdd userBdd); |
---|
141 | EXTERN int Cal_BddIsBddConst(Cal_BddManager bddManager, Cal_Bdd userBdd); |
---|
142 | EXTERN Cal_Bdd Cal_BddIdentity(Cal_BddManager bddManager, Cal_Bdd userBdd); |
---|
143 | EXTERN Cal_Bdd Cal_BddOne(Cal_BddManager bddManager); |
---|
144 | EXTERN Cal_Bdd Cal_BddZero(Cal_BddManager bddManager); |
---|
145 | EXTERN Cal_Bdd Cal_BddNot(Cal_BddManager bddManager, Cal_Bdd userBdd); |
---|
146 | EXTERN Cal_BddId_t Cal_BddGetIfIndex(Cal_BddManager bddManager, Cal_Bdd userBdd); |
---|
147 | EXTERN Cal_BddId_t Cal_BddGetIfId(Cal_BddManager bddManager, Cal_Bdd userBdd); |
---|
148 | EXTERN Cal_Bdd Cal_BddIf(Cal_BddManager bddManager, Cal_Bdd userBdd); |
---|
149 | EXTERN Cal_Bdd Cal_BddThen(Cal_BddManager bddManager, Cal_Bdd userBdd); |
---|
150 | EXTERN Cal_Bdd Cal_BddElse(Cal_BddManager bddManager, Cal_Bdd userBdd); |
---|
151 | EXTERN void Cal_BddFree(Cal_BddManager bddManager, Cal_Bdd userBdd); |
---|
152 | EXTERN void Cal_BddUnFree(Cal_BddManager bddManager, Cal_Bdd userBdd); |
---|
153 | EXTERN Cal_Bdd Cal_BddGetRegular(Cal_BddManager bddManager, Cal_Bdd userBdd); |
---|
154 | EXTERN Cal_Bdd Cal_BddIntersects(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd); |
---|
155 | EXTERN Cal_Bdd Cal_BddImplies(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd); |
---|
156 | EXTERN unsigned long Cal_BddTotalSize(Cal_BddManager bddManager); |
---|
157 | EXTERN void Cal_BddStats(Cal_BddManager bddManager, FILE * fp); |
---|
158 | EXTERN void Cal_BddDynamicReordering(Cal_BddManager bddManager, int technique); |
---|
159 | EXTERN void Cal_BddReorder(Cal_BddManager bddManager); |
---|
160 | EXTERN int Cal_BddType(Cal_BddManager bddManager, Cal_Bdd fUserBdd); |
---|
161 | EXTERN long Cal_BddVars(Cal_BddManager bddManager); |
---|
162 | EXTERN long Cal_BddNodeLimit(Cal_BddManager bddManager, long newLimit); |
---|
163 | EXTERN int Cal_BddOverflow(Cal_BddManager bddManager); |
---|
164 | EXTERN int Cal_BddIsCube(Cal_BddManager bddManager, Cal_Bdd fUserBdd); |
---|
165 | EXTERN void * Cal_BddManagerGetHooks(Cal_BddManager bddManager); |
---|
166 | EXTERN void Cal_BddManagerSetHooks(Cal_BddManager bddManager, void *hooks); |
---|
167 | EXTERN int Cal_AssociationInit(Cal_BddManager bddManager, Cal_Bdd *associationInfoUserBdds, int pairs); |
---|
168 | EXTERN void Cal_AssociationQuit(Cal_BddManager bddManager, int associationId); |
---|
169 | EXTERN int Cal_AssociationSetCurrent(Cal_BddManager bddManager, int associationId); |
---|
170 | EXTERN void Cal_TempAssociationAugment(Cal_BddManager bddManager, Cal_Bdd *associationInfoUserBdds, int pairs); |
---|
171 | EXTERN void Cal_TempAssociationInit(Cal_BddManager bddManager, Cal_Bdd *associationInfoUserBdds, int pairs); |
---|
172 | EXTERN void Cal_TempAssociationQuit(Cal_BddManager bddManager); |
---|
173 | EXTERN Cal_Bdd Cal_BddCompose(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd, Cal_Bdd hUserBdd); |
---|
174 | EXTERN Cal_Bdd Cal_BddITE(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd, Cal_Bdd hUserBdd); |
---|
175 | EXTERN Cal_BddManager Cal_BddManagerInit(void); |
---|
176 | EXTERN int Cal_BddManagerQuit(Cal_BddManager bddManager); |
---|
177 | EXTERN void Cal_BddManagerSetParameters(Cal_BddManager bddManager, long reorderingThreshold, long maxForwardedNodes, double repackAfterGCThreshold, double tableRepackThreshold); |
---|
178 | EXTERN unsigned long Cal_BddManagerGetNumNodes(Cal_BddManager bddManager); |
---|
179 | EXTERN Cal_Bdd Cal_BddManagerCreateNewVarFirst(Cal_BddManager bddManager); |
---|
180 | EXTERN Cal_Bdd Cal_BddManagerCreateNewVarLast(Cal_BddManager bddManager); |
---|
181 | EXTERN Cal_Bdd Cal_BddManagerCreateNewVarBefore(Cal_BddManager bddManager, Cal_Bdd userBdd); |
---|
182 | EXTERN Cal_Bdd Cal_BddManagerCreateNewVarAfter(Cal_BddManager bddManager, Cal_Bdd userBdd); |
---|
183 | EXTERN Cal_Bdd Cal_BddManagerGetVarWithIndex(Cal_BddManager bddManager, Cal_BddIndex_t index); |
---|
184 | EXTERN Cal_Bdd Cal_BddManagerGetVarWithId(Cal_BddManager bddManager, Cal_BddId_t id); |
---|
185 | EXTERN Cal_Bdd Cal_BddAnd(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd); |
---|
186 | EXTERN Cal_Bdd Cal_BddNand(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd); |
---|
187 | EXTERN Cal_Bdd Cal_BddOr(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd); |
---|
188 | EXTERN Cal_Bdd Cal_BddNor(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd); |
---|
189 | EXTERN Cal_Bdd Cal_BddXor(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd); |
---|
190 | EXTERN Cal_Bdd Cal_BddXnor(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd); |
---|
191 | EXTERN Cal_Bdd * Cal_BddPairwiseAnd(Cal_BddManager bddManager, Cal_Bdd *userBddArray); |
---|
192 | EXTERN Cal_Bdd * Cal_BddPairwiseOr(Cal_BddManager bddManager, Cal_Bdd *userBddArray); |
---|
193 | EXTERN Cal_Bdd * Cal_BddPairwiseXor(Cal_BddManager bddManager, Cal_Bdd *userBddArray); |
---|
194 | EXTERN Cal_Bdd Cal_BddMultiwayAnd(Cal_BddManager bddManager, Cal_Bdd *userBddArray); |
---|
195 | EXTERN Cal_Bdd Cal_BddMultiwayOr(Cal_BddManager bddManager, Cal_Bdd *userBddArray); |
---|
196 | EXTERN Cal_Bdd Cal_BddMultiwayXor(Cal_BddManager bddManager, Cal_Bdd *userBddArray); |
---|
197 | EXTERN Cal_Bdd Cal_BddSatisfy(Cal_BddManager bddManager, Cal_Bdd fUserBdd); |
---|
198 | EXTERN Cal_Bdd Cal_BddSatisfySupport(Cal_BddManager bddManager, Cal_Bdd fUserBdd); |
---|
199 | EXTERN double Cal_BddSatisfyingFraction(Cal_BddManager bddManager, Cal_Bdd fUserBdd); |
---|
200 | EXTERN long Cal_BddSize(Cal_BddManager bddManager, Cal_Bdd fUserBdd, int negout); |
---|
201 | EXTERN long Cal_BddSizeMultiple(Cal_BddManager bddManager, Cal_Bdd *fUserBddArray, int negout); |
---|
202 | EXTERN void Cal_BddProfile(Cal_BddManager bddManager, Cal_Bdd fUserBdd, long * levelCounts, int negout); |
---|
203 | EXTERN void Cal_BddProfileMultiple(Cal_BddManager bddManager, Cal_Bdd *fUserBddArray, long * levelCounts, int negout); |
---|
204 | EXTERN void Cal_BddFunctionProfile(Cal_BddManager bddManager, Cal_Bdd fUserBdd, long * funcCounts); |
---|
205 | EXTERN void Cal_BddFunctionProfileMultiple(Cal_BddManager bddManager, Cal_Bdd *fUserBddArray, long * funcCounts); |
---|
206 | EXTERN Cal_Bdd Cal_BddSubstitute(Cal_BddManager bddManager, Cal_Bdd fUserBdd); |
---|
207 | EXTERN void Cal_BddSupport(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd *support); |
---|
208 | EXTERN int Cal_BddDependsOn(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd varUserBdd); |
---|
209 | EXTERN Cal_Bdd Cal_BddSwapVars(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd, Cal_Bdd hUserBdd); |
---|
210 | EXTERN Cal_Bdd Cal_BddVarSubstitute(Cal_BddManager bddManager, Cal_Bdd fUserBdd); |
---|
211 | EXTERN Cal_Block Cal_BddNewVarBlock(Cal_BddManager bddManager, Cal_Bdd variable, long length); |
---|
212 | EXTERN void Cal_BddVarBlockReorderable(Cal_BddManager bddManager, Cal_Block block, int reorderable); |
---|
213 | EXTERN Cal_Bdd Cal_BddUndumpBdd(Cal_BddManager bddManager, Cal_Bdd * userVars, FILE * fp, int * error); |
---|
214 | EXTERN int Cal_BddDumpBdd(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd * userVars, FILE * fp); |
---|
215 | EXTERN void Cal_BddSetGCMode(Cal_BddManager bddManager, int gcMode); |
---|
216 | EXTERN int Cal_BddManagerGC(Cal_BddManager bddManager); |
---|
217 | EXTERN void Cal_BddManagerSetGCLimit(Cal_BddManager manager); |
---|
218 | EXTERN void Cal_MemFatal(char *message); |
---|
219 | EXTERN Cal_Address_t Cal_MemAllocation(void); |
---|
220 | EXTERN Cal_Pointer_t Cal_MemGetBlock(Cal_Address_t size); |
---|
221 | EXTERN void Cal_MemFreeBlock(Cal_Pointer_t p); |
---|
222 | EXTERN Cal_Pointer_t Cal_MemResizeBlock(Cal_Pointer_t p, Cal_Address_t newSize); |
---|
223 | EXTERN Cal_Pointer_t Cal_MemNewRec(Cal_RecMgr mgr); |
---|
224 | EXTERN void Cal_MemFreeRec(Cal_RecMgr mgr, Cal_Pointer_t rec); |
---|
225 | EXTERN Cal_RecMgr Cal_MemNewRecMgr(int size); |
---|
226 | EXTERN void Cal_MemFreeRecMgr(Cal_RecMgr mgr); |
---|
227 | EXTERN int Cal_PerformanceTest(Cal_BddManager bddManager, Cal_Bdd *outputBddArray, int numFunctions, int iteration, int seed, int andPerformanceFlag, int multiwayPerformanceFlag, int onewayPerformanceFlag, int quantifyPerformanceFlag, int composePerformanceFlag, int relprodPerformanceFlag, int swapPerformanceFlag, int substitutePerformanceFlag, int sanityCheckFlag, int computeMemoryOverheadFlag, int superscalarFlag); |
---|
228 | EXTERN void Cal_PipelineSetDepth(Cal_BddManager bddManager, int depth); |
---|
229 | EXTERN int Cal_PipelineInit(Cal_BddManager bddManager, Cal_BddOp_t bddOp); |
---|
230 | EXTERN Cal_Bdd Cal_PipelineCreateProvisionalBdd(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd); |
---|
231 | EXTERN int Cal_PipelineExecute(Cal_BddManager bddManager); |
---|
232 | EXTERN Cal_Bdd Cal_PipelineUpdateProvisionalBdd(Cal_BddManager bddManager, Cal_Bdd provisionalBdd); |
---|
233 | EXTERN int Cal_BddIsProvisional(Cal_BddManager bddManager, Cal_Bdd userBdd); |
---|
234 | EXTERN void Cal_PipelineQuit(Cal_BddManager bddManager); |
---|
235 | EXTERN void Cal_BddPrintBdd(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_VarNamingFn_t VarNamingFn, Cal_TerminalIdFn_t TerminalIdFn, Cal_Pointer_t env, FILE *fp); |
---|
236 | EXTERN void Cal_BddPrintProfile(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_VarNamingFn_t varNamingProc, char * env, int lineLength, FILE * fp); |
---|
237 | EXTERN void Cal_BddPrintProfileMultiple(Cal_BddManager bddManager, Cal_Bdd *userBdds, Cal_VarNamingFn_t varNamingProc, char * env, int lineLength, FILE * fp); |
---|
238 | EXTERN void Cal_BddPrintFunctionProfile(Cal_BddManager bddManager, Cal_Bdd f, Cal_VarNamingFn_t varNamingProc, char * env, int lineLength, FILE * fp); |
---|
239 | EXTERN void Cal_BddPrintFunctionProfileMultiple(Cal_BddManager bddManager, Cal_Bdd *userBdds, Cal_VarNamingFn_t varNamingProc, char * env, int lineLength, FILE * fp); |
---|
240 | EXTERN Cal_Bdd Cal_BddExists(Cal_BddManager bddManager, Cal_Bdd fUserBdd); |
---|
241 | EXTERN Cal_Bdd Cal_BddRelProd(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd gUserBdd); |
---|
242 | EXTERN Cal_Bdd Cal_BddForAll(Cal_BddManager bddManager, Cal_Bdd fUserBdd); |
---|
243 | EXTERN Cal_Bdd Cal_BddCofactor(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd cUserBdd); |
---|
244 | EXTERN Cal_Bdd Cal_BddReduce(Cal_BddManager bddManager, Cal_Bdd fUserBdd, Cal_Bdd cUserBdd); |
---|
245 | EXTERN Cal_Bdd Cal_BddBetween(Cal_BddManager bddManager, Cal_Bdd fMinUserBdd, Cal_Bdd fMaxUserBdd); |
---|
246 | EXTERN void Cal_ImageDump(Cal_BddManager_t *bddManager, FILE *fp); |
---|
247 | EXTERN void Cal_BddFunctionPrint(Cal_BddManager bddManager, Cal_Bdd userBdd, char *name); |
---|
248 | |
---|
249 | /**AutomaticEnd***************************************************************/ |
---|
250 | |
---|
251 | #endif /* _CAL */ |
---|