1 /**CFile****************************************************************
2 
3   FileName    [nwkMerge.h]
4 
5   SystemName  [ABC: Logic synthesis and verification system.]
6 
7   PackageName [Logic network representation.]
8 
9   Synopsis    [External declarations.]
10 
11   Author      [Alan Mishchenko]
12 
13   Affiliation [UC Berkeley]
14 
15   Date        [Ver. 1.0. Started - June 20, 2005.]
16 
17   Revision    [$Id: nwkMerge.h,v 1.1 2008/05/14 22:13:09 wudenni Exp $]
18 
19 ***********************************************************************/
20 
21 #ifndef __NWK_MERGE_H__
22 #define __NWK_MERGE_H__
23 
24 
25 ////////////////////////////////////////////////////////////////////////
26 ///                          INCLUDES                                ///
27 ////////////////////////////////////////////////////////////////////////
28 
29 ////////////////////////////////////////////////////////////////////////
30 ///                         PARAMETERS                               ///
31 ////////////////////////////////////////////////////////////////////////
32 
33 
34 
35 ABC_NAMESPACE_HEADER_START
36 
37 
38 #define NWK_MAX_LIST  16
39 
40 ////////////////////////////////////////////////////////////////////////
41 ///                         BASIC TYPES                              ///
42 ////////////////////////////////////////////////////////////////////////
43 
44 // the LUT merging parameters
45 typedef struct Nwk_LMPars_t_  Nwk_LMPars_t;
46 struct Nwk_LMPars_t_
47 {
48     int    nMaxLutSize;    // the max LUT size for merging (N=5)
49     int    nMaxSuppSize;   // the max total support size after merging (S=5)
50     int    nMaxDistance;   // the max number of nodes separating LUTs
51     int    nMaxLevelDiff;  // the max difference in levels
52     int    nMaxFanout;     // the max number of fanouts to traverse
53     int    fUseDiffSupp;   // enables the use of nodes with different support
54     int    fUseTfiTfo;     // enables the use of TFO/TFO nodes as candidates
55     int    fVeryVerbose;   // enables additional verbose output
56     int    fVerbose;       // enables verbose output
57 };
58 
59 // edge of the graph
60 typedef struct Nwk_Edg_t_  Nwk_Edg_t;
61 struct Nwk_Edg_t_
62 {
63     int             iNode1;      // the first node
64     int             iNode2;      // the second node
65     Nwk_Edg_t *     pNext;       // the next edge
66 };
67 
68 // vertex of the graph
69 typedef struct Nwk_Vrt_t_  Nwk_Vrt_t;
70 struct Nwk_Vrt_t_
71 {
72     int             Id;          // the vertex number
73     int             iPrev;       // the previous vertex in the list
74     int             iNext;       // the next vertex in the list
75     int             nEdges;      // the number of edges
76     int             pEdges[0];   // the array of edges
77 };
78 
79 // the connectivity graph
80 typedef struct Nwk_Grf_t_  Nwk_Grf_t;
81 struct Nwk_Grf_t_
82 {
83     // preliminary graph representation
84     int             nObjs;       // the number of objects
85     int             nVertsMax;   // the upper bound on the number of vertices
86     int             nEdgeHash;   // an approximate number of edges
87     Nwk_Edg_t **    pEdgeHash;   // hash table for edges
88     Aig_MmFixed_t * pMemEdges;   // memory for edges
89     // graph representation
90     int             nEdges;      // the number of edges
91     int             nVerts;      // the number of vertices
92     Nwk_Vrt_t **    pVerts;      // the array of vertices
93     Aig_MmFlex_t *  pMemVerts;   // memory for vertices
94     // intermediate data
95     int pLists1[NWK_MAX_LIST+1]; // lists of nodes with one edge
96     int pLists2[NWK_MAX_LIST+1]; // lists of nodes with more than one edge
97     // the results of matching
98     Vec_Int_t *     vPairs;      // pairs matched in the graph
99     // object mappings
100     int *           pMapLut2Id;  // LUT numbers into vertex IDs
101     int *           pMapId2Lut;  // vertex IDs into LUT numbers
102     // other things
103     int             nMemBytes1;  // memory usage in bytes
104     int             nMemBytes2;  // memory usage in bytes
105 };
106 
107 ////////////////////////////////////////////////////////////////////////
108 ///                      MACRO DEFINITIONS                           ///
109 ////////////////////////////////////////////////////////////////////////
110 
111 #define Nwk_GraphForEachEdge( p, pEdge, k )             \
112     for ( k = 0; k < p->nEdgeHash; k++ )                \
113         for ( pEdge = p->pEdgeHash[k]; pEdge; pEdge = pEdge->pNext )
114 
115 #define Nwk_ListForEachVertex( p, List, pVrt )          \
116     for ( pVrt = List? p->pVerts[List] : NULL;  pVrt;   \
117           pVrt = pVrt->iNext? p->pVerts[pVrt->iNext] : NULL )
118 
119 #define Nwk_VertexForEachAdjacent( p, pVrt, pNext, k )  \
120     for ( k = 0; (k < pVrt->nEdges) && (((pNext) = p->pVerts[pVrt->pEdges[k]]), 1); k++ )
121 
122 ////////////////////////////////////////////////////////////////////////
123 ///                      INLINED FUNCTIONS                           ///
124 ////////////////////////////////////////////////////////////////////////
125 
126 ////////////////////////////////////////////////////////////////////////
127 ///                         ITERATORS                                ///
128 ////////////////////////////////////////////////////////////////////////
129 
130 ////////////////////////////////////////////////////////////////////////
131 ///                    FUNCTION DECLARATIONS                         ///
132 ////////////////////////////////////////////////////////////////////////
133 
134 /*=== nwkMerge.c ==========================================================*/
135 extern ABC_DLL Nwk_Grf_t *   Nwk_ManGraphAlloc( int nVertsMax );
136 extern ABC_DLL void          Nwk_ManGraphFree( Nwk_Grf_t * p );
137 extern ABC_DLL void          Nwk_ManGraphReportMemoryUsage( Nwk_Grf_t * p );
138 extern ABC_DLL void          Nwk_ManGraphHashEdge( Nwk_Grf_t * p, int iLut1, int iLut2 );
139 extern ABC_DLL void          Nwk_ManGraphSolve( Nwk_Grf_t * p );
140 extern ABC_DLL int           Nwk_ManLutMergeGraphTest( char * pFileName );
141 
142 
143 
144 ABC_NAMESPACE_HEADER_END
145 
146 
147 
148 #endif
149 
150 ////////////////////////////////////////////////////////////////////////
151 ///                       END OF FILE                                ///
152 ////////////////////////////////////////////////////////////////////////
153 
154