Commit 4e492ea0 by Alan Mishchenko

Merged in ysho/abc (pull request #68)

Improvements to %pdra
parents d81d9cc0 06a8d505
...@@ -45,6 +45,28 @@ struct Int_Pair_t_ ...@@ -45,6 +45,28 @@ struct Int_Pair_t_
int second; int second;
}; };
typedef struct Wla_Man_t_ Wla_Man_t;
struct Wla_Man_t_
{
Wlc_Ntk_t * p;
Wlc_Par_t * pPars;
Pdr_Par_t * pPdrPars;
Vec_Vec_t * vClauses;
Vec_Int_t * vBlacks;
Abc_Cex_t * pCex;
Gia_Man_t * pGia;
Vec_Bit_t * vUnmark;
int nIters;
int nTotalCla;
int nDisj;
int nNDisj;
abctime tPdr;
abctime tCbr;
abctime tPbr;
};
int IntPairPtrCompare ( Int_Pair_t ** a, Int_Pair_t ** b ) int IntPairPtrCompare ( Int_Pair_t ** a, Int_Pair_t ** b )
{ {
return (*a)->second < (*b)->second; return (*a)->second < (*b)->second;
...@@ -54,6 +76,62 @@ int IntPairPtrCompare ( Int_Pair_t ** a, Int_Pair_t ** b ) ...@@ -54,6 +76,62 @@ int IntPairPtrCompare ( Int_Pair_t ** a, Int_Pair_t ** b )
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
void Wlc_NtkPrintNtk( Wlc_Ntk_t * p )
{
int i;
Wlc_Obj_t * pObj;
Abc_Print( 1, "PIs:");
Wlc_NtkForEachPi( p, pObj, i )
Abc_Print( 1, " %s", Wlc_ObjName(p, Wlc_ObjId(p, pObj)) );
Abc_Print( 1, "\n\n");
Abc_Print( 1, "POs:");
Wlc_NtkForEachPo( p, pObj, i )
Abc_Print( 1, " %s", Wlc_ObjName(p, Wlc_ObjId(p, pObj)) );
Abc_Print( 1, "\n\n");
Abc_Print( 1, "FO(Fi)s:");
Wlc_NtkForEachCi( p, pObj, i )
if ( !Wlc_ObjIsPi( pObj ) )
Abc_Print( 1, " %s(%s)", Wlc_ObjName(p, Wlc_ObjId(p, pObj)), Wlc_ObjName(p, Wlc_ObjId(p, Wlc_ObjFo2Fi(p, pObj))) );
Abc_Print( 1, "\n\n");
Abc_Print( 1, "Objs:\n");
Wlc_NtkForEachObj( p, pObj, i )
{
if ( !Wlc_ObjIsCi(pObj) )
Wlc_NtkPrintNode( p, pObj ) ;
}
}
void Wlc_NtkAbsGetSupp_rec( Wlc_Ntk_t * p, Wlc_Obj_t * pObj, Vec_Bit_t * vCiMarks, Vec_Int_t * vSuppRefs, Vec_Int_t * vSuppList )
{
int i, iFanin, iObj;
if ( pObj->Mark ) // visited
return;
pObj->Mark = 1;
iObj = Wlc_ObjId( p, pObj );
if ( Vec_BitEntry( vCiMarks, iObj ) )
{
if ( vSuppRefs )
Vec_IntAddToEntry( vSuppRefs, iObj, 1 );
if ( vSuppList )
Vec_IntPush( vSuppList, iObj );
return;
}
Wlc_ObjForEachFanin( pObj, iFanin, i )
Wlc_NtkAbsGetSupp_rec( p, Wlc_NtkObj(p, iFanin), vCiMarks, vSuppRefs, vSuppList );
}
void Wlc_NtkAbsGetSupp( Wlc_Ntk_t * p, Wlc_Obj_t * pObj, Vec_Bit_t * vCiMarks, Vec_Int_t * vSuppRefs, Vec_Int_t * vSuppList)
{
assert( vSuppRefs || vSuppList );
Wlc_NtkCleanMarks( p );
Wlc_NtkAbsGetSupp_rec( p, pObj, vCiMarks, vSuppRefs, vSuppList );
}
int Wlc_NtkNumPiBits( Wlc_Ntk_t * pNtk ) int Wlc_NtkNumPiBits( Wlc_Ntk_t * pNtk )
{ {
int num = 0; int num = 0;
...@@ -65,6 +143,93 @@ int Wlc_NtkNumPiBits( Wlc_Ntk_t * pNtk ) ...@@ -65,6 +143,93 @@ int Wlc_NtkNumPiBits( Wlc_Ntk_t * pNtk )
return num; return num;
} }
void Wlc_NtkAbsAnalyzeRefine( Wlc_Ntk_t * p, Vec_Int_t * vBlacks, Vec_Bit_t * vUnmark, int * nDisj, int * nNDisj )
{
Vec_Bit_t * vCurCis, * vCandCis;
Vec_Int_t * vSuppList;
Vec_Int_t * vDeltaB;
Vec_Int_t * vSuppRefs;
int i, Entry;
Wlc_Obj_t * pObj;
vCurCis = Vec_BitStart( Wlc_NtkObjNumMax( p ) );
vCandCis = Vec_BitStart( Wlc_NtkObjNumMax( p ) );
vDeltaB = Vec_IntAlloc( Vec_IntSize(vBlacks) );
vSuppList = Vec_IntAlloc( Wlc_NtkCiNum(p) + Vec_IntSize(vBlacks) );
vSuppRefs = Vec_IntAlloc( Wlc_NtkObjNumMax( p ) );
Vec_IntFill( vSuppRefs, Wlc_NtkObjNumMax( p ), 0 );
Wlc_NtkForEachCi( p, pObj, i )
{
Vec_BitWriteEntry( vCurCis, Wlc_ObjId(p, pObj), 1 ) ;
Vec_BitWriteEntry( vCandCis, Wlc_ObjId(p, pObj), 1 ) ;
}
Vec_IntForEachEntry( vBlacks, Entry, i )
{
Vec_BitWriteEntry( vCurCis, Entry, 1 );
if ( !Vec_BitEntry( vUnmark, Entry ) )
Vec_BitWriteEntry( vCandCis, Entry, 1 );
else
Vec_IntPush( vDeltaB, Entry );
}
assert( Vec_IntSize( vDeltaB ) );
Wlc_NtkForEachCo( p, pObj, i )
Wlc_NtkAbsGetSupp( p, pObj, vCurCis, vSuppRefs, NULL );
/*
Abc_Print( 1, "SuppCurrentAbs =" );
Wlc_NtkForEachObj( p, pObj, i )
if ( Vec_IntEntry(vSuppRefs, i) > 0 )
Abc_Print( 1, " %d", i );
Abc_Print( 1, "\n" );
*/
Vec_IntForEachEntry( vDeltaB, Entry, i )
Wlc_NtkAbsGetSupp( p, Wlc_NtkObj(p, Entry), vCandCis, vSuppRefs, NULL );
Vec_IntForEachEntry( vDeltaB, Entry, i )
{
int iSupp, ii;
int fDisjoint = 1;
Vec_IntClear( vSuppList );
Wlc_NtkAbsGetSupp( p, Wlc_NtkObj(p, Entry), vCandCis, NULL, vSuppList );
//Abc_Print( 1, "SuppCandAbs =" );
Vec_IntForEachEntry( vSuppList, iSupp, ii )
{
//Abc_Print( 1, " %d(%d)", iSupp, Vec_IntEntry( vSuppRefs, iSupp ) );
if ( Vec_IntEntry( vSuppRefs, iSupp ) >= 2 )
{
fDisjoint = 0;
break;
}
}
//Abc_Print( 1, "\n" );
if ( fDisjoint )
{
//Abc_Print( 1, "PPI[%d] is disjoint.\n", Entry );
++(*nDisj);
}
else
{
//Abc_Print( 1, "PPI[%d] is non-disjoint.\n", Entry );
++(*nNDisj);
}
}
Vec_BitFree( vCurCis );
Vec_BitFree( vCandCis );
Vec_IntFree( vDeltaB );
Vec_IntFree( vSuppList );
Vec_IntFree( vSuppRefs );
}
static Vec_Int_t * Wlc_NtkGetCoreSels( Gia_Man_t * pFrames, int nFrames, int num_sel_pis, int num_other_pis, Vec_Bit_t * vMark, int sel_pi_first, int nConfLimit, Wlc_Par_t * pPars ) static Vec_Int_t * Wlc_NtkGetCoreSels( Gia_Man_t * pFrames, int nFrames, int num_sel_pis, int num_other_pis, Vec_Bit_t * vMark, int sel_pi_first, int nConfLimit, Wlc_Par_t * pPars )
{ {
Vec_Int_t * vCores = NULL; Vec_Int_t * vCores = NULL;
...@@ -1035,272 +1200,276 @@ Vec_Int_t * Wlc_NtkFlopsRemap( Wlc_Ntk_t * p, Vec_Int_t * vFfOld, Vec_Int_t * vF ...@@ -1035,272 +1200,276 @@ Vec_Int_t * Wlc_NtkFlopsRemap( Wlc_Ntk_t * p, Vec_Int_t * vFfOld, Vec_Int_t * vF
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Wlc_NtkPdrAbs( Wlc_Ntk_t * p, Wlc_Par_t * pPars )
Wlc_Ntk_t * Wla_ManCreateAbs( Wla_Man_t * pWla )
{ {
abctime clk = Abc_Clock(); Wlc_Ntk_t * pAbs;
abctime clk2;
abctime tPdr = 0, tCbr = 0, tPbr = 0, tTotal = 0;
Pdr_Man_t * pPdr;
Vec_Vec_t * vClauses = NULL;
Vec_Int_t * vFfOld = NULL, * vFfNew = NULL, * vMap = NULL;
Vec_Int_t * vBlacks = NULL;
int nIters, nNodes, nDcFlops, RetValue = -1, nGiaFfNumOld = -1;
int nTotalCla = 0;
// start the bitmap to mark objects that cannot be abstracted because of refinement
// currently, this bitmap is empty because abstraction begins without refinement
Vec_Bit_t * vUnmark = Vec_BitStart( Wlc_NtkObjNumMax(p) );
// set up parameters to run PDR
Pdr_Par_t PdrPars, * pPdrPars = &PdrPars;
Pdr_ManSetDefaultParams( pPdrPars );
pPdrPars->fVerbose = pPars->fPdrVerbose;
pPdrPars->fVeryVerbose = 0;
if ( pPars->fPdra )
{
pPdrPars->fUseAbs = 1; // use 'pdr -t' (on-the-fly abstraction)
pPdrPars->fCtgs = 1; // use 'pdr -nc' (improved generalization)
pPdrPars->fSkipDown = 0; // use 'pdr -nc' (improved generalization)
pPdrPars->nRestLimit = 500; // reset queue or proof-obligations when it gets larger than this
}
// perform refinement iterations // get abstracted GIA and the set of pseudo-PIs (vBlacks)
for ( nIters = 1; nIters < pPars->nIterMax; nIters++ ) if ( pWla->vBlacks == NULL )
pWla->vBlacks = Wlc_NtkGetBlacks( pWla->p, pWla->pPars );
else
Wlc_NtkUpdateBlacks( pWla->p, pWla->pPars, &pWla->vBlacks, pWla->vUnmark );
pAbs = Wlc_NtkAbs2( pWla->p, pWla->vBlacks, NULL );
return pAbs;
}
Aig_Man_t * Wla_ManBitBlast( Wla_Man_t * pWla, Wlc_Ntk_t * pAbs )
{
int nDcFlops;
Gia_Man_t * pTemp;
Aig_Man_t * pAig;
pWla->pGia = Wlc_NtkBitBlast( pAbs, NULL, -1, 0, 0, 0, 0, 0 );
// if the abstraction has flops with DC-init state,
// new PIs were introduced by bit-blasting at the end of the PI list
// here we move these variables to be *before* PPIs, because
// PPIs are supposed to be at the end of the PI list for refinement
nDcFlops = Wlc_NtkDcFlopNum(pAbs);
if ( nDcFlops > 0 ) // DC-init flops are present
{ {
Aig_Man_t * pAig; pWla->pGia = Gia_ManPermuteInputs( pTemp = pWla->pGia, Wlc_NtkCountObjBits(pWla->p, pWla->vBlacks), nDcFlops );
Abc_Cex_t * pCex; Gia_ManStop( pTemp );
Vec_Int_t * vPisNew = NULL; }
Vec_Int_t * vRefine; // if the word-level outputs have to be XORs, this is a place to do it
Gia_Man_t * pGia, * pTemp; if ( pWla->pPars->fXorOutput )
Wlc_Ntk_t * pAbs; {
pWla->pGia = Gia_ManTransformMiter2( pTemp = pWla->pGia );
Gia_ManStop( pTemp );
}
if ( pWla->pPars->fVerbose )
{
printf( "Derived abstraction with %d objects and %d PPIs. Bit-blasted AIG stats are:\n", Wlc_NtkObjNum(pAbs), Vec_IntSize(pWla->vBlacks) );
Gia_ManPrintStats( pWla->pGia, NULL );
}
if ( pPars->fVerbose ) // try to prove abstracted GIA by converting it to AIG and calling PDR
printf( "\nIteration %d:\n", nIters ); pAig = Gia_ManToAigSimple( pWla->pGia );
// get abstracted GIA and the set of pseudo-PIs (vPisNew) return pAig;
if ( pPars->fAbs2 || pPars->fProofRefine ) }
{
if ( vBlacks == NULL )
vBlacks = Wlc_NtkGetBlacks( p, pPars );
else
Wlc_NtkUpdateBlacks( p, pPars, &vBlacks, vUnmark );
pAbs = Wlc_NtkAbs2( p, vBlacks, &vFfNew );
vPisNew = Vec_IntDup( vBlacks );
}
else
{
if ( nIters == 1 && pPars->nLimit < ABC_INFINITY )
Wlc_NtkSetUnmark( p, pPars, vUnmark );
pAbs = Wlc_NtkAbs( p, pPars, vUnmark, &vPisNew, &vFfNew, pPars->fVerbose ); int Wla_ManSolve( Wla_Man_t * pWla, Aig_Man_t * pAig )
} {
pGia = Wlc_NtkBitBlast( pAbs, NULL, -1, 0, 0, 0, 0, 0 ); abctime clk;
Pdr_Man_t * pPdr;
int RetValue = -1;
// map old flops into new flops if ( pWla->vClauses && pWla->pPars->fCheckCombUnsat )
if ( vFfOld ) {
{ if ( Aig_ManAndNum( pAig ) <= 20000 )
assert( nGiaFfNumOld >= 0 ); {
vMap = Wlc_NtkFlopsRemap( p, vFfOld, vFfNew ); Aig_Man_t * pAigScorr;
//Vec_IntPrint( vMap ); Ssw_Pars_t ScorrPars, * pScorrPars = &ScorrPars;
// if reset flop was added in the previous iteration, it will be added again in this iteration int nAnds;
// remap the last flop (reset flop) into the last flop (reset flop) of the current AIG
if ( Vec_IntSize(vMap) + 1 == nGiaFfNumOld ) clk = Abc_Clock();
Vec_IntPush( vMap, Gia_ManRegNum(pGia)-1 );
assert( Vec_IntSize(vMap) == nGiaFfNumOld ); Ssw_ManSetDefaultParams( pScorrPars );
Vec_IntFreeP( &vFfOld ); pScorrPars->fStopWhenGone = 1;
pScorrPars->nFramesK = 1;
pAigScorr = Ssw_SignalCorrespondence( pAig, pScorrPars );
assert ( pAigScorr );
nAnds = Aig_ManAndNum( pAigScorr);
Aig_ManStop( pAigScorr );
if ( nAnds == 0 )
{
if ( pWla->pPars->fVerbose )
Abc_PrintTime( 1, "SCORR proved UNSAT. Time", Abc_Clock() - clk );
return 1;
}
else if ( pWla->pPars->fVerbose )
{
Abc_Print( 1, "SCORR failed with %d ANDs. ", nAnds);
Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
}
} }
ABC_SWAP( Vec_Int_t *, vFfOld, vFfNew );
nGiaFfNumOld = Gia_ManRegNum(pGia);
// if the abstraction has flops with DC-init state, clk = Abc_Clock();
// new PIs were introduced by bit-blasting at the end of the PI list
// here we move these variables to be *before* PPIs, because pWla->pPdrPars->fVerbose = 0;
// PPIs are supposed to be at the end of the PI list for refinement pPdr = Pdr_ManStart( pAig, pWla->pPdrPars, NULL );
nDcFlops = Wlc_NtkDcFlopNum(pAbs); RetValue = IPdr_ManCheckCombUnsat( pPdr );
if ( nDcFlops > 0 ) // DC-init flops are present Pdr_ManStop( pPdr );
{ pWla->pPdrPars->fVerbose = pWla->pPars->fPdrVerbose;
pGia = Gia_ManPermuteInputs( pTemp = pGia, Wlc_NtkCountObjBits(p, vPisNew), nDcFlops );
Gia_ManStop( pTemp ); pWla->tPdr += Abc_Clock() - clk;
}
// if the word-level outputs have to be XORs, this is a place to do it if ( RetValue == 1 )
if ( pPars->fXorOutput )
{
pGia = Gia_ManTransformMiter2( pTemp = pGia );
Gia_ManStop( pTemp );
}
if ( pPars->fVerbose )
{ {
printf( "Derived abstraction with %d objects and %d PPIs. Bit-blasted AIG stats are:\n", Wlc_NtkObjNum(pAbs), Vec_IntSize(vPisNew) ); if ( pWla->pPars->fVerbose )
Gia_ManPrintStats( pGia, NULL ); Abc_PrintTime( 1, "ABS becomes combinationally UNSAT. Time", Abc_Clock() - clk );
return 1;
} }
Wlc_NtkFree( pAbs );
// Gia_AigerWrite( pGia, "abs.aig", 0, 0 );
// try to prove abstracted GIA by converting it to AIG and calling PDR if ( pWla->pPars->fVerbose )
pAig = Gia_ManToAigSimple( pGia ); Abc_PrintTime( 1, "Check comb. unsat failed. Time", Abc_Clock() - clk );
}
clk = Abc_Clock();
pPdr = Pdr_ManStart( pAig, pWla->pPdrPars, NULL );
if ( pWla->vClauses ) {
assert( Vec_VecSize( pWla->vClauses) >= 2 );
IPdr_ManRestore( pPdr, pWla->vClauses, NULL );
}
if ( vClauses && pPars->fCheckCombUnsat ) RetValue = IPdr_ManSolveInt( pPdr, pWla->pPars->fCheckClauses, pWla->pPars->fPushClauses );
{ pPdr->tTotal += Abc_Clock() - clk;
Pdr_Man_t * pPdr2; pWla->tPdr += pPdr->tTotal;
pWla->vClauses = IPdr_ManSaveClauses( pPdr, 0 );
if ( Aig_ManAndNum( pAig ) <= 20000 ) Pdr_ManStop( pPdr );
{
Aig_Man_t * pAigScorr;
Ssw_Pars_t ScorrPars, * pScorrPars = &ScorrPars;
int nAnds;
clk2 = Abc_Clock();
Ssw_ManSetDefaultParams( pScorrPars );
pScorrPars->fStopWhenGone = 1;
pScorrPars->nFramesK = 1;
pAigScorr = Ssw_SignalCorrespondence( pAig, pScorrPars );
assert ( pAigScorr );
nAnds = Aig_ManAndNum( pAigScorr);
Aig_ManStop( pAigScorr );
if ( nAnds == 0 )
{
if ( pPars->fVerbose )
Abc_PrintTime( 1, "SCORR proved UNSAT. Time", Abc_Clock() - clk2 );
RetValue = 1;
Gia_ManStop( pGia );
Vec_IntFree( vPisNew );
Aig_ManStop( pAig );
break;
}
else if ( pPars->fVerbose )
{
Abc_Print( 1, "SCORR failed with %d ANDs. ", nAnds);
Abc_PrintTime( 1, "Time", Abc_Clock() - clk2 );
}
}
clk2 = Abc_Clock(); pWla->pCex = pAig->pSeqModel;
pAig->pSeqModel = NULL;
pPdrPars->fVerbose = 0; // consider outcomes
pPdr2 = Pdr_ManStart( pAig, pPdrPars, NULL ); if ( pWla->pCex == NULL )
RetValue = IPdr_ManCheckCombUnsat( pPdr2 ); {
Pdr_ManStop( pPdr2 ); assert( RetValue ); // proved or undecided
pPdrPars->fVerbose = pPars->fPdrVerbose; return RetValue;
}
tPdr += Abc_Clock() - clk2; // verify CEX
if ( Wlc_NtkCexIsReal( pWla->p, pWla->pCex ) )
return 0;
if ( RetValue == 1 ) return -1;
{ }
if ( pPars->fVerbose )
Abc_PrintTime( 1, "ABS becomes combinationally UNSAT. Time", Abc_Clock() - clk2 );
Gia_ManStop( pGia );
Vec_IntFree( vPisNew );
Aig_ManStop( pAig );
break;
}
if ( pPars->fVerbose )
Abc_PrintTime( 1, "Check comb. unsat failed. Time", Abc_Clock() - clk2 );
}
clk2 = Abc_Clock(); void Wla_ManRefine( Wla_Man_t * pWla )
pPdr = Pdr_ManStart( pAig, pPdrPars, NULL ); {
if ( vClauses ) { abctime clk;
assert( Vec_VecSize( vClauses) >= 2 ); int nNodes;
IPdr_ManRestore( pPdr, vClauses, vMap ); Vec_Int_t * vRefine = NULL;
} // perform refinement
Vec_IntFreeP( &vMap ); if ( pWla->pPars->fHybrid || !pWla->pPars->fProofRefine )
{
clk = Abc_Clock();
vRefine = Wlc_NtkAbsRefinement( pWla->p, pWla->pGia, pWla->pCex, pWla->vBlacks );
pWla->tCbr += Abc_Clock() - clk;
}
else // proof-based only
{
vRefine = Vec_IntDup( pWla->vBlacks );
}
if ( pWla->pPars->fProofRefine )
{
clk = Abc_Clock();
Wlc_NtkProofRefine( pWla->p, pWla->pPars, pWla->pCex, pWla->vBlacks, &vRefine );
pWla->tPbr += Abc_Clock() - clk;
}
if ( !vClauses || RetValue != 1 ) if ( pWla->vClauses && pWla->pPars->fVerbose )
RetValue = IPdr_ManSolveInt( pPdr, pPars->fCheckClauses, pPars->fPushClauses ); {
pPdr->tTotal += Abc_Clock() - clk2; int i;
tPdr += pPdr->tTotal; Vec_Ptr_t * vVec;
Vec_VecForEachLevel( pWla->vClauses, vVec, i )
pWla->nTotalCla += Vec_PtrSize( vVec );
}
pCex = pAig->pSeqModel; pAig->pSeqModel = NULL; // update the set of objects to be un-abstracted
clk = Abc_Clock();
if ( pWla->pPars->fMFFC )
{
nNodes = Wlc_NtkRemoveFromAbstraction( pWla->p, vRefine, pWla->vUnmark );
if ( pWla->pPars->fVerbose )
printf( "Refinement of CEX in frame %d came up with %d un-abstacted PPIs, whose MFFCs include %d objects.\n", pWla->pCex->iFrame, Vec_IntSize(vRefine), nNodes );
}
else
{
nNodes = Wlc_NtkUnmarkRefinement( pWla->p, vRefine, pWla->vUnmark );
if ( pWla->pPars->fVerbose )
printf( "Refinement of CEX in frame %d came up with %d un-abstacted PPIs.\n", pWla->pCex->iFrame, Vec_IntSize(vRefine) );
// consider outcomes }
if ( pCex == NULL ) /*
{ if ( pWla->pPars->fVerbose )
assert( RetValue ); // proved or undecided {
Gia_ManStop( pGia ); Wlc_NtkAbsAnalyzeRefine( pWla->p, pWla->vBlacks, pWla->vUnmark, &pWla->nDisj, &pWla->nNDisj );
Vec_IntFree( vPisNew ); Abc_Print( 1, "Refine analysis (total): %d disjoint PPIs and %d non-disjoint PPIs\n", pWla->nDisj, pWla->nNDisj );
Pdr_ManStop( pPdr ); }
Aig_ManStop( pAig ); */
break; pWla->tCbr += Abc_Clock() - clk;
}
// verify CEX Vec_IntFree( vRefine );
if ( Wlc_NtkCexIsReal( p, pCex ) ) Gia_ManStop( pWla->pGia ); pWla->pGia = NULL;
{ Abc_CexFree( pWla->pCex ); pWla->pCex = NULL;
vRefine = NULL; }
Abc_CexFree( pCex ); // return CEX in the future
Pdr_ManStop( pPdr );
Aig_ManStop( pAig );
break;
}
// perform refinement Wla_Man_t * Wla_ManStart( Wlc_Ntk_t * pNtk, Wlc_Par_t * pPars )
if ( pPars->fHybrid || !pPars->fProofRefine ) {
{ Wla_Man_t * p = ABC_CALLOC( Wla_Man_t, 1 );
clk2 = Abc_Clock(); Pdr_Par_t * pPdrPars;
vRefine = Wlc_NtkAbsRefinement( p, pGia, pCex, vPisNew ); p->p = pNtk;
tCbr += Abc_Clock() - clk2; p->pPars = pPars;
} p->vUnmark = Vec_BitStart( Wlc_NtkObjNumMax(pNtk) );
else // proof-based only
{
vRefine = Vec_IntDup( vPisNew );
}
if ( pPars->fProofRefine )
{
clk2 = Abc_Clock();
Wlc_NtkProofRefine( p, pPars, pCex, vPisNew, &vRefine );
tPbr += Abc_Clock() - clk2;
}
Gia_ManStop( pGia );
Vec_IntFree( vPisNew );
if ( vRefine == NULL ) // real CEX
{
Abc_CexFree( pCex ); // return CEX in the future
Pdr_ManStop( pPdr );
Aig_ManStop( pAig );
break;
}
// spurious CEX, continue solving pPdrPars = ABC_CALLOC( Pdr_Par_t, 1 );
vClauses = IPdr_ManSaveClauses( pPdr, 0 ); Pdr_ManSetDefaultParams( pPdrPars );
if ( vClauses && pPars->fVerbose ) pPdrPars->fVerbose = pPars->fPdrVerbose;
{ pPdrPars->fVeryVerbose = 0;
int i; if ( pPars->fPdra )
Vec_Ptr_t * vVec; {
Vec_VecForEachLevel( vClauses, vVec, i ) pPdrPars->fUseAbs = 1; // use 'pdr -t' (on-the-fly abstraction)
nTotalCla += Vec_PtrSize( vVec ); pPdrPars->fCtgs = 1; // use 'pdr -nc' (improved generalization)
} pPdrPars->fSkipDown = 0; // use 'pdr -nc' (improved generalization)
pPdrPars->nRestLimit = 500; // reset queue or proof-obligations when it gets larger than this
}
p->pPdrPars = pPdrPars;
Pdr_ManStop( pPdr ); p->nIters = 1;
p->nTotalCla = 0;
p->nDisj = 0;
p->nNDisj = 0;
// update the set of objects to be un-abstracted return p;
clk2 = Abc_Clock(); }
if ( pPars->fMFFC )
{
nNodes = Wlc_NtkRemoveFromAbstraction( p, vRefine, vUnmark );
if ( pPars->fVerbose )
printf( "Refinement of CEX in frame %d came up with %d un-abstacted PPIs, whose MFFCs include %d objects.\n", pCex->iFrame, Vec_IntSize(vRefine), nNodes );
}
else
{
nNodes = Wlc_NtkUnmarkRefinement( p, vRefine, vUnmark );
if ( pPars->fVerbose )
printf( "Refinement of CEX in frame %d came up with %d un-abstacted PPIs.\n", pCex->iFrame, Vec_IntSize(vRefine) );
} void Wla_ManStop( Wla_Man_t * p )
tCbr += Abc_Clock() - clk2; {
if ( p->vBlacks ) Vec_IntFree( p->vBlacks );
if ( p->pGia ) Gia_ManStop( p->pGia );
if ( p->pCex ) Abc_CexFree( p->pCex );
Vec_BitFree( p->vUnmark );
ABC_FREE( p->pPdrPars );
ABC_FREE( p );
}
Vec_IntFree( vRefine ); int Wlc_NtkPdrAbs( Wlc_Ntk_t * p, Wlc_Par_t * pPars )
Abc_CexFree( pCex ); {
abctime clk = Abc_Clock();
abctime tTotal;
Wla_Man_t * pWla = NULL;
Wlc_Ntk_t * pAbs = NULL;
Aig_Man_t * pAig = NULL;
int RetValue = -1;
pWla = Wla_ManStart( p, pPars );
// perform refinement iterations
for ( pWla->nIters = 1; pWla->nIters < pPars->nIterMax; ++pWla->nIters )
{
if ( pPars->fVerbose )
printf( "\nIteration %d:\n", pWla->nIters );
pAbs = Wla_ManCreateAbs( pWla );
pAig = Wla_ManBitBlast( pWla, pAbs );
Wlc_NtkFree( pAbs );
RetValue = Wla_ManSolve( pWla, pAig );
Aig_ManStop( pAig ); Aig_ManStop( pAig );
if ( RetValue != -1 )
break;
Wla_ManRefine( pWla );
} }
if ( vBlacks )
Vec_IntFree( vBlacks );
Vec_IntFreeP( &vFfOld );
Vec_BitFree( vUnmark );
// report the result // report the result
if ( pPars->fVerbose ) if ( pPars->fVerbose )
printf( "\n" ); printf( "\n" );
...@@ -1311,20 +1480,22 @@ int Wlc_NtkPdrAbs( Wlc_Ntk_t * p, Wlc_Par_t * pPars ) ...@@ -1311,20 +1480,22 @@ int Wlc_NtkPdrAbs( Wlc_Ntk_t * p, Wlc_Par_t * pPars )
printf( "is successfully proved" ); printf( "is successfully proved" );
else else
printf( "timed out" ); printf( "timed out" );
printf( " after %d iterations. ", nIters ); printf( " after %d iterations. ", pWla->nIters );
tTotal = Abc_Clock() - clk; tTotal = Abc_Clock() - clk;
Abc_PrintTime( 1, "Time", tTotal ); Abc_PrintTime( 1, "Time", tTotal );
if ( pPars->fVerbose ) if ( pPars->fVerbose )
Abc_Print( 1, "PDRA reused %d clauses.\n", nTotalCla ); Abc_Print( 1, "PDRA reused %d clauses.\n", pWla->nTotalCla );
if ( pPars->fVerbose ) if ( pPars->fVerbose )
{ {
ABC_PRTP( "PDR ", tPdr, tTotal ); ABC_PRTP( "PDR ", pWla->tPdr, tTotal );
ABC_PRTP( "CEX Refine ", tCbr, tTotal ); ABC_PRTP( "CEX Refine ", pWla->tCbr, tTotal );
ABC_PRTP( "Proof Refine ", tPbr, tTotal ); ABC_PRTP( "Proof Refine ", pWla->tPbr, tTotal );
ABC_PRTP( "Misc. ", tTotal - tPdr - tCbr - tPbr, tTotal ); ABC_PRTP( "Misc. ", tTotal - pWla->tPdr - pWla->tCbr - pWla->tPbr, tTotal );
ABC_PRTP( "Total ", tTotal, tTotal ); ABC_PRTP( "Total ", tTotal, tTotal );
} }
Wla_ManStop( pWla );
return RetValue; return RetValue;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment