ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
lpkInt.h
Go to the documentation of this file.
1
20
21#ifndef ABC__opt__lpk__lpkInt_h
22#define ABC__opt__lpk__lpkInt_h
23
24
28
29#include "base/abc/abc.h"
30#include "bool/kit/kit.h"
31#include "map/if/if.h"
32#include "lpk.h"
33
37
38
39
41
42
46
47#define LPK_SIZE_MAX 100 // the largest size of the function
48#define LPK_CUTS_MAX 10000 // the largest number of cuts considered
49
50typedef struct Lpk_Man_t_ Lpk_Man_t;
51typedef struct Lpk_Cut_t_ Lpk_Cut_t;
52
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
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
97 // truth table representation
98 Vec_Ptr_t * vTtElems; // elementary truth tables
99 Vec_Ptr_t * vTtNodes; // storage for temporary truth tables of the nodes
103 unsigned puSupps[32]; // the supports of the cofactors
104 unsigned * ppTruths[5][16];
105 // variable sets
108 // statistics
109 int nNodesTotal; // total number of nodes
110 int nNodesOver; // nodes with cuts over the limit
111 int nCutsTotal; // total number of cuts
112 int nCutsUseful; // useful cuts
113 int nGainTotal; // the gain in LUTs
114 int nChanges; // the number of changed nodes
115 int nBenefited; // the number of gainful that benefited from decomposition
117 int nDsds;
122 // counter of non-DSD blocks
123 int nBlocks[17];
124 // runtime
134 // runtime of eval
139
140};
141
142
143// internal representation of the function to be decomposed
144typedef struct Lpk_Fun_t_ Lpk_Fun_t;
146{
147 Vec_Ptr_t * vNodes; // the array of leaves and decomposition nodes
148 unsigned Id : 7; // the ID of this node
149 unsigned nVars : 5; // the number of variables
150 unsigned nLutK : 4; // the number of LUT inputs
151 unsigned nAreaLim : 14; // the area 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 unsigned nDelayLim; // the delay limit (the largest allowed)
157 int pDelays[16]; // the delays of the inputs
158 char pFanins[16]; // the fanins of this function
159 unsigned pTruth[0]; // the truth table (contains room for three truth tables)
160};
161
162// preliminary decomposition result
163typedef struct Lpk_Res_t_ Lpk_Res_t;
165{
166 int nBSVars; // the number of bound set variables
167 unsigned BSVars; // the bound set
168 int nCofVars; // the number of cofactoring variables
169 char pCofVars[4]; // the cofactoring variables
170 int nSuppSizeS; // support size of the smaller (decomposed) function
171 int nSuppSizeL; // support size of the larger (composition) function
172 int DelayEst; // estimated delay of the decomposition
173 int AreaEst; // estimated area of the decomposition
174 int Variable; // variable in MUX decomposition
175 int Polarity; // polarity in MUX decomposition
176};
177
178static inline int Lpk_LutNumVars( int nLutsLim, int nLutK ) { return nLutsLim * (nLutK - 1) + 1; }
179static inline int Lpk_LutNumLuts( int nVarsMax, int nLutK ) { return (nVarsMax - 1) / (nLutK - 1) + (int)((nVarsMax - 1) % (nLutK - 1) > 0); }
180static inline unsigned * Lpk_FunTruth( Lpk_Fun_t * p, int Num ) { assert( Num < 3 ); return p->pTruth + Kit_TruthWordNum(p->nVars) * Num; }
181
185
189
190#define Lpk_CutForEachLeaf( pNtk, pCut, pObj, i ) \
191 for ( i = 0; (i < (int)(pCut)->nLeaves) && (((pObj) = Abc_NtkObj(pNtk, (pCut)->pLeaves[i])), 1); i++ )
192#define Lpk_CutForEachNode( pNtk, pCut, pObj, i ) \
193 for ( i = 0; (i < (int)(pCut)->nNodes) && (((pObj) = Abc_NtkObj(pNtk, (pCut)->pNodes[i])), 1); i++ )
194#define Lpk_CutForEachNodeReverse( pNtk, pCut, pObj, i ) \
195 for ( i = (int)(pCut)->nNodes - 1; (i >= 0) && (((pObj) = Abc_NtkObj(pNtk, (pCut)->pNodes[i])), 1); i-- )
196#define Lpk_SuppForEachVar( Supp, Var )\
197 for ( Var = 0; Var < 16; Var++ )\
198 if ( !(Supp & (1<<Var)) ) {} else
199
203
204/*=== lpkAbcDec.c ============================================================*/
205extern 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 );
206/*=== lpkAbcDsd.c ============================================================*/
207extern Lpk_Res_t * Lpk_DsdAnalize( Lpk_Man_t * pMan, Lpk_Fun_t * p, int nShared );
208extern Lpk_Fun_t * Lpk_DsdSplit( Lpk_Man_t * pMan, Lpk_Fun_t * p, char * pCofVars, int nCofVars, unsigned uBoundSet );
209/*=== lpkAbcMux.c ============================================================*/
210extern Lpk_Res_t * Lpk_MuxAnalize( Lpk_Man_t * pMan, Lpk_Fun_t * p );
211extern Lpk_Fun_t * Lpk_MuxSplit( Lpk_Man_t * pMan, Lpk_Fun_t * p, int Var, int Pol );
212/*=== lpkAbcUtil.c ============================================================*/
213extern Lpk_Fun_t * Lpk_FunAlloc( int nVars );
214extern void Lpk_FunFree( Lpk_Fun_t * p );
215extern Lpk_Fun_t * Lpk_FunCreate( Abc_Ntk_t * pNtk, Vec_Ptr_t * vLeaves, unsigned * pTruth, int nLutK, int AreaLim, int DelayLim );
216extern Lpk_Fun_t * Lpk_FunDup( Lpk_Fun_t * p, unsigned * pTruth );
217extern int Lpk_FunSuppMinimize( Lpk_Fun_t * p );
218extern void Lpk_FunComputeCofSupps( Lpk_Fun_t * p );
219extern int Lpk_SuppDelay( unsigned uSupp, int * pDelays );
220extern int Lpk_SuppToVars( unsigned uBoundSet, char * pVars );
221
222
223/*=== lpkCut.c =========================================================*/
224extern unsigned * Lpk_CutTruth( Lpk_Man_t * p, Lpk_Cut_t * pCut, int fInv );
225extern int Lpk_NodeCuts( Lpk_Man_t * p );
226/*=== lpkMap.c =========================================================*/
227extern Lpk_Man_t * Lpk_ManStart( Lpk_Par_t * pPars );
228extern void Lpk_ManStop( Lpk_Man_t * p );
229/*=== lpkMap.c =========================================================*/
230extern If_Obj_t * Lpk_MapPrime( Lpk_Man_t * p, unsigned * pTruth, int nVars, If_Obj_t ** ppLeaves );
231extern If_Obj_t * Lpk_MapTree_rec( Lpk_Man_t * p, Kit_DsdNtk_t * pNtk, If_Obj_t ** ppLeaves, int iLit, If_Obj_t * pResult );
232/*=== lpkMulti.c =======================================================*/
233extern If_Obj_t * Lpk_MapTreeMulti( Lpk_Man_t * p, unsigned * pTruth, int nLeaves, If_Obj_t ** ppLeaves );
234/*=== lpkMux.c =========================================================*/
235extern If_Obj_t * Lpk_MapTreeMux_rec( Lpk_Man_t * p, unsigned * pTruth, int nVars, If_Obj_t ** ppLeaves );
236extern If_Obj_t * Lpk_MapSuppRedDec_rec( Lpk_Man_t * p, unsigned * pTruth, int nVars, If_Obj_t ** ppLeaves );
237/*=== lpkSets.c =========================================================*/
238extern unsigned Lpk_MapSuppRedDecSelect( Lpk_Man_t * p, unsigned * pTruth, int nVars, int * piVar, int * piVarReused );
239
240
241
243
244
245
246#endif
247
251
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_NAMESPACE_HEADER_END
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Cube * p
Definition exorList.c:222
int Var
Definition exorList.c:228
struct If_Man_t_ If_Man_t
BASIC TYPES ///.
Definition if.h:77
struct If_Obj_t_ If_Obj_t
Definition if.h:79
struct Kit_DsdNtk_t_ Kit_DsdNtk_t
Definition kit.h:124
struct Kit_DsdMan_t_ Kit_DsdMan_t
Definition kit.h:137
Lpk_Res_t * Lpk_MuxAnalize(Lpk_Man_t *pMan, Lpk_Fun_t *p)
DECLARATIONS ///.
Definition lpkAbcMux.c:45
Lpk_Res_t * Lpk_DsdAnalize(Lpk_Man_t *pMan, Lpk_Fun_t *p, int nShared)
Definition lpkAbcDsd.c:452
int Lpk_SuppToVars(unsigned uBoundSet, char *pVars)
Definition lpkAbcUtil.c:235
Lpk_Man_t * Lpk_ManStart(Lpk_Par_t *pPars)
DECLARATIONS ///.
Definition lpkMan.c:45
#define LPK_SIZE_MAX
INCLUDES ///.
Definition lpkInt.h:47
If_Obj_t * Lpk_MapPrime(Lpk_Man_t *p, unsigned *pTruth, int nVars, If_Obj_t **ppLeaves)
Definition lpkMap.c:79
Lpk_Fun_t * Lpk_MuxSplit(Lpk_Man_t *pMan, Lpk_Fun_t *p, int Var, int Pol)
Definition lpkAbcMux.c:164
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
If_Obj_t * Lpk_MapTreeMux_rec(Lpk_Man_t *p, unsigned *pTruth, int nVars, If_Obj_t **ppLeaves)
Definition lpkMux.c:89
void Lpk_FunFree(Lpk_Fun_t *p)
Definition lpkAbcUtil.c:64
Lpk_Fun_t * Lpk_FunDup(Lpk_Fun_t *p, unsigned *pTruth)
Definition lpkAbcUtil.c:114
int Lpk_SuppDelay(unsigned uSupp, int *pDelays)
Definition lpkAbcUtil.c:215
#define LPK_CUTS_MAX
Definition lpkInt.h:48
unsigned Lpk_MapSuppRedDecSelect(Lpk_Man_t *p, unsigned *pTruth, int nVars, int *piVar, int *piVarReused)
Definition lpkSets.c:323
Lpk_Fun_t * Lpk_FunAlloc(int nVars)
DECLARATIONS ///.
Definition lpkAbcUtil.c:45
If_Obj_t * Lpk_MapSuppRedDec_rec(Lpk_Man_t *p, unsigned *pTruth, int nVars, If_Obj_t **ppLeaves)
Definition lpkMux.c:133
int Lpk_NodeCuts(Lpk_Man_t *p)
Definition lpkCut.c:619
struct Lpk_Fun_t_ Lpk_Fun_t
Definition lpkInt.h:144
struct Lpk_Man_t_ Lpk_Man_t
Definition lpkInt.h:50
int Lpk_FunSuppMinimize(Lpk_Fun_t *p)
Definition lpkAbcUtil.c:143
void Lpk_ManStop(Lpk_Man_t *p)
Definition lpkMan.c:95
unsigned * Lpk_CutTruth(Lpk_Man_t *p, Lpk_Cut_t *pCut, int fInv)
Definition lpkCut.c:175
void Lpk_FunComputeCofSupps(Lpk_Fun_t *p)
Definition lpkAbcUtil.c:186
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
struct Lpk_Res_t_ Lpk_Res_t
Definition lpkInt.h:163
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
If_Obj_t * Lpk_MapTreeMulti(Lpk_Man_t *p, unsigned *pTruth, int nLeaves, If_Obj_t **ppLeaves)
Definition lpkMulti.c:347
Lpk_Fun_t * Lpk_DsdSplit(Lpk_Man_t *pMan, Lpk_Fun_t *p, char *pCofVars, int nCofVars, unsigned uBoundSet)
Definition lpkAbcDsd.c:564
struct Lpk_Cut_t_ Lpk_Cut_t
Definition lpkInt.h:51
typedefABC_NAMESPACE_HEADER_START struct Lpk_Par_t_ Lpk_Par_t
INCLUDES ///.
Definition lpk.h:42
unsigned fMark
Definition lpkInt.h:61
unsigned uSign[2]
Definition lpkInt.h:62
unsigned unused
Definition lpkInt.h:59
int Gain
Definition lpkInt.h:64
unsigned nNodes
Definition lpkInt.h:56
unsigned nLuts
Definition lpkInt.h:58
float Weight
Definition lpkInt.h:63
int pNodes[LPK_SIZE_MAX]
Definition lpkInt.h:66
int pLeaves[LPK_SIZE_MAX]
Definition lpkInt.h:65
unsigned nNodesDup
Definition lpkInt.h:57
unsigned fHasDsd
Definition lpkInt.h:60
unsigned nLeaves
Definition lpkInt.h:55
int pDelays[16]
Definition lpkInt.h:157
unsigned nAreaLim
Definition lpkInt.h:151
unsigned nLutK
Definition lpkInt.h:150
char pFanins[16]
Definition lpkInt.h:158
unsigned nDelayLim
Definition lpkInt.h:156
unsigned nVars
Definition lpkInt.h:149
unsigned uSupp
Definition lpkInt.h:154
unsigned Id
Definition lpkInt.h:148
unsigned fSupports
Definition lpkInt.h:152
Vec_Ptr_t * vNodes
Definition lpkInt.h:147
unsigned fMark
Definition lpkInt.h:153
unsigned puSupps[32]
Definition lpkInt.h:155
unsigned pTruth[0]
Definition lpkInt.h:159
int nDsds
Definition lpkInt.h:117
Vec_Vec_t * vVisited
Definition lpkInt.h:84
abctime timeTruth2
Definition lpkInt.h:128
Vec_Vec_t * vLevels
Definition lpkInt.h:88
int nTotalNodes
Definition lpkInt.h:120
Vec_Int_t * vMemory
Definition lpkInt.h:100
int nCalledSRed
Definition lpkInt.h:92
Vec_Ptr_t * vTtNodes
Definition lpkInt.h:99
abctime timeOther
Definition lpkInt.h:132
abctime timeEvalDsdAn
Definition lpkInt.h:137
int nMffc
Definition lpkInt.h:77
unsigned * ppTruths[5][16]
Definition lpkInt.h:104
Lpk_Cut_t pCuts[LPK_CUTS_MAX]
Definition lpkInt.h:81
int nCutsUseful
Definition lpkInt.h:112
int pEvals[LPK_CUTS_MAX]
Definition lpkInt.h:82
abctime timeEvalMuxSp
Definition lpkInt.h:136
int pRefs[LPK_SIZE_MAX]
Definition lpkInt.h:93
If_Man_t * pIfMan
Definition lpkInt.h:86
int nTotalNets2
Definition lpkInt.h:119
Abc_Obj_t * pObj
Definition lpkInt.h:75
int fCofactoring
Definition lpkInt.h:90
int nGainTotal
Definition lpkInt.h:113
Kit_DsdMan_t * pDsdMan
Definition lpkInt.h:107
int nNodesOver
Definition lpkInt.h:110
int nBlocks[17]
Definition lpkInt.h:123
abctime timeTruth
Definition lpkInt.h:126
Lpk_Par_t * pPars
Definition lpkInt.h:72
int nMuxes
Definition lpkInt.h:116
abctime timeTruth3
Definition lpkInt.h:129
Vec_Int_t * vSets[8]
Definition lpkInt.h:106
abctime timeEvalMuxAn
Definition lpkInt.h:135
Vec_Ptr_t * vLeaves
Definition lpkInt.h:95
Vec_Ptr_t * vTtElems
Definition lpkInt.h:98
abctime timeEval
Definition lpkInt.h:130
unsigned puSupps[32]
Definition lpkInt.h:103
Vec_Int_t * vBddDir
Definition lpkInt.h:101
int nCuts
Definition lpkInt.h:78
int nBenefited
Definition lpkInt.h:115
int nTotalNets
Definition lpkInt.h:118
abctime timeCuts
Definition lpkInt.h:125
int nCutsTotal
Definition lpkInt.h:111
int nCutsMax
Definition lpkInt.h:79
int nTotalNodes2
Definition lpkInt.h:121
Vec_Int_t * vCover
Definition lpkInt.h:87
abctime timeMap
Definition lpkInt.h:131
Vec_Ptr_t * vTemp
Definition lpkInt.h:96
int nEvals
Definition lpkInt.h:80
int nChanges
Definition lpkInt.h:114
Abc_Ntk_t * pNtk
Definition lpkInt.h:74
abctime timeEvalDsdSp
Definition lpkInt.h:138
abctime timeSupps
Definition lpkInt.h:127
int pCands[LPK_SIZE_MAX]
Definition lpkInt.h:94
int nNodesTotal
Definition lpkInt.h:109
Vec_Int_t * vBddInv
Definition lpkInt.h:102
int fCalledOnce
Definition lpkInt.h:91
abctime timeTotal
Definition lpkInt.h:133
int nSuppSizeS
Definition lpkInt.h:170
int Variable
Definition lpkInt.h:174
int nCofVars
Definition lpkInt.h:168
int Polarity
Definition lpkInt.h:175
unsigned BSVars
Definition lpkInt.h:167
int DelayEst
Definition lpkInt.h:172
int nBSVars
Definition lpkInt.h:166
int AreaEst
Definition lpkInt.h:173
char pCofVars[4]
Definition lpkInt.h:169
int nSuppSizeL
Definition lpkInt.h:171
#define assert(ex)
Definition util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition vecVec.h:42