106 if ( Gia_ObjIsTravIdCurrent(
p, pObj) )
108 Gia_ObjSetTravIdCurrent(
p, pObj);
109 if ( Gia_ObjIsCi(pObj) )
111 if ( Gia_ObjIsRo(
p, pObj) )
112 Vec_IntPush( vFlops, Gia_ObjId(
p, pObj) );
115 assert( Gia_ObjIsAnd(pObj) );
116 vLeaves = Ga2_ObjLeaves(
p, pObj );
118 Rnm_ManRefineCollect_rec(
p, pFanin, vVisited, vFlops );
119 Vec_IntPush( vVisited, Gia_ObjId(
p, pObj) );
125 Vec_Int_t * vLeaves, * vLits, * vPpi2Map;
126 Vec_Int_t * vVisited, * vFlops, * vCore, * vCoreFinal;
128 int i, k, f,
Status, Entry, pLits[5], iBit =
p->pCex->nRegs;
130 vPpi2Map = Vec_IntAlloc( Vec_IntSize(vPPIs) );
133 Entry = Vec_IntFind(
p->vMap, Entry );
135 Vec_IntPush( vPpi2Map, Entry );
138 vFlops = Vec_IntAlloc( 100 );
139 vVisited = Vec_IntAlloc( 100 );
143 Rnm_ManRefineCollect_rec(
p->pGia, pObj, vVisited, vFlops );
145 Vec_IntFill(
p->vSat2Ids, 1, -1 );
148 Vec_IntFill(
p->vSatVars, Gia_ManObjNum(
p->pGia), 0 );
151 Rnm_ObjFindOrAddSatVar(
p, pObj );
155 vLeaves = Ga2_ObjLeaves(
p->pGia, pObj );
157 pLits[k] = Rnm_ObjFindOrAddSatVar(
p, pFanin );
158 vCnf0 =
Ga2_ManCnfCompute( Ga2_ObjTruth(
p->pGia, pObj), Vec_IntSize(vLeaves),
p->vIsopMem );
159 vCnf1 =
Ga2_ManCnfCompute( ~Ga2_ObjTruth(
p->pGia, pObj), Vec_IntSize(vLeaves),
p->vIsopMem );
160 Ga2_ManCnfAddStatic(
p->pSat, vCnf0, vCnf1, pLits, Rnm_ObjFindOrAddSatVar(
p, pObj), Rnm_ObjFindOrAddSatVar(
p, pObj)/2 );
161 Vec_IntFree( vCnf0 );
162 Vec_IntFree( vCnf1 );
167 p->pSat->pPrf2 = Prf_ManAlloc();
168 Prf_ManRestart(
p->pSat->pPrf2, NULL, sat_solver2_nlearnts(
p->pSat), Vec_IntSize(
p->vSat2Ids) );
171 vLits = Vec_IntAlloc( 100 );
172 vCoreFinal = Vec_IntAlloc( 100 );
173 for ( f = 0; f <=
p->pCex->iFrame; f++, iBit +=
p->pCex->nPis )
176 Vec_IntClear( vLits );
179 Entry = Abc_InfoHasBit(
p->pCex->pData, iBit + Vec_IntEntry(vPpi2Map, i) );
180 Vec_IntPush( vLits, Abc_LitNotCond( Rnm_ObjFindOrAddSatVar(
p, pObj), !Entry ) );
186 if ( Vec_IntFind( vPPIs, Gia_ObjId(
p->pGia, pObj) ) == -1 )
187 Vec_IntPush( vLits, Abc_LitNotCond( Rnm_ObjFindOrAddSatVar(
p, pObj), 1 ) );
199 Status =
sat_solver2_solve(
p->pSat, Vec_IntArray(vLits), Vec_IntLimit(vLits), (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
205 Vec_IntAppend( vCoreFinal, vCore );
209 Vec_IntFree( vCore );
211 assert( iBit ==
p->pCex->nBits );
212 Vec_IntUniqify( vCoreFinal );
213 Vec_IntFree( vLits );
214 Prf_ManStopP( &
p->pSat->pPrf2 );
221 assert( Vec_IntEntry(
p->vSat2Ids, Entry) >= 0 );
222 assert( Vec_IntEntry(
p->vSat2Ids, Entry) < Gia_ManObjNum(
p->pGia) );
223 Vec_IntWriteEntry( vCoreFinal, i, Vec_IntEntry(
p->vSat2Ids, Entry) );
227 if ( Gia_ObjIsRo(
p->pGia, pObj) )
228 Vec_IntPush( vCoreFinal, Gia_ObjId(
p->pGia, pObj) );
229 Vec_IntUniqify( vCoreFinal );
240 Rnm_ObjSetSatVar(
p, pObj, 0 );
241 vLeaves = Ga2_ObjLeaves(
p->pGia, pObj );
243 Rnm_ObjSetSatVar(
p, pFanin, 0 );
245 Vec_IntFree( vFlops );
246 Vec_IntFree( vVisited );
247 Vec_IntFree( vPpi2Map );
267 assert( Gia_ManPoNum(pGia) == 1 );
270 p->vObjs = Vec_IntAlloc( 100 );
271 p->vCounts = Vec_StrStart( Gia_ManObjNum(pGia) );
272 p->vFanins = Vec_IntAlloc( 1000 );
276 p->nObjsAlloc = 10000;
278 if (
p->pGia->vFanout == NULL )
289 if ( fProfile &&
p->nCalls )
291 double MemGia =
sizeof(
Gia_Man_t) +
sizeof(
Gia_Obj_t) *
p->pGia->nObjsAlloc +
sizeof(int) *
p->pGia->nTravIdsAlloc;
292 double MemOther =
sizeof(
Rnm_Man_t) +
sizeof(
Rnm_Obj_t) *
p->nObjsAlloc +
sizeof(int) * Vec_IntCap(
p->vObjs);
294 printf(
"Abstraction refinement runtime statistics:\n" );
295 ABC_PRTP(
"Sensetization",
p->timeFwd,
p->timeTotal );
296 ABC_PRTP(
"Justification",
p->timeBwd,
p->timeTotal );
297 ABC_PRTP(
"Verification ",
p->timeVer,
p->timeTotal );
299 ABC_PRTP(
"TOTAL ",
p->timeTotal,
p->timeTotal );
300 printf(
"Total calls = %d. Average refine = %.1f. GIA mem = %.3f MB. Other mem = %.3f MB.\n",
301 p->nCalls, 1.0*
p->nRefines/
p->nCalls, MemGia/(1<<20), MemOther/(1<<20) );
311 Vec_StrFree(
p->vCounts );
312 Vec_IntFree(
p->vFanins );
313 Vec_IntFree(
p->vObjs );
319 return (
double)(
sizeof(
Rnm_Man_t) +
sizeof(
Rnm_Obj_t) *
p->nObjsAlloc +
sizeof(int) * Vec_IntCap(
p->vObjs));
336 if ( Gia_ObjIsTravIdCurrent(
p, pObj) )
338 Gia_ObjSetTravIdCurrent(
p, pObj);
339 if ( Gia_ObjIsCo(pObj) )
341 else if ( Gia_ObjIsAnd(pObj) )
346 else if ( !Gia_ObjIsRo(
p, pObj) )
348 pObj->
Value = Vec_IntSize(vObjs) + nAddOn;
349 Vec_IntPush( vObjs, Gia_ObjId(
p, pObj) );
357 Gia_ObjSetTravIdCurrent(
p->pGia, Gia_ManConst0(
p->pGia) );
358 Gia_ManConst0(
p->pGia)->Value = 0;
361 assert( Gia_ObjIsCi(pObj) || Gia_ObjIsAnd(pObj) );
362 Gia_ObjSetTravIdCurrent(
p->pGia, pObj );
366 Vec_IntClear(
p->vObjs );
369 if ( Gia_ObjIsRo(
p->pGia, pObj) )
372 assert( Gia_ObjIsCo(pObj) );
373 assert( (
int)pObj->
Value == Vec_IntSize(
p->vMap) + Vec_IntSize(
p->vObjs) );
400 int f, i, iBit =
p->pCex->nRegs;
402 for ( f = 0; f <=
p->pCex->iFrame; f++, iBit +=
p->pCex->nPis )
406 assert( Gia_ObjIsCi(pObj) || Gia_ObjIsAnd(pObj) );
407 pRnm = Rnm_ManObj(
p, pObj, f );
408 pRnm->Value = Abc_InfoHasBit(
p->pCex->pData, iBit + i );
409 if ( !Gia_ObjIsPi(
p->pGia, pObj) )
412 pRnm->Prio = pObj->
Value;
418 assert( Gia_ObjIsRo(
p->pGia, pObj) || Gia_ObjIsAnd(pObj) || Gia_ObjIsCo(pObj) );
419 pRnm = Rnm_ManObj(
p, pObj, f );
421 if ( Gia_ObjIsRo(
p->pGia, pObj) )
425 pRnm0 = Rnm_ManObj(
p, Gia_ObjRoToRi(
p->pGia, pObj), f-1 );
426 pRnm->Value = pRnm0->Value;
427 pRnm->Prio = pRnm0->Prio;
430 if ( Gia_ObjIsCo(pObj) )
432 pRnm0 = Rnm_ManObj(
p, Gia_ObjFanin0(pObj), f );
433 pRnm->Value = (pRnm0->Value ^ Gia_ObjFaninC0(pObj));
434 pRnm->Prio = pRnm0->Prio;
437 assert( Gia_ObjIsAnd(pObj) );
438 pRnm0 = Rnm_ManObj(
p, Gia_ObjFanin0(pObj), f );
439 pRnm1 = Rnm_ManObj(
p, Gia_ObjFanin1(pObj), f );
440 pRnm->Value = (pRnm0->Value ^ Gia_ObjFaninC0(pObj)) & (pRnm1->Value ^ Gia_ObjFaninC1(pObj));
441 if ( pRnm->Value == 1 )
442 pRnm->Prio = Abc_MaxInt( pRnm0->Prio, pRnm1->Prio );
443 else if ( (pRnm0->Value ^ Gia_ObjFaninC0(pObj)) == 0 && (pRnm1->Value ^ Gia_ObjFaninC1(pObj)) == 0 )
444 pRnm->Prio = Abc_MinInt( pRnm0->Prio, pRnm1->Prio );
445 else if ( (pRnm0->Value ^ Gia_ObjFaninC0(pObj)) == 0 )
446 pRnm->Prio = pRnm0->Prio;
448 pRnm->Prio = pRnm1->Prio;
451 assert( iBit ==
p->pCex->nBits );
452 pRnm = Rnm_ManObj(
p, Gia_ManPo(
p->pGia, 0),
p->pCex->iFrame );
453 if ( pRnm->Value != 1 )
454 printf(
"Output value is incorrect.\n" );
472 Rnm_Obj_t * pRnm0, * pRnm1, * pRnm = Rnm_ManObj(
p, pObj, f );
475 assert( pRnm->fVisit == 0 );
477 if ( Rnm_ManObj(
p, pObj, 0 )->fVisitJ == 0 )
479 Rnm_ManObj(
p, pObj, 0 )->fVisitJ = 1;
484 assert( (
int)pRnm->Prio > 0 );
485 for ( i =
p->pCex->iFrame; i >= 0; i-- )
486 if ( !Rnm_ManObj(
p, pObj, i)->fVisit )
488 Vec_IntPush( vSelect, Gia_ObjId(
p->pGia, pObj) );
491 if ( (Gia_ObjIsCo(pObj) && f ==
p->pCex->iFrame) || Gia_ObjIsPo(
p->pGia, pObj) )
493 if ( Gia_ObjIsRi(
p->pGia, pObj) )
495 pFanout = Gia_ObjRiToRo(
p->pGia, pObj);
496 if ( !Rnm_ManObj(
p, pFanout, f+1)->fVisit )
500 assert( Gia_ObjIsRo(
p->pGia, pObj) || Gia_ObjIsAnd(pObj) );
504 if ( pFanout->
Value == 0 )
506 pRnmF = Rnm_ManObj(
p, pFanout, f);
507 if ( pRnmF->fPPi || pRnmF->fVisit )
509 if ( Gia_ObjIsCo(pFanout) )
514 assert( Gia_ObjIsAnd(pFanout) );
515 pRnm0 = Rnm_ManObj(
p, Gia_ObjFanin0(pFanout), f );
516 pRnm1 = Rnm_ManObj(
p, Gia_ObjFanin1(pFanout), f );
517 if ( ((pRnm0->Value ^ Gia_ObjFaninC0(pFanout)) == 0 && pRnm0->fVisit) ||
518 ((pRnm1->Value ^ Gia_ObjFaninC1(pFanout)) == 0 && pRnm1->fVisit) ||
519 ( ((pRnm0->Value ^ Gia_ObjFaninC0(pFanout)) == 1 && pRnm0->fVisit) &&
520 ((pRnm1->Value ^ Gia_ObjFaninC1(pFanout)) == 1 && pRnm1->fVisit) ) )
530 if (
p->fPropFanout )
535 if ( Rnm_ManObj(
p, pObj, 0 )->fVisitJ == 0 )
537 Rnm_ManObj(
p, pObj, 0 )->fVisitJ = 1;
543 assert( (
int)pRnm->Prio > 0 );
544 if (
p->fPropFanout )
546 for ( i =
p->pCex->iFrame; i >= 0; i-- )
547 if ( !Rnm_ManObj(
p, pObj, i)->fVisit )
552 Vec_IntPush( vSelect, Gia_ObjId(
p->pGia, pObj) );
558 if ( Gia_ObjIsPi(
p->pGia, pObj) || Gia_ObjIsConst0(pObj) )
560 if ( Gia_ObjIsRo(
p->pGia, pObj) )
566 if ( Gia_ObjIsAnd(pObj) )
568 Rnm_Obj_t * pRnm0 = Rnm_ManObj(
p, Gia_ObjFanin0(pObj), f );
569 Rnm_Obj_t * pRnm1 = Rnm_ManObj(
p, Gia_ObjFanin1(pObj), f );
570 if ( pRnm->Value == 1 )
572 if ( pRnm0->Prio > 0 )
574 if ( pRnm1->Prio > 0 )
579 if ( (pRnm0->Value ^ Gia_ObjFaninC0(pObj)) == 0 && (pRnm1->Value ^ Gia_ObjFaninC1(pObj)) == 0 )
581 if ( pRnm0->Prio <= pRnm1->Prio )
583 if ( pRnm0->Prio > 0 )
588 if ( pRnm1->Prio > 0 )
592 else if ( (pRnm0->Value ^ Gia_ObjFaninC0(pObj)) == 0 )
594 if ( pRnm0->Prio > 0 )
597 else if ( (pRnm1->Value ^ Gia_ObjFaninC1(pObj)) == 0 )
599 if ( pRnm1->Prio > 0 )
622 int i, f, iBit = pCex->nRegs;
623 Gia_ObjTerSimSet0( Gia_ManConst0(
p) );
624 for ( f = 0; f <= pCex->iFrame; f++, iBit += pCex->nPis )
628 pObj->
Value = Abc_InfoHasBit( pCex->pData, iBit + i );
629 if ( !Gia_ObjIsPi(
p, pObj) )
630 Gia_ObjTerSimSetX( pObj );
631 else if ( pObj->
Value )
632 Gia_ObjTerSimSet1( pObj );
634 Gia_ObjTerSimSet0( pObj );
639 Gia_ObjTerSimSet1( pObj );
641 Gia_ObjTerSimSet0( pObj );
645 if ( Gia_ObjIsCo(pObj) )
646 Gia_ObjTerSimCo( pObj );
647 else if ( Gia_ObjIsAnd(pObj) )
648 Gia_ObjTerSimAnd( pObj );
650 Gia_ObjTerSimSet0( pObj );
652 Gia_ObjTerSimRo(
p, pObj );
657 pObj = Gia_ManPo(
p, 0 );
658 if ( !Gia_ObjTerSimGet1(pObj) )
659 Abc_Print( 1,
"\nRefinement verification has failed!!!\n" );
677 abctime clk, clk2 = Abc_Clock();
684 p->fPropFanout = fPropFanout;
685 p->fVerbose = fVerbose;
689 p->nObjsFrame = 1 + Vec_IntSize(vMap) + Vec_IntSize(
p->vObjs);
690 p->nObjs =
p->nObjsFrame * (pCex->iFrame + 1);
691 if (
p->nObjs >
p->nObjsAlloc )
696 vGoodPPis = Vec_IntAlloc( 100 );
699 p->timeFwd += Abc_Clock() - clk;
704 RetValue = Vec_IntUniqify( vGoodPPis );
706 p->timeBwd += Abc_Clock() - clk;
715 p->timeVer += Abc_Clock() - clk;
719 if ( Vec_IntSize(vGoodPPis) > 0 )
722 if ( !fNewRefinement )
728 if ( Vec_IntSize(vNewPPis) > 0 )
729 Vec_IntFree( vGoodPPis ), vGoodPPis = vNewPPis;
731 Vec_IntFree( vNewPPis );
740 p->timeTotal += Abc_Clock() - clk2;
741 p->nRefines += Vec_IntSize(vGoodPPis);
#define ABC_ALLOC(type, num)
#define ABC_PRTP(a, t, T)
#define ABC_REALLOC(type, obj, num)
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
void Rnm_ManJustify_rec(Rnm_Man_t *p, Gia_Obj_t *pObj, int f, Vec_Int_t *vSelect)
ABC_NAMESPACE_IMPL_START void Ga2_ManCnfAddStatic(sat_solver2 *pSat, Vec_Int_t *vCnf0, Vec_Int_t *vCnf1, int *pLits, int iLitOut, int ProofId)
DECLARATIONS ///.
void Rnm_ManStop(Rnm_Man_t *p, int fProfile)
void Rnm_ManVerifyUsingTerSim(Gia_Man_t *p, Abc_Cex_t *pCex, Vec_Int_t *vMap, Vec_Int_t *vObjs, Vec_Int_t *vRes)
void Rnm_ManCleanValues(Rnm_Man_t *p)
double Rnm_ManMemoryUsage(Rnm_Man_t *p)
Vec_Int_t * Ga2_ManCnfCompute(unsigned uTruth, int nVars, Vec_Int_t *vCover)
int Rnm_ManSensitize(Rnm_Man_t *p)
void Rnm_ManJustifyPropFanout_rec(Rnm_Man_t *p, Gia_Obj_t *pObj, int f, Vec_Int_t *vSelect)
void Rnm_ManCollect_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vObjs, int nAddOn)
Vec_Int_t * Rnm_ManRefine(Rnm_Man_t *p, Abc_Cex_t *pCex, Vec_Int_t *vMap, int fPropFanout, int fNewRefinement, int fVerbose)
Rnm_Man_t * Rnm_ManStart(Gia_Man_t *pGia)
FUNCTION DEFINITIONS ///.
void Rnm_ManCollect(Rnm_Man_t *p)
Vec_Int_t * Rnm_ManFilterSelectedNew(Rnm_Man_t *p, Vec_Int_t *vOldPPis)
typedefABC_NAMESPACE_HEADER_START struct Rnm_Obj_t_ Rnm_Obj_t
INCLUDES ///.
Vec_Int_t * Rnm_ManFilterSelected(Rnm_Man_t *p, Vec_Int_t *vOldPPis)
struct Rnm_Man_t_ Rnm_Man_t
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
#define Gia_ObjForEachFanoutStatic(p, pObj, pFanout, i)
void Gia_ManStaticFanoutStart(Gia_Man_t *p)
void Gia_ManStaticFanoutStop(Gia_Man_t *p)
struct Gia_Obj_t_ Gia_Obj_t
struct Gia_Man_t_ Gia_Man_t
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
void Gia_ManCleanValue(Gia_Man_t *p)
void Gia_ManCleanMark0(Gia_Man_t *p)
void Gia_ManIncrementTravId(Gia_Man_t *p)
void Gia_ManCleanMark1(Gia_Man_t *p)
void sat_solver2_delete(sat_solver2 *s)
sat_solver2 * sat_solver2_new(void)
int sat_solver2_solve(sat_solver2 *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
void * Sat_ProofCore(sat_solver2 *s)
struct sat_solver2_t sat_solver2
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.