1 | /**CHeaderFile***************************************************************** |
---|
2 | |
---|
3 | FileName [synthInt.h] |
---|
4 | |
---|
5 | PackageName [synth] |
---|
6 | |
---|
7 | Synopsis [Internal declarations.] |
---|
8 | |
---|
9 | Author [In-Ho Moon, Balakrishna Kumthekar] |
---|
10 | |
---|
11 | Copyright [This file was created at the University of Colorado at |
---|
12 | Boulder. The University of Colorado at Boulder makes no warranty |
---|
13 | about the suitability of this software for any purpose. It is |
---|
14 | presented on an AS IS basis.] |
---|
15 | |
---|
16 | Revision [$Id: synthInt.h,v 1.36 2005/05/13 08:47:48 hhhan Exp $] |
---|
17 | |
---|
18 | ******************************************************************************/ |
---|
19 | |
---|
20 | #ifndef _SYNTHINT |
---|
21 | #define _SYNTHINT |
---|
22 | |
---|
23 | /*---------------------------------------------------------------------------*/ |
---|
24 | /* Nested includes */ |
---|
25 | /*---------------------------------------------------------------------------*/ |
---|
26 | #include "synth.h" |
---|
27 | #include "ntm.h" |
---|
28 | #include "ntk.h" |
---|
29 | #include "ord.h" |
---|
30 | #include <string.h> |
---|
31 | |
---|
32 | /*---------------------------------------------------------------------------*/ |
---|
33 | /* Constant declarations */ |
---|
34 | /*---------------------------------------------------------------------------*/ |
---|
35 | |
---|
36 | |
---|
37 | /*---------------------------------------------------------------------------*/ |
---|
38 | /* Type declarations */ |
---|
39 | /*---------------------------------------------------------------------------*/ |
---|
40 | |
---|
41 | |
---|
42 | /*---------------------------------------------------------------------------*/ |
---|
43 | /* Structure declarations */ |
---|
44 | /*---------------------------------------------------------------------------*/ |
---|
45 | |
---|
46 | /**Struct********************************************************************** |
---|
47 | |
---|
48 | Synopsis [Structure holding the synthesis command options.] |
---|
49 | |
---|
50 | Description [Structure holding the synthesis command options.] |
---|
51 | |
---|
52 | SeeAlso [] |
---|
53 | |
---|
54 | ******************************************************************************/ |
---|
55 | struct SynthInfoDataStruct { |
---|
56 | int factoring; /* factoring method */ |
---|
57 | int divisor; /* divisor method */ |
---|
58 | int unreachDC; /* use unreachable states as don't cares */ |
---|
59 | int reordering; /* allow reordering in BDD and/or ZDD */ |
---|
60 | int trySharing; /* try to share more nodes */ |
---|
61 | int realign; /* allow realignment to ZDD/BDD after BDD/ZDD reordering */ |
---|
62 | char *filehead; /* output file name */ |
---|
63 | char *prefix; /* prefix of internal node names */ |
---|
64 | boolean eqn; /* if true, output synthesized circuit in equation format too */ |
---|
65 | }; |
---|
66 | |
---|
67 | /**Struct********************************************************************** |
---|
68 | |
---|
69 | Synopsis [Structure representing multi-level logic by quotient, divisor, |
---|
70 | and remainder.] |
---|
71 | |
---|
72 | Description [Structure representing multi-level logic by quotient, |
---|
73 | divisor, and remainder. In spite of the name this is a graph |
---|
74 | structure, not a tree. Each node of the graph has 3 children: |
---|
75 | quotient, divisor, and remainder. The purpose of the field |
---|
76 | complement is to have both phases in a tree, so if the field 'comp' |
---|
77 | is set to 1, then the field 'complement' is taken instead of the |
---|
78 | field 'node'. When an output function is the same as either another |
---|
79 | output function or the complement of another function, the tree of |
---|
80 | the output function is made by copying the tree of the other |
---|
81 | function, then the field 'ref' of this tree is set to 1. The fields |
---|
82 | 'q(d,r)_ref' tell each child tree was newly created or already |
---|
83 | existing, and the fields 'q(d,r)_comp' tell whether each child tree |
---|
84 | is complemented or not. To increase sharing, every time a function |
---|
85 | is factored, a tree representing quotient * divisor is made if the |
---|
86 | tree does not exist, and the field 'candidate' of this tree is set |
---|
87 | to 1.] |
---|
88 | |
---|
89 | SeeAlso [] |
---|
90 | |
---|
91 | ******************************************************************************/ |
---|
92 | typedef struct ml_tree { |
---|
93 | bdd_node *node; /* a ZDD */ |
---|
94 | bdd_node *complement; /* complement ZDD of node */ |
---|
95 | struct ml_tree *q; /* quotient */ |
---|
96 | struct ml_tree *d; /* divisor */ |
---|
97 | struct ml_tree *r; /* remainder */ |
---|
98 | unsigned int *support; /* a set of support of node */ |
---|
99 | int nLiterals; /* number of literals of this ml_tree */ |
---|
100 | unsigned short id; /* id of this ml_tree */ |
---|
101 | unsigned leaf: 1; /* set to 1 when this ml_tree is leaf */ |
---|
102 | unsigned pi: 1; /* set to 1 if node is primary input */ |
---|
103 | unsigned ref: 1; /* set to 1 if this ml_tree is made by |
---|
104 | * copying an existing tree */ |
---|
105 | unsigned q_ref: 1; /* set to 1 if q is already existing tree */ |
---|
106 | unsigned d_ref: 1; /* set to 1 if d is already existing tree */ |
---|
107 | unsigned r_ref: 1; /* set to 1 if r is already existing tree */ |
---|
108 | unsigned top: 1; /* set to 1 if this ml_tree is a primary |
---|
109 | * output or next state function */ |
---|
110 | unsigned comp: 1; /* take complement of ml_tree if 1 */ |
---|
111 | unsigned q_comp: 1; /* take complement of q as quotient if 1 */ |
---|
112 | unsigned d_comp: 1; /* take complement of d as divisor if 1 */ |
---|
113 | unsigned r_comp: 1; /* take complement of r as remainder if 1 */ |
---|
114 | unsigned shared: 1; /* set to 1 if this ml_tree has more than |
---|
115 | * one assendent */ |
---|
116 | unsigned candidate: 1; |
---|
117 | unsigned flag: 1; |
---|
118 | unsigned dummy: 2; |
---|
119 | struct ml_tree *next; |
---|
120 | } MlTree; |
---|
121 | |
---|
122 | |
---|
123 | /*---------------------------------------------------------------------------*/ |
---|
124 | /* Type declarations */ |
---|
125 | /*---------------------------------------------------------------------------*/ |
---|
126 | |
---|
127 | |
---|
128 | /*---------------------------------------------------------------------------*/ |
---|
129 | /* Variable declarations */ |
---|
130 | /*---------------------------------------------------------------------------*/ |
---|
131 | |
---|
132 | |
---|
133 | /*---------------------------------------------------------------------------*/ |
---|
134 | /* Macro declarations */ |
---|
135 | /*---------------------------------------------------------------------------*/ |
---|
136 | |
---|
137 | #define MlTree_Not(tree) ((MlTree *)((long)(tree) ^ 01)) |
---|
138 | #define MlTree_IsComplement(tree) ((long)(tree) & 01) |
---|
139 | #define MlTree_Regular(tree) ((MlTree *)((long)(tree) & ~01)) |
---|
140 | |
---|
141 | #define MAX_EQ_LEN 4096 |
---|
142 | #define MAX_NAME_LEN 256 |
---|
143 | |
---|
144 | /**AutomaticStart*************************************************************/ |
---|
145 | |
---|
146 | /*---------------------------------------------------------------------------*/ |
---|
147 | /* Function prototypes */ |
---|
148 | /*---------------------------------------------------------------------------*/ |
---|
149 | |
---|
150 | EXTERN int SynthCountMlLiteral(bdd_manager *dd, MlTree *tree, int ref); |
---|
151 | EXTERN void SynthZddSupportStep(bdd_node *f, int *support); |
---|
152 | EXTERN void SynthZddClearFlag(bdd_node *f); |
---|
153 | EXTERN int SynthGetLiteralCount(bdd_manager *dd, bdd_node *node); |
---|
154 | EXTERN bdd_node * SynthZddQuickDivisor(bdd_manager *dd, bdd_node *f); |
---|
155 | EXTERN bdd_node * SynthZddLeastDivisor(bdd_manager *dd, bdd_node *f); |
---|
156 | EXTERN bdd_node * SynthZddMostDivisor(bdd_manager *dd, bdd_node *f); |
---|
157 | EXTERN bdd_node * SynthZddLevelZeroDivisor(bdd_manager *dd, bdd_node *f); |
---|
158 | EXTERN bdd_node * SynthZddCommonDivisor(bdd_manager *dd, bdd_node *f); |
---|
159 | EXTERN bdd_node * SynthZddLpDivisor(bdd_manager *dd, bdd_node *f); |
---|
160 | EXTERN void SynthCountLiteralOccurrence(bdd_manager *dd, bdd_node *f, int *count); |
---|
161 | EXTERN bdd_node * (* SynthGetZddProductFunc(void)) (bdd_manager *, bdd_node *, bdd_node *); |
---|
162 | EXTERN bdd_node * (* SynthGetZddProductRecurFunc(void)) (bdd_manager *, bdd_node *, bdd_node *); |
---|
163 | EXTERN bdd_node * (* SynthGetZddDivideFunc(void)) (bdd_manager *, bdd_node *, bdd_node *); |
---|
164 | EXTERN bdd_node * (* SynthGetZddDivideRecurFunc(void)) (bdd_manager *, bdd_node *, bdd_node *); |
---|
165 | EXTERN void SynthSetZddDivisorFunc(int mode); |
---|
166 | EXTERN bdd_node * (* SynthGetZddDivisorFunc(void)) (bdd_manager *, bdd_node *); |
---|
167 | EXTERN void SynthGetSpaceString(char *string, int n, int max); |
---|
168 | EXTERN MlTree * SynthLookupMlTable(st_table *table, bdd_manager *dd, bdd_node *node, int candidate, int verbosity); |
---|
169 | EXTERN int SynthUseCandidate(st_table *table, bdd_manager *dd, MlTree *m_tree, int verbosity); |
---|
170 | EXTERN MlTree * SynthFindOrCreateMlTree(st_table *table, bdd_manager *dd, bdd_node *f, int leaf, int candidate, int *ref, int verbosity); |
---|
171 | EXTERN void SynthInitMlTable(void); |
---|
172 | EXTERN void SynthClearMlTable(bdd_manager *dd, st_table *table); |
---|
173 | EXTERN void SynthPutMlTreeInList(bdd_manager *dd, MlTree *tree, int candidate); |
---|
174 | EXTERN MlTree * SynthGetHeadTreeOfSize(int size); |
---|
175 | EXTERN int SynthGetSupportMask(bdd_manager *dd, bdd_node *node, unsigned int *mask); |
---|
176 | EXTERN int SynthGetSupportCount(bdd_manager *dd, bdd_node *node); |
---|
177 | EXTERN MlTree * SynthCheckAndMakeComplement(bdd_manager *dd, st_table *table, MlTree *tree, int *comp_flag, int verbosity); |
---|
178 | EXTERN void SynthSetSharedFlag(bdd_manager *dd, MlTree *tree); |
---|
179 | EXTERN int SynthPostFactoring(bdd_manager *dd, st_table *table, MlTree *(* factoring_func)(bdd_manager *, st_table *, bdd_node *, int, int *, MlTree *, int, MlTree *, int), int verbosity); |
---|
180 | EXTERN void SynthUpdateRefOfParent(MlTree *top); |
---|
181 | EXTERN void SynthVerifyTree(bdd_manager *dd, MlTree *tree, int flag); |
---|
182 | EXTERN void SynthVerifyMlTable(bdd_manager *dd, st_table *table); |
---|
183 | EXTERN void SynthPrintTreeList(MlTree *list); |
---|
184 | EXTERN void SynthPrintLeafList(MlTree *list); |
---|
185 | EXTERN MlTree * SynthGenericFactorTree(bdd_manager *dd, st_table *table, bdd_node *f, int level, int *ref, MlTree *comp_d_tree, int comp_d_flag, MlTree *bring, int verbosity); |
---|
186 | EXTERN bdd_node * SynthMakeCubeFree(bdd_manager *dd, bdd_node *f); |
---|
187 | EXTERN void SynthMultiLevelOptimize(Ntk_Network_t *network, bdd_node **combOutBdds, bdd_node **combUpperBdds, char **combOutNames, int *initStates, Synth_InfoData_t *synthInfo, int verbosity); |
---|
188 | EXTERN void SynthSetUseFuncDivisor(int mode); |
---|
189 | EXTERN void SynthSetOutputOrdering(int mode); |
---|
190 | EXTERN void SynthSetCostFactors(float supp, float prob); |
---|
191 | EXTERN void SynthSetSupportCount(int *count); |
---|
192 | EXTERN void SynthSetProbability(float *prob); |
---|
193 | EXTERN int SynthFindDivisorForLowPower(int *count, int nvars, int min_count, int min_pos); |
---|
194 | EXTERN char * SynthGetIthOutputName(int i); |
---|
195 | EXTERN int SynthIsSubsetOfSupport(int size, unsigned int *mask1, unsigned int *mask2); |
---|
196 | EXTERN MlTree * SynthSimpleFactorTree(bdd_manager *dd, st_table *table, bdd_node *f, int level, int *ref, MlTree *comp_d_tree, int comp_d_flag, MlTree *bring, int verbosity); |
---|
197 | EXTERN bdd_node * SynthFindBiggerDivisorInList(bdd_manager *dd, st_table *table, bdd_node *f, bdd_node *d, int *found, int *comp_d_flag, MlTree **comp_d_tree, int verbosity); |
---|
198 | EXTERN MlTree * SynthGetFactorTreeWithCommonDivisor(bdd_manager *dd, st_table *table, MlTree *(* factoring_func)(bdd_manager *, st_table *, bdd_node *, int, int *, MlTree *, int, MlTree *, int), bdd_node *f, bdd_node *d, int level, int *ref, int verbosity); |
---|
199 | EXTERN MlTree * SynthPostFactorTree(bdd_manager *dd, st_table *table, bdd_node *f, bdd_node *q, bdd_node *d, MlTree *bring, MlTree *comp_d_tree, int comp_d_flag, char *message, int *ref, int verbosity); |
---|
200 | EXTERN MlTree * SynthFactorTreeRecur(bdd_manager *dd, st_table *table, MlTree *(* factoring_func)(bdd_manager *, st_table *, bdd_node *, int, int *, MlTree *, int, MlTree *, int), bdd_node *f, bdd_node *q, bdd_node *d, bdd_node *r, bdd_node *m, MlTree *q_tree, MlTree *d_tree, MlTree *r_tree, MlTree *comp_q_tree, MlTree *comp_d_tree, MlTree *comp_r_tree, MlTree *bring, int level, char *space, char *message, int *ref, int verbosity); |
---|
201 | EXTERN void SynthPrintZddTree(bdd_manager *dd, bdd_node *f); |
---|
202 | EXTERN void SynthPrintZddTreeMessage(bdd_manager *dd, bdd_node *f, char *mess); |
---|
203 | EXTERN void SynthPrintMlTreeMessage(bdd_manager *dd, MlTree *tree, char *mess); |
---|
204 | EXTERN void SynthFreeMlTree(MlTree *tree, int flag); |
---|
205 | EXTERN void SynthPrintMlTreeWithName(Ntk_Network_t *net, bdd_manager *dd, MlTree *tree, char *mess); |
---|
206 | EXTERN int SynthGetChildMlTreeWithName(Ntk_Network_t *net, bdd_manager *dd, MlTree *tree, char *eq); |
---|
207 | EXTERN int SynthGetChildTreeWithName(Ntk_Network_t *net, bdd_manager *dd, bdd_node *f, char *eq); |
---|
208 | EXTERN int SynthGetPrimaryNodeName(Ntk_Network_t *net, bdd_node *node, char *name); |
---|
209 | EXTERN void SynthGetPrimaryIndexName(Ntk_Network_t *net, int index, char *name); |
---|
210 | EXTERN void SynthPrintZddCoverWithName(Ntk_Network_t *net, bdd_manager *dd, bdd_node *node); |
---|
211 | EXTERN void SynthMakeComplementString(char *eq); |
---|
212 | EXTERN int SynthStringCompare(char **a, char **b); |
---|
213 | EXTERN void SynthWriteBlifFile(Ntk_Network_t *net, bdd_manager *dd, MlTree **tree, char *filename, int no, bdd_node **ofuncs, int *initStates, int ml_mode, int verbosity); |
---|
214 | EXTERN void SynthWriteEqnHeader(FILE *fout, Ntk_Network_t *net, bdd_manager *dd); |
---|
215 | EXTERN void SynthWriteEqn(FILE *fout, Ntk_Network_t *net, bdd_manager *dd, MlTree *tree, bdd_node **ofuncs, char *func_name, int ref); |
---|
216 | EXTERN void SynthSetInternalNodePrefix(char *prefix); |
---|
217 | EXTERN void SynthSetupNodeNameTable(Ntk_Network_t *net); |
---|
218 | EXTERN void SynthFreeNodeNameTable(void); |
---|
219 | EXTERN void SynthGetInternalNodeName(char *name, int id); |
---|
220 | EXTERN void SynthDumpBlif(Ntk_Network_t *net, bdd_manager *dd, int no, bdd_node **ofuncs, char **onames, int *initStates, char *model); |
---|
221 | |
---|
222 | /**AutomaticEnd***************************************************************/ |
---|
223 | |
---|
224 | #endif /* _SYNTHINT */ |
---|