33 #define TSIM_MAX_ROUNDS 10000
34 #define TSIM_ONE_SERIES 3000
71 }
while ( RetValue == 0 );
90 fprintf( pFile,
"0" );
95 fprintf( pFile,
"1" );
99 fprintf( pFile,
"x" );
120 static inline unsigned *
Saig_TsiNext(
unsigned * pState,
int nWords ) {
return *((
unsigned **)(pState + nWords)); }
121 static inline void Saig_TsiSetNext(
unsigned * pState,
int nWords,
unsigned * pNext ) { *((
unsigned **)(pState + nWords)) = pNext; }
191 static int s_FPrimes[128] = {
192 1009, 1049, 1093, 1151, 1201, 1249, 1297, 1361, 1427, 1459,
193 1499, 1559, 1607, 1657, 1709, 1759, 1823, 1877, 1933, 1997,
194 2039, 2089, 2141, 2213, 2269, 2311, 2371, 2411, 2467, 2543,
195 2609, 2663, 2699, 2741, 2797, 2851, 2909, 2969, 3037, 3089,
196 3169, 3221, 3299, 3331, 3389, 3461, 3517, 3557, 3613, 3671,
197 3719, 3779, 3847, 3907, 3943, 4013, 4073, 4129, 4201, 4243,
198 4289, 4363, 4441, 4493, 4549, 4621, 4663, 4729, 4793, 4871,
199 4933, 4973, 5021, 5087, 5153, 5227, 5281, 5351, 5417, 5471,
200 5519, 5573, 5651, 5693, 5749, 5821, 5861, 5923, 6011, 6073,
201 6131, 6199, 6257, 6301, 6353, 6397, 6481, 6563, 6619, 6689,
202 6737, 6803, 6863, 6917, 6977, 7027, 7109, 7187, 7237, 7309,
203 7393, 7477, 7523, 7561, 7607, 7681, 7727, 7817, 7877, 7933,
204 8011, 8039, 8059, 8081, 8093, 8111, 8123, 8147
209 for ( i = 0; i <
nWords; i++ )
210 uHash ^= pState[i] * s_FPrimes[i & 0x7F];
211 return uHash % nTableSize;
228 int nRegs = p->
pAig->nRegs;
232 for ( i = 0; i < nRegs; i++ )
262 int ValueThis = -1, ValuePrev = -1, StepPrev = -1;
263 int i, k, nRegs = p->
pAig->nRegs;
265 for ( i = 0; i < nRegs; i++ )
272 if ( ValuePrev != ValueThis )
274 ValuePrev = ValueThis;
281 if ( StepPrev >= nPref )
287 if ( ValueThis == 0 )
308 int nRegs = p->
pAig->nRegs;
310 printf(
"Ternary traces for each flop:\n" );
313 printf(
"%d", i%10 );
315 for ( i = 0; i < nLoop; i++ )
316 printf(
"%d", i%10 );
318 for ( i = 0; i < nRegs; i++ )
335 printf(
"%5d : ", Counter++ );
347 if ( k == nPrefix - 1 )
367 unsigned * pEntry, * pPrev;
371 if ( !
memcmp( pEntry, pState,
sizeof(
unsigned) * nWords ) )
375 if ( pPrev == pEntry )
401 if ( !
memcmp( pEntry, pState,
sizeof(
unsigned) * nWords ) )
422 p->
pBins[Hash] = pState;
458 int i, Value, nZeros = 0, nOnes = 0, nDcs = 0;
463 printf(
"0" ), nZeros++;
465 printf(
"1" ), nOnes++;
467 printf(
"x" ), nDcs++;
471 printf(
" (0=%5d, 1=%5d, x=%5d)\n", nZeros, nOnes, nDcs );
488 int i, Value, nCounter = 0;
514 for ( k = 0; k < pTsi->
nWords; k++ )
515 pState[k] |= pPrev[k];
536 int i, f, Value, nCounter;
572 printf(
"Ternary simulation converged after %d iterations.\n", f );
596 printf(
"Saig_ManReachableTernary(): Did not reach a fixed point after %d iterations (not a bug).\n", TSIM_MAX_ROUNDS );
614 Aig_Obj_t * pObj, * pReg, * pCtrl, * pAnd;
631 printf(
"Register is not found.\n" );
634 printf(
"Clock-like register: \n" );
637 printf(
"Control register: \n" );
640 printf(
"Their fanout: \n" );
645 printf(
"Fanouts of the fanout: \n" );
668 int Values[257] = {0};
670 int r, i, k, Reg, Value;
676 for ( k = 0; k < nTests; k++ )
678 if ( k < pTsi->nPrefix + pTsi->
nCycle )
684 if ( k < nFrames || (fIgnore && k == nFrames) )
685 Values[k % nFrames] = Value;
686 else if ( Values[k % nFrames] != Value )
694 for ( k = 1; k < nFrames; k++ )
695 if ( Values[k] != Values[0] )
704 printf(
"Register %5d has generator: [", Reg );
705 for ( k = 0; k < nFrames; k++ )
751 Aig_Obj_t * pObj, * pObjLi, * pObjLo, * pObjNew;
754 int i, f, Reg, Value;
767 for ( f = 0; f < nFrames; f++ )
770 for ( f = 0; f < nFrames; f++ )
778 for ( f = 0; f < nFrames; f++ )
800 if ( f < nFrames - 1 )
804 for ( f = 0; f < nFrames; f++ )
812 pFrames->nRegs = pAig->nRegs;
844 int nFrames, nPrefix;
874 int nFrames, nPrefix, nNonXRegs;
892 printf(
"Lead = %5d. Loop = %5d. Total flops = %5d. Binary flops = %5d.\n", nPrefix, nFrames, p->nRegs, nNonXRegs );
929 printf(
"Lead = %5d. Loop = %5d. Total flops = %5d. Binary flops = %5d.\n",
935 printf(
"Print-out finished. Phase assignment is not performed.\n" );
936 else if ( nFrames < 2 )
937 printf(
"The number of frames is less than 2. Phase assignment is not performed.\n" );
938 else if ( nFrames > 256 )
939 printf(
"The number of frames is more than 256. Phase assignment is not performed.\n" );
940 else if ( pTsi->
nCycle == 1 )
941 printf(
"The cycle of ternary states is trivial. Phase abstraction cannot be done.\n" );
942 else if ( pTsi->
nCycle % nFrames != 0 )
943 printf(
"The cycle (%d) is not modulo the number of frames (%d). Phase abstraction cannot be done.\n", pTsi->
nCycle, nFrames );
945 printf(
"All registers have X-valued states. Phase abstraction cannot be done.\n" );
947 printf(
"There is no registers to abstract with %d frames.\n", nFrames );
985 printf(
"Lead = %5d. Loop = %5d. Total flops = %5d. Binary flops = %5d.\n",
993 printf(
"Print-out finished. Phase assignment is not performed.\n" );
995 else if ( nFrames < 2 )
999 else if ( nFrames > 256 )
1003 else if ( pTsi->
nCycle == 1 )
1007 else if ( pTsi->
nCycle % nFrames != 0 )
1048 int i, k, iFrame, nFrames;
1054 printf(
"The PI count in the AIG and in the CEX do not match.\n" );
1060 iFrame = pCex->iFrame * nFrames + pCex->iPo /
Saig_ManPoNum(p);
1063 assert( pNew->nBits == pNew->nPis * (iFrame + 1) + pNew->nRegs );
1065 pNew->iFrame = iFrame;
1068 for ( i = pCex->nRegs, k = pNew->nRegs; k < pNew->nBits; k++, i++ )
1071 assert( i <= pCex->nBits );
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
static int Saig_XsimRand2()
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
static int Abc_PrimeCudd(unsigned int p)
int Saig_TsiStateHash(unsigned *pState, int nWords, int nTableSize)
static unsigned * Saig_TsiNext(unsigned *pState, int nWords)
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
static void Saig_TsiSetNext(unsigned *pState, int nWords, unsigned *pNext)
static int Saig_ManPoNum(Aig_Man_t *p)
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
int Saig_TsiCountNonXValuedRegisters(Saig_Tsim_t *p, int nPref)
void Aig_ManStop(Aig_Man_t *p)
int Saig_ManPhasePrefixLength(Aig_Man_t *p, int fVerbose, int fVeryVerbose, Vec_Int_t **pvTrans)
static int Abc_InfoHasBit(unsigned *p, int i)
ABC_NAMESPACE_IMPL_START Abc_Cex_t * Abc_CexAlloc(int nRegs, int nRealPis, int nFrames)
DECLARATIONS ///.
int Aig_ManSeqCleanup(Aig_Man_t *p)
#define Saig_ManForEachLiLo(p, pObjLi, pObjLo, i)
static Aig_Obj_t * Saig_ManLo(Aig_Man_t *p, int i)
void Aig_MmFixedStop(Aig_MmFixed_t *p, int fVerbose)
static void Saig_ObjSetFrames(Aig_Obj_t **pObjMap, int nFs, Aig_Obj_t *pObj, int i, Aig_Obj_t *pNode)
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
int Saig_TsiStateLookup(Saig_Tsim_t *p, unsigned *pState, int nWords)
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
static Aig_Obj_t * Aig_ManConst0(Aig_Man_t *p)
#define ABC_ALLOC(type, num)
unsigned Aig_ManRandom(int fReset)
void Saig_TsiStateInsert(Saig_Tsim_t *p, unsigned *pState, int nWords)
Abc_Cex_t * Saig_PhaseTranslateCex(Aig_Man_t *p, Abc_Cex_t *pCex)
static Aig_Obj_t * Saig_ObjChild0Frames(Aig_Obj_t **pObjMap, int nFs, Aig_Obj_t *pObj, int i)
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
static int Vec_PtrSize(Vec_Ptr_t *p)
Aig_MmFixed_t * Aig_MmFixedStart(int nEntrySize, int nEntriesMax)
FUNCTION DEFINITIONS ///.
void Saig_TsiStateOrAll(Saig_Tsim_t *pTsi, unsigned *pState)
static int Saig_XsimAnd(int Value0, int Value1)
Saig_Tsim_t * Saig_TsiStart(Aig_Man_t *pAig)
DECLARATIONS ///.
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
void Aig_ObjPrint(Aig_Man_t *p, Aig_Obj_t *pObj)
int Saig_ManPhaseFrameNum(Aig_Man_t *p, Vec_Int_t *vInits)
Aig_Man_t * Saig_ManPhaseAbstract(Aig_Man_t *p, Vec_Int_t *vInits, int nFrames, int nPref, int fIgnore, int fPrint, int fVerbose)
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
static int Aig_ManCoNum(Aig_Man_t *p)
static int Abc_MinInt(int a, int b)
static Vec_Int_t * Vec_IntStart(int nSize)
Aig_Man_t * Saig_ManPerformAbstraction(Saig_Tsim_t *pTsi, int nFrames, int fVerbose)
#define Aig_ManForEachNode(p, pObj, i)
int Saig_TsiComputePrefix(Saig_Tsim_t *p, unsigned *pState, int nWords)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static void * Vec_PtrEntryLast(Vec_Ptr_t *p)
#define Saig_ManForEachLi(p, pObj, i)
Vec_Int_t * Saig_TsiComputeTransient(Saig_Tsim_t *p, int nPref)
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
#define Aig_ManForEachLiLoSeq(p, pObjLi, pObjLo, k)
void Saig_TsiPrintTraces(Saig_Tsim_t *p, int nWords, int nPrefix, int nLoop)
static int Vec_IntEntry(Vec_Int_t *p, int i)
static int Aig_ManCiNum(Aig_Man_t *p)
int Saig_TsiStateCount(Saig_Tsim_t *p, unsigned *pState)
#define ABC_NAMESPACE_IMPL_END
static int Saig_ObjGetXsimFanin1(Aig_Obj_t *pObj)
char * Aig_MmFixedEntryFetch(Aig_MmFixed_t *p)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
#define Saig_ManForEachLo(p, pObj, i)
unsigned * Saig_TsiStateNew(Saig_Tsim_t *p)
static int Saig_ObjGetXsimFanin0(Aig_Obj_t *pObj)
static int Saig_XsimInv(int Value)
static void Saig_ObjSetXsim(Aig_Obj_t *pObj, int Value)
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
static int Saig_ManRegNum(Aig_Man_t *p)
static int Aig_ManObjNumMax(Aig_Man_t *p)
Saig_Tsim_t * Saig_ManReachableTernary(Aig_Man_t *p, Vec_Int_t *vInits, int fVerbose)
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
#define ABC_NAMESPACE_IMPL_START
static int Saig_XsimRand3()
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
static void Abc_InfoSetBit(unsigned *p, int i)
static int Aig_ManRegNum(Aig_Man_t *p)
static int Vec_IntSize(Vec_Int_t *p)
#define Vec_PtrForEachEntryStop(Type, vVec, pEntry, i, Stop)
#define Aig_ManForEachObj(p, pObj, i)
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static int Saig_ManPiNum(Aig_Man_t *p)
MACRO DEFINITIONS ///.
static void Vec_IntShrink(Vec_Int_t *p, int nSizeNew)
void Saig_TsiStatePrint(Saig_Tsim_t *p, unsigned *pState)
#define Aig_ManForEachLoSeq(p, pObj, i)
static int Saig_ObjGetXsim(Aig_Obj_t *pObj)
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
static Aig_Obj_t * Saig_ObjChild1Frames(Aig_Obj_t **pObjMap, int nFs, Aig_Obj_t *pObj, int i)
static Aig_Obj_t * Saig_ObjFrames(Aig_Obj_t **pObjMap, int nFs, Aig_Obj_t *pObj, int i)
static int Abc_BitWordNum(int nBits)
#define Aig_ManForEachLiSeq(p, pObj, i)
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.
void Saig_TsiStop(Saig_Tsim_t *p)
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
static void Vec_IntFree(Vec_Int_t *p)
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
#define Aig_ManForEachPoSeq(p, pObj, i)
static void Saig_XsimPrint(FILE *pFile, int Value)
char * Abc_UtilStrsav(char *s)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Aig_Man_t * Aig_ManDupSimple(Aig_Man_t *p)
DECLARATIONS ///.
static int Saig_XsimConvertValue(int v)
#define Aig_ManForEachPiSeq(p, pObj, i)
SEQUENTIAL ITERATORS ///.
Aig_Man_t * Saig_ManPhaseAbstractAuto(Aig_Man_t *p, int fVerbose)
int Saig_ManFindRegisters(Saig_Tsim_t *pTsi, int nFrames, int fIgnore, int fVerbose)
static void Vec_PtrFree(Vec_Ptr_t *p)
void Saig_ManAnalizeControl(Aig_Man_t *p, int Reg)
#define Saig_ManForEachPi(p, pObj, i)