abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
lpkInt.h
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [lpkInt.h]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Fast Boolean matching for LUT structures.]
8 
9  Synopsis [Internal declarations.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - April 28, 2007.]
16 
17  Revision [$Id: lpkInt.h,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #ifndef ABC__opt__lpk__lpkInt_h
22 #define ABC__opt__lpk__lpkInt_h
23 
24 
25 ////////////////////////////////////////////////////////////////////////
26 /// INCLUDES ///
27 ////////////////////////////////////////////////////////////////////////
28 
29 #include "base/abc/abc.h"
30 #include "bool/kit/kit.h"
31 #include "map/if/if.h"
32 #include "lpk.h"
33 
34 ////////////////////////////////////////////////////////////////////////
35 /// PARAMETERS ///
36 ////////////////////////////////////////////////////////////////////////
37 
38 
39 
41 
42 
43 ////////////////////////////////////////////////////////////////////////
44 /// BASIC TYPES ///
45 ////////////////////////////////////////////////////////////////////////
46 
47 #define LPK_SIZE_MAX 24 // the largest size of the function
48 #define LPK_CUTS_MAX 512 // the largest number of cuts considered
49 
50 typedef struct Lpk_Man_t_ Lpk_Man_t;
51 typedef struct Lpk_Cut_t_ Lpk_Cut_t;
52 
53 struct Lpk_Cut_t_
54 {
55  unsigned nLeaves : 6; // (L) the number of leaves
56  unsigned nNodes : 6; // (M) the number of nodes
57  unsigned nNodesDup : 6; // (Q) nodes outside of MFFC
58  unsigned nLuts : 6; // (N) the number of LUTs to try
59  unsigned unused : 6; // unused
60  unsigned fHasDsd : 1; // set to 1 if the cut has structural DSD (and so cannot be used)
61  unsigned fMark : 1; // multipurpose mark
62  unsigned uSign[2]; // the signature
63  float Weight; // the weight of the cut: (M - Q)/N(V) (the larger the better)
64  int Gain; // the gain achieved using this cut
65  int pLeaves[LPK_SIZE_MAX]; // the leaves of the cut
66  int pNodes[LPK_SIZE_MAX]; // the nodes of the cut
67 };
68 
69 struct Lpk_Man_t_
70 {
71  // parameters
72  Lpk_Par_t * pPars; // the set of parameters
73  // current representation
74  Abc_Ntk_t * pNtk; // the network
75  Abc_Obj_t * pObj; // the node to resynthesize
76  // cut representation
77  int nMffc; // the size of MFFC of the node
78  int nCuts; // the total number of cuts
79  int nCutsMax; // the largest possible number of cuts
80  int nEvals; // the number of good cuts
81  Lpk_Cut_t pCuts[LPK_CUTS_MAX]; // the storage for cuts
82  int pEvals[LPK_CUTS_MAX]; // the good cuts
83  // visited nodes
85  // mapping manager
89  // temporary variables
90  int fCofactoring; // working in the cofactoring mode
91  int fCalledOnce; // limits the depth of MUX cofactoring
92  int nCalledSRed; // the number of called to SRed
93  int pRefs[LPK_SIZE_MAX]; // fanin reference counters
94  int pCands[LPK_SIZE_MAX]; // internal nodes pointing only to the leaves
96  // truth table representation
97  Vec_Ptr_t * vTtElems; // elementary truth tables
98  Vec_Ptr_t * vTtNodes; // storage for temporary truth tables of the nodes
102  unsigned puSupps[32]; // the supports of the cofactors
103  unsigned * ppTruths[5][16];
104  // variable sets
107  // statistics
108  int nNodesTotal; // total number of nodes
109  int nNodesOver; // nodes with cuts over the limit
110  int nCutsTotal; // total number of cuts
111  int nCutsUseful; // useful cuts
112  int nGainTotal; // the gain in LUTs
113  int nChanges; // the number of changed nodes
114  int nBenefited; // the number of gainful that benefited from decomposition
115  int nMuxes;
116  int nDsds;
121  // counter of non-DSD blocks
122  int nBlocks[17];
123  // runtime
133  // runtime of eval
138 
139 };
140 
141 
142 // internal representation of the function to be decomposed
143 typedef struct Lpk_Fun_t_ Lpk_Fun_t;
145 {
146  Vec_Ptr_t * vNodes; // the array of leaves and decomposition nodes
147  unsigned Id : 7; // the ID of this node
148  unsigned nVars : 5; // the number of variables
149  unsigned nLutK : 4; // the number of LUT inputs
150  unsigned nAreaLim : 5; // the area limit (the largest allowed)
151  unsigned nDelayLim : 9; // the delay limit (the largest allowed)
152  unsigned fSupports : 1; // supports of cofactors were precomputed
153  unsigned fMark : 1; // marks the MUX-based dec
154  unsigned uSupp; // the support of this component
155  unsigned puSupps[32]; // the supports of the cofactors
156  char pDelays[16]; // the delays of the inputs
157  char pFanins[16]; // the fanins of this function
158  unsigned pTruth[0]; // the truth table (contains room for three truth tables)
159 };
160 
161 // preliminary decomposition result
162 typedef struct Lpk_Res_t_ Lpk_Res_t;
164 {
165  int nBSVars; // the number of bound set variables
166  unsigned BSVars; // the bound set
167  int nCofVars; // the number of cofactoring variables
168  char pCofVars[4]; // the cofactoring variables
169  int nSuppSizeS; // support size of the smaller (decomposed) function
170  int nSuppSizeL; // support size of the larger (composition) function
171  int DelayEst; // estimated delay of the decomposition
172  int AreaEst; // estimated area of the decomposition
173  int Variable; // variable in MUX decomposition
174  int Polarity; // polarity in MUX decomposition
175 };
176 
177 static inline int Lpk_LutNumVars( int nLutsLim, int nLutK ) { return nLutsLim * (nLutK - 1) + 1; }
178 static inline int Lpk_LutNumLuts( int nVarsMax, int nLutK ) { return (nVarsMax - 1) / (nLutK - 1) + (int)((nVarsMax - 1) % (nLutK - 1) > 0); }
179 static inline unsigned * Lpk_FunTruth( Lpk_Fun_t * p, int Num ) { assert( Num < 3 ); return p->pTruth + Kit_TruthWordNum(p->nVars) * Num; }
180 
181 ////////////////////////////////////////////////////////////////////////
182 /// MACRO DEFINITIONS ///
183 ////////////////////////////////////////////////////////////////////////
184 
185 ////////////////////////////////////////////////////////////////////////
186 /// ITERATORS ///
187 ////////////////////////////////////////////////////////////////////////
188 
189 #define Lpk_CutForEachLeaf( pNtk, pCut, pObj, i ) \
190  for ( i = 0; (i < (int)(pCut)->nLeaves) && (((pObj) = Abc_NtkObj(pNtk, (pCut)->pLeaves[i])), 1); i++ )
191 #define Lpk_CutForEachNode( pNtk, pCut, pObj, i ) \
192  for ( i = 0; (i < (int)(pCut)->nNodes) && (((pObj) = Abc_NtkObj(pNtk, (pCut)->pNodes[i])), 1); i++ )
193 #define Lpk_CutForEachNodeReverse( pNtk, pCut, pObj, i ) \
194  for ( i = (int)(pCut)->nNodes - 1; (i >= 0) && (((pObj) = Abc_NtkObj(pNtk, (pCut)->pNodes[i])), 1); i-- )
195 #define Lpk_SuppForEachVar( Supp, Var )\
196  for ( Var = 0; Var < 16; Var++ )\
197  if ( !(Supp & (1<<Var)) ) {} else
198 
199 ////////////////////////////////////////////////////////////////////////
200 /// FUNCTION DECLARATIONS ///
201 ////////////////////////////////////////////////////////////////////////
202 
203 /*=== lpkAbcDec.c ============================================================*/
204 extern Abc_Obj_t * Lpk_Decompose( Lpk_Man_t * pMan, Abc_Ntk_t * pNtk, Vec_Ptr_t * vLeaves, unsigned * pTruth, unsigned * puSupps, int nLutK, int AreaLim, int DelayLim );
205 /*=== lpkAbcDsd.c ============================================================*/
206 extern Lpk_Res_t * Lpk_DsdAnalize( Lpk_Man_t * pMan, Lpk_Fun_t * p, int nShared );
207 extern Lpk_Fun_t * Lpk_DsdSplit( Lpk_Man_t * pMan, Lpk_Fun_t * p, char * pCofVars, int nCofVars, unsigned uBoundSet );
208 /*=== lpkAbcMux.c ============================================================*/
209 extern Lpk_Res_t * Lpk_MuxAnalize( Lpk_Man_t * pMan, Lpk_Fun_t * p );
210 extern Lpk_Fun_t * Lpk_MuxSplit( Lpk_Man_t * pMan, Lpk_Fun_t * p, int Var, int Pol );
211 /*=== lpkAbcUtil.c ============================================================*/
212 extern Lpk_Fun_t * Lpk_FunAlloc( int nVars );
213 extern void Lpk_FunFree( Lpk_Fun_t * p );
214 extern Lpk_Fun_t * Lpk_FunCreate( Abc_Ntk_t * pNtk, Vec_Ptr_t * vLeaves, unsigned * pTruth, int nLutK, int AreaLim, int DelayLim );
215 extern Lpk_Fun_t * Lpk_FunDup( Lpk_Fun_t * p, unsigned * pTruth );
216 extern int Lpk_FunSuppMinimize( Lpk_Fun_t * p );
217 extern void Lpk_FunComputeCofSupps( Lpk_Fun_t * p );
218 extern int Lpk_SuppDelay( unsigned uSupp, char * pDelays );
219 extern int Lpk_SuppToVars( unsigned uBoundSet, char * pVars );
220 
221 
222 /*=== lpkCut.c =========================================================*/
223 extern unsigned * Lpk_CutTruth( Lpk_Man_t * p, Lpk_Cut_t * pCut, int fInv );
224 extern int Lpk_NodeCuts( Lpk_Man_t * p );
225 /*=== lpkMap.c =========================================================*/
226 extern Lpk_Man_t * Lpk_ManStart( Lpk_Par_t * pPars );
227 extern void Lpk_ManStop( Lpk_Man_t * p );
228 /*=== lpkMap.c =========================================================*/
229 extern If_Obj_t * Lpk_MapPrime( Lpk_Man_t * p, unsigned * pTruth, int nVars, If_Obj_t ** ppLeaves );
230 extern If_Obj_t * Lpk_MapTree_rec( Lpk_Man_t * p, Kit_DsdNtk_t * pNtk, If_Obj_t ** ppLeaves, int iLit, If_Obj_t * pResult );
231 /*=== lpkMulti.c =======================================================*/
232 extern If_Obj_t * Lpk_MapTreeMulti( Lpk_Man_t * p, unsigned * pTruth, int nLeaves, If_Obj_t ** ppLeaves );
233 /*=== lpkMux.c =========================================================*/
234 extern If_Obj_t * Lpk_MapTreeMux_rec( Lpk_Man_t * p, unsigned * pTruth, int nVars, If_Obj_t ** ppLeaves );
235 extern If_Obj_t * Lpk_MapSuppRedDec_rec( Lpk_Man_t * p, unsigned * pTruth, int nVars, If_Obj_t ** ppLeaves );
236 /*=== lpkSets.c =========================================================*/
237 extern unsigned Lpk_MapSuppRedDecSelect( Lpk_Man_t * p, unsigned * pTruth, int nVars, int * piVar, int * piVarReused );
238 
239 
240 
242 
243 
244 
245 #endif
246 
247 ////////////////////////////////////////////////////////////////////////
248 /// END OF FILE ///
249 ////////////////////////////////////////////////////////////////////////
250 
void Lpk_FunFree(Lpk_Fun_t *p)
Definition: lpkAbcUtil.c:64
int nNodesTotal
Definition: lpkInt.h:108
int pLeaves[LPK_SIZE_MAX]
Definition: lpkInt.h:65
unsigned uSign[2]
Definition: lpkInt.h:62
unsigned nAreaLim
Definition: lpkInt.h:150
Lpk_Par_t * pPars
Definition: lpkInt.h:72
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
int nTotalNets2
Definition: lpkInt.h:118
float Weight
Definition: lpkInt.h:63
int nCofVars
Definition: lpkInt.h:167
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
Vec_Vec_t * vVisited
Definition: lpkInt.h:84
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned nVars
Definition: lpkInt.h:148
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int Variable
Definition: lpkInt.h:173
abctime timeTruth3
Definition: lpkInt.h:128
int nCuts
Definition: lpkInt.h:78
abctime timeMap
Definition: lpkInt.h:130
Definition: if.h:303
unsigned nLutK
Definition: lpkInt.h:149
int nChanges
Definition: lpkInt.h:113
int AreaEst
Definition: lpkInt.h:172
If_Obj_t * Lpk_MapTree_rec(Lpk_Man_t *p, Kit_DsdNtk_t *pNtk, If_Obj_t **ppLeaves, int iLit, If_Obj_t *pResult)
Definition: lpkMap.c:110
abctime timeEvalMuxSp
Definition: lpkInt.h:135
Vec_Int_t * vBddDir
Definition: lpkInt.h:100
Vec_Ptr_t * vNodes
Definition: lpkInt.h:146
unsigned nLeaves
Definition: lpkInt.h:55
Vec_Int_t * vSets[8]
Definition: lpkInt.h:105
unsigned uSupp
Definition: lpkInt.h:154
Lpk_Fun_t * Lpk_FunCreate(Abc_Ntk_t *pNtk, Vec_Ptr_t *vLeaves, unsigned *pTruth, int nLutK, int AreaLim, int DelayLim)
Definition: lpkAbcUtil.c:80
unsigned fSupports
Definition: lpkInt.h:152
Vec_Int_t * vCover
Definition: lpkInt.h:87
int Lpk_NodeCuts(Lpk_Man_t *p)
Definition: lpkCut.c:588
Lpk_Fun_t * Lpk_FunDup(Lpk_Fun_t *p, unsigned *pTruth)
Definition: lpkAbcUtil.c:114
unsigned pTruth[0]
Definition: lpkInt.h:158
unsigned fMark
Definition: lpkInt.h:61
If_Obj_t * Lpk_MapPrime(Lpk_Man_t *p, unsigned *pTruth, int nVars, If_Obj_t **ppLeaves)
Definition: lpkMap.c:79
int nBenefited
Definition: lpkInt.h:114
int nCutsUseful
Definition: lpkInt.h:111
int nBSVars
Definition: lpkInt.h:165
Lpk_Man_t * Lpk_ManStart(Lpk_Par_t *pPars)
DECLARATIONS ///.
Definition: lpkMan.c:45
Lpk_Fun_t * Lpk_DsdSplit(Lpk_Man_t *pMan, Lpk_Fun_t *p, char *pCofVars, int nCofVars, unsigned uBoundSet)
Definition: lpkAbcDsd.c:564
void Lpk_FunComputeCofSupps(Lpk_Fun_t *p)
Definition: lpkAbcUtil.c:186
Vec_Ptr_t * vTtNodes
Definition: lpkInt.h:98
Abc_Obj_t * pObj
Definition: lpkInt.h:75
unsigned BSVars
Definition: lpkInt.h:166
int nNodesOver
Definition: lpkInt.h:109
unsigned Id
Definition: lpkInt.h:147
static unsigned * Lpk_FunTruth(Lpk_Fun_t *p, int Num)
Definition: lpkInt.h:179
Lpk_Res_t * Lpk_MuxAnalize(Lpk_Man_t *pMan, Lpk_Fun_t *p)
DECLARATIONS ///.
Definition: lpkAbcMux.c:45
Abc_Ntk_t * pNtk
Definition: lpkInt.h:74
abctime timeEvalMuxAn
Definition: lpkInt.h:134
int nDsds
Definition: lpkInt.h:116
Lpk_Cut_t pCuts[LPK_CUTS_MAX]
Definition: lpkInt.h:81
char pCofVars[4]
Definition: lpkInt.h:168
int Lpk_SuppDelay(unsigned uSupp, char *pDelays)
Definition: lpkAbcUtil.c:215
static int Lpk_LutNumVars(int nLutsLim, int nLutK)
Definition: lpkInt.h:177
Abc_Obj_t * Lpk_Decompose(Lpk_Man_t *pMan, Abc_Ntk_t *pNtk, Vec_Ptr_t *vLeaves, unsigned *pTruth, unsigned *puSupps, int nLutK, int AreaLim, int DelayLim)
FUNCTION DECLARATIONS ///.
Definition: lpkAbcDec.c:258
abctime timeEvalDsdSp
Definition: lpkInt.h:137
If_Obj_t * Lpk_MapTreeMulti(Lpk_Man_t *p, unsigned *pTruth, int nLeaves, If_Obj_t **ppLeaves)
Definition: lpkMulti.c:347
unsigned fHasDsd
Definition: lpkInt.h:60
Definition: if.h:180
int nCalledSRed
Definition: lpkInt.h:92
int fCofactoring
Definition: lpkInt.h:90
If_Obj_t * Lpk_MapTreeMux_rec(Lpk_Man_t *p, unsigned *pTruth, int nVars, If_Obj_t **ppLeaves)
Definition: lpkMux.c:89
unsigned * Lpk_CutTruth(Lpk_Man_t *p, Lpk_Cut_t *pCut, int fInv)
Definition: lpkCut.c:175
unsigned * ppTruths[5][16]
Definition: lpkInt.h:103
int fCalledOnce
Definition: lpkInt.h:91
int Lpk_FunSuppMinimize(Lpk_Fun_t *p)
Definition: lpkAbcUtil.c:143
int pEvals[LPK_CUTS_MAX]
Definition: lpkInt.h:82
Vec_Vec_t * vLevels
Definition: lpkInt.h:88
int nCutsMax
Definition: lpkInt.h:79
abctime timeEval
Definition: lpkInt.h:129
int nTotalNodes
Definition: lpkInt.h:119
Vec_Ptr_t * vTtElems
Definition: lpkInt.h:97
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
Definition: abc_global.h:105
unsigned nNodes
Definition: lpkInt.h:56
Lpk_Res_t * Lpk_DsdAnalize(Lpk_Man_t *pMan, Lpk_Fun_t *p, int nShared)
Definition: lpkAbcDsd.c:452
unsigned fMark
Definition: lpkInt.h:153
int nCutsTotal
Definition: lpkInt.h:110
Vec_Int_t * vBddInv
Definition: lpkInt.h:101
#define ABC_NAMESPACE_HEADER_END
Definition: abc_global.h:106
abctime timeSupps
Definition: lpkInt.h:126
If_Man_t * pIfMan
Definition: lpkInt.h:86
int pCands[LPK_SIZE_MAX]
Definition: lpkInt.h:94
int Gain
Definition: lpkInt.h:64
Vec_Int_t * vMemory
Definition: lpkInt.h:99
abctime timeTruth
Definition: lpkInt.h:125
int DelayEst
Definition: lpkInt.h:171
int nSuppSizeS
Definition: lpkInt.h:169
abctime timeTotal
Definition: lpkInt.h:132
Vec_Ptr_t * vLeaves
Definition: lpkInt.h:95
Kit_DsdMan_t * pDsdMan
Definition: lpkInt.h:106
int nMffc
Definition: lpkInt.h:77
int nEvals
Definition: lpkInt.h:80
unsigned nNodesDup
Definition: lpkInt.h:57
char pDelays[16]
Definition: lpkInt.h:156
int pRefs[LPK_SIZE_MAX]
Definition: lpkInt.h:93
void Lpk_ManStop(Lpk_Man_t *p)
Definition: lpkMan.c:94
Lpk_Fun_t * Lpk_FunAlloc(int nVars)
DECLARATIONS ///.
Definition: lpkAbcUtil.c:45
typedefABC_NAMESPACE_HEADER_START struct Lpk_Par_t_ Lpk_Par_t
INCLUDES ///.
Definition: lpk.h:42
unsigned puSupps[32]
Definition: lpkInt.h:102
int Polarity
Definition: lpkInt.h:174
abctime timeOther
Definition: lpkInt.h:131
int Var
Definition: SolverTypes.h:42
unsigned nLuts
Definition: lpkInt.h:58
char pFanins[16]
Definition: lpkInt.h:157
int Lpk_SuppToVars(unsigned uBoundSet, char *pVars)
Definition: lpkAbcUtil.c:235
static int Lpk_LutNumLuts(int nVarsMax, int nLutK)
Definition: lpkInt.h:178
int pNodes[LPK_SIZE_MAX]
Definition: lpkInt.h:66
abctime timeEvalDsdAn
Definition: lpkInt.h:136
unsigned Lpk_MapSuppRedDecSelect(Lpk_Man_t *p, unsigned *pTruth, int nVars, int *piVar, int *piVarReused)
Definition: lpkSets.c:323
#define assert(ex)
Definition: util_old.h:213
int nBlocks[17]
Definition: lpkInt.h:122
int nGainTotal
Definition: lpkInt.h:112
int nTotalNets
Definition: lpkInt.h:117
unsigned unused
Definition: lpkInt.h:59
int nTotalNodes2
Definition: lpkInt.h:120
Lpk_Fun_t * Lpk_MuxSplit(Lpk_Man_t *pMan, Lpk_Fun_t *p, int Var, int Pol)
Definition: lpkAbcMux.c:164
#define LPK_CUTS_MAX
Definition: lpkInt.h:48
int nMuxes
Definition: lpkInt.h:115
ABC_INT64_T abctime
Definition: abc_global.h:278
#define LPK_SIZE_MAX
INCLUDES ///.
Definition: lpkInt.h:47
unsigned puSupps[32]
Definition: lpkInt.h:155
If_Obj_t * Lpk_MapSuppRedDec_rec(Lpk_Man_t *p, unsigned *pTruth, int nVars, If_Obj_t **ppLeaves)
Definition: lpkMux.c:133
int nSuppSizeL
Definition: lpkInt.h:170
unsigned nDelayLim
Definition: lpkInt.h:151
abctime timeCuts
Definition: lpkInt.h:124
abctime timeTruth2
Definition: lpkInt.h:127