49 static int s_FPrimes[128] = {
50 1009, 1049, 1093, 1151, 1201, 1249, 1297, 1361, 1427, 1459,
51 1499, 1559, 1607, 1657, 1709, 1759, 1823, 1877, 1933, 1997,
52 2039, 2089, 2141, 2213, 2269, 2311, 2371, 2411, 2467, 2543,
53 2609, 2663, 2699, 2741, 2797, 2851, 2909, 2969, 3037, 3089,
54 3169, 3221, 3299, 3331, 3389, 3461, 3517, 3557, 3613, 3671,
55 3719, 3779, 3847, 3907, 3943, 4013, 4073, 4129, 4201, 4243,
56 4289, 4363, 4441, 4493, 4549, 4621, 4663, 4729, 4793, 4871,
57 4933, 4973, 5021, 5087, 5153, 5227, 5281, 5351, 5417, 5471,
58 5519, 5573, 5651, 5693, 5749, 5821, 5861, 5923, 6011, 6073,
59 6131, 6199, 6257, 6301, 6353, 6397, 6481, 6563, 6619, 6689,
60 6737, 6803, 6863, 6917, 6977, 7027, 7109, 7187, 7237, 7309,
61 7393, 7477, 7523, 7561, 7607, 7681, 7727, 7817, 7877, 7933,
62 8011, 8039, 8059, 8081, 8093, 8111, 8123, 8147
69 pSims = Fra_ObjSim(
p->pSml, pObj->
Id);
70 for ( i =
p->pSml->nWordsPref; i < p->pSml->nWordsTotal; i++ )
71 uHash ^= pSims[i] * s_FPrimes[i & 0x7F];
72 return uHash % nTableSize;
91 pSims = Fra_ObjSim(
p->pSml, pObj->
Id);
92 for ( i =
p->pSml->nWordsPref; i < p->pSml->nWordsTotal; i++ )
112 unsigned * pSims0, * pSims1;
114 pSims0 = Fra_ObjSim(
p->pSml, pObj0->
Id);
115 pSims1 = Fra_ObjSim(
p->pSml, pObj1->
Id);
116 for ( i =
p->pSml->nWordsPref; i < p->pSml->nWordsTotal; i++ )
117 if ( pSims0[i] != pSims1[i] )
135 unsigned * pSimL, * pSimR;
137 pSimL = Fra_ObjSim(
p, Left );
138 pSimR = Fra_ObjSim(
p, Right );
139 for ( k =
p->nWordsPref; k < p->nWordsTotal; k++ )
140 Counter += Aig_WordCountOnes( pSimL[k] ^ pSimR[k] );
159 pSims = Fra_ObjSim(
p, pObj->
Id);
160 for ( i =
p->nWordsPref; i < p->nWordsTotal; i++ )
181 pSims = Fra_ObjSim(
p, pObj->
Id);
182 for ( i = 0; i <
p->nWordsTotal; i++ )
183 Counter += Aig_WordCountOnes( pSims[i] );
202 memset(
p->pPatWords, 0,
sizeof(
unsigned) *
p->nPatWords );
220 memset(
p->pPatWords, 0xff,
sizeof(
unsigned) *
p->nPatWords );
224 nTruePis = Aig_ManCiNum(
p->pManAig) - Aig_ManRegNum(
p->pManAig);
227 Abc_InfoXorBit(
p->pPatWords, nTruePis *
p->nFramesAll + k++ );
245 memset(
p->pPatWords, 0,
sizeof(
unsigned) *
p->nPatWords );
248 if ( sat_solver_var_value(
p->pSat, Fra_ObjSatNum(pObj)) )
249 Abc_InfoSetBit(
p->pPatWords, i );
253 Vec_IntClear(
p->vCex );
254 for ( i = 0; i < Aig_ManCiNum(
p->pManAig) - Aig_ManRegNum(
p->pManAig); i++ )
255 Vec_IntPush(
p->vCex, Abc_InfoHasBit(
p->pPatWords, i ) );
256 for ( i = Aig_ManCiNum(
p->pManFraig) - Aig_ManRegNum(
p->pManFraig); i < Aig_ManCiNum(
p->pManFraig); i++ )
257 Vec_IntPush(
p->vCex, Abc_InfoHasBit(
p->pPatWords, i ) );
285 int i, k, BestPat, * pModel;
287 pFanin = Aig_ObjFanin0(pObjPo);
288 pSims = Fra_ObjSim(
p->pSml, pFanin->
Id);
289 for ( i = 0; i <
p->pSml->nWordsTotal; i++ )
292 assert( i < p->pSml->nWordsTotal );
294 for ( k = 0; k < 32; k++ )
295 if ( pSims[i] & (1 << k) )
299 BestPat = i * 32 + k;
301 pModel =
ABC_ALLOC(
int, Aig_ManCiNum(
p->pManFraig)+1 );
304 pModel[i] = Abc_InfoHasBit(Fra_ObjSim(
p->pSml, pObjPi->
Id), BestPat);
307 pModel[Aig_ManCiNum(
p->pManAig)] = pObjPo->
Id;
310 assert(
p->pManFraig->pData == NULL );
311 p->pManFraig->pData = pModel;
331 pObj = Aig_ManCo(
p->pManAig, 0 );
332 assert( Aig_ObjFanin0(pObj)->fPhase == (
unsigned)Aig_ObjFaninC0(pObj) );
362 assert( Aig_ObjIsCi(pObj) );
363 pSims = Fra_ObjSim(
p, pObj->
Id );
364 for ( i = 0; i <
p->nWordsTotal; i++ )
365 pSims[i] = Fra_ObjRandomSim();
383 assert( Aig_ObjIsCi(pObj) || Aig_ObjIsConst1(pObj) );
384 pSims = Fra_ObjSim(
p, pObj->
Id ) +
p->nWordsFrame * iFrame;
385 for ( i = 0; i <
p->nWordsFrame; i++ )
386 pSims[i] = fConst1? ~(
unsigned)0 : 0;
406 assert( Aig_ManRegNum(
p->pAig) > 0 );
407 assert( Aig_ManRegNum(
p->pAig) < Aig_ManCiNum(
p->pAig) );
436 int f, i, k, Limit, nTruePis;
438 if (
p->nFrames == 1 )
444 Limit = Abc_MinInt( Aig_ManCiNum(
p->pAig),
p->nWordsTotal * 32 - 1 );
445 for ( i = 0; i < Limit; i++ )
446 Abc_InfoXorBit( Fra_ObjSim(
p, Aig_ManCi(
p->pAig,i)->Id ), i+1 );
453 nTruePis = Aig_ManCiNum(
p->pAig) - Aig_ManRegNum(
p->pAig);
454 for ( f = 0; f <
p->nFrames; f++ )
466 Limit = Abc_MinInt( nTruePis,
p->nWordsFrame * 32 - 1 );
467 for ( i = 0; i < Limit; i++ )
468 Abc_InfoXorBit( Fra_ObjSim(
p, Aig_ManCi(
p->pAig, i)->Id ) +
p->nWordsFrame*(
p->nFrames-1), i+1 );
487 unsigned * pSims, * pSims0, * pSims1;
488 int fCompl, fCompl0, fCompl1, i;
489 assert( !Aig_IsComplement(pObj) );
490 assert( Aig_ObjIsNode(pObj) );
491 assert( iFrame == 0 ||
p->nWordsFrame <
p->nWordsTotal );
493 pSims = Fra_ObjSim(
p, pObj->
Id) +
p->nWordsFrame * iFrame;
494 pSims0 = Fra_ObjSim(
p, Aig_ObjFanin0(pObj)->Id) +
p->nWordsFrame * iFrame;
495 pSims1 = Fra_ObjSim(
p, Aig_ObjFanin1(pObj)->Id) +
p->nWordsFrame * iFrame;
498 fCompl0 = Aig_ObjPhaseReal(Aig_ObjChild0(pObj));
499 fCompl1 = Aig_ObjPhaseReal(Aig_ObjChild1(pObj));
501 if ( fCompl0 && fCompl1 )
504 for ( i = 0; i <
p->nWordsFrame; i++ )
505 pSims[i] = (pSims0[i] | pSims1[i]);
507 for ( i = 0; i <
p->nWordsFrame; i++ )
508 pSims[i] = ~(pSims0[i] | pSims1[i]);
510 else if ( fCompl0 && !fCompl1 )
513 for ( i = 0; i <
p->nWordsFrame; i++ )
514 pSims[i] = (pSims0[i] | ~pSims1[i]);
516 for ( i = 0; i <
p->nWordsFrame; i++ )
517 pSims[i] = (~pSims0[i] & pSims1[i]);
519 else if ( !fCompl0 && fCompl1 )
522 for ( i = 0; i <
p->nWordsFrame; i++ )
523 pSims[i] = (~pSims0[i] | pSims1[i]);
525 for ( i = 0; i <
p->nWordsFrame; i++ )
526 pSims[i] = (pSims0[i] & ~pSims1[i]);
531 for ( i = 0; i <
p->nWordsFrame; i++ )
532 pSims[i] = ~(pSims0[i] & pSims1[i]);
534 for ( i = 0; i <
p->nWordsFrame; i++ )
535 pSims[i] = (pSims0[i] & pSims1[i]);
552 unsigned * pSims0, * pSims1;
554 assert( !Aig_IsComplement(pObj0) );
555 assert( !Aig_IsComplement(pObj1) );
556 assert( iFrame0 == 0 ||
p->nWordsFrame <
p->nWordsTotal );
557 assert( iFrame1 == 0 ||
p->nWordsFrame <
p->nWordsTotal );
559 pSims0 = Fra_ObjSim(
p, pObj0->
Id) +
p->nWordsFrame * iFrame0;
560 pSims1 = Fra_ObjSim(
p, pObj1->
Id) +
p->nWordsFrame * iFrame1;
562 for ( i = 0; i <
p->nWordsFrame; i++ )
563 if ( pSims0[i] != pSims1[i] )
581 unsigned * pSims, * pSims0;
582 int fCompl, fCompl0, i;
583 assert( !Aig_IsComplement(pObj) );
584 assert( Aig_ObjIsCo(pObj) );
585 assert( iFrame == 0 ||
p->nWordsFrame <
p->nWordsTotal );
587 pSims = Fra_ObjSim(
p, pObj->
Id) +
p->nWordsFrame * iFrame;
588 pSims0 = Fra_ObjSim(
p, Aig_ObjFanin0(pObj)->Id) +
p->nWordsFrame * iFrame;
591 fCompl0 = Aig_ObjPhaseReal(Aig_ObjChild0(pObj));
595 for ( i = 0; i <
p->nWordsFrame; i++ )
596 pSims[i] = ~pSims0[i];
598 for ( i = 0; i <
p->nWordsFrame; i++ )
599 pSims[i] = pSims0[i];
615 unsigned * pSims0, * pSims1;
617 assert( !Aig_IsComplement(pOut) );
618 assert( !Aig_IsComplement(pIn) );
619 assert( Aig_ObjIsCo(pOut) );
620 assert( Aig_ObjIsCi(pIn) );
621 assert( iFrame == 0 ||
p->nWordsFrame <
p->nWordsTotal );
623 pSims0 = Fra_ObjSim(
p, pOut->
Id) +
p->nWordsFrame * iFrame;
624 pSims1 = Fra_ObjSim(
p, pIn->
Id) +
p->nWordsFrame * (iFrame+1);
626 for ( i = 0; i <
p->nWordsFrame; i++ )
627 pSims1[i] = pSims0[i];
669 for ( f = 0; f <
p->nFrames; f++ )
678 if ( f ==
p->nFrames - 1 )
687p->timeSim += Abc_Clock() - clk;
716 if (
p->pCla->vImps )
720p->timeRef += Abc_Clock() - clk;
721 if ( !
p->pPars->nFramesK && nChanges < 1 )
722 printf(
"Error: A counter-example did not refine classes!\n" );
741 int nChanges, nClasses;
743 assert( !fInit || Aig_ManRegNum(
p->pManAig) );
752printf(
"Starting classes = %5d. Lits = %6d.\n", Vec_PtrSize(
p->pCla->vClasses),
Fra_ClassesCountLits(
p->pCla) );
765p->timeRef += Abc_Clock() - clk;
767printf(
"Refined classes = %5d. Changes = %4d. Lits = %6d.\n", Vec_PtrSize(
p->pCla->vClasses), nChanges,
Fra_ClassesCountLits(
p->pCla) );
776p->timeRef += Abc_Clock() - clk;
779printf(
"Refined classes = %5d. Changes = %4d. Lits = %6d.\n", Vec_PtrSize(
p->pCla->vClasses), nChanges,
Fra_ClassesCountLits(
p->pCla) );
784 nClasses = Vec_PtrSize(
p->pCla->vClasses);
790p->timeRef += Abc_Clock() - clk;
792printf(
"Refined classes = %5d. Changes = %4d. Lits = %6d.\n", Vec_PtrSize(
p->pCla->vClasses), nChanges,
Fra_ClassesCountLits(
p->pCla) );
793 }
while ( (
double)nChanges / nClasses >
p->pPars->dSimSatur );
817 memset(
p, 0,
sizeof(
Fra_Sml_t) +
sizeof(
unsigned) * (nPref + nFrames) * nWordsFrame );
820 p->nFrames = nPref + nFrames;
821 p->nWordsFrame = nWordsFrame;
822 p->nWordsTotal = (nPref + nFrames) * nWordsFrame;
823 p->nWordsPref = nPref * nWordsFrame;
884 pFile = fopen( pFileName,
"rb" );
887 printf(
"Cannot open file \"%s\" with simulation patterns.\n", pFileName );
890 vRes = Vec_StrAlloc( 1000 );
891 while ( (c = fgetc(pFile)) != EOF )
893 if ( c ==
'0' || c ==
'1' )
894 Vec_StrPush( vRes, (
char)(c -
'0') );
895 else if ( c !=
' ' && c !=
'\r' && c !=
'\n' && c !=
'\t' )
897 printf(
"File \"%s\" contains symbol (%c) other than \'0\' or \'1\'.\n", pFileName, (
char)c );
898 Vec_StrFreeP( &vRes );
921 int i, k, nPats = Vec_StrSize(vSimInfo) / Aig_ManCiNum(
p->pAig);
922 int nPatsPadded =
p->nWordsTotal * 32;
923 assert( Aig_ManRegNum(
p->pAig) == 0 );
924 assert( Vec_StrSize(vSimInfo) % Aig_ManCiNum(
p->pAig) == 0 );
925 assert( nPats <= nPatsPadded );
928 pSims = Fra_ObjSim(
p, pObj->
Id );
930 for ( k = 0; k <
p->nWordsTotal; k++ )
933 for ( k = 0; k < nPats; k++ )
934 if ( Vec_StrEntry(vSimInfo, k * Aig_ManCiNum(
p->pAig) + i) )
935 Abc_InfoSetBit( pSims, k );
937 for ( ; k < nPatsPadded; k++ )
938 if ( Vec_StrEntry(vSimInfo, (nPats-1) * Aig_ManCiNum(
p->pAig) + i) )
939 Abc_InfoSetBit( pSims, k );
959 for ( k = 0; k < nPatterns; k++ )
963 pSims = Fra_ObjSim(
p, pObj->
Id );
964 printf(
"%d", Abc_InfoHasBit( pSims, k ) );
969 pSims = Fra_ObjSim(
p, pObj->
Id );
970 printf(
"%d", Abc_InfoHasBit( pSims, k ) );
992 assert( Aig_ManRegNum(pAig) == 0 );
995 if ( vSimInfo == NULL )
997 if ( Vec_StrSize(vSimInfo) % Aig_ManCiNum(pAig) != 0 )
999 printf(
"File \"%s\": The number of binary digits (%d) is not divisible by the number of primary inputs (%d).\n",
1000 pFileName, Vec_StrSize(vSimInfo), Aig_ManCiNum(pAig) );
1001 Vec_StrFree( vSimInfo );
1004 p =
Fra_SmlStart( pAig, 0, 1, Abc_BitWordNum(Vec_StrSize(vSimInfo) / Aig_ManCiNum(pAig)) );
1006 nPatterns = Vec_StrSize(vSimInfo) / Aig_ManCiNum(pAig);
1007 Vec_StrFree( vSimInfo );
1054 int iPo, iFrame, iBit, i, k;
1067 pSims = Fra_ObjSim(
p, pObj->
Id );
1068 for ( i =
p->nWordsPref; i < p->nWordsTotal; i++ )
1071 iFrame = i /
p->nWordsFrame;
1072 iBit = 32 * (i %
p->nWordsFrame) + Aig_WordFindFirstBit( pSims[i] );
1077 assert( iPo < Aig_ManCoNum(
p->pAig)-Aig_ManRegNum(
p->pAig) );
1078 assert( iFrame < p->nFrames );
1079 assert( iBit < 32 * p->nWordsFrame );
1082 pCex =
Abc_CexAlloc( Aig_ManRegNum(
p->pAig), Aig_ManCiNum(
p->pAig) - Aig_ManRegNum(
p->pAig), iFrame + 1 );
1084 pCex->iFrame = iFrame;
1089 pSims = Fra_ObjSim(
p, pObj->
Id );
1090 if ( Abc_InfoHasBit( pSims, iBit ) )
1091 Abc_InfoSetBit( pCex->pData, k );
1093 for ( i = 0; i <= iFrame; i++ )
1097 pSims = Fra_ObjSim(
p, pObj->
Id );
1098 if ( Abc_InfoHasBit( pSims, 32 *
p->nWordsFrame * i + iBit ) )
1099 Abc_InfoSetBit( pCex->pData, pCex->nRegs + pCex->nPis * i + k );
1105 printf(
"Fra_SmlGetCounterExample(): Counter-example is invalid.\n" );
1127 int i, nFrames, nTruePis, nTruePos, iPo, iFrame;
1129 assert( Aig_ManRegNum(pAig) > 0 );
1130 assert( Aig_ManRegNum(pFrames) == 0 );
1131 nTruePis = Aig_ManCiNum(pAig)-Aig_ManRegNum(pAig);
1132 nTruePos = Aig_ManCoNum(pAig)-Aig_ManRegNum(pAig);
1133 nFrames = Aig_ManCiNum(pFrames) / nTruePis;
1134 assert( nTruePis * nFrames == Aig_ManCiNum(pFrames) );
1135 assert( nTruePos * nFrames == Aig_ManCoNum(pFrames) );
1140 if ( pObj->
Id == pModel[Aig_ManCiNum(pFrames)] )
1143 iFrame = i / nTruePos;
1148 pCex =
Abc_CexAlloc( Aig_ManRegNum(pAig), nTruePis, iFrame + 1 );
1150 pCex->iFrame = iFrame;
1153 for ( i = 0; i < Aig_ManCiNum(pFrames); i++ )
1156 Abc_InfoSetBit( pCex->pData, pCex->nRegs + i );
1157 if ( pCex->nRegs + i == pCex->nBits - 1 )
1164 printf(
"Fra_SmlGetCounterExample(): Counter-example is invalid.\n" );
#define ABC_ALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
#define Aig_ManForEachLiSeq(p, pObj, i)
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
struct Aig_Obj_t_ Aig_Obj_t
#define Aig_ManForEachNode(p, pObj, i)
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
#define Aig_ManForEachPiSeq(p, pObj, i)
SEQUENTIAL ITERATORS ///.
#define Aig_ManForEachCo(p, pObj, i)
#define Aig_ManForEachPoSeq(p, pObj, i)
#define Aig_ManForEachLoSeq(p, pObj, i)
#define Aig_ManForEachLiLoSeq(p, pObjLi, pObjLo, k)
struct Vec_Str_t_ Vec_Str_t
void Fra_SmlPrintOutputs(Fra_Sml_t *p, int nPatterns)
void Fra_SmlNodeCopyFanin(Fra_Sml_t *p, Aig_Obj_t *pObj, int iFrame)
int Fra_SmlNodeIsConst(Aig_Obj_t *pObj)
void Fra_SmlNodeTransferNext(Fra_Sml_t *p, Aig_Obj_t *pOut, Aig_Obj_t *pIn, int iFrame)
void Fra_SmlAssignDist1(Fra_Sml_t *p, unsigned *pPat)
int Fra_SmlCheckNonConstOutputs(Fra_Sml_t *p)
void Fra_SmlSimulate(Fra_Man_t *p, int fInit)
void Fra_SmlAssignConst(Fra_Sml_t *p, Aig_Obj_t *pObj, int fConst1, int iFrame)
void Fra_SmlCheckOutputSavePattern(Fra_Man_t *p, Aig_Obj_t *pObjPo)
void Fra_SmlStop(Fra_Sml_t *p)
void Fra_SmlInitializeGiven(Fra_Sml_t *p, Vec_Str_t *vSimInfo)
void Fra_SmlAssignRandom(Fra_Sml_t *p, Aig_Obj_t *pObj)
Fra_Sml_t * Fra_SmlStart(Aig_Man_t *pAig, int nPref, int nFrames, int nWordsFrame)
int Fra_SmlCheckOutput(Fra_Man_t *p)
int Fra_SmlNodeNotEquWeight(Fra_Sml_t *p, int Left, int Right)
int Fra_SmlNodesCompareInFrame(Fra_Sml_t *p, Aig_Obj_t *pObj0, Aig_Obj_t *pObj1, int iFrame0, int iFrame1)
void Fra_SmlSimulateOne(Fra_Sml_t *p)
int Fra_SmlNodeIsZero(Fra_Sml_t *p, Aig_Obj_t *pObj)
Fra_Sml_t * Fra_SmlSimulateComb(Aig_Man_t *pAig, int nWords, int fCheckMiter)
Abc_Cex_t * Fra_SmlCopyCounterExample(Aig_Man_t *pAig, Aig_Man_t *pFrames, int *pModel)
void Fra_SmlNodeSimulate(Fra_Sml_t *p, Aig_Obj_t *pObj, int iFrame)
Fra_Sml_t * Fra_SmlSimulateCombGiven(Aig_Man_t *pAig, char *pFileName, int fCheckMiter, int fVerbose)
int Fra_SmlNodesAreEqual(Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
void Fra_SmlResimulate(Fra_Man_t *p)
int Fra_SmlNodeCountOnes(Fra_Sml_t *p, Aig_Obj_t *pObj)
void Fra_SmlSavePattern1(Fra_Man_t *p, int fInit)
void Fra_SmlInitialize(Fra_Sml_t *p, int fInit)
ABC_NAMESPACE_IMPL_START int Fra_SmlNodeHash(Aig_Obj_t *pObj, int nTableSize)
DECLARATIONS ///.
Fra_Sml_t * Fra_SmlSimulateSeq(Aig_Man_t *pAig, int nPref, int nFrames, int nWords, int fCheckMiter)
Vec_Str_t * Fra_SmlSimulateReadFile(char *pFileName)
Abc_Cex_t * Fra_SmlGetCounterExample(Fra_Sml_t *p)
void Fra_SmlSavePattern(Fra_Man_t *p)
void Fra_SmlSavePattern0(Fra_Man_t *p, int fInit)
int Fra_ClassesRefine1(Fra_Cla_t *p, int fRefineNewClass, int *pSkipped)
void Fra_ClassesPrepare(Fra_Cla_t *p, int fLatchCorr, int nMaxLevs)
struct Fra_Man_t_ Fra_Man_t
int Fra_SmlCheckOutput(Fra_Man_t *p)
int Fra_OneHotRefineUsingCex(Fra_Man_t *p, Vec_Int_t *vOneHots)
int Fra_ClassesRefine(Fra_Cla_t *p)
int Fra_ClassesCountLits(Fra_Cla_t *p)
struct Fra_Sml_t_ Fra_Sml_t
int Fra_ImpRefineUsingCex(Fra_Man_t *p, Vec_Int_t *vImps)
int Saig_ManVerifyCex(Aig_Man_t *pAig, Abc_Cex_t *p)
void Abc_CexFree(Abc_Cex_t *p)
ABC_NAMESPACE_IMPL_START Abc_Cex_t * Abc_CexAlloc(int nRegs, int nRealPis, int nFrames)
DECLARATIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.