61static inline int Raig_Var2Lit(
int Var,
int fCompl ) {
return Var +
Var + fCompl; }
62static inline int Raig_Lit2Var(
int Lit ) {
return Lit >> 1; }
63static inline int Raig_LitIsCompl(
int Lit ) {
return Lit & 1; }
64static inline int Raig_LitNot(
int Lit ) {
return Lit ^ 1; }
65static inline int Raig_LitNotCond(
int Lit,
int c ) {
return Lit ^ (int)(c > 0); }
66static inline int Raig_LitRegular(
int Lit ) {
return Lit & ~01; }
88 if ( pObj->
iData == iNode )
107 assert( !Aig_IsComplement(pObj) );
110 assert( !Aig_ObjIsConst1(pObj) );
111 if ( Aig_ObjIsNode(pObj) )
114 iFan0 = (iFan0 << 1) | Aig_ObjFaninC0(pObj);
116 iFan1 = (iFan1 << 1) | Aig_ObjFaninC1(pObj);
118 else if ( Aig_ObjIsCo(pObj) )
121 iFan0 = (iFan0 << 1) | Aig_ObjFaninC0(pObj);
127 Vec_IntPush(
p->vCis2Ids, Aig_ObjCioId(pObj) );
129 p->pFans0[
p->nObjs] = iFan0;
130 p->pFans1[
p->nObjs] = iFan1;
131 p->pRefs[
p->nObjs] = Aig_ObjRefs(pObj);
132 return pObj->
iData =
p->nObjs++;
155 p->nPis = Saig_ManPiNum(pAig);
156 p->nPos = Saig_ManPoNum(pAig);
157 p->nCis = Aig_ManCiNum(pAig);
158 p->nCos = Aig_ManCoNum(pAig);
159 p->nNodes = Aig_ManNodeNum(pAig);
160 nObjs =
p->nCis +
p->nCos +
p->nNodes + 2;
165 p->vCis2Ids = Vec_IntAlloc( Aig_ManCiNum(pAig) );
168 pObj = Aig_ManConst1( pAig );
171 if ( Aig_ObjRefs(pObj) == 0 )
175 assert( Vec_IntSize(
p->vCis2Ids) == Aig_ManCiNum(pAig) );
178 p->vLos = Vec_IntAlloc( Aig_ManRegNum(pAig) );
180 Vec_IntPush(
p->vLos, pObj->
iData );
182 p->vLis = Vec_IntAlloc( Aig_ManRegNum(pAig) );
185 Vec_IntPush(
p->vLis, pObj->
iData );
187 p->pRefs[ pObj->
iData ]++;
205 Vec_IntFree(
p->vCis2Ids );
206 Vec_IntFree(
p->vLos );
207 Vec_IntFree(
p->vLis );
232 if (
p->MemFree == 0 )
234 unsigned * pPlace, Ent;
235 if (
p->nWordsAlloc == 0 )
238 p->nWordsAlloc = (1<<17);
243 memset(
p->pMems, 0xff,
sizeof(
unsigned) * (
p->nWords + 1) );
244 pPlace = (
unsigned *)&
p->MemFree;
245 for ( Ent =
p->nMems * (
p->nWords + 1);
246 Ent +
p->nWords + 1 < (
unsigned)
p->nWordsAlloc;
247 Ent +=
p->nWords + 1 )
250 pPlace =
p->pMems + Ent;
254 p->pSims[i] =
p->MemFree;
255 pSim =
p->pMems +
p->MemFree;
256 p->MemFree = pSim[0];
257 pSim[0] =
p->pRefs[i];
259 if (
p->nMemsMax <
p->nMems )
260 p->nMemsMax =
p->nMems;
282 pSim =
p->pMems +
p->pSims[i];
283 if ( --pSim[0] == 0 )
285 pSim[0] =
p->MemFree;
286 p->MemFree =
p->pSims[i];
306 unsigned * pRes0, * pRes1, * pRes;
307 int i, w, nCis, nCos, iFan0, iFan1, iPioNum;
311 if ( iPioNum < p->nPis )
315 memset( pRes + 1, 0,
sizeof(
unsigned) *
p->nWords );
319 for ( w = 1; w <=
p->nWords; w++ )
331 for ( i = 2; i <
p->nObjs; i++ )
333 if (
p->pFans0[i] == 0 )
335 iPioNum = Vec_IntEntry(
p->vCis2Ids, nCis );
336 if ( iPioNum < p->nPis )
339 for ( w = 1; w <=
p->nWords; w++ )
349 assert( Vec_IntEntry(
p->vLos, iPioNum-
p->nPis) == i );
353 if (
p->pFans1[i] == 0 )
356 if ( nCos < p->nPos && fMiter )
358 unsigned Const = Raig_LitIsCompl(
p->pFans0[i])? ~0 : 0;
359 for ( w = 1; w <=
p->nWords; w++ )
360 if ( pRes0[w] != Const )
362 *piPat = 32*(w-1) + Aig_WordFindFirstBit( pRes0[w] ^ Const );
370 if ( Raig_LitIsCompl(
p->pFans0[i]) )
371 for ( w = 1; w <=
p->nWords; w++ )
374 for ( w = 1; w <=
p->nWords; w++ )
382 iFan0 =
p->pFans0[i];
383 iFan1 =
p->pFans1[i];
386 if ( Raig_LitIsCompl(iFan0) && Raig_LitIsCompl(iFan1) )
387 for ( w = 1; w <=
p->nWords; w++ )
388 pRes[w] = ~(pRes0[w] | pRes1[w]);
389 else if ( Raig_LitIsCompl(iFan0) && !Raig_LitIsCompl(iFan1) )
390 for ( w = 1; w <=
p->nWords; w++ )
391 pRes[w] = ~pRes0[w] & pRes1[w];
392 else if ( !Raig_LitIsCompl(iFan0) && Raig_LitIsCompl(iFan1) )
393 for ( w = 1; w <=
p->nWords; w++ )
394 pRes[w] = pRes0[w] & ~pRes1[w];
395 else if ( !Raig_LitIsCompl(iFan0) && !Raig_LitIsCompl(iFan1) )
396 for ( w = 1; w <=
p->nWords; w++ )
397 pRes[w] = pRes0[w] & pRes1[w];
401 assert(
p->nMems == 1 + Vec_IntSize(
p->vLis) );
420 int f, i, w, iPioId, Counter;
421 p =
Abc_CexAlloc( Aig_ManRegNum(pAig), Saig_ManPiNum(pAig), iFrame+1 );
428 for ( f = 0; f <= iFrame; f++, Counter +=
p->nPis )
429 for ( i = 0; i < Aig_ManCiNum(pAig); i++ )
431 iPioId = Vec_IntEntry( vCis2Ids, i );
432 if ( iPioId >=
p->nPis )
434 for ( w = 0; w <
nWords; w++ )
436 if ( Abc_InfoHasBit( pData, iPat ) )
437 Abc_InfoSetBit(
p->pData, Counter + iPioId );
458 int i, iPat, RetValue = 0;
459 abctime clk, clkTotal = Abc_Clock();
460 assert( Aig_ManRegNum(pAig) > 0 );
462 if ( Status.nSat > 0 )
464 printf(
"Miter is trivially satisfiable (output %d).\n", Status.iOut );
467 if ( Status.nUndec == 0 )
469 printf(
"Miter is trivially unsatisfiable.\n" );
476 for ( i = 0; i < nIters; i++ )
482 printf(
"Frame %4d out of %4d and timeout %3d sec. ", i+1, nIters, TimeLimit );
483 printf(
"Time = %7.2f sec\r", (1.0*Abc_Clock()-clkTotal)/CLOCKS_PER_SEC);
488 assert( pAig->pSeqModel == NULL );
491 printf(
"Miter is satisfiable after simulation (output %d).\n", iOut );
494 if ( (Abc_Clock() - clk)/CLOCKS_PER_SEC >= TimeLimit )
496 printf(
"No bug detected after %d frames with time limit %d seconds.\n", i+1, TimeLimit );
502 printf(
"Maxcut = %8d. AigMem = %7.2f MB. SimMem = %7.2f MB. ",
504 1.0*(
p->nObjs * 16)/(1<<20),
505 1.0*(
p->nMemsMax * 4 * (
nWords+1))/(1<<20) );
506 ABC_PRT(
"Total time", Abc_Clock() - clkTotal );
#define ABC_ALLOC(type, num)
#define ABC_REALLOC(type, obj, num)
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
struct Aig_Obj_t_ Aig_Obj_t
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
#define Aig_ManForEachCo(p, pObj, i)
void Aig_ManCleanData(Aig_Man_t *p)
unsigned Aig_ManRandom(int fReset)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
unsigned * Raig_ManSimRef(Raig_Man_t *p, int i)
typedefABC_NAMESPACE_IMPL_START struct Raig_Man_t_ Raig_Man_t
DECLARATIONS ///.
int Raig_ManCreate_rec(Raig_Man_t *p, Aig_Obj_t *pObj)
Abc_Cex_t * Raig_ManGenerateCounter(Aig_Man_t *pAig, int iFrame, int iOut, int nWords, int iPat, Vec_Int_t *vCis2Ids)
int Raig_ManSimulate(Aig_Man_t *pAig, int nWords, int nIters, int TimeLimit, int fMiter, int fVerbose)
void Raig_ManDelete(Raig_Man_t *p)
Raig_Man_t * Raig_ManCreate(Aig_Man_t *pAig)
int Raig_ManFindPo(Aig_Man_t *pAig, int iNode)
FUNCTION DEFINITIONS ///.
unsigned * Raig_ManSimDeref(Raig_Man_t *p, int i)
int Raig_ManSimulateRound(Raig_Man_t *p, int fMiter, int fFirst, int *piPat)
#define Saig_ManForEachLi(p, pObj, i)
#define Saig_ManForEachPo(p, pObj, i)
Sec_MtrStatus_t Sec_MiterStatus(Aig_Man_t *p)
DECLARATIONS ///.
#define Saig_ManForEachLo(p, pObj, i)
typedefABC_NAMESPACE_HEADER_START struct Sec_MtrStatus_t_ Sec_MtrStatus_t
INCLUDES ///.
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 ///.
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.