00001
00021 #ifndef __SIM_H__
00022 #define __SIM_H__
00023
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027
00028
00029
00030
00031
00032
00033
00037
00041
00045
00046 typedef struct Sym_Man_t_ Sym_Man_t;
00047 struct Sym_Man_t_
00048 {
00049
00050 Abc_Ntk_t * pNtk;
00051 Vec_Ptr_t * vNodes;
00052 int nInputs;
00053 int nOutputs;
00054
00055 int nSimWords;
00056 Vec_Ptr_t * vSim;
00057
00058 Vec_Ptr_t * vSuppFun;
00059 Vec_Vec_t * vSupports;
00060
00061 Vec_Ptr_t * vMatrSymms;
00062 Vec_Ptr_t * vMatrNonSymms;
00063 Vec_Int_t * vPairsTotal;
00064 Vec_Int_t * vPairsSym;
00065 Vec_Int_t * vPairsNonSym;
00066
00067 unsigned * uPatRand;
00068 unsigned * uPatCol;
00069 unsigned * uPatRow;
00070
00071 Vec_Int_t * vVarsU;
00072 Vec_Int_t * vVarsV;
00073 int iOutput;
00074 int iVar1;
00075 int iVar2;
00076 int iVar1Old;
00077 int iVar2Old;
00078
00079 int nSatRuns;
00080 int nSatRunsSat;
00081 int nSatRunsUnsat;
00082
00083 int nPairsSymm;
00084 int nPairsSymmStr;
00085 int nPairsNonSymm;
00086 int nPairsRem;
00087 int nPairsTotal;
00088
00089 int timeStruct;
00090 int timeCount;
00091 int timeMatr;
00092 int timeSim;
00093 int timeFraig;
00094 int timeSat;
00095 int timeTotal;
00096 };
00097
00098 typedef struct Sim_Man_t_ Sim_Man_t;
00099 struct Sim_Man_t_
00100 {
00101
00102 Abc_Ntk_t * pNtk;
00103 int nInputs;
00104 int nOutputs;
00105 int fLightweight;
00106
00107 int nSimBits;
00108 int nSimWords;
00109 Vec_Ptr_t * vSim0;
00110 Vec_Ptr_t * vSim1;
00111
00112 int nSuppBits;
00113 int nSuppWords;
00114 Vec_Ptr_t * vSuppStr;
00115 Vec_Ptr_t * vSuppFun;
00116
00117 Vec_Vec_t * vSuppTargs;
00118 int iInput;
00119
00120 Extra_MmFixed_t * pMmPat;
00121 Vec_Ptr_t * vFifo;
00122 Vec_Int_t * vDiffs;
00123 int nSatRuns;
00124 int nSatRunsSat;
00125 int nSatRunsUnsat;
00126
00127 int timeSim;
00128 int timeTrav;
00129 int timeFraig;
00130 int timeSat;
00131 int timeTotal;
00132 };
00133
00134 typedef struct Sim_Pat_t_ Sim_Pat_t;
00135 struct Sim_Pat_t_
00136 {
00137 int Input;
00138 int Output;
00139 unsigned * pData;
00140 };
00141
00145
00146 #define SIM_NUM_WORDS(n) (((n)>>5) + (((n)&31) > 0))
00147 #define SIM_LAST_BITS(n) ((((n)&31) > 0)? (n)&31 : 32)
00148
00149 #define SIM_MASK_FULL (0xFFFFFFFF)
00150 #define SIM_MASK_BEG(n) (SIM_MASK_FULL >> (32-n))
00151 #define SIM_MASK_END(n) (SIM_MASK_FULL << (n))
00152 #define SIM_SET_0_FROM(m,n) ((m) & ~SIM_MASK_BEG(n))
00153 #define SIM_SET_1_FROM(m,n) ((m) | SIM_MASK_END(n))
00154
00155
00156 #define SIM_RANDOM_UNSIGNED ((((unsigned)rand()) << 24) ^ (((unsigned)rand()) << 12) ^ ((unsigned)rand()))
00157
00158
00159 #define Sim_SetBit(p,i) ((p)[(i)>>5] |= (1<<((i) & 31)))
00160 #define Sim_XorBit(p,i) ((p)[(i)>>5] ^= (1<<((i) & 31)))
00161 #define Sim_HasBit(p,i) (((p)[(i)>>5] & (1<<((i) & 31))) > 0)
00162
00163
00164 #define Sim_SuppStrSetVar(vSupps,pNode,v) Sim_SetBit((unsigned*)(vSupps)->pArray[(pNode)->Id],(v))
00165 #define Sim_SuppStrHasVar(vSupps,pNode,v) Sim_HasBit((unsigned*)(vSupps)->pArray[(pNode)->Id],(v))
00166 #define Sim_SuppFunSetVar(vSupps,Output,v) Sim_SetBit((unsigned*)(vSupps)->pArray[Output],(v))
00167 #define Sim_SuppFunHasVar(vSupps,Output,v) Sim_HasBit((unsigned*)(vSupps)->pArray[Output],(v))
00168 #define Sim_SimInfoSetVar(vSupps,pNode,v) Sim_SetBit((unsigned*)(vSupps)->pArray[(pNode)->Id],(v))
00169 #define Sim_SimInfoHasVar(vSupps,pNode,v) Sim_HasBit((unsigned*)(vSupps)->pArray[(pNode)->Id],(v))
00170 #define Sim_SimInfoGet(vInfo,pNode) ((unsigned *)((vInfo)->pArray[(pNode)->Id]))
00171
00175
00176
00177 extern Sym_Man_t * Sym_ManStart( Abc_Ntk_t * pNtk, int fVerbose );
00178 extern void Sym_ManStop( Sym_Man_t * p );
00179 extern void Sym_ManPrintStats( Sym_Man_t * p );
00180 extern Sim_Man_t * Sim_ManStart( Abc_Ntk_t * pNtk, int fLightweight );
00181 extern void Sim_ManStop( Sim_Man_t * p );
00182 extern void Sim_ManPrintStats( Sim_Man_t * p );
00183 extern Sim_Pat_t * Sim_ManPatAlloc( Sim_Man_t * p );
00184 extern void Sim_ManPatFree( Sim_Man_t * p, Sim_Pat_t * pPat );
00185
00186 extern Vec_Ptr_t * Sim_SimulateSeqRandom( Abc_Ntk_t * pNtk, int nFrames, int nWords );
00187 extern Vec_Ptr_t * Sim_SimulateSeqModel( Abc_Ntk_t * pNtk, int nFrames, int * pModel );
00188
00189 extern Vec_Ptr_t * Sim_ComputeStrSupp( Abc_Ntk_t * pNtk );
00190 extern Vec_Ptr_t * Sim_ComputeFunSupp( Abc_Ntk_t * pNtk, int fVerbose );
00191
00192 extern int Sim_ComputeTwoVarSymms( Abc_Ntk_t * pNtk, int fVerbose );
00193
00194 extern int Sim_SymmsGetPatternUsingSat( Sym_Man_t * p, unsigned * pPattern );
00195
00196 extern void Sim_SymmsStructCompute( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMatrs, Vec_Ptr_t * vSuppFun );
00197
00198 extern void Sim_SymmsSimulate( Sym_Man_t * p, unsigned * pPatRand, Vec_Ptr_t * vMatrsNonSym );
00199
00200 extern Vec_Ptr_t * Sim_UtilInfoAlloc( int nSize, int nWords, bool fClean );
00201 extern void Sim_UtilInfoFree( Vec_Ptr_t * p );
00202 extern void Sim_UtilInfoAdd( unsigned * pInfo1, unsigned * pInfo2, int nWords );
00203 extern void Sim_UtilInfoDetectDiffs( unsigned * pInfo1, unsigned * pInfo2, int nWords, Vec_Int_t * vDiffs );
00204 extern void Sim_UtilInfoDetectNews( unsigned * pInfo1, unsigned * pInfo2, int nWords, Vec_Int_t * vDiffs );
00205 extern void Sim_UtilInfoFlip( Sim_Man_t * p, Abc_Obj_t * pNode );
00206 extern bool Sim_UtilInfoCompare( Sim_Man_t * p, Abc_Obj_t * pNode );
00207 extern void Sim_UtilSimulate( Sim_Man_t * p, bool fFirst );
00208 extern void Sim_UtilSimulateNode( Sim_Man_t * p, Abc_Obj_t * pNode, bool fType, bool fType1, bool fType2 );
00209 extern void Sim_UtilSimulateNodeOne( Abc_Obj_t * pNode, Vec_Ptr_t * vSimInfo, int nSimWords, int nOffset );
00210 extern void Sim_UtilTransferNodeOne( Abc_Obj_t * pNode, Vec_Ptr_t * vSimInfo, int nSimWords, int nOffset, int fShift );
00211 extern int Sim_UtilCountSuppSizes( Sim_Man_t * p, int fStruct );
00212 extern int Sim_UtilCountOnes( unsigned * pSimInfo, int nSimWords );
00213 extern Vec_Int_t * Sim_UtilCountOnesArray( Vec_Ptr_t * vInfo, int nSimWords );
00214 extern void Sim_UtilSetRandom( unsigned * pPatRand, int nSimWords );
00215 extern void Sim_UtilSetCompl( unsigned * pPatRand, int nSimWords );
00216 extern void Sim_UtilSetConst( unsigned * pPatRand, int nSimWords, int fConst1 );
00217 extern int Sim_UtilInfoIsEqual( unsigned * pPats1, unsigned * pPats2, int nSimWords );
00218 extern int Sim_UtilInfoIsImp( unsigned * pPats1, unsigned * pPats2, int nSimWords );
00219 extern int Sim_UtilInfoIsClause( unsigned * pPats1, unsigned * pPats2, int nSimWords );
00220 extern int Sim_UtilCountAllPairs( Vec_Ptr_t * vSuppFun, int nSimWords, Vec_Int_t * vCounters );
00221 extern void Sim_UtilCountPairsAll( Sym_Man_t * p );
00222 extern int Sim_UtilMatrsAreDisjoint( Sym_Man_t * p );
00223
00224 #ifdef __cplusplus
00225 }
00226 #endif
00227
00228 #endif
00229
00233