Commit cd32ae50 by Alan Mishchenko

Counter-example analysis and optimization.

parent f1a52889
...@@ -28865,7 +28865,7 @@ usage: ...@@ -28865,7 +28865,7 @@ usage:
***********************************************************************/ ***********************************************************************/
int Abc_CommandAbc9CexInfo( Abc_Frame_t * pAbc, int argc, char ** argv ) int Abc_CommandAbc9CexInfo( Abc_Frame_t * pAbc, int argc, char ** argv )
{ {
extern void Bmc_CexTest( Gia_Man_t * p, Abc_Cex_t * pCex ); extern void Bmc_CexTest( Gia_Man_t * p, Abc_Cex_t * pCex, int fVerbose );
int c, fDualOut = 0, fVerbose = 0; int c, fDualOut = 0, fVerbose = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "dvh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "dvh" ) ) != EOF )
...@@ -28894,12 +28894,12 @@ int Abc_CommandAbc9CexInfo( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -28894,12 +28894,12 @@ int Abc_CommandAbc9CexInfo( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Abc_CommandAbc9CexInfo(): There is no CEX.\n" ); Abc_Print( -1, "Abc_CommandAbc9CexInfo(): There is no CEX.\n" );
return 1; return 1;
} }
Bmc_CexTest( pAbc->pGia, pAbc->pCex ); Bmc_CexTest( pAbc->pGia, pAbc->pCex, fVerbose );
return 0; return 0;
usage: usage:
Abc_Print( -2, "usage: &cexinfo [-vh]\n" ); Abc_Print( -2, "usage: &cexinfo [-vh]\n" );
Abc_Print( -2, "\t prints information about counter-examples\n" ); Abc_Print( -2, "\t prints information about the current counter-example\n" );
Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n"); Abc_Print( -2, "\t-h : print the command usage\n");
return 1; return 1;
...@@ -30192,8 +30192,8 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -30192,8 +30192,8 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv )
// extern int Gia_ManSuppSizeTest( Gia_Man_t * p ); // extern int Gia_ManSuppSizeTest( Gia_Man_t * p );
// extern void Gia_VtaTest( Gia_Man_t * p, int nFramesStart, int nFramesMax, int nConfMax, int nTimeMax, int fVerbose ); // extern void Gia_VtaTest( Gia_Man_t * p, int nFramesStart, int nFramesMax, int nConfMax, int nTimeMax, int fVerbose );
// extern void Gia_IsoTest( Gia_Man_t * p, int fVerbose ); // extern void Gia_IsoTest( Gia_Man_t * p, int fVerbose );
extern void Ga2_ManComputeTest( Gia_Man_t * p ); // extern void Ga2_ManComputeTest( Gia_Man_t * p );
extern void Bmc_CexTest( Gia_Man_t * p, Abc_Cex_t * pCex ); // extern void Bmc_CexTest( Gia_Man_t * p, Abc_Cex_t * pCex, int fVerbose );
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
...@@ -30239,7 +30239,7 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -30239,7 +30239,7 @@ int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv )
// Gia_VtaTest( pAbc->pGia, 10, 100000, 0, 0, 1 ); // Gia_VtaTest( pAbc->pGia, 10, 100000, 0, 0, 1 );
// Gia_IsoTest( pAbc->pGia, fVerbose ); // Gia_IsoTest( pAbc->pGia, fVerbose );
// Ga2_ManComputeTest( pAbc->pGia ); // Ga2_ManComputeTest( pAbc->pGia );
Bmc_CexTest( pAbc->pGia, pAbc->pCex ); // Bmc_CexTest( pAbc->pGia, pAbc->pCex, fVerbose );
return 0; return 0;
usage: usage:
Abc_Print( -2, "usage: &test [-svh]\n" ); Abc_Print( -2, "usage: &test [-svh]\n" );
......
...@@ -48,10 +48,11 @@ static inline int Bmc_CexSim( Vec_Wrd_t * vSims, int iObj, int i ) ...@@ -48,10 +48,11 @@ static inline int Bmc_CexSim( Vec_Wrd_t * vSims, int iObj, int i )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Bmc_CexPrint( Abc_Cex_t * pCex, int nInputs ) void Bmc_CexPrint( Abc_Cex_t * pCex, int nInputs, int fVerbose )
{ {
int i, k, Count, iBit = 0; int i, k, Count, iBit = 0;
Abc_CexPrintStatsInputs( pCex, nInputs ); Abc_CexPrintStatsInputs( pCex, nInputs );
if ( !fVerbose )
return; return;
for ( i = 0; i <= pCex->iFrame; i++ ) for ( i = 0; i <= pCex->iFrame; i++ )
...@@ -128,7 +129,7 @@ int Bmc_CexVerify( Gia_Man_t * p, Abc_Cex_t * pCex, Abc_Cex_t * pCexCare ) ...@@ -128,7 +129,7 @@ int Bmc_CexVerify( Gia_Man_t * p, Abc_Cex_t * pCex, Abc_Cex_t * pCexCare )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Abc_Cex_t * Bmc_CexInnerStates( Gia_Man_t * p, Abc_Cex_t * pCex, Abc_Cex_t ** ppCexImpl ) Abc_Cex_t * Bmc_CexInnerStates( Gia_Man_t * p, Abc_Cex_t * pCex, Abc_Cex_t ** ppCexImpl, int fVerbose )
{ {
Abc_Cex_t * pNew, * pNew2; Abc_Cex_t * pNew, * pNew2;
Gia_Obj_t * pObj, * pObjRo, * pObjRi; Gia_Obj_t * pObj, * pObjRo, * pObjRi;
...@@ -210,9 +211,9 @@ Abc_Cex_t * Bmc_CexInnerStates( Gia_Man_t * p, Abc_Cex_t * pCex, Abc_Cex_t ** pp ...@@ -210,9 +211,9 @@ Abc_Cex_t * Bmc_CexInnerStates( Gia_Man_t * p, Abc_Cex_t * pCex, Abc_Cex_t ** pp
assert( Gia_ManPo(p, pCex->iPo)->fMark0 == 1 ); assert( Gia_ManPo(p, pCex->iPo)->fMark0 == 1 );
printf( "Inner states: " ); printf( "Inner states: " );
Bmc_CexPrint( pNew, Gia_ManPiNum(p) ); Bmc_CexPrint( pNew, Gia_ManPiNum(p), fVerbose );
printf( "Implications: " ); printf( "Implications: " );
Bmc_CexPrint( pNew2, Gia_ManPiNum(p) ); Bmc_CexPrint( pNew2, Gia_ManPiNum(p), fVerbose );
if ( ppCexImpl ) if ( ppCexImpl )
*ppCexImpl = pNew2; *ppCexImpl = pNew2;
else else
...@@ -290,7 +291,7 @@ void Bmc_CexCareBits2_rec( Gia_Man_t * p, Gia_Obj_t * pObj ) ...@@ -290,7 +291,7 @@ void Bmc_CexCareBits2_rec( Gia_Man_t * p, Gia_Obj_t * pObj )
Bmc_CexCareBits2_rec( p, Gia_ObjFanin1(pObj) ); Bmc_CexCareBits2_rec( p, Gia_ObjFanin1(pObj) );
} }
} }
Abc_Cex_t * Bmc_CexCareBits( Gia_Man_t * p, Abc_Cex_t * pCexState, Abc_Cex_t * pCexImpl, Abc_Cex_t * pCexEss, int fFindAll ) Abc_Cex_t * Bmc_CexCareBits( Gia_Man_t * p, Abc_Cex_t * pCexState, Abc_Cex_t * pCexImpl, Abc_Cex_t * pCexEss, int fFindAll, int fVerbose )
{ {
Abc_Cex_t * pNew; Abc_Cex_t * pNew;
Gia_Obj_t * pObj; Gia_Obj_t * pObj;
...@@ -365,8 +366,11 @@ Abc_Cex_t * Bmc_CexCareBits( Gia_Man_t * p, Abc_Cex_t * pCexState, Abc_Cex_t * p ...@@ -365,8 +366,11 @@ Abc_Cex_t * Bmc_CexCareBits( Gia_Man_t * p, Abc_Cex_t * pCexState, Abc_Cex_t * p
Abc_InfoSetBit(pNew->pData, pNew->nPis * i + k); Abc_InfoSetBit(pNew->pData, pNew->nPis * i + k);
} }
} }
if ( pCexEss )
printf( "Minimized: " );
else
printf( "Care bits: " ); printf( "Care bits: " );
Bmc_CexPrint( pNew, Gia_ManPiNum(p) ); Bmc_CexPrint( pNew, Gia_ManPiNum(p), fVerbose );
return pNew; return pNew;
} }
...@@ -472,7 +476,7 @@ void Bmc_CexEssentialBitTest( Gia_Man_t * p, Abc_Cex_t * pCexState ) ...@@ -472,7 +476,7 @@ void Bmc_CexEssentialBitTest( Gia_Man_t * p, Abc_Cex_t * pCexState )
if ( b % 100 ) if ( b % 100 )
continue; continue;
pNew = Bmc_CexEssentialBitOne( p, pCexState, b, NULL, NULL ); pNew = Bmc_CexEssentialBitOne( p, pCexState, b, NULL, NULL );
Bmc_CexPrint( pNew, Gia_ManPiNum(p) ); Bmc_CexPrint( pNew, Gia_ManPiNum(p), 0 );
if ( Gia_ManPo(p, pCexState->iPo)->fMark1 ) if ( Gia_ManPo(p, pCexState->iPo)->fMark1 )
printf( "Not essential\n" ); printf( "Not essential\n" );
...@@ -494,7 +498,7 @@ void Bmc_CexEssentialBitTest( Gia_Man_t * p, Abc_Cex_t * pCexState ) ...@@ -494,7 +498,7 @@ void Bmc_CexEssentialBitTest( Gia_Man_t * p, Abc_Cex_t * pCexState )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Abc_Cex_t * Bmc_CexEssentialBits( Gia_Man_t * p, Abc_Cex_t * pCexState, Abc_Cex_t * pCexCare ) Abc_Cex_t * Bmc_CexEssentialBits( Gia_Man_t * p, Abc_Cex_t * pCexState, Abc_Cex_t * pCexCare, int fVerbose )
{ {
Abc_Cex_t * pNew, * pTemp, * pPrev = NULL; Abc_Cex_t * pNew, * pTemp, * pPrev = NULL;
int b, fEqual = 0, fPrevStatus = 0; int b, fEqual = 0, fPrevStatus = 0;
...@@ -527,7 +531,7 @@ Abc_Cex_t * Bmc_CexEssentialBits( Gia_Man_t * p, Abc_Cex_t * pCexState, Abc_Cex_ ...@@ -527,7 +531,7 @@ Abc_Cex_t * Bmc_CexEssentialBits( Gia_Man_t * p, Abc_Cex_t * pCexState, Abc_Cex_
Abc_InfoSetBit( pNew->pData, b ); Abc_InfoSetBit( pNew->pData, b );
continue; continue;
} }
// Bmc_CexPrint( pTemp, Gia_ManPiNum(p) ); // Bmc_CexPrint( pTemp, Gia_ManPiNum(p), fVerbose );
Abc_CexFree( pPrev ); Abc_CexFree( pPrev );
pPrev = pTemp; pPrev = pTemp;
...@@ -539,7 +543,7 @@ Abc_Cex_t * Bmc_CexEssentialBits( Gia_Man_t * p, Abc_Cex_t * pCexState, Abc_Cex_ ...@@ -539,7 +543,7 @@ Abc_Cex_t * Bmc_CexEssentialBits( Gia_Man_t * p, Abc_Cex_t * pCexState, Abc_Cex_
Abc_CexFreeP( &pPrev ); Abc_CexFreeP( &pPrev );
// Abc_PrintTime( 1, "Time", clock() - clk ); // Abc_PrintTime( 1, "Time", clock() - clk );
printf( "Essentials: " ); printf( "Essentials: " );
Bmc_CexPrint( pNew, Gia_ManPiNum(p) ); Bmc_CexPrint( pNew, Gia_ManPiNum(p), fVerbose );
return pNew; return pNew;
} }
...@@ -619,19 +623,19 @@ void Bmc_CexDumpStats( Gia_Man_t * p, Abc_Cex_t * pCex, Abc_Cex_t * pCexCare, Ab ...@@ -619,19 +623,19 @@ void Bmc_CexDumpStats( Gia_Man_t * p, Abc_Cex_t * pCex, Abc_Cex_t * pCexCare, Ab
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Bmc_CexTest( Gia_Man_t * p, Abc_Cex_t * pCex ) void Bmc_CexTest( Gia_Man_t * p, Abc_Cex_t * pCex, int fVerbose )
{ {
clock_t clk = clock(); clock_t clk = clock();
Abc_Cex_t * pCexImpl = NULL; Abc_Cex_t * pCexImpl = NULL;
Abc_Cex_t * pCexStates = Bmc_CexInnerStates( p, pCex, &pCexImpl ); Abc_Cex_t * pCexStates = Bmc_CexInnerStates( p, pCex, &pCexImpl, fVerbose );
Abc_Cex_t * pCexCare = Bmc_CexCareBits( p, pCexStates, pCexImpl, NULL, 1 ); Abc_Cex_t * pCexCare = Bmc_CexCareBits( p, pCexStates, pCexImpl, NULL, 1, fVerbose );
Abc_Cex_t * pCexEss, * pCexMin; Abc_Cex_t * pCexEss, * pCexMin;
if ( !Bmc_CexVerify( p, pCex, pCexCare ) ) if ( !Bmc_CexVerify( p, pCex, pCexCare ) )
printf( "Counter-example care-set verification has failed.\n" ); printf( "Counter-example care-set verification has failed.\n" );
pCexEss = Bmc_CexEssentialBits( p, pCexStates, pCexCare ); pCexEss = Bmc_CexEssentialBits( p, pCexStates, pCexCare, fVerbose );
pCexMin = Bmc_CexCareBits( p, pCexStates, pCexImpl, pCexEss, 0 ); pCexMin = Bmc_CexCareBits( p, pCexStates, pCexImpl, pCexEss, 0, fVerbose );
if ( !Bmc_CexVerify( p, pCex, pCexMin ) ) if ( !Bmc_CexVerify( p, pCex, pCexMin ) )
printf( "Counter-example min-set verification has failed.\n" ); printf( "Counter-example min-set verification has failed.\n" );
......
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