27#define VTA_LARGE 0xFFFFFFF
87static inline int Vta_ValIs0(
Vta_Obj_t * pThis,
int fCompl )
95static inline int Vta_ValIs1(
Vta_Obj_t * pThis,
int fCompl )
104static inline Vta_Obj_t * Vta_ManObj(
Vta_Man_t *
p,
int i ) {
assert( i >= 0 && i < p->nObjs );
return i ?
p->pObjs + i : NULL; }
105static inline int Vta_ObjId(
Vta_Man_t *
p,
Vta_Obj_t * pObj ) {
assert( pObj >
p->pObjs && pObj < p->pObjs +
p->nObjs );
return pObj -
p->pObjs; }
107#define Vta_ManForEachObj( p, pObj, i ) \
108 for ( i = 1; (i < p->nObjs) && ((pObj) = Vta_ManObj(p, i)); i++ )
109#define Vta_ManForEachObjObj( p, pObjVta, pObjGia, i ) \
110 for ( i = 1; (i < p->nObjs) && ((pObjVta) = Vta_ManObj(p, i)) && ((pObjGia) = Gia_ManObj(p->pGia, pObjVta->iObj)); i++ )
111#define Vta_ManForEachObjObjReverse( p, pObjVta, pObjGia, i ) \
112 for ( i = Vec_IntSize(vVec) - 1; (i >= 1) && ((pObjVta) = Vta_ManObj(p, i)) && ((pObjGia) = Gia_ManObj(p->pGia, pObjVta->iObj)); i++ )
114#define Vta_ManForEachObjVec( vVec, p, pObj, i ) \
115 for ( i = 0; (i < Vec_IntSize(vVec)) && ((pObj) = Vta_ManObj(p, Vec_IntEntry(vVec,i))); i++ )
116#define Vta_ManForEachObjVecReverse( vVec, p, pObj, i ) \
117 for ( i = Vec_IntSize(vVec) - 1; (i >= 0) && ((pObj) = Vta_ManObj(p, Vec_IntEntry(vVec,i))); i-- )
119#define Vta_ManForEachObjObjVec( vVec, p, pObj, pObjG, i ) \
120 for ( i = 0; (i < Vec_IntSize(vVec)) && ((pObj) = Vta_ManObj(p, Vec_IntEntry(vVec,i))) && ((pObjG) = Gia_ManObj(p->pGia, pObj->iObj)); i++ )
121#define Vta_ManForEachObjObjVecReverse( vVec, p, pObj, pObjG, i ) \
122 for ( i = Vec_IntSize(vVec) - 1; (i >= 0) && ((pObj) = Vta_ManObj(p, Vec_IntEntry(vVec,i))) && ((pObjG) = Gia_ManObj(p->pGia, pObj->iObj)); i-- )
152 int i, k, Entry, iStart, iStop = -1;
153 int nFrames = Vec_IntEntry( vAbs, 0 );
154 assert( Vec_IntEntry(vAbs, nFrames+1) == Vec_IntSize(vAbs) );
155 vFrames = Vec_PtrAlloc( nFrames );
156 for ( i = 0; i < nFrames; i++ )
158 iStart = Vec_IntEntry( vAbs, i+1 );
159 iStop = Vec_IntEntry( vAbs, i+2 );
160 vFrame = Vec_IntAlloc( iStop - iStart );
162 Vec_IntPush( vFrame, Entry );
163 Vec_PtrPush( vFrames, vFrame );
165 assert( iStop == Vec_IntSize(vAbs) );
183 int i, k, Entry, nSize;
184 vAbs = Vec_IntAlloc( 2 + Vec_VecSize(vFrames) + Vec_VecSizeSize(vFrames) );
185 Vec_IntPush( vAbs, Vec_VecSize(vFrames) );
186 nSize = Vec_VecSize(vFrames) + 2;
189 Vec_IntPush( vAbs, nSize );
190 nSize += Vec_IntSize( vOne );
192 Vec_IntPush( vAbs, nSize );
193 assert( Vec_IntSize(vAbs) == Vec_VecSize(vFrames) + 2 );
196 Vec_IntPush( vAbs, Entry );
197 assert( Vec_IntEntry(vAbs, Vec_IntEntry(vAbs,0)+1) == Vec_IntSize(vAbs) );
216 int i, w, nObjs = Vec_IntSize(
p) /
nWords;
218 vRes = Vec_IntAlloc( nObjs );
219 for ( i = 0; i < nObjs; i++ )
221 pThis = (
unsigned *)Vec_IntEntryP(
p,
nWords * i );
222 for ( w = 0; w <
nWords; w++ )
225 Vec_IntPush( vRes, (
int)(w <
nWords) );
243 int * pArray =
ABC_CALLOC(
int, Vec_IntSize(
p) * 2 );
244 int i, w, nObjs = Vec_IntSize(
p) /
nWords;
246 for ( i = 0; i < nObjs; i++ )
247 for ( w = 0; w <
nWords; w++ )
269static inline int Vga_ManHash(
int iObj,
int iFrame,
int nBins )
271 return ((
unsigned)((iObj + iFrame)*(iObj + iFrame + 1))) % nBins;
273static inline int * Vga_ManLookup(
Vta_Man_t *
p,
int iObj,
int iFrame )
276 int * pPlace =
p->pBins + Vga_ManHash( iObj, iFrame,
p->nBins );
277 for ( pThis = Vta_ManObj(
p, *pPlace);
278 pThis; pPlace = &pThis->
iNext,
279 pThis = Vta_ManObj(
p, *pPlace) )
280 if ( pThis->
iObj == iObj && pThis->
iFrame == iFrame )
286 int * pPlace = Vga_ManLookup(
p, iObj, iFrame );
287 return Vta_ManObj(
p, *pPlace);
293 assert( iObj >= 0 && iFrame >= -1 );
294 if (
p->nObjs ==
p->nObjsAlloc )
302 p->nBins = Abc_PrimeCudd( 2 *
p->nBins );
307 pPlace = Vga_ManLookup(
p, pThis->
iObj, pThis->
iFrame );
312 pPlace = Vga_ManLookup(
p, iObj, iFrame );
314 return Vta_ManObj(
p, *pPlace);
315 *pPlace =
p->nObjs++;
316 pThis = Vta_ManObj(
p, *pPlace);
321static inline void Vga_ManDelete(
Vta_Man_t *
p,
int iObj,
int iFrame )
323 int * pPlace = Vga_ManLookup(
p, iObj, iFrame );
326 *pPlace = pThis->
iNext;
348 pCex =
Abc_CexAlloc( Gia_ManRegNum(
p->pGia), Gia_ManPiNum(
p->pGia),
p->pPars->iFrame+1 );
350 pCex->iFrame =
p->pPars->iFrame;
352 if ( Gia_ObjIsPi(
p->pGia, pObj) && sat_solver2_var_value(
p->pSat, Vta_ObjId(
p, pThis)) )
353 Abc_InfoSetBit( pCex->pData, pCex->nRegs + pThis->
iFrame * pCex->nPis + Gia_ObjCioId(pObj) );
374 pThis = Vta_ManObj(
p, Entry );
375 Entry = (pThis->
iFrame <<
p->nObjBits) | pThis->
iObj;
376 Vec_IntWriteEntry( vCore, i, Entry );
393 int Diff = (*pp1)->Prio - (*pp2)->Prio;
398 Diff = (*pp1) - (*pp2);
420 unsigned * pInfo = (
unsigned *)Vec_IntEntryP(
p->vSeens,
p->nWords * iObj );
421 for ( i = 0; i <
p->nWords; i++ )
444 assert( !Gia_ObjIsPi(
p->pGia, pObj) );
445 if ( Gia_ObjIsConst0(pObj) || (Gia_ObjIsCi(pObj) && pThis->
iFrame == 0) )
447 if ( Gia_ObjIsAnd(pObj) )
449 *ppThis0 = Vga_ManFind(
p, Gia_ObjFaninId0p(
p->pGia, pObj), pThis->
iFrame );
450 *ppThis1 = Vga_ManFind(
p, Gia_ObjFaninId1p(
p->pGia, pObj), pThis->
iFrame );
455 pObj = Gia_ObjRoToRi(
p->pGia, pObj );
456 *ppThis0 = Vga_ManFind(
p, Gia_ObjFaninId0p(
p->pGia, pObj), pThis->
iFrame-1 );
478 pObj = Gia_ManObj(
p->pGia, pThis->
iObj );
481 Vta_ObjPreds(
p, pThis, pObj, &pThis0, &pThis1 );
485 Vec_IntPush( vOrder, Vta_ObjId(
p, pThis) );
491 Vec_IntClear(
p->vOrder );
492 pObj = Gia_ManPo(
p->pGia, 0 );
493 pThis = Vga_ManFind(
p, Gia_ObjFaninId0p(
p->pGia, pObj), f );
523 Vta_ObjPreds(
p, pThis, pObj, &pThis0, &pThis1 );
524 if ( Gia_ObjIsAnd(pObj) )
527 assert( Vta_ValIs1(pThis0, Gia_ObjFaninC0(pObj)) && Vta_ValIs1(pThis1, Gia_ObjFaninC1(pObj)) );
529 assert( Vta_ValIs0(pThis0, Gia_ObjFaninC0(pObj)) || Vta_ValIs0(pThis1, Gia_ObjFaninC1(pObj)) );
532 else if ( Gia_ObjIsRo(
p->pGia, pObj) )
534 pObj = Gia_ObjRoToRi(
p->pGia, pObj );
538 assert( Vta_ValIs0(pThis0, Gia_ObjFaninC0(pObj)) );
540 assert( Vta_ValIs1(pThis0, Gia_ObjFaninC0(pObj)) );
562 int i, * pCounters =
ABC_CALLOC(
int,
p->pPars->iFrame+1 );
564 pCounters[pThis->
iFrame]++;
565 for ( i = 0; i <=
p->pPars->iFrame; i++ )
566 Abc_Print( 1,
"%2d", pCounters[i] );
567 Abc_Print( 1,
"***\n" );
587 Vta_Obj_t * pThis, * pThis0, * pThis1, * pTop;
609 Vta_ObjPreds(
p, pThis, pObj, &pThis0, &pThis1 );
610 if ( Gia_ObjIsAnd(pObj) )
613 assert( Vta_ValIs1(pThis0, Gia_ObjFaninC0(pObj)) && Vta_ValIs1(pThis1, Gia_ObjFaninC1(pObj)) );
615 assert( Vta_ValIs0(pThis0, Gia_ObjFaninC0(pObj)) || Vta_ValIs0(pThis1, Gia_ObjFaninC1(pObj)) );
618 else if ( Gia_ObjIsRo(
p->pGia, pObj) )
620 pObj = Gia_ObjRoToRi(
p->pGia, pObj );
624 assert( Vta_ValIs0(pThis0, Gia_ObjFaninC0(pObj)) );
626 assert( Vta_ValIs1(pThis0, Gia_ObjFaninC0(pObj)) );
632 pThis = Vta_ManObj(
p, Vec_IntEntryLast(vOrder) );
635 vTermsUsed = Vec_PtrAlloc( 1015 );
636 vTermsUnused = Vec_PtrAlloc( 1016 );
642 if ( Gia_ObjIsConst0(pObj) || Gia_ObjIsPi(
p->pGia, pObj) )
648 assert( Gia_ObjIsAnd(pObj) || Gia_ObjIsRo(
p->pGia, pObj) );
653 Vec_PtrPush( vTermsUsed, pThis );
655 Vec_PtrPush( vTermsUnused, pThis );
659 Vta_ObjPreds(
p, pThis, pObj, &pThis0, &pThis1 );
661 pThis0->
Prio = Abc_MinInt( pThis0->
Prio, pThis->
Prio + 1 );
663 pThis1->
Prio = Abc_MinInt( pThis1->
Prio, pThis->
Prio + 1 );
710 if ( Vec_PtrSize(vTermsUsed) > 1 )
712 pThis0 = (
Vta_Obj_t *)Vec_PtrEntry(vTermsUsed, 0);
713 pThis1 = (
Vta_Obj_t *)Vec_PtrEntryLast(vTermsUsed);
719 pThis->
Prio = Counter++;
721 pThis->
Prio = Counter++;
736 if ( Gia_ObjIsAnd(pObj) )
738 pThis0 = Vga_ManFind(
p, Gia_ObjFaninId0p(
p->pGia, pObj), pThis->
iFrame );
739 pThis1 = Vga_ManFind(
p, Gia_ObjFaninId1p(
p->pGia, pObj), pThis->
iFrame );
740 assert( pThis0 && pThis1 );
743 assert( Vta_ValIs1(pThis0, Gia_ObjFaninC0(pObj)) && Vta_ValIs1(pThis1, Gia_ObjFaninC1(pObj)) );
748 if ( Vta_ValIs0(pThis0, Gia_ObjFaninC0(pObj)) && Vta_ValIs0(pThis1, Gia_ObjFaninC1(pObj)) )
750 else if ( Vta_ValIs0(pThis0, Gia_ObjFaninC0(pObj)) )
752 else if ( Vta_ValIs0(pThis1, Gia_ObjFaninC1(pObj)) )
758 else if ( Gia_ObjIsRo(
p->pGia, pObj) )
762 pObj = Gia_ObjRoToRi(
p->pGia, pObj );
763 pThis0 = Vga_ManFind(
p, Gia_ObjFaninId0p(
p->pGia, pObj), pThis->
iFrame-1 );
770 else if ( Gia_ObjIsConst0(pObj) )
777 pTop = Vta_ManObj(
p, Vec_IntEntryLast(vOrder) );
779 vTermsToAdd = Vec_IntAlloc( 100 );
789 assert( Gia_ObjIsAnd(pObj) || Gia_ObjIsRo(
p->pGia, pObj) || Gia_ObjIsConst0(pObj) || Gia_ObjIsPi(
p->pGia, pObj) );
790 Vec_IntPush( vTermsToAdd, Vta_ObjId(
p, pThis) );
796 if ( Gia_ObjIsAnd(pObj) )
798 pThis0 = Vga_ManFind(
p, Gia_ObjFaninId0p(
p->pGia, pObj), pThis->
iFrame );
799 pThis1 = Vga_ManFind(
p, Gia_ObjFaninId1p(
p->pGia, pObj), pThis->
iFrame );
800 assert( pThis0 && pThis1 );
803 assert( Vta_ValIs1(pThis0, Gia_ObjFaninC0(pObj)) && Vta_ValIs1(pThis1, Gia_ObjFaninC1(pObj)) );
811 if ( Vta_ValIs0(pThis0, Gia_ObjFaninC0(pObj)) && Vta_ValIs0(pThis1, Gia_ObjFaninC1(pObj)) )
816 else if ( pThis1->
fVisit )
819 else if ( pThis0->
Prio <= pThis1->
Prio )
830 else if ( Vta_ValIs0(pThis0, Gia_ObjFaninC0(pObj)) )
835 else if ( Vta_ValIs0(pThis1, Gia_ObjFaninC1(pObj)) )
844 else if ( Gia_ObjIsRo(
p->pGia, pObj) )
848 pObj = Gia_ObjRoToRi(
p->pGia, pObj );
849 pThis0 = Vga_ManFind(
p, Gia_ObjFaninId0p(
p->pGia, pObj), pThis->
iFrame-1 );
855 else if ( !Gia_ObjIsConst0(pObj) )
859 if (
p->pPars->fAddLayer )
868 Counter = Vec_IntSize(vTermsToAdd);
875 Vec_IntPush( vTermsToAdd, Vta_ObjId(
p, pThis) );
887 Vec_PtrFree( vTermsUsed );
888 Vec_PtrFree( vTermsUnused );
907 if ( Gia_ObjIsAnd(pObj) )
909 pThis0 = Vga_ManFind(
p, Gia_ObjFaninId0p(
p->pGia, pObj), pThis->
iFrame );
910 pThis1 = Vga_ManFind(
p, Gia_ObjFaninId1p(
p->pGia, pObj), pThis->
iFrame );
911 assert( pThis0 && pThis1 );
912 if ( Vta_ValIs1(pThis0, Gia_ObjFaninC0(pObj)) && Vta_ValIs1(pThis1, Gia_ObjFaninC1(pObj)) )
914 else if ( Vta_ValIs0(pThis0, Gia_ObjFaninC0(pObj)) || Vta_ValIs0(pThis1, Gia_ObjFaninC1(pObj)) )
919 else if ( Gia_ObjIsRo(
p->pGia, pObj) )
923 pObj = Gia_ObjRoToRi(
p->pGia, pObj );
924 pThis0 = Vga_ManFind(
p, Gia_ObjFaninId0p(
p->pGia, pObj), pThis->
iFrame-1 );
926 if ( Vta_ValIs0(pThis0, Gia_ObjFaninC0(pObj)) )
928 else if ( Vta_ValIs1(pThis0, Gia_ObjFaninC0(pObj)) )
938 else if ( Gia_ObjIsConst0(pObj) )
948 if ( !Vta_ValIs1(pTop, Gia_ObjFaninC0(Gia_ManPo(
p->pGia, 0))) )
949 Abc_Print( 1,
"Vta_ManRefineAbstraction(): Terminary simulation verification failed!\n" );
956 if ( pTop->
Prio == 0 )
963 if ( !Gia_ObjIsPi(
p->pGia, pObj) )
967 p->nObjAdded += Vec_IntSize(vTermsToAdd);
968 Vec_IntFree( vTermsToAdd );
990 p->nObjsAlloc = (1 << 18);
993 p->nBins = Abc_PrimeCudd( 2*
p->nObjsAlloc );
995 p->vOrder = Vec_IntAlloc( 1013 );
997 p->nObjBits = Abc_Base2Log( Gia_ManObjNum(pGia) );
998 p->nObjMask = (1 <<
p->nObjBits) - 1;
999 assert( Gia_ManObjNum(pGia) <= (
int)
p->nObjMask );
1001 p->vSeens = Vec_IntStart( Gia_ManObjNum(pGia) *
p->nWords );
1002 p->vSeenGla = Vec_BitStart( Gia_ManObjNum(pGia) );
1006 p->vCores = Vec_PtrAlloc( 100 );
1008 p->pSat->pPrf1 = Vec_SetAlloc( 20 );
1011 p->pSat->nLearntStart =
p->pPars->nLearnedStart;
1012 p->pSat->nLearntDelta =
p->pPars->nLearnedDelta;
1013 p->pSat->nLearntRatio =
p->pPars->nLearnedPerce;
1014 p->pSat->nLearntMax =
p->pSat->nLearntStart;
1018 p->vAddedNew = Vec_IntAlloc( 1000 );
1035 if (
p->pPars->fVerbose )
1036 Abc_Print( 1,
"SAT solver: Var = %d Cla = %d Conf = %d Lrn = %d Reduce = %d Cex = %d Objs+ = %d\n",
1037 sat_solver2_nvars(
p->pSat), sat_solver2_nclauses(
p->pSat), sat_solver2_nconflicts(
p->pSat),
1038 sat_solver2_nlearnts(
p->pSat),
p->pSat->nDBreduces,
p->nCexes,
p->nObjAdded );
1041 Vec_BitFreeP( &
p->vSeenGla );
1042 Vec_IntFreeP( &
p->vSeens );
1043 Vec_IntFreeP( &
p->vOrder );
1044 Vec_IntFreeP( &
p->vAddedNew );
1062static inline int Vga_ManGetOutLit(
Vta_Man_t *
p,
int f )
1065 Vta_Obj_t * pThis = Vga_ManFind(
p, Gia_ObjFaninId0p(
p->pGia, pObj), f );
1067 if ( f == 0 && Gia_ObjIsRo(
p->pGia, Gia_ObjFanin0(pObj)) && !Gia_ObjFaninC0(pObj) )
1068 return -Vta_ObjId(
p, pThis);
1069 return Abc_Var2Lit( Vta_ObjId(
p, pThis), Gia_ObjFaninC0(pObj) );
1094 vCore = Vec_IntAlloc( 1 );
1095 Vec_IntPush( vCore, -iLit );
1099 RetValue =
sat_solver2_solve( pSat, &iLit, &iLit+1, (ABC_INT64_T)nConfMax, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
1108 if ( RetValue ==
l_True )
1146 int * pCountAll = NULL, * pCountUni = NULL;
1147 int i, iFrame, iObj, Entry, fChanges = 0;
1155 iObj = (Entry &
p->nObjMask);
1156 iFrame = (Entry >>
p->nObjBits);
1157 assert( iFrame < nFrames );
1158 pInfo = (
unsigned *)Vec_IntEntryP(
p->vSeens,
p->nWords * iObj );
1159 if ( !Abc_InfoHasBit(pInfo, iFrame) )
1161 Abc_InfoSetBit( pInfo, iFrame );
1162 pCountUni[iFrame+1]++;
1166 pCountAll[iFrame+1]++;
1168 if ( !Vec_BitEntry(
p->vSeenGla, iObj) )
1170 Vec_BitWriteEntry(
p->vSeenGla, iObj, 1);
1187 Abc_Print( 1,
"%4d :", nFrames-1 );
1188 Abc_Print( 1,
"%4d", Abc_MinInt(100, 100 *
p->nSeenGla / (Gia_ManRegNum(
p->pGia) + Gia_ManAndNum(
p->pGia) + 1)) );
1189 Abc_Print( 1,
"%6d",
p->nSeenGla );
1190 Abc_Print( 1,
"%4d", Abc_MinInt(100, 100 *
p->nSeenAll / (
p->nSeenGla * nFrames)) );
1191 Abc_Print( 1,
"%8d", nConfls );
1193 Abc_Print( 1,
"%5c",
'-' );
1195 Abc_Print( 1,
"%5d", nCexes );
1197 Abc_PrintInt( sat_solver2_nvars(
p->pSat) );
1198 Abc_PrintInt( sat_solver2_nclauses(
p->pSat) );
1199 Abc_PrintInt( sat_solver2_nlearnts(
p->pSat) );
1200 if ( vCore == NULL )
1202 Abc_Print( 1,
" ..." );
1205 Abc_Print( 1,
"%9.2f sec", 1.0*Time/CLOCKS_PER_SEC );
1207 Abc_Print( 1,
"\r" );
1211 Abc_PrintInt( pCountAll[0] );
1229 Abc_Print( 1,
"%9.2f sec", 1.0*Time/CLOCKS_PER_SEC );
1231 Abc_Print( 1,
"\n" );
1257 Gia_Obj_t * pObj = Gia_ManObj(
p->pGia, iObj );
1258 Vta_Obj_t * pThis = Vga_ManFindOrAdd(
p, iObj, iFrame );
1259 int iThis0, iMainVar = Vta_ObjId(
p, pThis);
1264 Vec_IntPush(
p->vAddedNew, iMainVar );
1265 if ( Gia_ObjIsAnd(pObj) )
1267 pThis0 = Vga_ManFindOrAdd(
p, Gia_ObjFaninId0p(
p->pGia, pObj), iFrame );
1268 iThis0 = Vta_ObjId(
p, pThis0);
1269 pThis1 = Vga_ManFindOrAdd(
p, Gia_ObjFaninId1p(
p->pGia, pObj), iFrame );
1270 sat_solver2_add_and(
p->pSat, iMainVar, iThis0, Vta_ObjId(
p, pThis1),
1271 Gia_ObjFaninC0(pObj), Gia_ObjFaninC1(pObj), 0, iMainVar );
1273 else if ( Gia_ObjIsRo(
p->pGia, pObj) )
1277 if (
p->pPars->fUseTermVars )
1279 pThis0 = Vga_ManFindOrAdd(
p, iObj, -1 );
1280 sat_solver2_add_constraint(
p->pSat, iMainVar, Vta_ObjId(
p, pThis0), 1, 0, iMainVar );
1284 sat_solver2_add_const(
p->pSat, iMainVar, 1, 0, iMainVar );
1289 pObj = Gia_ObjRoToRi(
p->pGia, pObj );
1290 pThis0 = Vga_ManFindOrAdd(
p, Gia_ObjFaninId0p(
p->pGia, pObj), iFrame-1 );
1291 sat_solver2_add_buffer(
p->pSat, iMainVar, Vta_ObjId(
p, pThis0), Gia_ObjFaninC0(pObj), 0, iMainVar );
1294 else if ( Gia_ObjIsConst0(pObj) )
1296 sat_solver2_add_const(
p->pSat, iMainVar, 1, 0, iMainVar );
1334 int i, Entry, iObj, iFrame;
1337 iObj = (Entry &
p->nObjMask);
1338 iFrame = (Entry >>
p->nObjBits);
1339 Abc_Print( 1,
"%d*%d ", iObj, iFrame+Lift );
1341 Abc_Print( 1,
"\n" );
1360 for ( ; pThis < pLimit; pThis++ )
1365 if ( Entry < p->nObjs )
1367 pThis = Vta_ManObj(
p, Entry);
1391 Vec_IntFreeP( &
p->pGia->vObjClasses );
1394 Vec_IntFreeP( &
p->pGia->vGateClasses );
1396 Vec_IntFreeP( &
p->pGia->vObjClasses );
1399 Vec_IntFreeP( &
p->pGia->vGateClasses );
1426 char * pFileNameDef =
"vabs.aig";
1427 char * pFileName =
p->pPars->pFileVabs ?
p->pPars->pFileVabs : pFileNameDef;
1430 Abc_Print( 1,
"Dumping abstracted model into file \"%s\"...\n", pFileName );
1432 Vec_IntFreeP( &
p->pGia->vObjClasses );
1435 Vec_IntFreeP( &
p->pGia->vGateClasses );
1437 Vec_IntFreeP( &
p->pGia->vObjClasses );
1440 Vec_IntFreeP( &
p->pGia->vGateClasses );
1461 double memAig = Gia_ManObjNum(
p->pGia) *
sizeof(
Gia_Obj_t);
1464 double memMap =
p->nObjsAlloc *
sizeof(
Vta_Obj_t) +
p->nBins *
sizeof(
int);
1466 memOth += Vec_IntCap(
p->vOrder) *
sizeof(int);
1467 memOth += Vec_VecMemoryInt( (
Vec_Vec_t *)
p->vFrames );
1468 memOth += Vec_BitCap(
p->vSeenGla) *
sizeof(int);
1469 memOth += Vec_VecMemoryInt( (
Vec_Vec_t *)
p->vCores );
1470 memOth += Vec_IntCap(
p->vAddedNew) *
sizeof(int);
1471 memTot = memAig + memSat + memPro + memMap + memOth;
1472 ABC_PRMP(
"Memory: AIG ", memAig, memTot );
1473 ABC_PRMP(
"Memory: SAT ", memSat, memTot );
1474 ABC_PRMP(
"Memory: Proof ", memPro, memTot );
1475 ABC_PRMP(
"Memory: Map ", memMap, memTot );
1476 ABC_PRMP(
"Memory: Other ", memOth, memTot );
1477 ABC_PRMP(
"Memory: TOTAL ", memTot, memTot );
1497 int i, f, nConfls, Status, nObjOld, RetValue = -1, nCountNoChange = 0, fOneIsSent = 0;
1498 abctime clk = Abc_Clock(), clk2;
1500 assert( Gia_ManPoNum(pAig) == 1 );
1501 assert( pPars->nFramesMax == 0 || pPars->nFramesStart <= pPars->nFramesMax );
1502 if ( Gia_ObjIsConst0(Gia_ObjFanin0(Gia_ManPo(pAig,0))) )
1504 if ( !Gia_ObjFaninC0(Gia_ManPo(pAig,0)) )
1506 printf(
"Sequential miter is trivially UNSAT.\n" );
1511 printf(
"Sequential miter is trivially SAT.\n" );
1522 Vec_IntPush( pAig->
vObjClasses, Gia_ObjFaninId0p(pAig, Gia_ManPo(pAig, 0)) );
1527 if (
p->pPars->nTimeOut )
1528 sat_solver2_set_runtime_limit(
p->pSat,
p->pPars->nTimeOut * CLOCKS_PER_SEC + Abc_Clock() );
1530 if (
p->pPars->fVerbose )
1532 Abc_Print( 1,
"Running variable-timeframe abstraction (VTA) with the following parameters:\n" );
1533 Abc_Print( 1,
"FramePast = %d FrameMax = %d ConfMax = %d Timeout = %d RatioMin = %d %%\n",
1534 pPars->nFramesPast, pPars->nFramesMax, pPars->nConfLimit, pPars->nTimeOut, pPars->nRatioMin );
1535 Abc_Print( 1,
"LearnStart = %d LearnDelta = %d LearnRatio = %d %%.\n",
1536 pPars->nLearnedStart, pPars->nLearnedDelta, pPars->nLearnedPerce );
1538 Abc_Print( 1,
" Frame %% Abs %% Confl Cex Vars Clas Lrns Core Time Mem\n" );
1540 assert( Vec_PtrSize(
p->vFrames) > 0 );
1541 for ( f = i = 0; !
p->pPars->nFramesMax || f <
p->pPars->nFramesMax; f++ )
1543 int nConflsBeg = sat_solver2_nconflicts(
p->pSat);
1544 p->pPars->iFrame = f;
1546 if ( f ==
p->nWords * 32 )
1551 sat_solver2_bookmark(
p->pSat );
1552 Vec_IntClear(
p->vAddedNew );
1556 if ( f < Vec_PtrSize(
p->vFrames) )
1560 for ( i = 1; i <= Abc_MinInt(
p->pPars->nFramesPast, f); i++ )
1565 for ( i = 0; ; i++ )
1568 vCore =
Vta_ManUnsatCore( Vga_ManGetOutLit(
p, f),
p->pSat, pPars->nConfLimit, pPars->fVerbose, &Status, &nConfls );
1569 assert( (vCore != NULL) == (Status == 1) );
1576 if (
p->pSat->nRuntimeLimit && Abc_Clock() >
p->pSat->nRuntimeLimit )
1581 if ( vCore != NULL )
1583 p->timeUnsat += Abc_Clock() - clk2;
1586 p->timeSat += Abc_Clock() - clk2;
1592 p->timeCex += Abc_Clock() - clk2;
1596 Vta_ManAbsPrintFrame(
p, NULL, f+1, sat_solver2_nconflicts(
p->pSat)-nConflsBeg, i, Abc_Clock() - clk,
p->pPars->fVerbose );
1601 Vec_IntSort( vCore, 1 );
1608 Vec_IntFree( vCore );
1612 vCore =
Vta_ManUnsatCore( Vga_ManGetOutLit(
p, f),
p->pSat, pPars->nConfLimit,
p->pPars->fVerbose, &Status, &nConfls );
1613 p->timeUnsat += Abc_Clock() - clk2;
1614 assert( (vCore != NULL) == (Status == 1) );
1628 Vec_IntSort( vCore, 1 );
1629 Vec_PtrPush(
p->vCores, vCore );
1631 if (
Vta_ManAbsPrintFrame(
p, vCore, f+1, sat_solver2_nconflicts(
p->pSat)-nConflsBeg, i, Abc_Clock() - clk,
p->pPars->fVerbose ) )
1635 p->pPars->nFramesNoChange = 0;
1637 else if ( ++nCountNoChange == 2 )
1639 p->pPars->nFramesNoChange++;
1651 if (
p->pPars->fDumpVabs && (f & 1) )
1662 if (
p->nSeenGla >= Gia_ManCandNum(pAig) * (100-pPars->nRatioMin) / 100 )
1672 if (
p->pPars->fVerbose && Status == -1 )
1674 if ( Vec_PtrSize(
p->vCores) == 0 )
1675 Abc_Print( 1,
"Abstraction is not produced because first frame is not solved. " );
1678 assert( Vec_PtrSize(
p->vCores) > 0 );
1685 if (
p->pPars->nTimeOut && Abc_Clock() >=
p->pSat->nRuntimeLimit )
1686 Abc_Print( 1,
"Timeout %d sec in frame %d with a %d-stable abstraction. ",
p->pPars->nTimeOut, f,
p->pPars->nFramesNoChange );
1687 else if ( pPars->nConfLimit && sat_solver2_nconflicts(
p->pSat) >= pPars->nConfLimit )
1688 Abc_Print( 1,
"Exceeded %d conflicts in frame %d with a %d-stable abstraction. ", pPars->nConfLimit, f,
p->pPars->nFramesNoChange );
1689 else if (
p->nSeenGla >= Gia_ManCandNum(pAig) * (100-pPars->nRatioMin) / 100 )
1690 Abc_Print( 1,
"The ratio of abstracted objects is less than %d %% in frame %d. ", pPars->nRatioMin, f );
1692 Abc_Print( 1,
"Abstraction stopped for unknown reason in frame %d. ", f );
1697 Abc_Print( 1,
"VTA completed %d frames with a %d-stable abstraction. ", f,
p->pPars->nFramesNoChange );
1703 if (
p->pPars->fVerbose )
1706 p->pGia->pCexSeq = pCex;
1708 Abc_Print( 1,
" Gia_VtaPerform(): CEX verification has failed!\n" );
1709 Abc_Print( 1,
"Counter-example detected in frame %d. ", f );
1710 p->pPars->iFrame = pCex->iFrame - 1;
1714 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
1716 if (
p->pPars->fVerbose )
1718 p->timeOther = (Abc_Clock() - clk) -
p->timeUnsat -
p->timeSat -
p->timeCex;
1719 ABC_PRTP(
"Runtime: Solver UNSAT",
p->timeUnsat, Abc_Clock() - clk );
1720 ABC_PRTP(
"Runtime: Solver SAT ",
p->timeSat, Abc_Clock() - clk );
1721 ABC_PRTP(
"Runtime: Refinement ",
p->timeCex, Abc_Clock() - clk );
1722 ABC_PRTP(
"Runtime: Other ",
p->timeOther, Abc_Clock() - clk );
1723 ABC_PRTP(
"Runtime: TOTAL ", Abc_Clock() - clk, Abc_Clock() - clk );
1746 if ( pAig->
vObjClasses == NULL && pPars->fUseRollback )
1748 int nFramesMaxOld = pPars->nFramesMax;
1749 pPars->nFramesMax = pPars->nFramesStart;
1751 pPars->nFramesMax = nFramesMaxOld;
1753 if ( RetValue == 0 )
#define ABC_PRTP(a, t, T)
int Gia_ManToBridgeAbsNetlist(FILE *pFile, void *p, int pkg_type)
#define ABC_REALLOC(type, obj, num)
#define ABC_PRMP(a, f, F)
#define BRIDGE_ABS_NETLIST
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
ABC_DLL Abc_Frame_t * Abc_FrameGetGlobalFrame()
void Vta_ManProfileAddition(Vta_Man_t *p, Vec_Int_t *vTermsToAdd)
#define Vta_ManForEachObjVec(vVec, p, pObj, i)
void Gia_VtaSendAbsracted(Vta_Man_t *p, int fVerbose)
void Vta_ManUnsatCoreRemap(Vta_Man_t *p, Vec_Int_t *vCore)
Vec_Int_t * Gia_VtaFramesToAbs(Vec_Vec_t *vFrames)
#define Vta_ManForEachObj(p, pObj, i)
void Vga_ManPrintCore(Vta_Man_t *p, Vec_Int_t *vCore, int Lift)
Abc_Cex_t * Vta_ManRefineAbstraction(Vta_Man_t *p, int f)
int Vta_ManObjIsUsed(Vta_Man_t *p, int iObj)
void Gia_VtaPrintMemory(Vta_Man_t *p)
Vec_Int_t * Vta_ManCollectNodes(Vta_Man_t *p, int f)
void Gia_VtaDumpAbsracted(Vta_Man_t *p, int fVerbose)
struct Vta_Obj_t_ Vta_Obj_t
DECLARATIONS ///.
void Vta_ManSatVerify(Vta_Man_t *p)
int Vec_IntDoubleWidth(Vec_Int_t *p, int nWords)
#define Vta_ManForEachObjObj(p, pObjVta, pObjGia, i)
Vta_Man_t * Vga_ManStart(Gia_Man_t *pGia, Abs_Par_t *pPars)
void Gia_VtaSendCancel(Vta_Man_t *p, int fVerbose)
#define Vta_ManForEachObjObjVecReverse(vVec, p, pObj, pObjG, i)
void Vga_ManLoadSlice(Vta_Man_t *p, Vec_Int_t *vOne, int Lift)
void Vga_ManStop(Vta_Man_t *p)
int Vta_ManAbsPrintFrame(Vta_Man_t *p, Vec_Int_t *vCore, int nFrames, int nConfls, int nCexes, abctime Time, int fVerbose)
Vec_Int_t * Vta_ManUnsatCore(int iLit, sat_solver2 *pSat, int nConfMax, int fVerbose, int *piRetValue, int *pnConfls)
void Vga_ManAddClausesOne(Vta_Man_t *p, int iObj, int iFrame)
int Gia_VtaPerform(Gia_Man_t *pAig, Abs_Par_t *pPars)
#define Vta_ManForEachObjObjVec(vVec, p, pObj, pObjG, i)
int Vta_ManComputeDepthIncrease(Vta_Obj_t **pp1, Vta_Obj_t **pp2)
Vec_Ptr_t * Gia_VtaAbsToFrames(Vec_Int_t *vAbs)
FUNCTION DEFINITIONS ///.
int Gia_VtaPerformInt(Gia_Man_t *pAig, Abs_Par_t *pPars)
void Vta_ManCollectNodes_rec(Vta_Man_t *p, Vta_Obj_t *pThis, Vec_Int_t *vOrder)
Abc_Cex_t * Vga_ManDeriveCex(Vta_Man_t *p)
void Vga_ManRollBack(Vta_Man_t *p, int nObjOld)
struct Vta_Man_t_ Vta_Man_t
Gia_Man_t * Gia_ManDupAbsGates(Gia_Man_t *p, Vec_Int_t *vGateClasses)
Vec_Int_t * Gia_VtaConvertToGla(Gia_Man_t *p, Vec_Int_t *vVta)
typedefABC_NAMESPACE_HEADER_START struct Abs_Par_t_ Abs_Par_t
INCLUDES ///.
ABC_DLL void Abc_FrameSetNFrames(int nFrames)
ABC_DLL void Abc_FrameSetStatus(int Status)
ABC_DLL void Abc_FrameSetCex(Abc_Cex_t *pCex)
ABC_DLL int Abc_FrameIsBridgeMode()
ABC_DLL int Abc_FrameIsBatchMode()
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
ABC_DLL int Cmd_CommandExecute(Abc_Frame_t *pAbc, const char *sCommand)
void Gia_ManStop(Gia_Man_t *p)
struct Gia_Obj_t_ Gia_Obj_t
struct Gia_Man_t_ Gia_Man_t
int Gia_ManVerifyCex(Gia_Man_t *pAig, Abc_Cex_t *p, int fDualOut)
DECLARATIONS ///.
void Gia_AigerWrite(Gia_Man_t *p, char *pFileName, int fWriteSymbols, int fCompact, int fWriteNewLine)
double sat_solver2_memory_proof(sat_solver2 *s)
void sat_solver2_delete(sat_solver2 *s)
double sat_solver2_memory(sat_solver2 *s, int fAll)
int sat_solver2_simplify(sat_solver2 *s)
sat_solver2 * sat_solver2_new(void)
void sat_solver2_rollback(sat_solver2 *s)
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
int Gia_ManToBridgeBadAbs(FILE *pFile)
Abc_Cex_t * Abc_CexMakeTriv(int nRegs, int nTruePis, int nTruePos, int iFrameOut)
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 ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Bit_t_ Vec_Bit_t
INCLUDES ///.
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
#define Vec_IntForEachEntryStartStop(vVec, Entry, i, Start, Stop)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
#define Vec_VecForEachLevelInt(vGlob, vVec, i)
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.