source: vis_dev/vis-2.3/src/spfd/spfdInt.h @ 93

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

vis2.3

File size: 14.1 KB
Line 
1/**CHeaderFile*****************************************************************
2
3  FileName    [spfdInt.h]
4
5  PackageName [spfd]
6
7  Synopsis    [Internal data structures for the spfd package.]
8
9  Description [Internal data structures for the spfd package.]
10
11  SeeAlso     [spfd.h]
12
13  Author      [Balakrishna Kumthekar]
14
15  Copyright   [This file was created at the University of Colorado at Boulder.
16  The University of Colorado at Boulder makes no warranty about the suitability
17  of this software for any purpose.  It is presented on an AS IS basis.]
18
19******************************************************************************/
20
21#ifndef _SPFDINT
22#define _SPFDINT
23
24#include "part.h"
25#include "ntm.h"
26#include "cmd.h"
27#include "spfd.h"
28#include "truesim.h"
29#include <string.h>
30
31#ifdef USE_VPR
32#include "vpr.h"
33#endif
34
35/*---------------------------------------------------------------------------*/
36/* Constant declarations                                                     */
37/*---------------------------------------------------------------------------*/
38
39#define SPFD_NETWORK_APPL_KEY "Spfd_NetworkApplKey"
40/* Methods to sort nodes during logic optimization. */
41#define RANDOM 0 /* Choose a network node randomly */
42#define MAXSWCAP 1 /* Choose the node that has the maximum switched capacitance.
43                      Switched capacitance is the product of the node's output
44                      capacitance (approximated by the fanout count) and the
45                      average switching acitivity (switching probability). */
46#define MAXFANOUT 2 /* Choose the node with maximum fanout */
47#define MINSWCAP 3 /* Choose the node with minimum switched capacitance */
48#define MINFANOUT 4 /* Choose the node with minimum fanout */
49
50/* Methods of optimizing the selected node */
51#define REDUCE_FANIN_WIRES 0 /* Fanin wires of the selected node are selected
52                                one at a time to attempt to remove it. */
53#define OPTIMIZE_MAX_NODE 1 /* Compute a suitable alternate implementation at
54                               the selected node. */
55#define OPTIMIZE_FANIN_NODES 2 /* Compute a suitable alternate implementation at
56                               the fanin nodes of the selected node. */
57#define REDUCE_FANOUT_WIRES 3 /* Attempt to remove fanout wires of the
58                                 selected node. */
59
60/* Used during random value generation */
61#define MODULUS1 2147483563
62
63/*---------------------------------------------------------------------------*/
64/* Type declarations                                                         */
65/*---------------------------------------------------------------------------*/
66
67
68/*---------------------------------------------------------------------------*/
69/* Structure declarations                                                    */
70/*---------------------------------------------------------------------------*/
71
72/**Struct**********************************************************************
73
74  Synopsis [Data structure used during simultaneous logic and
75  placement optimization.]
76
77  Description [Data structure used during simultaneous logic and
78  placement optimization. This data structure stores information
79  extracted from the data structures in VPR.]
80
81  SeeAlso     [SpfdNodeData_t]
82
83******************************************************************************/
84typedef struct SpfdPlaceData_t {
85  st_table *nodeToNetIndex; /* Table to store the index of net in nets[] (VPR)*/
86  st_table *wireDelayTable; /* Table to store wire delays */
87  st_table *nodeDelayTable; /* Table to store node delays */
88  st_table *wireSeen; /* Wires processed. Used only in timing-based method */
89} SpfdPlaceData_t;
90
91
92/**Struct**********************************************************************
93
94  Synopsis [The package application data structure.]
95
96  Description [The package application data structure. This data
97  structure is hooked to the network for easy access.]
98
99  SeeAlso     [SpfdPlaceData_t SpfdNodeData_t]
100
101******************************************************************************/
102typedef struct SpfdApplData_t {
103  bdd_manager *ddManager; /* BDD manager */
104  bdd_node *currXCube; /* BDD of cube of primary inputs that are in the
105                          transitive fanin of the network region under
106                          optimization.   */
107  st_table *nodeToData; /* Table of node and SpfdNodeData_t */
108  st_table *currRegionNodes; /* internal and boundary nodes of the region.
109                                The region under consideration includes nodes
110                                (upto a user specified depth) in the
111                                transitive fanout of the selected node. */
112  st_table *currBddReq; /* BDDs of the nodes in the current region */
113  st_table *currInUseVars; /* BDD variable IDs currently in use. This is
114                              necessary because we reuse previously allocated
115                              BDD IDs. */
116  st_table *currPiAltVars; /* Extra (auxillary variables) BDD variable IDs
117                              for PIs in the transitive fanin of the region */
118  st_table *currWireTable; /* Table to store wires that can be removed */
119  st_table *currReplaceTable; /* Table to store wires that can be replaced */
120  st_table *wiresRemoved; /* Table to store wires that have been removed */
121  st_table *nodesRemoved; /* Table to store nodes that can be removed */
122  SpfdPlaceData_t *placeData; /* Struct to store placement data */
123} SpfdApplData_t;
124
125
126/**Struct**********************************************************************
127
128  Synopsis [Data structure to store additional information in a node.]
129
130  Description [Data structure to store additional information in a
131  node. The information stored is derived while computing SPFDs in the
132  network.]
133
134  SeeAlso     [SpfdPlaceData_t]
135
136******************************************************************************/
137typedef struct SpfdNodeData_t {
138  bdd_node *spfd; /* Node SPFD */
139  bdd_node *localAlt; /* An alternate function (implementation) chosen from
140                         the node's SPFD */
141  bdd_node *alternative; /* localAlt in terms of primary inputs */
142  bdd_node **parameters; /* Binary parameters used during SPFD computation*/
143  int numParams; /* size of parameters */
144  array_t *faninOrder; /* Order of fanin nodes. The SPFDs for fanin nodes are
145                          assigned according to this order. */
146  int auxId; /* Two sets of variables are required to represent
147                SPFDs. mddId of the node is one, and auxId is the
148                other. */
149  boolean locked; /* Set to TRUE after the node is optimized */
150} SpfdNodeData_t;
151
152
153/*---------------------------------------------------------------------------*/
154/* Variable declarations                                                     */
155/*---------------------------------------------------------------------------*/
156extern int spfdCreatedPart; /* Whether network BDDs were created in the package */
157extern int spfdVerbose; /* verbosity */
158extern float spfdAlpha; /* spfdAlpha * load + (1-spfdAlpha) * topDepth, is used to order
159                fanin nodes during SPFD computation */
160extern boolean spfdPerfSim; /* Perform simulation */
161extern boolean spfdNtkChanged; /* TRUE if network changes structurally or functionally */
162extern boolean spfdReprogNoWire; /* If TRUE, no functional changes are performed
163                         unless required by structural changes */
164extern int spfdWiresAdded, spfdNumWiresRem; /* Number of wires added and removed */
165extern int spfdSortNodes; /* Method to sort nodes */
166extern int spfdMethod; /* Optimization method */
167
168/*---------------------------------------------------------------------------*/
169/* Macro declarations                                                        */
170/*---------------------------------------------------------------------------*/
171
172/**AutomaticStart*************************************************************/
173
174/*---------------------------------------------------------------------------*/
175/* Function prototypes                                                       */
176/*---------------------------------------------------------------------------*/
177
178EXTERN boolean SpfdNodeReadLocked(SpfdApplData_t *applData, Ntk_Node_t *node);
179EXTERN int SpfdNodeReadAuxId(SpfdApplData_t *applData, Ntk_Node_t *node);
180EXTERN void SpfdNodeSetAuxId(SpfdApplData_t *applData, Ntk_Node_t *node, int auxId);
181EXTERN bdd_node * SpfdNodeReadSpfd(SpfdApplData_t *applData, Ntk_Node_t *node);
182EXTERN void SpfdNodeDeleteSpfd(SpfdApplData_t *applData, Ntk_Node_t *node);
183EXTERN void SpfdNodeSetSpfd(SpfdApplData_t *applData, Ntk_Node_t *node, bdd_node *spfd);
184EXTERN bdd_node ** SpfdNodeReadParameters(SpfdApplData_t *applData, Ntk_Node_t *node);
185EXTERN void SpfdNodeDeleteParameters(SpfdApplData_t *applData, Ntk_Node_t *node);
186EXTERN void SpfdNodeSetParameters(SpfdApplData_t *applData, Ntk_Node_t *node, bdd_node **parameters, int numParams);
187EXTERN array_t * SpfdNodeReadFaninOrder(SpfdApplData_t *applData, Ntk_Node_t *node);
188EXTERN void SpfdNodeDeleteFaninOrder(SpfdApplData_t *applData, Ntk_Node_t *node);
189EXTERN void SpfdNodeSetFaninOrder(SpfdApplData_t *applData, Ntk_Node_t *node, array_t *faninOrder);
190EXTERN bdd_node * SpfdNodeReadGlobalAlternative(SpfdApplData_t *applData, Ntk_Node_t *node);
191EXTERN void SpfdNodeDeleteGlobalAlternative(SpfdApplData_t *applData, Ntk_Node_t *node);
192EXTERN void SpfdNodeSetGlobalAlternative(SpfdApplData_t *applData, Ntk_Node_t *node, bdd_node *alternative);
193EXTERN bdd_node * SpfdNodeReadLocalAlt(SpfdApplData_t *applData, Ntk_Node_t *node);
194EXTERN void SpfdNodeDeleteLocalAlt(SpfdApplData_t *applData, Ntk_Node_t *node);
195EXTERN void SpfdNodeSetLocalAlt(SpfdApplData_t *applData, Ntk_Node_t *node, bdd_node *localAlt);
196EXTERN void SpfdNodeSetLocked(SpfdApplData_t *applData, Ntk_Node_t *node, boolean locked);
197EXTERN int SpfdNodeReadNumParams(SpfdApplData_t *applData, Ntk_Node_t *node);
198EXTERN int SpfdNodeReadNetIndex(SpfdApplData_t *applData, Ntk_Node_t *node);
199EXTERN void SpfdApplFreeCallback(void *data);
200EXTERN enum st_retval SpfdStBddFree(char *key, char *value, char *arg);
201EXTERN enum st_retval SpfdStTableClean(char *key, char *value, char *arg);
202EXTERN void SpfdReleaseAndCleanNodeData(SpfdApplData_t *applData, Ntk_Node_t *regNode, st_table *nodeTable);
203EXTERN void SpfdReleaseAlternatePiIds(SpfdApplData_t *applData, Ntk_Node_t *regNode, st_table *nodeTable);
204EXTERN void SpfdCleanUpAuxIds(SpfdApplData_t *applData);
205EXTERN void SpfdRegionComputeSinglePairSpfd(Ntk_Network_t *network, SpfdApplData_t *applData, array_t *regionArray);
206EXTERN bdd_node * SpfdNodeComputeOptParams(SpfdApplData_t *applData, Ntk_Node_t *regNode, bdd_node *result, bdd_node **parameters, int numIsfs);
207EXTERN void SpfdNodeReduceSCCToSinglePair(SpfdApplData_t *applData, Ntk_Node_t *regNode, st_table *SCC);
208EXTERN void SpfdComputeRequiredGlobalBdds(Ntk_Network_t *network, SpfdApplData_t *applData);
209EXTERN int SpfdNetworkOptimize(Ntk_Network_t *network, char *simFile, int percent, int frequency, int regionDepth);
210EXTERN void SpfdProcessFanoutWires(Ntk_Network_t *network, Ntk_Node_t *maxNode, int regionDepth, boolean replRem);
211EXTERN Ntk_Node_t * SpfdCheckIfWireIsRedundantOrReplaceable(Ntk_Network_t *network, SpfdApplData_t *applData, Ntk_Node_t *from, Ntk_Node_t *to, array_t *replaceArray);
212EXTERN Ntk_Node_t * SpfdTestIfNodeGlobalFuncSatisfiesWireSpfd(Ntk_Network_t *network, array_t *replaceArray, Ntk_Node_t *from, Ntk_Node_t *to, bdd_node *wireSpfd);
213EXTERN void SpfdOptimizeFaninWires(Ntk_Network_t *network, Ntk_Node_t *maxNode, int regionDepth, boolean replRem);
214EXTERN void SpfdOptimizeFanoutWires(Ntk_Network_t *network, Ntk_Node_t *maxNode, int regionDepth, boolean replRem);
215EXTERN void SpfdOptimizeFaninNodes(Ntk_Network_t *network, Ntk_Node_t *maxNode, int regionDepth);
216EXTERN void SpfdOptimizeWire(Ntk_Network_t *network, Ntk_Node_t *maxNode, Ntk_Node_t *ntkNode, int regionDepth, boolean replRem);
217EXTERN void SpfdOptimizeNode(Ntk_Network_t *network, Ntk_Node_t *ntkNode, int regionDepth);
218EXTERN void SpfdReprogramRegionNodes(Ntk_Network_t *network, SpfdApplData_t *applData, array_t *regionArray);
219EXTERN void SpfdReprogramNode(Ntk_Network_t *network, SpfdApplData_t *applData, Ntk_Node_t *regNode);
220EXTERN void SpfdNetworkRemoveWire(Ntk_Network_t *network, Ntk_Node_t *from, Ntk_Node_t *to);
221EXTERN void SpfdNetworkAddWire(Ntk_Network_t *network, Ntk_Node_t *from, Ntk_Node_t *to);
222EXTERN array_t * SpfdNodeComputeFanoutRegion(SpfdApplData_t *applData, Ntk_Node_t *startNode, int regionDepth);
223EXTERN array_t * SpfdNodeComputeTFIUntilDepth(Ntk_Node_t *startNode, int regionDepth);
224EXTERN void SpfdNodesInTFO(Ntk_Network_t *network, Ntk_Node_t *node, st_table *tfoNodes);
225EXTERN bdd_node * SpfdNodeComputeSpfdFromOnAndOffSet(SpfdApplData_t *applData, Ntk_Node_t *regNode, bdd_node *bdd1, bdd_node *bdd0);
226EXTERN bdd_node * SpfdNodeComputeSpfdFromFanouts(SpfdApplData_t *applData, Ntk_Node_t *from);
227EXTERN st_table * SpfdNodeComputeSCCs(SpfdApplData_t *applData, Ntk_Node_t *regNode, bdd_node **tempVars);
228EXTERN SpfdApplData_t * SpfdInitializeApplData(Ntk_Network_t *network);
229EXTERN bdd_node ** SpfdComputeParameters(SpfdApplData_t *applData, st_table *SCC);
230EXTERN bdd_node ** SpfdAllocateTemporaryVariables(bdd_manager *ddManager, st_table *inUseVars, int num);
231EXTERN void SpfdAllocateOrReuseAuxVariables(Ntk_Network_t *network, SpfdApplData_t *applData);
232EXTERN void SpfdOrderFaninOfRegionNodes(Ntk_Network_t *network, SpfdApplData_t *applData, int (*compareFunc)(const void *, const void *));
233EXTERN int SpfdSwitchedCapAndDepthCompare(const void *obj1, const void *obj2);
234EXTERN int SpfdFanoutCountAndDepthCompare(const void *obj1, const void *obj2);
235EXTERN int SpfdDepthCompare(const void *obj1, const void *obj2);
236EXTERN int SpfdDescendDepthCompare(const void *obj1, const void *obj2);
237EXTERN void SpfdMddCreateVariables(mdd_manager *mgr, int numVarsToBeAdded, int level);
238EXTERN bdd_node * SpfdAddEqual(bdd_manager *ddManager, bdd_node **f, bdd_node **g);
239EXTERN int SpfdNetworkWriteBlifFile(Ntk_Network_t *network, char *fileName);
240EXTERN bdd_node * SpfdComputeNodeArrayRelation(SpfdApplData_t *applData, st_table *currBddReq, array_t *nodeBdds, array_t *nodeArray, boolean useMddIds, int *piSwap);
241EXTERN bdd_node * SpfdSwapPiAndAltPi(SpfdApplData_t *applData, bdd_node *fun);
242EXTERN bdd_node * SpfdNodeReadLocalBdd(Ntk_Network_t *network, Ntk_Node_t *node);
243EXTERN array_t * SpfdFetchInternalPatternArray(array_t *patternArray, int percent, double randomValue);
244EXTERN Ntk_Node_t * SpfdFindNode(Ntk_Network_t *network, array_t *nodeArray);
245
246/**AutomaticEnd***************************************************************/
247
248#endif /* _SPFDINT */
Note: See TracBrowser for help on using the repository browser.