abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
rwr.h
Go to the documentation of this file.
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 
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
82  int nNodesBeg;
83  int nNodesEnd;
84  int nScores[222];
85  int nCutsGood;
86  int nCutsBad;
88  // runtime statistics
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
116 static inline int Rwr_IsComplement( Rwr_Node_t * p ) { return (int )(((ABC_PTRUINT_T)p) & 01); }
117 static inline Rwr_Node_t * Rwr_Regular( Rwr_Node_t * p ) { return (Rwr_Node_t *)((ABC_PTRUINT_T)(p) & ~01); }
118 static inline Rwr_Node_t * Rwr_Not( Rwr_Node_t * p ) { return (Rwr_Node_t *)((ABC_PTRUINT_T)(p) ^ 01); }
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 
165 
166 
167 
168 #endif
169 
170 ////////////////////////////////////////////////////////////////////////
171 /// END OF FILE ///
172 ////////////////////////////////////////////////////////////////////////
173 
unsigned fUsed
Definition: rwr.h:108
void Rwr_ManPrintStatsFile(Rwr_Man_t *p)
Definition: rwrMan.c:190
abctime timeTotal
Definition: rwr.h:95
char * Rwr_ManGetPractical(Rwr_Man_t *p)
Definition: rwrUtil.c:640
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
abctime timeEval
Definition: rwr.h:92
int Rwr_ManReadCompl(Rwr_Man_t *p)
Definition: rwrMan.c:245
abctime timeStart
Definition: rwr.h:89
short nScore
Definition: rwr.h:102
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
int nNodesEnd
Definition: rwr.h:83
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Rwr_Node_t * Rwr_ManAddVar(Rwr_Man_t *p, unsigned uTruth, int fPrecompute)
Definition: rwrLib.c:253
void Rwr_ManPrecompute(Rwr_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition: rwrLib.c:48
unsigned char * pMap
Definition: rwr.h:57
Definition: rwr.h:50
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int nConsidered
Definition: rwr.h:68
int Id
Definition: rwr.h:100
unsigned Level
Definition: rwr.h:107
void Rwr_ManWriteToArray(Rwr_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition: rwrUtil.c:426
int nNodesBeg
Definition: rwr.h:82
unsigned short * puCanons
Definition: rwr.h:54
int nNodesGained
Definition: rwr.h:81
void Rwr_ManPreprocess(Rwr_Man_t *p)
MACRO DEFINITIONS ///.
Definition: rwrDec.c:49
unsigned uTruth
Definition: rwr.h:105
char ** pPerms4
Definition: rwr.h:60
static int Rwr_IsComplement(Rwr_Node_t *p)
Definition: rwr.h:116
Rwr_Node_t * p0
Definition: rwr.h:110
Vec_Ptr_t * vNodesTemp
Definition: rwr.h:77
Vec_Int_t * vLevNums
Definition: rwr.h:76
abctime timeCut
Definition: rwr.h:90
Extra_MmFixed_t * pMmNode
Definition: rwr.h:65
int nTravIds
Definition: rwr.h:67
Vec_Vec_t * vClasses
Definition: rwr.h:64
void Rwr_ManAddTimeTotal(Rwr_Man_t *p, abctime Time)
Definition: rwrMan.c:293
short nGain
Definition: rwr.h:103
static Rwr_Node_t * Rwr_NotCond(Rwr_Node_t *p, int c)
Definition: rwr.h:119
Vec_Ptr_t * vFanins
Definition: rwr.h:74
void Rwr_ManIncTravId(Rwr_Man_t *p)
Definition: rwrLib.c:350
void Rwr_ManPrintStats(Rwr_Man_t *p)
Definition: rwrMan.c:143
int Rwr_ManNodeVolume(Rwr_Man_t *p, Rwr_Node_t *p0, Rwr_Node_t *p1)
Definition: rwrLib.c:330
int TravId
Definition: rwr.h:101
void * Rwr_ManReadDecs(Rwr_Man_t *p)
Definition: rwrMan.c:213
Vec_Ptr_t * vFaninsCur
Definition: rwr.h:75
Rwr_Man_t * Rwr_ManStart(int fPrecompute)
DECLARATIONS ///.
Definition: rwrMan.c:47
void Rwr_ManAddTimeUpdate(Rwr_Man_t *p, abctime Time)
Definition: rwrMan.c:277
unsigned fExor
Definition: rwr.h:109
int nSubgraphs
Definition: rwr.h:87
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
Definition: abc_global.h:105
char * pPhases
Definition: rwr.h:55
#define ABC_NAMESPACE_HEADER_END
Definition: abc_global.h:106
unsigned short * pMapInv
Definition: rwr.h:58
int fCompl
Definition: rwr.h:72
int nCutsGood
Definition: rwr.h:85
void Rwr_ManAddTimeCuts(Rwr_Man_t *p, abctime Time)
Definition: rwrMan.c:261
void Rwr_ScoresReport(Rwr_Man_t *p)
Definition: rwrEva.c:550
void Rwr_ManWriteToFile(Rwr_Man_t *p, char *pFileName)
Definition: rwrUtil.c:524
int nClasses
Definition: rwr.h:70
int nCutsBad
Definition: rwr.h:86
Rwr_Node_t ** pTable
Definition: rwr.h:63
Rwr_Node_t * p1
Definition: rwr.h:111
void Rwr_ManLoadFromArray(Rwr_Man_t *p, int fVerbose)
Definition: rwrUtil.c:472
char * pPractical
Definition: rwr.h:59
void * pGraph
Definition: rwr.h:73
int nNodesRewritten
Definition: rwr.h:80
unsigned Volume
Definition: rwr.h:106
int nNodesConsidered
Definition: rwr.h:79
int nAdded
Definition: rwr.h:69
void Rwr_ListAddToTail(Rwr_Node_t **ppList, Rwr_Node_t *pNode)
Definition: rwrUtil.c:619
static Rwr_Node_t * Rwr_Not(Rwr_Node_t *p)
Definition: rwr.h:118
short nAdded
Definition: rwr.h:104
Rwr_Node_t * Rwr_ManAddNode(Rwr_Man_t *p, Rwr_Node_t *p0, Rwr_Node_t *p1, int fExor, int Level, int Volume)
Definition: rwrLib.c:206
abctime timeMffc
Definition: rwr.h:93
Rwr_Node_t * pNext
Definition: rwr.h:112
ABC_INT64_T abctime
Definition: abc_global.h:278
abctime timeUpdate
Definition: rwr.h:94
void Rwr_ManLoadFromFile(Rwr_Man_t *p, char *pFileName)
Definition: rwrUtil.c:562
static Rwr_Node_t * Rwr_Regular(Rwr_Node_t *p)
Definition: rwr.h:117
Vec_Ptr_t * vForest
Definition: rwr.h:62
void Rwr_ManStop(Rwr_Man_t *p)
Definition: rwrMan.c:109
void Rwr_ManPrint(Rwr_Man_t *p)
Definition: rwrPrint.c:237
abctime timeRes
Definition: rwr.h:91
int nFuncs
Definition: rwr.h:53
Vec_Ptr_t * Rwr_ManReadLeaves(Rwr_Man_t *p)
Definition: rwrMan.c:229
int Rwr_NodeRewrite(Rwr_Man_t *p, Cut_Man_t *pManCut, Abc_Obj_t *pNode, int fUpdateLevel, int fUseZeros, int fPlaceEnable)
FUNCTION DEFINITIONS ///.
Definition: rwrEva.c:59
char * pPerms
Definition: rwr.h:56
int nScores[222]
Definition: rwr.h:84
void Rwr_ScoresClean(Rwr_Man_t *p)
Definition: rwrEva.c:504