Commit 6c3363f7 by Alan Mishchenko

Adding restart to rarity simulation in sim3 and &sim3.

parent e80bd69e
...@@ -16630,21 +16630,23 @@ int Abc_CommandSim3( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -16630,21 +16630,23 @@ int Abc_CommandSim3( Abc_Frame_t * pAbc, int argc, char ** argv )
int nWords; int nWords;
int nBinSize; int nBinSize;
int nRounds; int nRounds;
int nRestart;
int nRandSeed; int nRandSeed;
int TimeOut; int TimeOut;
int fVerbose; int fVerbose;
extern int Abc_NtkDarSeqSim3( Abc_Ntk_t * pNtk, int nFrames, int nWords, int nBinSize, int nRounds, int nRandSeed, int TimeOut, int fVerbose ); extern int Abc_NtkDarSeqSim3( Abc_Ntk_t * pNtk, int nFrames, int nWords, int nBinSize, int nRounds, int nRestart, int nRandSeed, int TimeOut, int fVerbose );
// set defaults // set defaults
nFrames = 20; nFrames = 20;
nWords = 50; nWords = 50;
nBinSize = 8; nBinSize = 8;
nRounds = 80; nRounds = 0;
nRestart = 100;
nRandSeed = 0; nRandSeed = 0;
TimeOut = 0; TimeOut = 0;
fVerbose = 0; fVerbose = 0;
// parse command line // parse command line
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "FWBRNTvh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "FWBRSNTvh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
...@@ -16692,6 +16694,17 @@ int Abc_CommandSim3( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -16692,6 +16694,17 @@ int Abc_CommandSim3( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( nRounds < 0 ) if ( nRounds < 0 )
goto usage; goto usage;
break; break;
case 'S':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
goto usage;
}
nRestart = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nRestart < 0 )
goto usage;
break;
case 'N': case 'N':
if ( globalUtilOptind >= argc ) if ( globalUtilOptind >= argc )
{ {
...@@ -16734,18 +16747,19 @@ int Abc_CommandSim3( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -16734,18 +16747,19 @@ int Abc_CommandSim3( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1; return 1;
} }
ABC_FREE( pNtk->pSeqModel ); ABC_FREE( pNtk->pSeqModel );
pAbc->Status = Abc_NtkDarSeqSim3( pNtk, nFrames, nWords, nBinSize, nRounds, nRandSeed, TimeOut, fVerbose ); pAbc->Status = Abc_NtkDarSeqSim3( pNtk, nFrames, nWords, nBinSize, nRounds, nRestart, nRandSeed, TimeOut, fVerbose );
// pAbc->nFrames = pAbc->pCex->iFrame; // pAbc->nFrames = pAbc->pCex->iFrame;
Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel ); Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
return 0; return 0;
usage: usage:
Abc_Print( -2, "usage: sim3 [-FWBRNT num] [-vh]\n" ); Abc_Print( -2, "usage: sim3 [-FWBRSNT num] [-vh]\n" );
Abc_Print( -2, "\t performs random simulation of the sequential miter\n" ); Abc_Print( -2, "\t performs random simulation of the sequential miter\n" );
Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n", nFrames ); Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n", nFrames );
Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n", nWords ); Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n", nWords );
Abc_Print( -2, "\t-B num : the number of flops in one bin [default = %d]\n", nBinSize ); Abc_Print( -2, "\t-B num : the number of flops in one bin [default = %d]\n", nBinSize );
Abc_Print( -2, "\t-R num : the number of simulation rounds [default = %d]\n", nRounds ); Abc_Print( -2, "\t-R num : the number of simulation rounds [default = %d]\n", nRounds );
Abc_Print( -2, "\t-S num : the number of rounds before a restart [default = %d]\n", nRestart );
Abc_Print( -2, "\t-N num : random number seed (1 <= num <= 1000) [default = %d]\n", nRandSeed ); Abc_Print( -2, "\t-N num : random number seed (1 <= num <= 1000) [default = %d]\n", nRandSeed );
Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", TimeOut ); Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", TimeOut );
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" );
...@@ -23257,21 +23271,23 @@ int Abc_CommandAbc9Sim3( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -23257,21 +23271,23 @@ int Abc_CommandAbc9Sim3( Abc_Frame_t * pAbc, int argc, char ** argv )
int nWords; int nWords;
int nBinSize; int nBinSize;
int nRounds; int nRounds;
int nRestart;
int nRandSeed; int nRandSeed;
int TimeOut; int TimeOut;
int fVerbose; int fVerbose;
extern int Ssw_RarSimulateGia( Gia_Man_t * p, int nFrames, int nWords, int nBinSize, int nRounds, int nRandSeed, int TimeOut, int fVerbose ); extern int Ssw_RarSimulateGia( Gia_Man_t * p, int nFrames, int nWords, int nBinSize, int nRounds, int nRestart, int nRandSeed, int TimeOut, int fVerbose );
// set defaults // set defaults
nFrames = 20; nFrames = 20;
nWords = 50; nWords = 50;
nBinSize = 8; nBinSize = 8;
nRounds = 80; nRounds = 0;
nRestart = 100;
nRandSeed = 0; nRandSeed = 0;
TimeOut = 0; TimeOut = 0;
fVerbose = 0; fVerbose = 0;
// parse command line // parse command line
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "FWBRNTvh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "FWBRSNTvh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
...@@ -23319,6 +23335,17 @@ int Abc_CommandAbc9Sim3( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -23319,6 +23335,17 @@ int Abc_CommandAbc9Sim3( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( nRounds < 0 ) if ( nRounds < 0 )
goto usage; goto usage;
break; break;
case 'S':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
goto usage;
}
nRestart = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nRestart < 0 )
goto usage;
break;
case 'N': case 'N':
if ( globalUtilOptind >= argc ) if ( globalUtilOptind >= argc )
{ {
...@@ -23355,7 +23382,7 @@ int Abc_CommandAbc9Sim3( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -23355,7 +23382,7 @@ int Abc_CommandAbc9Sim3( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Abc_CommandAbc9Sim3(): There is no AIG.\n" ); Abc_Print( -1, "Abc_CommandAbc9Sim3(): There is no AIG.\n" );
return 1; return 1;
} }
pAbc->Status = Ssw_RarSimulateGia( pAbc->pGia, nFrames, nWords, nBinSize, nRounds, nRandSeed, TimeOut, fVerbose ); pAbc->Status = Ssw_RarSimulateGia( pAbc->pGia, nFrames, nWords, nBinSize, nRounds, nRestart, nRandSeed, TimeOut, fVerbose );
// pAbc->nFrames = pAbc->pGia->pCexSeq->iFrame; // pAbc->nFrames = pAbc->pGia->pCexSeq->iFrame;
Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexSeq ); Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexSeq );
return 0; return 0;
...@@ -23367,6 +23394,7 @@ usage: ...@@ -23367,6 +23394,7 @@ usage:
Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n", nWords ); Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n", nWords );
Abc_Print( -2, "\t-B num : the number of flops in one bin [default = %d]\n", nBinSize ); Abc_Print( -2, "\t-B num : the number of flops in one bin [default = %d]\n", nBinSize );
Abc_Print( -2, "\t-R num : the number of simulation rounds [default = %d]\n", nRounds ); Abc_Print( -2, "\t-R num : the number of simulation rounds [default = %d]\n", nRounds );
Abc_Print( -2, "\t-S num : the number of rounds before a restart [default = %d]\n", nRestart );
Abc_Print( -2, "\t-N num : random number seed (1 <= num <= 1000) [default = %d]\n", nRandSeed ); Abc_Print( -2, "\t-N num : random number seed (1 <= num <= 1000) [default = %d]\n", nRandSeed );
Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", TimeOut ); Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", TimeOut );
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" );
...@@ -23799,12 +23827,13 @@ usage: ...@@ -23799,12 +23827,13 @@ usage:
int Abc_CommandAbc9Equiv3( Abc_Frame_t * pAbc, int argc, char ** argv ) int Abc_CommandAbc9Equiv3( Abc_Frame_t * pAbc, int argc, char ** argv )
{ {
// extern int Ssw_RarSignalFilterGia2( Gia_Man_t * p, int nFrames, int nWords, int nBinSize, int nRounds, int TimeOut, Abc_Cex_t * pCex, int fLatchOnly, int fVerbose ); // extern int Ssw_RarSignalFilterGia2( Gia_Man_t * p, int nFrames, int nWords, int nBinSize, int nRounds, int TimeOut, Abc_Cex_t * pCex, int fLatchOnly, int fVerbose );
extern int Ssw_RarSignalFilterGia( Gia_Man_t * p, int nFrames, int nWords, int nBinSize, int nRounds, int nRandSeed, int TimeOut, int fMiter, Abc_Cex_t * pCex, int fLatchOnly, int fVerbose ); extern int Ssw_RarSignalFilterGia( Gia_Man_t * p, int nFrames, int nWords, int nBinSize, int nRounds, int nRestart, int nRandSeed, int TimeOut, int fMiter, Abc_Cex_t * pCex, int fLatchOnly, int fVerbose );
int c; int c;
int nFrames = 20; int nFrames = 20;
int nWords = 50; int nWords = 50;
int nBinSize = 8; int nBinSize = 8;
int nRounds = 80; int nRounds = 0;
int nRestart = 100;
int nRandSeed = 0; int nRandSeed = 0;
int TimeOut = 0; int TimeOut = 0;
int fMiter = 0; int fMiter = 0;
...@@ -23813,7 +23842,7 @@ int Abc_CommandAbc9Equiv3( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -23813,7 +23842,7 @@ int Abc_CommandAbc9Equiv3( Abc_Frame_t * pAbc, int argc, char ** argv )
int fNewAlgo = 1; int fNewAlgo = 1;
int fVerbose = 0; int fVerbose = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "FWBRNTmxlavh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "FWBRSNTmxlavh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
...@@ -23861,6 +23890,17 @@ int Abc_CommandAbc9Equiv3( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -23861,6 +23890,17 @@ int Abc_CommandAbc9Equiv3( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( nRounds < 0 ) if ( nRounds < 0 )
goto usage; goto usage;
break; break;
case 'S':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-S\" should be followed by an integer.\n" );
goto usage;
}
nRestart = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nRestart < 0 )
goto usage;
break;
case 'N': case 'N':
if ( globalUtilOptind >= argc ) if ( globalUtilOptind >= argc )
{ {
...@@ -23934,7 +23974,7 @@ int Abc_CommandAbc9Equiv3( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -23934,7 +23974,7 @@ int Abc_CommandAbc9Equiv3( Abc_Frame_t * pAbc, int argc, char ** argv )
} }
} }
// if ( fNewAlgo ) // if ( fNewAlgo )
pAbc->Status = Ssw_RarSignalFilterGia( pAbc->pGia, nFrames, nWords, nBinSize, nRounds, nRandSeed, TimeOut, fMiter, fUseCex? pAbc->pCex: NULL, fLatchOnly, fVerbose ); pAbc->Status = Ssw_RarSignalFilterGia( pAbc->pGia, nFrames, nWords, nBinSize, nRounds, nRestart, nRandSeed, TimeOut, fMiter, fUseCex? pAbc->pCex: NULL, fLatchOnly, fVerbose );
// else // else
// pAbc->Status = Ssw_RarSignalFilterGia2( pAbc->pGia, nFrames, nWords, nBinSize, nRounds, TimeOut, fUseCex? pAbc->pCex: NULL, fLatchOnly, fVerbose ); // pAbc->Status = Ssw_RarSignalFilterGia2( pAbc->pGia, nFrames, nWords, nBinSize, nRounds, TimeOut, fUseCex? pAbc->pCex: NULL, fLatchOnly, fVerbose );
// pAbc->nFrames = pAbc->pGia->pCexSeq->iFrame; // pAbc->nFrames = pAbc->pGia->pCexSeq->iFrame;
...@@ -23942,12 +23982,13 @@ int Abc_CommandAbc9Equiv3( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -23942,12 +23982,13 @@ int Abc_CommandAbc9Equiv3( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0; return 0;
usage: usage:
Abc_Print( -2, "usage: &equiv3 [-FWRNT num] [-mxlvh]\n" ); Abc_Print( -2, "usage: &equiv3 [-FWRSNT num] [-mxlvh]\n" );
Abc_Print( -2, "\t computes candidate equivalence classes\n" ); Abc_Print( -2, "\t computes candidate equivalence classes\n" );
Abc_Print( -2, "\t-F num : the max number of frames for BMC [default = %d]\n", nFrames ); Abc_Print( -2, "\t-F num : the max number of frames for BMC [default = %d]\n", nFrames );
Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n", nWords ); Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n", nWords );
// Abc_Print( -2, "\t-B num : the number of flops in one bin [default = %d]\n", nBinSize ); // Abc_Print( -2, "\t-B num : the number of flops in one bin [default = %d]\n", nBinSize );
Abc_Print( -2, "\t-R num : the max number of simulation rounds [default = %d]\n", nRounds ); Abc_Print( -2, "\t-R num : the max number of simulation rounds [default = %d]\n", nRounds );
Abc_Print( -2, "\t-S num : the number of rounds before a restart [default = %d]\n", nRestart );
Abc_Print( -2, "\t-N num : random number seed (1 <= num <= 1000) [default = %d]\n", nRandSeed ); Abc_Print( -2, "\t-N num : random number seed (1 <= num <= 1000) [default = %d]\n", nRandSeed );
Abc_Print( -2, "\t-T num : runtime limit in seconds for all rounds [default = %d]\n", TimeOut ); Abc_Print( -2, "\t-T num : runtime limit in seconds for all rounds [default = %d]\n", TimeOut );
Abc_Print( -2, "\t-m : toggle miter vs. any circuit [default = %s]\n", fMiter? "miter": "circuit" ); Abc_Print( -2, "\t-m : toggle miter vs. any circuit [default = %s]\n", fMiter? "miter": "circuit" );
......
...@@ -3199,7 +3199,7 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in ...@@ -3199,7 +3199,7 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Abc_NtkDarSeqSim3( Abc_Ntk_t * pNtk, int nFrames, int nWords, int nBinSize, int nRounds, int nRandSeed, int TimeOut, int fVerbose ) int Abc_NtkDarSeqSim3( Abc_Ntk_t * pNtk, int nFrames, int nWords, int nBinSize, int nRounds, int nRestart, int nRandSeed, int TimeOut, int fVerbose )
{ {
Aig_Man_t * pMan; Aig_Man_t * pMan;
int status, RetValue = -1; int status, RetValue = -1;
...@@ -3210,12 +3210,12 @@ int Abc_NtkDarSeqSim3( Abc_Ntk_t * pNtk, int nFrames, int nWords, int nBinSize, ...@@ -3210,12 +3210,12 @@ int Abc_NtkDarSeqSim3( Abc_Ntk_t * pNtk, int nFrames, int nWords, int nBinSize,
Abc_AigCleanup((Abc_Aig_t *)pNtk->pManFunc); Abc_AigCleanup((Abc_Aig_t *)pNtk->pManFunc);
} }
pMan = Abc_NtkToDar( pNtk, 0, 1 ); pMan = Abc_NtkToDar( pNtk, 0, 1 );
if ( Ssw_RarSimulate( pMan, nFrames, nWords, nBinSize, nRounds, nRandSeed, TimeOut, fVerbose ) == 0 ) if ( Ssw_RarSimulate( pMan, nFrames, nWords, nBinSize, nRounds, nRestart, nRandSeed, TimeOut, fVerbose ) == 0 )
{ {
if ( pMan->pSeqModel ) if ( pMan->pSeqModel )
{ {
Abc_Print( 1, "Simulation of %d frames with %d words asserted output %d in frame %d. ", // Abc_Print( 1, "Simulation of %d frames with %d words asserted output %d in frame %d. ",
nFrames, nWords, pMan->pSeqModel->iPo, pMan->pSeqModel->iFrame ); // nFrames, nWords, pMan->pSeqModel->iPo, pMan->pSeqModel->iFrame );
status = Saig_ManVerifyCex( pMan, pMan->pSeqModel ); status = Saig_ManVerifyCex( pMan, pMan->pSeqModel );
if ( status == 0 ) if ( status == 0 )
Abc_Print( 1, "Abc_NtkDarSeqSim(): Counter-example verification has FAILED.\n" ); Abc_Print( 1, "Abc_NtkDarSeqSim(): Counter-example verification has FAILED.\n" );
...@@ -3230,7 +3230,7 @@ int Abc_NtkDarSeqSim3( Abc_Ntk_t * pNtk, int nFrames, int nWords, int nBinSize, ...@@ -3230,7 +3230,7 @@ int Abc_NtkDarSeqSim3( Abc_Ntk_t * pNtk, int nFrames, int nWords, int nBinSize,
// Abc_Print( 1, "Simulation of %d frames with %d words did not assert the outputs. ", // Abc_Print( 1, "Simulation of %d frames with %d words did not assert the outputs. ",
// nFrames, nWords ); // nFrames, nWords );
} }
ABC_PRT( "Time", clock() - clk ); // ABC_PRT( "Time", clock() - clk );
Aig_ManStop( pMan ); Aig_ManStop( pMan );
return RetValue; return RetValue;
} }
......
...@@ -116,8 +116,8 @@ extern int Ssw_SecWithPairs( Aig_Man_t * pAig1, Aig_Man_t * pAig2, Vec ...@@ -116,8 +116,8 @@ extern int Ssw_SecWithPairs( Aig_Man_t * pAig1, Aig_Man_t * pAig2, Vec
extern int Ssw_SecGeneral( Aig_Man_t * pAig1, Aig_Man_t * pAig2, Ssw_Pars_t * pPars ); extern int Ssw_SecGeneral( Aig_Man_t * pAig1, Aig_Man_t * pAig2, Ssw_Pars_t * pPars );
extern int Ssw_SecGeneralMiter( Aig_Man_t * pMiter, Ssw_Pars_t * pPars ); extern int Ssw_SecGeneralMiter( Aig_Man_t * pMiter, Ssw_Pars_t * pPars );
/*=== sswRarity.c ===================================================*/ /*=== sswRarity.c ===================================================*/
extern int Ssw_RarSignalFilter( Aig_Man_t * pAig, int nFrames, int nWords, int nBinSize, int nRounds, int nRandSeed, int TimeOut, int fMiter, Abc_Cex_t * pCex, int fLatchOnly, int fVerbose ); extern int Ssw_RarSignalFilter( Aig_Man_t * pAig, int nFrames, int nWords, int nBinSize, int nRounds, int nRestart, int nRandSeed, int TimeOut, int fMiter, Abc_Cex_t * pCex, int fLatchOnly, int fVerbose );
extern int Ssw_RarSimulate( Aig_Man_t * pAig, int nFrames, int nWords, int nBinSize, int nRounds, int nRandSeed, int TimeOut, int fVerbose ); extern int Ssw_RarSimulate( Aig_Man_t * pAig, int nFrames, int nWords, int nBinSize, int nRounds, int nRestart, int nRandSeed, int TimeOut, int fVerbose );
/*=== sswSim.c ===================================================*/ /*=== sswSim.c ===================================================*/
extern Ssw_Sml_t * Ssw_SmlSimulateComb( Aig_Man_t * pAig, int nWords ); extern Ssw_Sml_t * Ssw_SmlSimulateComb( Aig_Man_t * pAig, int nWords );
extern Ssw_Sml_t * Ssw_SmlSimulateSeq( Aig_Man_t * pAig, int nPref, int nFrames, int nWords ); extern Ssw_Sml_t * Ssw_SmlSimulateSeq( Aig_Man_t * pAig, int nPref, int nFrames, int nWords );
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
Revision [$Id: sswRarity.c,v 1.00 2008/09/01 00:00:00 alanmi Exp $] Revision [$Id: sswRarity.c,v 1.00 2008/09/01 00:00:00 alanmi Exp $]
***********************************************************************/ ***********************************************************************/
#include "sswInt.h" #include "sswInt.h"
#include "aig/gia/giaAig.h" #include "aig/gia/giaAig.h"
#include "base/main/main.h" #include "base/main/main.h"
...@@ -191,8 +191,6 @@ Abc_Cex_t * Ssw_RarDeriveCex( Ssw_RarMan_t * p, int iFrame, int iPo, int iPatFin ...@@ -191,8 +191,6 @@ Abc_Cex_t * Ssw_RarDeriveCex( Ssw_RarMan_t * p, int iFrame, int iPo, int iPatFin
else else
{ {
// printf( "Counter-example verification is successful.\n" ); // printf( "Counter-example verification is successful.\n" );
if ( fVerbose )
printf( "Output %d was asserted in frame %d (use \"write_counter\" to dump a witness). \n", pCex->iPo, pCex->iFrame );
} }
return pCex; return pCex;
} }
...@@ -892,7 +890,7 @@ int Ssw_RarCheckTrivial( Aig_Man_t * pAig, int fVerbose ) ...@@ -892,7 +890,7 @@ int Ssw_RarCheckTrivial( Aig_Man_t * pAig, int fVerbose )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Ssw_RarSimulate( Aig_Man_t * pAig, int nFrames, int nWords, int nBinSize, int nRounds, int nRandSeed, int TimeOut, int fVerbose ) int Ssw_RarSimulate( Aig_Man_t * pAig, int nFrames, int nWords, int nBinSize, int nRounds, int nRestart, int nRandSeed, int TimeOut, int fVerbose )
{ {
int fTryBmc = 0; int fTryBmc = 0;
int fMiter = 1; int fMiter = 1;
...@@ -900,6 +898,8 @@ int Ssw_RarSimulate( Aig_Man_t * pAig, int nFrames, int nWords, int nBinSize, in ...@@ -900,6 +898,8 @@ int Ssw_RarSimulate( Aig_Man_t * pAig, int nFrames, int nWords, int nBinSize, in
int r, f = -1; int r, f = -1;
clock_t clk, clkTotal = clock(); clock_t clk, clkTotal = clock();
clock_t nTimeToStop = TimeOut ? TimeOut * CLOCKS_PER_SEC + clock(): 0; clock_t nTimeToStop = TimeOut ? TimeOut * CLOCKS_PER_SEC + clock(): 0;
int nNumRestart = 0;
int nSavedSeed = nRandSeed;
int RetValue = -1; int RetValue = -1;
int iFrameFail = -1; int iFrameFail = -1;
assert( Aig_ManRegNum(pAig) > 0 ); assert( Aig_ManRegNum(pAig) > 0 );
...@@ -914,14 +914,14 @@ int Ssw_RarSimulate( Aig_Man_t * pAig, int nFrames, int nWords, int nBinSize, in ...@@ -914,14 +914,14 @@ int Ssw_RarSimulate( Aig_Man_t * pAig, int nFrames, int nWords, int nBinSize, in
printf( "Rarity simulation with %d words, %d frames, %d rounds, %d seed, and %d sec timeout.\n", printf( "Rarity simulation with %d words, %d frames, %d rounds, %d seed, and %d sec timeout.\n",
nWords, nFrames, nRounds, nRandSeed, TimeOut ); nWords, nFrames, nRounds, nRandSeed, TimeOut );
// reset random numbers // reset random numbers
Ssw_RarManPrepareRandom( nRandSeed ); Ssw_RarManPrepareRandom( nSavedSeed );
// create manager // create manager
p = Ssw_RarManStart( pAig, nWords, nFrames, nBinSize, fVerbose ); p = Ssw_RarManStart( pAig, nWords, nFrames, nBinSize, fVerbose );
p->vInits = Vec_IntStart( Aig_ManRegNum(pAig) * nWords ); p->vInits = Vec_IntStart( Aig_ManRegNum(pAig) * nWords );
// perform simulation rounds // perform simulation rounds
for ( r = 0; r < nRounds; r++ ) for ( r = 0; !nRounds || (nNumRestart * nRestart + r < nRounds); r++ )
{ {
clk = clock(); clk = clock();
if ( fTryBmc ) if ( fTryBmc )
...@@ -940,9 +940,14 @@ int Ssw_RarSimulate( Aig_Man_t * pAig, int nFrames, int nWords, int nBinSize, in ...@@ -940,9 +940,14 @@ int Ssw_RarSimulate( Aig_Man_t * pAig, int nFrames, int nWords, int nBinSize, in
{ {
if ( fVerbose ) printf( "\n" ); if ( fVerbose ) printf( "\n" );
// printf( "Simulation asserted a PO in frame f: %d <= f < %d.\n", r * nFrames, (r+1) * nFrames ); // printf( "Simulation asserted a PO in frame f: %d <= f < %d.\n", r * nFrames, (r+1) * nFrames );
Ssw_RarManPrepareRandom( nRandSeed ); Ssw_RarManPrepareRandom( nSavedSeed );
ABC_FREE( pAig->pSeqModel ); ABC_FREE( pAig->pSeqModel );
if ( fVerbose )
printf( "Simulated %d frames for %d rounds with %d restarts.\n", nFrames, nNumRestart * nRestart + r, nNumRestart );
pAig->pSeqModel = Ssw_RarDeriveCex( p, r * p->nFrames + f, p->iFailPo, p->iFailPat, fVerbose ); pAig->pSeqModel = Ssw_RarDeriveCex( p, r * p->nFrames + f, p->iFailPo, p->iFailPat, fVerbose );
// print final report
printf( "Output %d was asserted in frame %d (use \"write_counter\" to dump a witness). ", pAig->pSeqModel->iPo, pAig->pSeqModel->iFrame );
Abc_PrintTime( 1, "Time", clock() - clkTotal );
RetValue = 0; RetValue = 0;
goto finish; goto finish;
} }
...@@ -950,12 +955,25 @@ int Ssw_RarSimulate( Aig_Man_t * pAig, int nFrames, int nWords, int nBinSize, in ...@@ -950,12 +955,25 @@ int Ssw_RarSimulate( Aig_Man_t * pAig, int nFrames, int nWords, int nBinSize, in
if ( TimeOut && clock() > nTimeToStop ) if ( TimeOut && clock() > nTimeToStop )
{ {
if ( fVerbose ) printf( "\n" ); if ( fVerbose ) printf( "\n" );
printf( "Reached timeout (%d seconds).\n", TimeOut ); printf( "Simulated %d frames for %d rounds with %d restarts. ", nFrames, nNumRestart * nRestart + r, nNumRestart );
printf( "Reached timeout (%d sec).\n", TimeOut );
goto finish; goto finish;
} }
} }
// get initialization patterns // get initialization patterns
Ssw_RarTransferPatterns( p, p->vInits ); if ( r == nRestart )
{
r = -1;
nSavedSeed = (nSavedSeed + 1) % 1000;
Ssw_RarManPrepareRandom( nSavedSeed );
Vec_IntFill( p->vInits, Aig_ManRegNum(pAig) * nWords, 0 );
nNumRestart++;
Vec_IntClear( p->vPatBests );
// clean rarity info
// memset( p->pRarity, 0, sizeof(int) * (1 << nBinSize) * p->nGroups );
}
else
Ssw_RarTransferPatterns( p, p->vInits );
// printout // printout
if ( fVerbose ) if ( fVerbose )
{ {
...@@ -988,12 +1006,12 @@ finish: ...@@ -988,12 +1006,12 @@ finish:
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Ssw_RarSimulateGia( Gia_Man_t * p, int nFrames, int nWords, int nBinSize, int nRounds, int nRandSeed, int TimeOut, int fVerbose ) int Ssw_RarSimulateGia( Gia_Man_t * p, int nFrames, int nWords, int nBinSize, int nRounds, int nRestart, int nRandSeed, int TimeOut, int fVerbose )
{ {
Aig_Man_t * pAig; Aig_Man_t * pAig;
int RetValue; int RetValue;
pAig = Gia_ManToAigSimple( p ); pAig = Gia_ManToAigSimple( p );
RetValue = Ssw_RarSimulate( pAig, nFrames, nWords, nBinSize, nRounds, nRandSeed, TimeOut, fVerbose ); RetValue = Ssw_RarSimulate( pAig, nFrames, nWords, nBinSize, nRounds, nRestart, nRandSeed, TimeOut, fVerbose );
// save counter-example // save counter-example
Abc_CexFree( p->pCexSeq ); Abc_CexFree( p->pCexSeq );
p->pCexSeq = pAig->pSeqModel; pAig->pSeqModel = NULL; p->pCexSeq = pAig->pSeqModel; pAig->pSeqModel = NULL;
...@@ -1012,7 +1030,7 @@ int Ssw_RarSimulateGia( Gia_Man_t * p, int nFrames, int nWords, int nBinSize, in ...@@ -1012,7 +1030,7 @@ int Ssw_RarSimulateGia( Gia_Man_t * p, int nFrames, int nWords, int nBinSize, in
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Ssw_RarSignalFilter( Aig_Man_t * pAig, int nFrames, int nWords, int nBinSize, int nRounds, int nRandSeed, int TimeOut, int fMiter, Abc_Cex_t * pCex, int fLatchOnly, int fVerbose ) int Ssw_RarSignalFilter( Aig_Man_t * pAig, int nFrames, int nWords, int nBinSize, int nRounds, int nRestart, int nRandSeed, int TimeOut, int fMiter, Abc_Cex_t * pCex, int fLatchOnly, int fVerbose )
{ {
Ssw_RarMan_t * p; Ssw_RarMan_t * p;
int r, f = -1, i, k; int r, f = -1, i, k;
...@@ -1063,7 +1081,7 @@ int Ssw_RarSignalFilter( Aig_Man_t * pAig, int nFrames, int nWords, int nBinSize ...@@ -1063,7 +1081,7 @@ int Ssw_RarSignalFilter( Aig_Man_t * pAig, int nFrames, int nWords, int nBinSize
Ssw_ClassesPrint( p->ppClasses, 0 ); Ssw_ClassesPrint( p->ppClasses, 0 );
} }
// refine classes using BMC // refine classes using BMC
for ( r = 0; r < nRounds; r++ ) for ( r = 0; !nRounds || r < nRounds; r++ )
{ {
// start filtering equivalence classes // start filtering equivalence classes
if ( Ssw_ClassesCand1Num(p->ppClasses) == 0 && Ssw_ClassesClassNum(p->ppClasses) == 0 ) if ( Ssw_ClassesCand1Num(p->ppClasses) == 0 && Ssw_ClassesClassNum(p->ppClasses) == 0 )
...@@ -1083,6 +1101,9 @@ int Ssw_RarSignalFilter( Aig_Man_t * pAig, int nFrames, int nWords, int nBinSize ...@@ -1083,6 +1101,9 @@ int Ssw_RarSignalFilter( Aig_Man_t * pAig, int nFrames, int nWords, int nBinSize
Ssw_RarManPrepareRandom( nRandSeed ); Ssw_RarManPrepareRandom( nRandSeed );
Abc_CexFree( pAig->pSeqModel ); Abc_CexFree( pAig->pSeqModel );
pAig->pSeqModel = Ssw_RarDeriveCex( p, r * p->nFrames + f, p->iFailPo, p->iFailPat, 1 ); pAig->pSeqModel = Ssw_RarDeriveCex( p, r * p->nFrames + f, p->iFailPo, p->iFailPat, 1 );
// print final report
printf( "Output %d was asserted in frame %d (use \"write_counter\" to dump a witness). ", pAig->pSeqModel->iPo, pAig->pSeqModel->iFrame );
Abc_PrintTime( 1, "Time", clock() - clkTotal );
RetValue = 0; RetValue = 0;
goto finish; goto finish;
} }
...@@ -1090,7 +1111,7 @@ int Ssw_RarSignalFilter( Aig_Man_t * pAig, int nFrames, int nWords, int nBinSize ...@@ -1090,7 +1111,7 @@ int Ssw_RarSignalFilter( Aig_Man_t * pAig, int nFrames, int nWords, int nBinSize
if ( TimeOut && clock() > nTimeToStop ) if ( TimeOut && clock() > nTimeToStop )
{ {
if ( fVerbose ) printf( "\n" ); if ( fVerbose ) printf( "\n" );
printf( "Reached timeout (%d seconds).\n", TimeOut ); printf( "Reached timeout (%d sec).\n", TimeOut );
goto finish; goto finish;
} }
} }
...@@ -1132,7 +1153,7 @@ finish: ...@@ -1132,7 +1153,7 @@ finish:
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Ssw_RarSignalFilterGia( Gia_Man_t * p, int nFrames, int nWords, int nBinSize, int nRounds, int nRandSeed, int TimeOut, int fMiter, Abc_Cex_t * pCex, int fLatchOnly, int fVerbose ) int Ssw_RarSignalFilterGia( Gia_Man_t * p, int nFrames, int nWords, int nBinSize, int nRounds, int nRestart, int nRandSeed, int TimeOut, int fMiter, Abc_Cex_t * pCex, int fLatchOnly, int fVerbose )
{ {
Aig_Man_t * pAig; Aig_Man_t * pAig;
int RetValue; int RetValue;
...@@ -1143,7 +1164,7 @@ int Ssw_RarSignalFilterGia( Gia_Man_t * p, int nFrames, int nWords, int nBinSize ...@@ -1143,7 +1164,7 @@ int Ssw_RarSignalFilterGia( Gia_Man_t * p, int nFrames, int nWords, int nBinSize
ABC_FREE( p->pReprs ); ABC_FREE( p->pReprs );
ABC_FREE( p->pNexts ); ABC_FREE( p->pNexts );
} }
RetValue = Ssw_RarSignalFilter( pAig, nFrames, nWords, nBinSize, nRounds, nRandSeed, TimeOut, fMiter, pCex, fLatchOnly, fVerbose ); RetValue = Ssw_RarSignalFilter( pAig, nFrames, nWords, nBinSize, nRounds, nRestart, nRandSeed, TimeOut, fMiter, pCex, fLatchOnly, fVerbose );
Gia_ManReprFromAigRepr( pAig, p ); Gia_ManReprFromAigRepr( pAig, p );
// save counter-example // save counter-example
Abc_CexFree( p->pCexSeq ); Abc_CexFree( p->pCexSeq );
......
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