1 /**CFile****************************************************************
2
3 FileName [rwr.h]
4
5 SystemName [ABC: Logic synthesis and verification system.]
6
7 PackageName [DAG-aware AIG rewriting package.]
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: rwr.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18
19 ***********************************************************************/
20
21 #ifndef ABC__opt__rwr__rwr_h
22 #define ABC__opt__rwr__rwr_h
23
24
25 ////////////////////////////////////////////////////////////////////////
26 /// INCLUDES ///
27 ////////////////////////////////////////////////////////////////////////
28
29 #include "base/abc/abc.h"
30 #include "opt/cut/cut.h"
31
32 ////////////////////////////////////////////////////////////////////////
33 /// PARAMETERS ///
34 ////////////////////////////////////////////////////////////////////////
35
36
37
38 ABC_NAMESPACE_HEADER_START
39
40
41 ////////////////////////////////////////////////////////////////////////
42 /// BASIC TYPES ///
43 ////////////////////////////////////////////////////////////////////////
44
45 #define RWR_LIMIT 1048576/4 // ((1 << 20)
46
47 typedef struct Rwr_Man_t_ Rwr_Man_t;
48 typedef struct Rwr_Node_t_ Rwr_Node_t;
49
50 struct Rwr_Man_t_
51 {
52 // internal lookups
53 int nFuncs; // number of four var functions
54 unsigned short * puCanons; // canonical forms
55 char * pPhases; // canonical phases
56 char * pPerms; // canonical permutations
57 unsigned char * pMap; // mapping of functions into class numbers
58 unsigned short * pMapInv; // mapping of classes into functions
59 char * pPractical; // practical NPN classes
60 char ** pPerms4; // four-var permutations
61 // node space
62 Vec_Ptr_t * vForest; // all the nodes
63 Rwr_Node_t ** pTable; // the hash table of nodes by their canonical form
64 Vec_Vec_t * vClasses; // the nodes of the equivalence classes
65 Extra_MmFixed_t * pMmNode; // memory for nodes and cuts
66 // statistical variables
67 int nTravIds; // the counter of traversal IDs
68 int nConsidered; // the number of nodes considered
69 int nAdded; // the number of nodes added to lists
70 int nClasses; // the number of NN classes
71 // the result of resynthesis
72 int fCompl; // indicates if the output of FF should be complemented
73 void * pGraph; // the decomposition tree (temporary)
74 Vec_Ptr_t * vFanins; // the fanins array (temporary)
75 Vec_Ptr_t * vFaninsCur; // the fanins array (temporary)
76 Vec_Int_t * vLevNums; // the array of levels (temporary)
77 Vec_Ptr_t * vNodesTemp; // the nodes in MFFC (temporary)
78 // node statistics
79 int nNodesConsidered;
80 int nNodesRewritten;
81 int nNodesGained;
82 int nNodesBeg;
83 int nNodesEnd;
84 int nScores[222];
85 int nCutsGood;
86 int nCutsBad;
87 int nSubgraphs;
88 // runtime statistics
89 abctime timeStart;
90 abctime timeCut;
91 abctime timeRes;
92 abctime timeEval;
93 abctime timeMffc;
94 abctime timeUpdate;
95 abctime timeTotal;
96 };
97
98 struct Rwr_Node_t_ // 24 bytes
99 {
100 int Id; // ID
101 int TravId; // traversal ID
102 short nScore;
103 short nGain;
104 short nAdded;
105 unsigned uTruth : 16; // truth table
106 unsigned Volume : 8; // volume
107 unsigned Level : 6; // level
108 unsigned fUsed : 1; // mark
109 unsigned fExor : 1; // mark
110 Rwr_Node_t * p0; // first child
111 Rwr_Node_t * p1; // second child
112 Rwr_Node_t * pNext; // next in the table
113 };
114
115 // manipulation of complemented attributes
Rwr_IsComplement(Rwr_Node_t * p)116 static inline int Rwr_IsComplement( Rwr_Node_t * p ) { return (int )(((ABC_PTRUINT_T)p) & 01); }
Rwr_Regular(Rwr_Node_t * p)117 static inline Rwr_Node_t * Rwr_Regular( Rwr_Node_t * p ) { return (Rwr_Node_t *)((ABC_PTRUINT_T)(p) & ~01); }
Rwr_Not(Rwr_Node_t * p)118 static inline Rwr_Node_t * Rwr_Not( Rwr_Node_t * p ) { return (Rwr_Node_t *)((ABC_PTRUINT_T)(p) ^ 01); }
Rwr_NotCond(Rwr_Node_t * p,int c)119 static inline Rwr_Node_t * Rwr_NotCond( Rwr_Node_t * p, int c ) { return (Rwr_Node_t *)((ABC_PTRUINT_T)(p) ^ (c)); }
120
121 ////////////////////////////////////////////////////////////////////////
122 /// MACRO DEFINITIONS ///
123 ////////////////////////////////////////////////////////////////////////
124
125 ////////////////////////////////////////////////////////////////////////
126 /// FUNCTION DECLARATIONS ///
127 ////////////////////////////////////////////////////////////////////////
128
129 /*=== rwrDec.c ========================================================*/
130 extern void Rwr_ManPreprocess( Rwr_Man_t * p );
131 /*=== rwrEva.c ========================================================*/
132 extern int Rwr_NodeRewrite( Rwr_Man_t * p, Cut_Man_t * pManCut, Abc_Obj_t * pNode, int fUpdateLevel, int fUseZeros, int fPlaceEnable );
133 extern void Rwr_ScoresClean( Rwr_Man_t * p );
134 extern void Rwr_ScoresReport( Rwr_Man_t * p );
135 /*=== rwrLib.c ========================================================*/
136 extern void Rwr_ManPrecompute( Rwr_Man_t * p );
137 extern Rwr_Node_t * Rwr_ManAddVar( Rwr_Man_t * p, unsigned uTruth, int fPrecompute );
138 extern Rwr_Node_t * Rwr_ManAddNode( Rwr_Man_t * p, Rwr_Node_t * p0, Rwr_Node_t * p1, int fExor, int Level, int Volume );
139 extern int Rwr_ManNodeVolume( Rwr_Man_t * p, Rwr_Node_t * p0, Rwr_Node_t * p1 );
140 extern void Rwr_ManIncTravId( Rwr_Man_t * p );
141 /*=== rwrMan.c ========================================================*/
142 extern Rwr_Man_t * Rwr_ManStart( int fPrecompute );
143 extern void Rwr_ManStop( Rwr_Man_t * p );
144 extern void Rwr_ManPrintStats( Rwr_Man_t * p );
145 extern void Rwr_ManPrintStatsFile( Rwr_Man_t * p );
146 extern void * Rwr_ManReadDecs( Rwr_Man_t * p );
147 extern Vec_Ptr_t * Rwr_ManReadLeaves( Rwr_Man_t * p );
148 extern int Rwr_ManReadCompl( Rwr_Man_t * p );
149 extern void Rwr_ManAddTimeCuts( Rwr_Man_t * p, abctime Time );
150 extern void Rwr_ManAddTimeUpdate( Rwr_Man_t * p, abctime Time );
151 extern void Rwr_ManAddTimeTotal( Rwr_Man_t * p, abctime Time );
152 /*=== rwrPrint.c ========================================================*/
153 extern void Rwr_ManPrint( Rwr_Man_t * p );
154 /*=== rwrUtil.c ========================================================*/
155 extern void Rwr_ManWriteToArray( Rwr_Man_t * p );
156 extern void Rwr_ManLoadFromArray( Rwr_Man_t * p, int fVerbose );
157 extern void Rwr_ManWriteToFile( Rwr_Man_t * p, char * pFileName );
158 extern void Rwr_ManLoadFromFile( Rwr_Man_t * p, char * pFileName );
159 extern void Rwr_ListAddToTail( Rwr_Node_t ** ppList, Rwr_Node_t * pNode );
160 extern char * Rwr_ManGetPractical( Rwr_Man_t * p );
161
162
163
164 ABC_NAMESPACE_HEADER_END
165
166
167
168 #endif
169
170 ////////////////////////////////////////////////////////////////////////
171 /// END OF FILE ///
172 ////////////////////////////////////////////////////////////////////////
173
174