abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
rwt.h
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [rwt.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: rwt.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #ifndef ABC__aig__rwt__rwt_h
22 #define ABC__aig__rwt__rwt_h
23 
24 
25 ////////////////////////////////////////////////////////////////////////
26 /// INCLUDES ///
27 ////////////////////////////////////////////////////////////////////////
28 
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <assert.h>
33 
34 #include "misc/vec/vec.h"
35 #include "misc/extra/extra.h"
36 #include "misc/mem/mem.h"
37 
38 ////////////////////////////////////////////////////////////////////////
39 /// PARAMETERS ///
40 ////////////////////////////////////////////////////////////////////////
41 
42 
43 
45 
46 
47 ////////////////////////////////////////////////////////////////////////
48 /// BASIC TYPES ///
49 ////////////////////////////////////////////////////////////////////////
50 
51 #define RWT_LIMIT 1048576/4 // ((1 << 20)
52 #define RWT_MIN(a,b) (((a) < (b))? (a) : (b))
53 #define RWT_MAX(a,b) (((a) > (b))? (a) : (b))
54 
55 typedef struct Rwt_Man_t_ Rwt_Man_t;
56 typedef struct Rwt_Node_t_ Rwt_Node_t;
57 
58 struct Rwt_Man_t_
59 {
60  // internal lookups
61  int nFuncs; // number of four var functions
62  unsigned short * puCanons; // canonical forms
63  char * pPhases; // canonical phases
64  char * pPerms; // canonical permutations
65  unsigned char * pMap; // mapping of functions into class numbers
66  unsigned short * pMapInv; // mapping of classes into functions
67  char * pPractical; // practical NPN classes
68  char ** pPerms4; // four-var permutations
69  // node space
70  Vec_Ptr_t * vForest; // all the nodes
71  Rwt_Node_t ** pTable; // the hash table of nodes by their canonical form
72  Vec_Vec_t * vClasses; // the nodes of the equivalence classes
73  Mem_Fixed_t * pMmNode; // memory for nodes and cuts
74  // statistical variables
75  int nTravIds; // the counter of traversal IDs
76  int nConsidered; // the number of nodes considered
77  int nAdded; // the number of nodes added to lists
78  int nClasses; // the number of NN classes
79  // the result of resynthesis
80  int fCompl; // indicates if the output of FF should be complemented
81  void * pCut; // the decomposition tree (temporary)
82  void * pGraph; // the decomposition tree (temporary)
83  char * pPerm; // permutation used for the best cut
84  Vec_Ptr_t * vFanins; // the fanins array (temporary)
85  Vec_Ptr_t * vFaninsCur; // the fanins array (temporary)
86  Vec_Int_t * vLevNums; // the array of levels (temporary)
87  Vec_Ptr_t * vNodesTemp; // the nodes in MFFC (temporary)
88  // node statistics
92  int nScores[222];
93  int nCutsGood;
94  int nCutsBad;
96  // runtime statistics
105 };
106 
107 struct Rwt_Node_t_ // 24 bytes
108 {
109  int Id; // ID
110  int TravId; // traversal ID
111  unsigned uTruth : 16; // truth table
112  unsigned Volume : 8; // volume
113  unsigned Level : 6; // level
114  unsigned fUsed : 1; // mark
115  unsigned fExor : 1; // mark
116  Rwt_Node_t * p0; // first child
117  Rwt_Node_t * p1; // second child
118  Rwt_Node_t * pNext; // next in the table
119 };
120 
121 // manipulation of complemented attributes
122 static inline int Rwt_IsComplement( Rwt_Node_t * p ) { return (int)(((ABC_PTRUINT_T)p) & 01); }
123 static inline Rwt_Node_t * Rwt_Regular( Rwt_Node_t * p ) { return (Rwt_Node_t *)((ABC_PTRUINT_T)(p) & ~01); }
124 static inline Rwt_Node_t * Rwt_Not( Rwt_Node_t * p ) { return (Rwt_Node_t *)((ABC_PTRUINT_T)(p) ^ 01); }
125 static inline Rwt_Node_t * Rwt_NotCond( Rwt_Node_t * p, int c ) { return (Rwt_Node_t *)((ABC_PTRUINT_T)(p) ^ (c)); }
126 
127 ////////////////////////////////////////////////////////////////////////
128 /// MACRO DEFINITIONS ///
129 ////////////////////////////////////////////////////////////////////////
130 
131 ////////////////////////////////////////////////////////////////////////
132 /// FUNCTION DECLARATIONS ///
133 ////////////////////////////////////////////////////////////////////////
134 
135 /*=== rwrDec.c ========================================================*/
136 extern void Rwt_ManPreprocess( Rwt_Man_t * p );
137 /*=== rwrMan.c ========================================================*/
138 extern Rwt_Man_t * Rwt_ManStart( int fPrecompute );
139 extern void Rwt_ManStop( Rwt_Man_t * p );
140 extern void Rwt_ManPrintStats( Rwt_Man_t * p );
141 extern void Rwt_ManPrintStatsFile( Rwt_Man_t * p );
142 extern void * Rwt_ManReadDecs( Rwt_Man_t * p );
143 extern Vec_Ptr_t * Rwt_ManReadLeaves( Rwt_Man_t * p );
144 extern int Rwt_ManReadCompl( Rwt_Man_t * p );
145 extern void Rwt_ManAddTimeCuts( Rwt_Man_t * p, abctime Time );
146 extern void Rwt_ManAddTimeUpdate( Rwt_Man_t * p, abctime Time );
147 extern void Rwt_ManAddTimeTotal( Rwt_Man_t * p, abctime Time );
148 /*=== rwrUtil.c ========================================================*/
149 extern void Rwt_ManLoadFromArray( Rwt_Man_t * p, int fVerbose );
150 extern char * Rwt_ManGetPractical( Rwt_Man_t * p );
151 extern Rwt_Node_t * Rwt_ManAddVar( Rwt_Man_t * p, unsigned uTruth, int fPrecompute );
152 extern void Rwt_ManIncTravId( Rwt_Man_t * p );
153 
154 
155 
157 
158 
159 
160 #endif
161 
162 ////////////////////////////////////////////////////////////////////////
163 /// END OF FILE ///
164 ////////////////////////////////////////////////////////////////////////
165 
void Rwt_ManStop(Rwt_Man_t *p)
Definition: rwtMan.c:149
void Rwt_ManIncTravId(Rwt_Man_t *p)
Definition: rwtUtil.c:547
int Id
Definition: rwt.h:109
int nAdded
Definition: rwt.h:77
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void Rwt_ManAddTimeTotal(Rwt_Man_t *p, abctime Time)
Definition: rwtMan.c:333
Rwt_Node_t * p1
Definition: rwt.h:117
Rwt_Node_t * pNext
Definition: rwt.h:118
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
Rwt_Node_t * Rwt_ManAddVar(Rwt_Man_t *p, unsigned uTruth, int fPrecompute)
Definition: rwtUtil.c:446
Vec_Ptr_t * Rwt_ManReadLeaves(Rwt_Man_t *p)
Definition: rwtMan.c:269
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int nConsidered
Definition: rwt.h:76
char ** pPerms4
Definition: rwt.h:68
unsigned short * pMapInv
Definition: rwt.h:66
void * pCut
Definition: rwt.h:81
abctime timeMffc
Definition: rwt.h:102
Rwt_Man_t * Rwt_ManStart(int fPrecompute)
Definition: rwtMan.c:87
unsigned uTruth
Definition: rwt.h:111
int nFuncs
Definition: rwt.h:61
Rwt_Node_t ** pTable
Definition: rwt.h:71
int fCompl
Definition: rwt.h:80
void Rwt_ManPrintStats(Rwt_Man_t *p)
Definition: rwtMan.c:183
Mem_Fixed_t * pMmNode
Definition: rwt.h:73
unsigned Level
Definition: rwt.h:113
static int Rwt_IsComplement(Rwt_Node_t *p)
Definition: rwt.h:122
Vec_Ptr_t * vNodesTemp
Definition: rwt.h:87
int Rwt_ManReadCompl(Rwt_Man_t *p)
Definition: rwtMan.c:285
void Rwt_ManLoadFromArray(Rwt_Man_t *p, int fVerbose)
Definition: rwtUtil.c:589
char * pPerms
Definition: rwt.h:64
Vec_Ptr_t * vFaninsCur
Definition: rwt.h:85
int nNodesGained
Definition: rwt.h:91
void * Rwt_ManReadDecs(Rwt_Man_t *p)
Definition: rwtMan.c:253
unsigned Volume
Definition: rwt.h:112
abctime timeEval
Definition: rwt.h:101
int nTravIds
Definition: rwt.h:75
abctime timeTotal
Definition: rwt.h:104
int nNodesRewritten
Definition: rwt.h:90
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
Definition: abc_global.h:105
typedefABC_NAMESPACE_HEADER_START struct Mem_Fixed_t_ Mem_Fixed_t
DECLARATIONS ///.
Definition: mem.h:33
int nNodesConsidered
Definition: rwt.h:89
abctime timeTruth
Definition: rwt.h:98
char * pPhases
Definition: rwt.h:63
#define ABC_NAMESPACE_HEADER_END
Definition: abc_global.h:106
Vec_Vec_t * vClasses
Definition: rwt.h:72
Rwt_Node_t * p0
Definition: rwt.h:116
void Rwt_ManPreprocess(Rwt_Man_t *p)
MACRO DEFINITIONS ///.
Definition: rwtDec.c:49
int nSubgraphs
Definition: rwt.h:95
static Rwt_Node_t * Rwt_NotCond(Rwt_Node_t *p, int c)
Definition: rwt.h:125
void Rwt_ManAddTimeCuts(Rwt_Man_t *p, abctime Time)
Definition: rwtMan.c:301
unsigned fExor
Definition: rwt.h:115
Definition: rwt.h:58
unsigned fUsed
Definition: rwt.h:114
int nScores[222]
Definition: rwt.h:92
abctime timeUpdate
Definition: rwt.h:103
abctime timeStart
Definition: rwt.h:97
void Rwt_ManAddTimeUpdate(Rwt_Man_t *p, abctime Time)
Definition: rwtMan.c:317
unsigned char * pMap
Definition: rwt.h:65
void Rwt_ManPrintStatsFile(Rwt_Man_t *p)
Definition: rwtMan.c:230
Vec_Ptr_t * vFanins
Definition: rwt.h:84
abctime timeCut
Definition: rwt.h:99
int nClasses
Definition: rwt.h:78
int TravId
Definition: rwt.h:110
void * pGraph
Definition: rwt.h:82
int nCutsBad
Definition: rwt.h:94
static Rwt_Node_t * Rwt_Regular(Rwt_Node_t *p)
Definition: rwt.h:123
int nCutsGood
Definition: rwt.h:93
ABC_INT64_T abctime
Definition: abc_global.h:278
static Rwt_Node_t * Rwt_Not(Rwt_Node_t *p)
Definition: rwt.h:124
Vec_Int_t * vLevNums
Definition: rwt.h:86
Vec_Ptr_t * vForest
Definition: rwt.h:70
char * pPractical
Definition: rwt.h:67
unsigned short * puCanons
Definition: rwt.h:62
abctime timeRes
Definition: rwt.h:100
char * Rwt_ManGetPractical(Rwt_Man_t *p)
Definition: rwtUtil.c:640
char * pPerm
Definition: rwt.h:83