source: vis_dev/vis-2.3/src/synth/synthInt.h @ 30

Last change on this file since 30 was 14, checked in by cecile, 13 years ago

vis2.3

File size: 12.9 KB
Line 
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******************************************************************************/
55struct 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******************************************************************************/
92typedef 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
150EXTERN int SynthCountMlLiteral(bdd_manager *dd, MlTree *tree, int ref);
151EXTERN void SynthZddSupportStep(bdd_node *f, int *support);
152EXTERN void SynthZddClearFlag(bdd_node *f);
153EXTERN int SynthGetLiteralCount(bdd_manager *dd, bdd_node *node);
154EXTERN bdd_node * SynthZddQuickDivisor(bdd_manager *dd, bdd_node *f);
155EXTERN bdd_node * SynthZddLeastDivisor(bdd_manager *dd, bdd_node *f);
156EXTERN bdd_node * SynthZddMostDivisor(bdd_manager *dd, bdd_node *f);
157EXTERN bdd_node * SynthZddLevelZeroDivisor(bdd_manager *dd, bdd_node *f);
158EXTERN bdd_node * SynthZddCommonDivisor(bdd_manager *dd, bdd_node *f);
159EXTERN bdd_node * SynthZddLpDivisor(bdd_manager *dd, bdd_node *f);
160EXTERN void SynthCountLiteralOccurrence(bdd_manager *dd, bdd_node *f, int *count);
161EXTERN bdd_node * (* SynthGetZddProductFunc(void)) (bdd_manager *, bdd_node *, bdd_node *);
162EXTERN bdd_node * (* SynthGetZddProductRecurFunc(void)) (bdd_manager *, bdd_node *, bdd_node *);
163EXTERN bdd_node * (* SynthGetZddDivideFunc(void)) (bdd_manager *, bdd_node *, bdd_node *);
164EXTERN bdd_node * (* SynthGetZddDivideRecurFunc(void)) (bdd_manager *, bdd_node *, bdd_node *);
165EXTERN  void SynthSetZddDivisorFunc(int mode);
166EXTERN bdd_node * (* SynthGetZddDivisorFunc(void)) (bdd_manager *, bdd_node *);
167EXTERN void SynthGetSpaceString(char *string, int n, int max);
168EXTERN MlTree   * SynthLookupMlTable(st_table *table, bdd_manager *dd, bdd_node *node, int candidate, int verbosity);
169EXTERN int SynthUseCandidate(st_table *table, bdd_manager *dd, MlTree *m_tree, int verbosity);
170EXTERN MlTree   * SynthFindOrCreateMlTree(st_table *table, bdd_manager *dd, bdd_node *f, int leaf, int candidate, int *ref, int verbosity);
171EXTERN void SynthInitMlTable(void);
172EXTERN void SynthClearMlTable(bdd_manager *dd, st_table *table);
173EXTERN void SynthPutMlTreeInList(bdd_manager *dd, MlTree *tree, int candidate);
174EXTERN MlTree * SynthGetHeadTreeOfSize(int size);
175EXTERN int SynthGetSupportMask(bdd_manager *dd, bdd_node *node, unsigned int *mask);
176EXTERN int SynthGetSupportCount(bdd_manager *dd, bdd_node *node);
177EXTERN MlTree   * SynthCheckAndMakeComplement(bdd_manager *dd, st_table *table, MlTree *tree, int *comp_flag, int verbosity);
178EXTERN void SynthSetSharedFlag(bdd_manager *dd, MlTree *tree);
179EXTERN 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);
180EXTERN void SynthUpdateRefOfParent(MlTree *top);
181EXTERN void SynthVerifyTree(bdd_manager *dd, MlTree *tree, int flag);
182EXTERN void SynthVerifyMlTable(bdd_manager *dd, st_table *table);
183EXTERN void SynthPrintTreeList(MlTree *list);
184EXTERN void SynthPrintLeafList(MlTree *list);
185EXTERN 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);
186EXTERN bdd_node * SynthMakeCubeFree(bdd_manager *dd, bdd_node *f);
187EXTERN void SynthMultiLevelOptimize(Ntk_Network_t *network, bdd_node **combOutBdds, bdd_node **combUpperBdds, char **combOutNames, int *initStates, Synth_InfoData_t *synthInfo, int verbosity);
188EXTERN void SynthSetUseFuncDivisor(int mode);
189EXTERN void SynthSetOutputOrdering(int mode);
190EXTERN void SynthSetCostFactors(float supp, float prob);
191EXTERN void SynthSetSupportCount(int *count);
192EXTERN void SynthSetProbability(float *prob);
193EXTERN  int SynthFindDivisorForLowPower(int *count, int nvars, int min_count, int min_pos);
194EXTERN char * SynthGetIthOutputName(int i);
195EXTERN int SynthIsSubsetOfSupport(int size, unsigned int *mask1, unsigned int *mask2);
196EXTERN 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);
197EXTERN 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);
198EXTERN 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);
199EXTERN 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);
200EXTERN 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);
201EXTERN void SynthPrintZddTree(bdd_manager *dd, bdd_node *f);
202EXTERN void SynthPrintZddTreeMessage(bdd_manager *dd, bdd_node *f, char *mess);
203EXTERN void SynthPrintMlTreeMessage(bdd_manager *dd, MlTree *tree, char *mess);
204EXTERN void SynthFreeMlTree(MlTree *tree, int flag);
205EXTERN void SynthPrintMlTreeWithName(Ntk_Network_t *net, bdd_manager *dd, MlTree *tree, char *mess);
206EXTERN int SynthGetChildMlTreeWithName(Ntk_Network_t *net, bdd_manager *dd, MlTree *tree, char *eq);
207EXTERN int SynthGetChildTreeWithName(Ntk_Network_t *net, bdd_manager *dd, bdd_node *f, char *eq);
208EXTERN int SynthGetPrimaryNodeName(Ntk_Network_t *net, bdd_node *node, char *name);
209EXTERN void SynthGetPrimaryIndexName(Ntk_Network_t *net, int index, char *name);
210EXTERN void SynthPrintZddCoverWithName(Ntk_Network_t *net, bdd_manager *dd, bdd_node *node);
211EXTERN  void SynthMakeComplementString(char *eq);
212EXTERN  int SynthStringCompare(char **a, char **b);
213EXTERN  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);
214EXTERN void SynthWriteEqnHeader(FILE *fout, Ntk_Network_t *net, bdd_manager *dd);
215EXTERN void SynthWriteEqn(FILE *fout, Ntk_Network_t *net, bdd_manager *dd, MlTree *tree, bdd_node **ofuncs, char *func_name, int ref);
216EXTERN void SynthSetInternalNodePrefix(char *prefix);
217EXTERN void SynthSetupNodeNameTable(Ntk_Network_t *net);
218EXTERN void SynthFreeNodeNameTable(void);
219EXTERN void SynthGetInternalNodeName(char *name, int id);
220EXTERN 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 */
Note: See TracBrowser for help on using the repository browser.