65 assert( iPat >= 0 && iPat < (1 << p->pPars->nBinSize) );
66 return p->pRarity[iBin * (1 << p->pPars->nBinSize) + iPat];
71 assert( iPat >= 0 && iPat < (1 << p->pPars->nBinSize) );
72 p->pRarity[iBin * (1 << p->pPars->nBinSize) + iPat] = Value;
77 assert( iPat >= 0 && iPat < (1 << p->pPars->nBinSize) );
78 p->pRarity[iBin * (1 << p->pPars->nBinSize) + iPat]++;
135 for ( i = 0; i < nRandSeed; i++ )
158 for ( w = 0; w < p->pPars->nWords; w++ )
162 pSim[0] = (pSim[0] << 4) | ((i & 1) ? 0xA : 0xC);
183 int i, r, f, iBit, iPatThis;
185 iPatThis = iPatFinal;
188 for ( r = iFrame / p->pPars->nFrames - 1; r >= 0; r-- )
190 iPatThis =
Vec_IntEntry( p->vPatBests, r * p->pPars->nWords + iPatThis / 64 );
195 pCex->iFrame = iFrame;
199 for ( f = 0; f <= iFrame; f++ )
202 iPatThis =
Vec_IntEntry( vTrace, f / p->pPars->nFrames );
212 assert( iBit == pCex->nBits );
216 Abc_Print( 1,
"Ssw_RarDeriveCex(): Counter-example is invalid.\n" );
242 unsigned t, m = 0x0000FFFF;
243 for ( j = 16; j != 0; j = j >> 1, m = m ^ (m << j) )
245 for ( k = 0; k < 32; k = (k + j + 1) & ~j )
247 t = (A[k] ^ (A[k+j] >> j)) & m;
249 A[k+j] = A[k+j] ^ (t << j);
268 word t, m = 0x00000000FFFFFFFF;
269 for ( j = 32; j != 0; j = j >> 1, m = m ^ (m << j) )
271 for ( k = 0; k < 64; k = (k + j + 1) & ~j )
273 t = (A[k] ^ (A[k+j] >> j)) & m;
275 A[k+j] = A[k+j] ^ (t << j);
294 for ( i = 0; i < 64; i++ )
296 for ( i = 0; i < 64; i++ )
297 for ( k = 0; k < 64; k++ )
298 if ( (A[i] >> k) & 1 )
299 B[k] |= ((
word)1 << (63-i));
321 for ( i = 0; i < 64; i++ )
327 for ( i = 0; i < 100001; i++ )
332 for ( i = 0; i < 100001; i++ )
336 for ( i = 0; i < 64; i++ )
365 for ( w = 0; w < p->pPars->nWords; w++ )
366 for ( r = 0; r < p->nWordsReg; r++ )
369 for ( i = 0; i < 64; i++ )
382 for ( i = 0; i < 64; i++ )
418 word * pSim, * pSimLi;
423 for ( w = 0; w < p->pPars->nWords; w++ )
434 for ( w = 0; w < p->pPars->nWords; w++ )
444 for ( w = 0; w < p->pPars->nWords; w++ )
466 for ( w = 0; w < p->pPars->nWords; w++ )
489 for ( w = 0; w < p->pPars->nWords; w++ )
490 if ( pSim[w] ^ Flip )
513 for ( w = 0; w < p->pPars->nWords; w++ )
514 if ( pSim0[w] ^ pSim1[w] ^ Flip )
533 static int s_SPrimes[128] = {
534 1009, 1049, 1093, 1151, 1201, 1249, 1297, 1361, 1427, 1459,
535 1499, 1559, 1607, 1657, 1709, 1759, 1823, 1877, 1933, 1997,
536 2039, 2089, 2141, 2213, 2269, 2311, 2371, 2411, 2467, 2543,
537 2609, 2663, 2699, 2741, 2797, 2851, 2909, 2969, 3037, 3089,
538 3169, 3221, 3299, 3331, 3389, 3461, 3517, 3557, 3613, 3671,
539 3719, 3779, 3847, 3907, 3943, 4013, 4073, 4129, 4201, 4243,
540 4289, 4363, 4441, 4493, 4549, 4621, 4663, 4729, 4793, 4871,
541 4933, 4973, 5021, 5087, 5153, 5227, 5281, 5351, 5417, 5471,
542 5519, 5573, 5651, 5693, 5749, 5821, 5861, 5923, 6011, 6073,
543 6131, 6199, 6257, 6301, 6353, 6397, 6481, 6563, 6619, 6689,
544 6737, 6803, 6863, 6917, 6977, 7027, 7109, 7187, 7237, 7309,
545 7393, 7477, 7523, 7561, 7607, 7681, 7727, 7817, 7877, 7933,
546 8011, 8039, 8059, 8081, 8093, 8111, 8123, 8147
553 for ( i = 0; i < 2 * p->pPars->nWords; i++ )
554 uHash ^= pSims[i] * s_SPrimes[i & 0x7F];
574 for ( w = 0; w < p->pPars->nWords; w++ )
575 if ( pSim[w] ^ Flip )
577 for ( i = 0; i < 64; i++ )
578 if ( ((pSim[w] ^ Flip) >> i) & 1 )
605 if ( p->pAig->nConstrs && i >=
Saig_ManPoNum(p->pAig) - p->pAig->nConstrs )
613 if ( !p->pPars->fSolveAll )
617 if ( p->vCexes == NULL )
621 if ( p->pPars->pFuncOnFail && p->pPars->pFuncOnFail(i, NULL) )
624 if ( !p->pPars->fNotVerbose )
627 Abc_Print( 1,
"Output %*d was asserted in frame %4d (solved %*d out of %*d outputs). ",
628 nOutDigits, p->iFailPo, iFrame,
629 nOutDigits, p->pPars->nSolved,
634 if ( p->iFailPo >= 0 )
654 word * pSim, * pSim0, * pSim1;
655 word Flip, Flip0, Flip1;
688 for ( w = 0; w < p->pPars->nWords; w++ )
689 pSim[w] = (Flip0 ^ pSim0[w]) & (Flip1 ^ pSim1[w]);
715 for ( w = 0; w < p->pPars->nWords; w++ )
716 pSim[w] = Flip ^ pSim0[w];
761 p->pPatCosts =
ABC_CALLOC(
double, p->pPars->nWords * 64 );
764 p->pPatData =
ABC_ALLOC(
word, 64 * p->pPars->nWords * p->nWordsReg );
787 assert( p->pAig->vSeqModelVec == NULL );
788 p->pAig->vSeqModelVec = p->vCexes;
817 unsigned char * pData;
825 for ( k = 0; k < p->pPars->nWords * 64; k++ )
828 for ( i = 0; i < p->nGroups; i++ )
833 for ( k = 0; k < p->pPars->nWords * 64; k++ )
837 p->pPatCosts[k] = 0.0;
838 for ( i = 0; i < p->nGroups; i++ )
842 p->pPatCosts[k] += 1.0/(Value*Value);
850 for ( i = 0; i < p->pPars->nWords; i++ )
855 for ( k = 0; k < p->pPars->nWords * 64; k++ )
856 if ( iCostBest < p->pPatCosts[k] )
858 iCostBest = p->pPatCosts[k];
896 for ( f = 0; f <= pCex->iFrame; f++ )
912 assert( iBit == pCex->nBits );
947 if ( pAig->nConstrs && i >=
Saig_ManPoNum(pAig) - pAig->nConstrs )
953 pAig->pSeqModel->iPo = i;
955 Abc_Print( 1,
"Output %d is trivally SAT in frame 0. \n", i );
996 Abc_Print( 1,
"Rarity simulation with %d words, %d frames, %d rounds, %d restart, %d seed, and %d sec timeout.\n",
1014 Saig_BmcPerform( pNewAig, 0, 100, 2000, 3, 0, 0, 1 , 0, &iFrameFail, 0 );
1020 for ( f = 0; f < pPars->
nFrames; f++ )
1028 Abc_Print( 1,
"Quitting due to callback on fail.\n" );
1040 Abc_Print( 1,
"Simulated %d frames for %d rounds with %d restarts.\n", pPars->
nFrames, nNumRestart * pPars->
nRestart + r, nNumRestart );
1043 Abc_Print( 1,
"Output %d of miter \"%s\" was asserted in frame %d. ", pAig->pSeqModel->iPo, pAig->pName, pAig->pSeqModel->iFrame );
1052 if ( pPars->
TimeOut && Abc_Clock() > nTimeToStop )
1057 Abc_Print( 1,
"Simulated %d frames for %d rounds with %d restarts and solved %d outputs. ", pPars->
nFrames, nNumRestart * pPars->
nRestart + r, nNumRestart, pPars->
nSolved );
1062 if ( pPars->
TimeOutGap && timeLastSolved && Abc_Clock() > timeLastSolved + pPars->
TimeOutGap * CLOCKS_PER_SEC )
1067 Abc_Print( 1,
"Simulated %d frames for %d rounds with %d restarts and solved %d outputs. ", pPars->
nFrames, nNumRestart * pPars->
nRestart + r, nNumRestart, pPars->
nSolved );
1080 nSavedSeed = (nSavedSeed + 1) % 1000;
1095 Abc_Print( 1,
"Starts =%6d ", nNumRestart );
1111 pAig->pData = p->vInits; p->vInits = NULL;
1129 Abc_Print( 1,
"Simulation of %d frames for %d rounds with %d restarts did not assert POs. ", pPars->
nFrames, nNumRestart * pPars->
nRestart + r, nNumRestart );
1155 printf(
"Generating random permutation of %d flops.\n", nFlops );
1158 for ( i = 0; i < nFlops; i++ )
1160 k = rand() % nFlops;
1161 ABC_SWAP(
int, pArray[i], pArray[k] );
1163 printf(
"Randomly adding %d unused flops.\n", nUnused );
1164 for ( i = 0; i < nUnused; i++ )
1203 p->
pCexSeq = pAig->pSeqModel; pAig->pSeqModel = NULL;
1222 int r, f = -1, i, k;
1225 int nNumRestart = 0;
1237 Abc_Print( 1,
"Rarity equiv filtering with %d words, %d frames, %d rounds, %d seed, and %d sec timeout.\n",
1245 assert( p->vInits == NULL );
1249 Abc_Print( 1,
"Beginning simulation from the state derived using the counter-example.\n" );
1254 for ( i = 1; i < pPars->
nWords; i++ )
1260 if ( pAig->pReprs == NULL )
1277 Abc_Print( 1,
"All equivalences are refined away.\n" );
1281 for ( f = 0; f < pPars->
nFrames; f++ )
1290 Abc_Print( 1,
"Simulated %d frames for %d rounds with %d restarts.\n", pPars->
nFrames, nNumRestart * pPars->
nRestart + r, nNumRestart );
1293 pAig->pSeqModel =
Ssw_RarDeriveCex( p, r * p->pPars->nFrames + f, p->iFailPo, p->iFailPat, 1 );
1295 Abc_Print( 1,
"Output %d of miter \"%s\" was asserted in frame %d. ", pAig->pSeqModel->iPo, pAig->pName, pAig->pSeqModel->iFrame );
1301 if ( pPars->
TimeOut && Abc_Clock() > nTimeToStop )
1304 Abc_Print( 1,
"Simulated %d frames for %d rounds with %d restarts. ", pPars->
nFrames, nNumRestart * pPars->
nRestart + r, nNumRestart );
1313 nSavedSeed = (nSavedSeed + 1) % 1000;
1340 Abc_Print( 1,
"Simulation of %d frames for %d rounds with %d restarts did not assert POs. ", pPars->
nFrames, nNumRestart * pPars->
nRestart + r, nNumRestart );
1374 p->
pCexSeq = pAig->pSeqModel; pAig->pSeqModel = NULL;
static int * Vec_IntArray(Vec_Int_t *p)
static Vec_Ptr_t * Vec_PtrStart(int nSize)
static Vec_Int_t * Ssw_RarFindStartingState(Aig_Man_t *pAig, Abc_Cex_t *pCex)
void Ssw_RarManInitialize(Ssw_RarMan_t *p, Vec_Int_t *vInit)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
int Ssw_ClassesRefineGroup(Ssw_Cla_t *p, Vec_Ptr_t *vReprs, int fRecursive)
int Ssw_ClassesClassNum(Ssw_Cla_t *p)
static Aig_Obj_t * Aig_ObjRepr(Aig_Man_t *p, Aig_Obj_t *pObj)
static int Aig_ObjFaninId0(Aig_Obj_t *pObj)
void Gia_ManStop(Gia_Man_t *p)
Aig_Man_t * Gia_ManToAigSimple(Gia_Man_t *p)
static int Aig_ManConstrNum(Aig_Man_t *p)
void Gia_ManReprFromAigRepr(Aig_Man_t *pAig, Gia_Man_t *pGia)
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 ///.
void Aig_ManStop(Aig_Man_t *p)
void transpose32(unsigned A[32])
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 Ssw_ClassesCand1Num(Ssw_Cla_t *p)
static int Aig_ObjIsTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
void Ssw_RarSetDefaultParams(Ssw_RarPars_t *p)
FUNCTION DEFINITIONS ///.
#define Saig_ManForEachLiLo(p, pObjLi, pObjLo, i)
int Saig_ManVerifyCex(Aig_Man_t *pAig, Abc_Cex_t *p)
ABC_DLL int Abc_FrameIsBatchMode()
unsigned Ssw_RarManObjHashWord(void *pMan, Aig_Obj_t *pObj)
void Ssw_RarManSimulate(Ssw_RarMan_t *p, Vec_Int_t *vInit, int fUpdate, int fFirst)
static void Ssw_RarManStop(Ssw_RarMan_t *p)
Vec_Int_t * Ssw_RarRandomPermFlop(int nFlops, int nUnused)
static word * Ssw_RarObjSim(Ssw_RarMan_t *p, int Id)
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
int Ssw_ClassesRefineConst1Group(Ssw_Cla_t *p, Vec_Ptr_t *vRoots, int fRecursive)
void Aig_ManCleanMarkB(Aig_Man_t *p)
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
int Ssw_RarManObjWhichOne(Ssw_RarMan_t *p, Aig_Obj_t *pObj)
void Ssw_ClassesStop(Ssw_Cla_t *p)
int Ssw_ClassesPrepareRehash(Ssw_Cla_t *p, Vec_Ptr_t *vCands, int fConstCorr)
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
#define Aig_ManForEachCo(p, pObj, i)
int Saig_BmcPerform(Aig_Man_t *pAig, int nStart, int nFramesMax, int nNodesMax, int nTimeOut, int nConfMaxOne, int nConfMaxAll, int fVerbose, int fVerbOverwrite, int *piFrames, int fSilent)
#define ABC_ALLOC(type, num)
word Aig_ManRandom64(int fReset)
unsigned Aig_ManRandom(int fReset)
static int Aig_ObjFaninId1(Aig_Obj_t *pObj)
static abctime Abc_Clock()
static Ssw_RarMan_t * Ssw_RarManStart(Aig_Man_t *pAig, Ssw_RarPars_t *pPars)
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
static Vec_Int_t * Vec_IntStartNatural(int nSize)
static int Vec_PtrSize(Vec_Ptr_t *p)
static Vec_Int_t * Vec_IntStartFull(int nSize)
static void Aig_ObjSetTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
word M(word f1, word f2, int n)
static int Aig_ManNodeNum(Aig_Man_t *p)
void Ssw_RarManAssingRandomPis(Ssw_RarMan_t *p)
#define ABC_SWAP(Type, a, b)
static void Ssw_RarTransferPatterns(Ssw_RarMan_t *p, Vec_Int_t *vInits)
void Aig_ManIncrementTravId(Aig_Man_t *p)
DECLARATIONS ///.
static void Abc_PrintTime(int level, const char *pStr, abctime time)
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
static Vec_Int_t * Vec_IntStart(int nSize)
void Ssw_RarTranspose(Ssw_RarMan_t *p)
#define Aig_ManForEachNode(p, pObj, i)
void Gia_ManReprToAigRepr2(Aig_Man_t *pAig, Gia_Man_t *pGia)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
void transpose64Simple(word A[64], word B[64])
#define Saig_ManForEachLi(p, pObj, i)
void Ssw_ClassesSetData(Ssw_Cla_t *p, void *pManData, unsigned(*pFuncNodeHash)(void *, Aig_Obj_t *), int(*pFuncNodeIsConst)(void *, Aig_Obj_t *), int(*pFuncNodesAreEqual)(void *, Aig_Obj_t *, Aig_Obj_t *))
void Ssw_ClassesPrint(Ssw_Cla_t *p, int fVeryVerbose)
static int Vec_IntEntry(Vec_Int_t *p, int i)
unsigned __int64 word
DECLARATIONS ///.
static int Abc_Base10Log(unsigned n)
int Ssw_RarManPoIsConst0(void *pMan, Aig_Obj_t *pObj)
#define ABC_NAMESPACE_IMPL_END
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
static Aig_Obj_t * Saig_ManLi(Aig_Man_t *p, int i)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
int Ssw_RarCheckTrivial(Aig_Man_t *pAig, int fVerbose)
#define Saig_ManForEachLo(p, pObj, i)
static void Ssw_RarSetBinPat(Ssw_RarMan_t *p, int iBin, int iPat, int Value)
Aig_Man_t * Saig_ManDupWithPhase(Aig_Man_t *pAig, Vec_Int_t *vInit)
int Ssw_RarSimulateGia(Gia_Man_t *p, Ssw_RarPars_t *pPars)
typedefABC_NAMESPACE_IMPL_START struct Ssw_RarMan_t_ Ssw_RarMan_t
DECLARATIONS ///.
static void Vec_IntFreeP(Vec_Int_t **p)
int Ssw_RarManCheckNonConstOutputs(Ssw_RarMan_t *p, int iFrame, abctime Time)
static void Abc_Print(int level, const char *format,...)
int Ssw_RarManObjIsConst(void *pMan, Aig_Obj_t *pObj)
static int Vec_PtrCountZero(Vec_Ptr_t *p)
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
static int Saig_ManRegNum(Aig_Man_t *p)
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
static int Aig_ManObjNumMax(Aig_Man_t *p)
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Ssw_Cla_t * Ssw_ClassesPrepareFromReprs(Aig_Man_t *pAig)
#define ABC_NAMESPACE_IMPL_START
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
static void Abc_InfoSetBit(unsigned *p, int i)
int Ssw_RarManObjsAreEqual(void *pMan, Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
Ssw_Cla_t * Ssw_ClassesPrepareSimple(Aig_Man_t *pAig, int fLatchCorr, int nMaxLevs)
static int Aig_ManRegNum(Aig_Man_t *p)
static int Vec_IntSize(Vec_Int_t *p)
#define Aig_ManForEachObj(p, pObj, i)
int Ssw_RarSignalFilterGia(Gia_Man_t *p, Ssw_RarPars_t *pPars)
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)
int Ssw_RarSimulate(Aig_Man_t *pAig, Ssw_RarPars_t *pPars)
static int Ssw_ObjIsConst1Cand(Aig_Man_t *pAig, Aig_Obj_t *pObj)
#define ABC_CALLOC(type, num)
static void Vec_PtrFreeP(Vec_Ptr_t **p)
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
#define ABC_INFINITY
MACRO DEFINITIONS ///.
#define Saig_ManForEachPo(p, pObj, i)
static int Aig_ObjId(Aig_Obj_t *pObj)
static word * Ssw_RarPatSim(Ssw_RarMan_t *p, int Id)
static void Vec_PtrClear(Vec_Ptr_t *p)
void transpose64(word A[64])
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.
int Ssw_RarSignalFilter(Aig_Man_t *pAig, Ssw_RarPars_t *pPars)
static void Vec_IntFree(Vec_Int_t *p)
void Abc_CexFree(Abc_Cex_t *p)
static void Vec_IntClear(Vec_Int_t *p)
Gia_Man_t * Gia_ManDupPermFlopGap(Gia_Man_t *p, Vec_Int_t *vFfPerm)
static int Ssw_RarGetBinPat(Ssw_RarMan_t *p, int iBin, int iPat)
Abc_Cex_t * Ssw_RarDeriveCex(Ssw_RarMan_t *p, int iFrame, int iPo, int iPatFinal, int fVerbose)
void Ssw_RarManPrepareRandom(int nRandSeed)
static int Ssw_RarBitWordNum(int nBits)
static void Ssw_RarAddToBinPat(Ssw_RarMan_t *p, int iBin, int iPat)
static void Vec_PtrFree(Vec_Ptr_t *p)
#define Saig_ManForEachPi(p, pObj, i)
static int Gia_ManRegNum(Gia_Man_t *p)