diff options
Diffstat (limited to 'src/aig')
-rw-r--r-- | src/aig/cec/cecSeq.c | 7 | ||||
-rw-r--r-- | src/aig/saig/saig.h | 2 | ||||
-rw-r--r-- | src/aig/saig/saigInd.c | 43 |
3 files changed, 45 insertions, 7 deletions
diff --git a/src/aig/cec/cecSeq.c b/src/aig/cec/cecSeq.c index e9f3df37..7e7549c0 100644 --- a/src/aig/cec/cecSeq.c +++ b/src/aig/cec/cecSeq.c @@ -49,21 +49,20 @@ void Cec_ManSeqDeriveInfoFromCex( Vec_Ptr_t * vInfo, Gia_Man_t * pAig, Abc_Cex_t assert( pCex->nBits == pCex->nRegs + pCex->nPis * (pCex->iFrame + 1) ); assert( pCex->nBits - pCex->nRegs + Gia_ManRegNum(pAig) <= Vec_PtrSize(vInfo) ); nWords = Vec_PtrReadWordsSimInfo( vInfo ); -/* for ( k = 0; k < pCex->nRegs; k++ ) { - pInfo = Vec_PtrEntry( vInfo, k ); + pInfo = (unsigned *)Vec_PtrEntry( vInfo, k ); for ( w = 0; w < nWords; w++ ) pInfo[w] = Gia_InfoHasBit( pCex->pData, k )? ~0 : 0; } -*/ +/* for ( k = 0; k < Gia_ManRegNum(pAig); k++ ) { pInfo = (unsigned *)Vec_PtrEntry( vInfo, k ); for ( w = 0; w < nWords; w++ ) pInfo[w] = 0; } - +*/ for ( i = pCex->nRegs; i < pCex->nBits; i++ ) { pInfo = (unsigned *)Vec_PtrEntry( vInfo, k++ ); diff --git a/src/aig/saig/saig.h b/src/aig/saig/saig.h index dd6064ad..9766768d 100644 --- a/src/aig/saig/saig.h +++ b/src/aig/saig/saig.h @@ -163,7 +163,7 @@ extern int Saig_ManFindFailedPoCex( Aig_Man_t * pAig, Abc_Cex_t * /*=== saigHaig.c ==========================================================*/ extern Aig_Man_t * Saig_ManHaigRecord( Aig_Man_t * p, int nIters, int nSteps, int fRetimingOnly, int fAddBugs, int fUseCnf, int fVerbose ); /*=== saigInd.c ==========================================================*/ -extern int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fUnique, int fUniqueAll, int fVerbose, int fVeryVerbose ); +extern int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fUnique, int fUniqueAll, int fGetCex, int fVerbose, int fVeryVerbose ); /*=== saigIoa.c ==========================================================*/ extern void Saig_ManDumpBlif( Aig_Man_t * p, char * pFileName ); extern Aig_Man_t * Saig_ManReadBlif( char * pFileName ); diff --git a/src/aig/saig/saigInd.c b/src/aig/saig/saigInd.c index 6bb29488..190d8d25 100644 --- a/src/aig/saig/saigInd.c +++ b/src/aig/saig/saigInd.c @@ -142,12 +142,12 @@ void Saig_ManAddUniqueness( sat_solver * pSat, Vec_Int_t * vState, int nRegs, in SeeAlso [] ***********************************************************************/ -int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fUnique, int fUniqueAll, int fVerbose, int fVeryVerbose ) +int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fUnique, int fUniqueAll, int fGetCex, int fVerbose, int fVeryVerbose ) { sat_solver * pSat; Aig_Man_t * pAigPart; Cnf_Dat_t * pCnfPart; - Vec_Int_t * vTopVarNums, * vState; + Vec_Int_t * vTopVarNums, * vState, * vTopVarIds = NULL; Vec_Ptr_t * vTop, * vBot; Aig_Obj_t * pObjPi, * pObjPiCopy, * pObjPo; int i, k, f, clk, Lits[2], status, RetValue, nSatVarNum, nConfPrev; @@ -190,6 +190,24 @@ int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fUnique, nSatVarNum += pCnfPart->nVars; nClauses += pCnfPart->nClauses; + // remember top frame var IDs + if ( fGetCex && vTopVarIds == NULL ) + { + vTopVarIds = Vec_IntStartFull( Aig_ManPiNum(p) ); + Aig_ManForEachPi( p, pObjPi, i ) + { + if ( pObjPi->pData == NULL ) + continue; + pObjPiCopy = (Aig_Obj_t *)pObjPi->pData; + assert( Aig_ObjIsPi(pObjPiCopy) ); + if ( Saig_ObjIsPi(p, pObjPi) ) + Vec_IntWriteEntry( vTopVarIds, Aig_ObjPioNum(pObjPi) + Saig_ManRegNum(p), pCnfPart->pVarNums[Aig_ObjId(pObjPiCopy)] ); + else if ( Saig_ObjIsLo(p, pObjPi) ) + Vec_IntWriteEntry( vTopVarIds, Aig_ObjPioNum(pObjPi) - Saig_ManPiNum(p), pCnfPart->pVarNums[Aig_ObjId(pObjPiCopy)] ); + else assert( 0 ); + } + } + // stitch variables of top and bot assert( Aig_ManPoNum(pAigPart)-1 == Vec_IntSize(vTopVarNums) ); Aig_ManForEachPo( pAigPart, pObjPo, i ) @@ -294,7 +312,27 @@ nextrun: printf( "\n" ); } if ( f == nFramesMax - 1 ) + { + // derive counter-example + assert( status == l_True ); + if ( fGetCex ) + { + int VarNum, iBit = 0; + Abc_Cex_t * pCex = Abc_CexAlloc( Aig_ManRegNum(p)-1, Saig_ManPiNum(p), 1 ); + pCex->iFrame = 0; + pCex->iPo = 0; + Vec_IntForEachEntryStart( vTopVarIds, VarNum, i, 1 ) + { + if ( VarNum >= 0 && sat_solver_var_value( pSat, VarNum ) ) + Aig_InfoSetBit( pCex->pData, iBit ); + iBit++; + } + assert( iBit == pCex->nBits ); + Abc_CexFree( p->pSeqModel ); + p->pSeqModel = pCex; + } break; + } if ( fUnique ) { for ( i = 1; i < iLast; i++ ) @@ -333,6 +371,7 @@ nextrun: Vec_PtrFree( vTop ); Vec_PtrFree( vBot ); Vec_IntFree( vState ); + Vec_IntFreeP( &vTopVarIds ); return RetValue; } |