00001
00021 #ifndef __LPK_INT_H__
00022 #define __LPK_INT_H__
00023
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027
00031
00032 #include "abc.h"
00033 #include "kit.h"
00034 #include "if.h"
00035 #include "lpk.h"
00036
00040
00044
00045 #define LPK_SIZE_MAX 24 // the largest size of the function
00046 #define LPK_CUTS_MAX 512 // the largest number of cuts considered
00047
00048 typedef struct Lpk_Man_t_ Lpk_Man_t;
00049 typedef struct Lpk_Cut_t_ Lpk_Cut_t;
00050
00051 struct Lpk_Cut_t_
00052 {
00053 unsigned nLeaves : 6;
00054 unsigned nNodes : 6;
00055 unsigned nNodesDup : 6;
00056 unsigned nLuts : 6;
00057 unsigned unused : 6;
00058 unsigned fHasDsd : 1;
00059 unsigned fMark : 1;
00060 unsigned uSign[2];
00061 float Weight;
00062 int Gain;
00063 int pLeaves[LPK_SIZE_MAX];
00064 int pNodes[LPK_SIZE_MAX];
00065 };
00066
00067 struct Lpk_Man_t_
00068 {
00069
00070 Lpk_Par_t * pPars;
00071
00072 Abc_Ntk_t * pNtk;
00073 Abc_Obj_t * pObj;
00074
00075 int nMffc;
00076 int nCuts;
00077 int nCutsMax;
00078 int nEvals;
00079 Lpk_Cut_t pCuts[LPK_CUTS_MAX];
00080 int pEvals[LPK_CUTS_MAX];
00081
00082 Vec_Vec_t * vVisited;
00083
00084 If_Man_t * pIfMan;
00085 Vec_Int_t * vCover;
00086 Vec_Vec_t * vLevels;
00087
00088 int fCofactoring;
00089 int fCalledOnce;
00090 int nCalledSRed;
00091 int pRefs[LPK_SIZE_MAX];
00092 int pCands[LPK_SIZE_MAX];
00093 Vec_Ptr_t * vLeaves;
00094
00095 Vec_Ptr_t * vTtElems;
00096 Vec_Ptr_t * vTtNodes;
00097 Vec_Int_t * vMemory;
00098 Vec_Int_t * vBddDir;
00099 Vec_Int_t * vBddInv;
00100 unsigned puSupps[32];
00101 unsigned * ppTruths[5][16];
00102
00103 Vec_Int_t * vSets[8];
00104 Kit_DsdMan_t* pDsdMan;
00105
00106 int nNodesTotal;
00107 int nNodesOver;
00108 int nCutsTotal;
00109 int nCutsUseful;
00110 int nGainTotal;
00111 int nChanges;
00112 int nBenefited;
00113 int nMuxes;
00114 int nDsds;
00115 int nTotalNets;
00116 int nTotalNets2;
00117 int nTotalNodes;
00118 int nTotalNodes2;
00119
00120 int nBlocks[17];
00121
00122 int timeCuts;
00123 int timeTruth;
00124 int timeSupps;
00125 int timeTruth2;
00126 int timeTruth3;
00127 int timeEval;
00128 int timeMap;
00129 int timeOther;
00130 int timeTotal;
00131
00132 int timeEvalMuxAn;
00133 int timeEvalMuxSp;
00134 int timeEvalDsdAn;
00135 int timeEvalDsdSp;
00136
00137 };
00138
00139
00140
00141 typedef struct Lpk_Fun_t_ Lpk_Fun_t;
00142 struct Lpk_Fun_t_
00143 {
00144 Vec_Ptr_t * vNodes;
00145 unsigned Id : 7;
00146 unsigned nVars : 5;
00147 unsigned nLutK : 4;
00148 unsigned nAreaLim : 5;
00149 unsigned nDelayLim : 9;
00150 unsigned fSupports : 1;
00151 unsigned fMark : 1;
00152 unsigned uSupp;
00153 unsigned puSupps[32];
00154 char pDelays[16];
00155 char pFanins[16];
00156 unsigned pTruth[0];
00157 };
00158
00159
00160 typedef struct Lpk_Res_t_ Lpk_Res_t;
00161 struct Lpk_Res_t_
00162 {
00163 int nBSVars;
00164 unsigned BSVars;
00165 int nCofVars;
00166 char pCofVars[4];
00167 int nSuppSizeS;
00168 int nSuppSizeL;
00169 int DelayEst;
00170 int AreaEst;
00171 int Variable;
00172 int Polarity;
00173 };
00174
00175 static inline int Lpk_LutNumVars( int nLutsLim, int nLutK ) { return nLutsLim * (nLutK - 1) + 1; }
00176 static inline int Lpk_LutNumLuts( int nVarsMax, int nLutK ) { return (nVarsMax - 1) / (nLutK - 1) + (int)((nVarsMax - 1) % (nLutK - 1) > 0); }
00177 static inline unsigned * Lpk_FunTruth( Lpk_Fun_t * p, int Num ) { assert( Num < 3 ); return p->pTruth + Kit_TruthWordNum(p->nVars) * Num; }
00178
00182
00186
00187 #define Lpk_CutForEachLeaf( pNtk, pCut, pObj, i ) \
00188 for ( i = 0; (i < (int)(pCut)->nLeaves) && (((pObj) = Abc_NtkObj(pNtk, (pCut)->pLeaves[i])), 1); i++ )
00189 #define Lpk_CutForEachNode( pNtk, pCut, pObj, i ) \
00190 for ( i = 0; (i < (int)(pCut)->nNodes) && (((pObj) = Abc_NtkObj(pNtk, (pCut)->pNodes[i])), 1); i++ )
00191 #define Lpk_CutForEachNodeReverse( pNtk, pCut, pObj, i ) \
00192 for ( i = (int)(pCut)->nNodes - 1; (i >= 0) && (((pObj) = Abc_NtkObj(pNtk, (pCut)->pNodes[i])), 1); i-- )
00193 #define Lpk_SuppForEachVar( Supp, Var )\
00194 for ( Var = 0; Var < 16; Var++ )\
00195 if ( !(Supp & (1<<Var)) ) {} else
00196
00200
00201
00202 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 );
00203
00204 extern Lpk_Res_t * Lpk_DsdAnalize( Lpk_Man_t * pMan, Lpk_Fun_t * p, int nShared );
00205 extern Lpk_Fun_t * Lpk_DsdSplit( Lpk_Man_t * pMan, Lpk_Fun_t * p, char * pCofVars, int nCofVars, unsigned uBoundSet );
00206
00207 extern Lpk_Res_t * Lpk_MuxAnalize( Lpk_Man_t * pMan, Lpk_Fun_t * p );
00208 extern Lpk_Fun_t * Lpk_MuxSplit( Lpk_Man_t * pMan, Lpk_Fun_t * p, int Var, int Pol );
00209
00210 extern Lpk_Fun_t * Lpk_FunAlloc( int nVars );
00211 extern void Lpk_FunFree( Lpk_Fun_t * p );
00212 extern Lpk_Fun_t * Lpk_FunCreate( Abc_Ntk_t * pNtk, Vec_Ptr_t * vLeaves, unsigned * pTruth, int nLutK, int AreaLim, int DelayLim );
00213 extern Lpk_Fun_t * Lpk_FunDup( Lpk_Fun_t * p, unsigned * pTruth );
00214 extern int Lpk_FunSuppMinimize( Lpk_Fun_t * p );
00215 extern void Lpk_FunComputeCofSupps( Lpk_Fun_t * p );
00216 extern int Lpk_SuppDelay( unsigned uSupp, char * pDelays );
00217 extern int Lpk_SuppToVars( unsigned uBoundSet, char * pVars );
00218
00219
00220
00221 extern unsigned * Lpk_CutTruth( Lpk_Man_t * p, Lpk_Cut_t * pCut, int fInv );
00222 extern int Lpk_NodeCuts( Lpk_Man_t * p );
00223
00224 extern Lpk_Man_t * Lpk_ManStart( Lpk_Par_t * pPars );
00225 extern void Lpk_ManStop( Lpk_Man_t * p );
00226
00227 extern If_Obj_t * Lpk_MapPrime( Lpk_Man_t * p, unsigned * pTruth, int nVars, If_Obj_t ** ppLeaves );
00228 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 );
00229
00230 extern If_Obj_t * Lpk_MapTreeMulti( Lpk_Man_t * p, unsigned * pTruth, int nLeaves, If_Obj_t ** ppLeaves );
00231
00232 extern If_Obj_t * Lpk_MapTreeMux_rec( Lpk_Man_t * p, unsigned * pTruth, int nVars, If_Obj_t ** ppLeaves );
00233 extern If_Obj_t * Lpk_MapSuppRedDec_rec( Lpk_Man_t * p, unsigned * pTruth, int nVars, If_Obj_t ** ppLeaves );
00234
00235 extern unsigned Lpk_MapSuppRedDecSelect( Lpk_Man_t * p, unsigned * pTruth, int nVars, int * piVar, int * piVarReused );
00236
00237 #ifdef __cplusplus
00238 }
00239 #endif
00240
00241 #endif
00242
00246