summaryrefslogtreecommitdiffstats
path: root/src/base
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2012-08-24 11:12:51 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2012-08-24 11:12:51 -0700
commit942600414dba2e32bf2529517e17eaee5991d29c (patch)
treee58e0f65b13952d1773f11731c48a955a7068206 /src/base
parent12c776ed6e5a17a491fdb986ccce99649a06850e (diff)
downloadabc-942600414dba2e32bf2529517e17eaee5991d29c.tar.gz
abc-942600414dba2e32bf2529517e17eaee5991d29c.tar.bz2
abc-942600414dba2e32bf2529517e17eaee5991d29c.zip
Added simulation of comb circuits with user-specified patterns in command 'sim'.
Diffstat (limited to 'src/base')
-rw-r--r--src/base/abci/abc.c46
-rw-r--r--src/base/abci/abcDar.c128
2 files changed, 46 insertions, 128 deletions
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index 3eabc252..0dcce40a 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.c
@@ -17148,7 +17148,8 @@ int Abc_CommandSim( Abc_Frame_t * pAbc, int argc, char ** argv )
int TimeOut;
int fMiter;
int fVerbose;
- extern int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, int fNew, int fComb, int fMiter, int fVerbose );
+ char * pFileSim;
+ extern int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, int fNew, int fMiter, int fVerbose, char * pFileSim );
// set defaults
fNew = 0;
fComb = 0;
@@ -17157,8 +17158,9 @@ int Abc_CommandSim( Abc_Frame_t * pAbc, int argc, char ** argv )
TimeOut = 30;
fMiter = 0;
fVerbose = 0;
+ pFileSim = NULL;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "FWTncmvh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "FWTAnmvh" ) ) != EOF )
{
switch ( c )
{
@@ -17195,12 +17197,18 @@ int Abc_CommandSim( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( TimeOut < 0 )
goto usage;
break;
+ case 'A':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-A\" should be followed by a file name.\n" );
+ goto usage;
+ }
+ pFileSim = argv[globalUtilOptind];
+ globalUtilOptind++;
+ break;
case 'n':
fNew ^= 1;
break;
- case 'c':
- fComb ^= 1;
- break;
case 'm':
fMiter ^= 1;
break;
@@ -17223,22 +17231,28 @@ int Abc_CommandSim( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Only works for strashed networks.\n" );
return 1;
}
+ if ( pFileSim != NULL && Abc_NtkLatchNum(pNtk) )
+ {
+ Abc_Print( -1, "Currently simulation with user-specified patterns works only for comb miters.\n" );
+ return 1;
+ }
ABC_FREE( pNtk->pSeqModel );
- pAbc->Status = Abc_NtkDarSeqSim( pNtk, nFrames, nWords, TimeOut, fNew, fComb, fMiter, fVerbose );
+ pAbc->Status = Abc_NtkDarSeqSim( pNtk, nFrames, nWords, TimeOut, fNew, fMiter, fVerbose, pFileSim );
Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
return 0;
usage:
- Abc_Print( -2, "usage: sim [-FWT num] [-ncmvh]\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-W num : the number of words to simulate [default = %d]\n", nWords );
- Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", TimeOut );
- Abc_Print( -2, "\t-n : toggle new vs. old implementation [default = %s]\n", fNew? "new": "old" );
- Abc_Print( -2, "\t-c : toggle comb vs. seq simulaton [default = %s]\n", fComb? "comb": "seq" );
- Abc_Print( -2, "\t-m : toggle miter vs. any circuit [default = %s]\n", fMiter? "miter": "circuit" );
- 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, "usage: sim [-FWT num] [-A file] [-nmvh]\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-W num : the number of words to simulate [default = %d]\n", nWords );
+ Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", TimeOut );
+ Abc_Print( -2, "\t-A file : text file name with user's patterns [default = random simulation]\n" );
+ Abc_Print( -2, "\t (patterns are listed, one per line, as sequences of 0s and 1s)\n" );
+ Abc_Print( -2, "\t-n : toggle new vs. old implementation [default = %s]\n", fNew? "new": "old" );
+ Abc_Print( -2, "\t-m : toggle miter vs. any circuit [default = %s]\n", fMiter? "miter": "circuit" );
+ 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");
return 1;
}
diff --git a/src/base/abci/abcDar.c b/src/base/abci/abcDar.c
index 62c09e3f..bea8e6b9 100644
--- a/src/base/abci/abcDar.c
+++ b/src/base/abci/abcDar.c
@@ -3005,10 +3005,8 @@ Abc_Ntk_t * Abc_NtkDarHaigRecord( Abc_Ntk_t * pNtk, int nIters, int nSteps, int
SeeAlso []
***********************************************************************/
-int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, int fNew, int fComb, int fMiter, int fVerbose )
+int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, int fNew, int fMiter, int fVerbose, char * pFileSim )
{
- extern int Cec_ManSimulate( Aig_Man_t * pAig, int nWords, int nIters, int TimeLimit, int fMiter, int fVerbose );
- extern int Raig_ManSimulate( Aig_Man_t * pAig, int nWords, int nIters, int TimeLimit, int fMiter, int fVerbose );
Aig_Man_t * pMan;
Abc_Cex_t * pCex;
int status, RetValue = -1;
@@ -3019,89 +3017,8 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in
Abc_AigCleanup((Abc_Aig_t *)pNtk->pManFunc);
}
pMan = Abc_NtkToDar( pNtk, 0, 1 );
- if ( fComb || Abc_NtkLatchNum(pNtk) == 0 )
+ if ( fNew )
{
-/*
- if ( Cec_ManSimulate( pMan, nWords, nFrames, TimeOut, fMiter, fVerbose ) )
- {
- pCex = pMan->pSeqModel;
- if ( pCex )
- {
- Abc_Print( 1, "Simulation iterated %d times with %d words asserted output %d in frame %d. ",
- nFrames, nWords, pCex->iPo, pCex->iFrame );
- status = Saig_ManVerifyCex( pMan, pCex );
- if ( status == 0 )
- Abc_Print( 1, "Abc_NtkDarSeqSim(): Counter-example verification has FAILED.\n" );
- }
- ABC_FREE( pNtk->pModel );
- ABC_FREE( pNtk->pSeqModel );
- pNtk->pSeqModel = pCex;
- RetValue = 1;
- }
- else
- {
- RetValue = 0;
- Abc_Print( 1, "Simulation iterated %d times with %d words did not assert the outputs. ",
- nFrames, nWords );
- }
-*/
- Abc_Print( 1, "Comb simulation is temporarily disabled.\n" );
- }
- else if ( fNew )
- {
-/*
- if ( Raig_ManSimulate( pMan, nWords, nFrames, TimeOut, fVerbose ) )
- {
- if ( (pCex = pMan->pSeqModel) )
- {
- Abc_Print( 1, "Simulation of %d frames with %d words asserted output %d in frame %d. ",
- nFrames, nWords, pCex->iPo, pCex->iFrame );
- status = Saig_ManVerifyCex( pMan, pCex );
- if ( status == 0 )
- Abc_Print( 1, "Abc_NtkDarSeqSim(): Counter-example verification has FAILED.\n" );
- }
- ABC_FREE( pNtk->pModel );
- ABC_FREE( pNtk->pSeqModel );
- pNtk->pSeqModel = pCex; pMan->pSeqModel = NULL;
- RetValue = 1;
- }
- else
- {
- RetValue = 0;
- Abc_Print( 1, "Simulation of %d frames with %d words did not assert the outputs. ",
- nFrames, nWords );
- }
-*/
-/*
- Fsim_ParSim_t Pars, * pPars = &Pars;
- Fsim_ManSetDefaultParamsSim( pPars );
- pPars->nWords = nWords;
- pPars->nIters = nFrames;
- pPars->TimeLimit = TimeOut;
- pPars->fCheckMiter = fMiter;
- pPars->fVerbose = fVerbose;
- if ( Fsim_ManSimulate( pMan, pPars ) )
- {
- if ( (pCex = pMan->pSeqModel) )
- {
- Abc_Print( 1, "Simulation of %d frames with %d words asserted output %d in frame %d. ",
- nFrames, nWords, pCex->iPo, pCex->iFrame );
- status = Saig_ManVerifyCex( pMan, pCex );
- if ( status == 0 )
- Abc_Print( 1, "Abc_NtkDarSeqSim(): Counter-example verification has FAILED.\n" );
- }
- ABC_FREE( pNtk->pModel );
- ABC_FREE( pNtk->pSeqModel );
- pNtk->pSeqModel = pCex; pMan->pSeqModel = NULL;
- RetValue = 1;
- }
- else
- {
- RetValue = 0;
- Abc_Print( 1, "Simulation of %d frames with %d words did not assert the outputs. ",
- nFrames, nWords );
- }
-*/
Gia_Man_t * pGia;
Gia_ParSim_t Pars, * pPars = &Pars;
Gia_ManSimSetDefaultParams( pPars );
@@ -3133,17 +3050,27 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in
}
Gia_ManStop( pGia );
}
- else
+ else // comb/seq simulator
{
Fra_Sml_t * pSml;
- pSml = Fra_SmlSimulateSeq( pMan, 0, nFrames, nWords, fMiter );
+ if ( pFileSim != NULL )
+ {
+ assert( Abc_NtkLatchNum(pNtk) == 0 );
+ pSml = Fra_SmlSimulateCombGiven( pMan, pFileSim, fMiter, fVerbose );
+ }
+ else if ( Abc_NtkLatchNum(pNtk) == 0 )
+ pSml = Fra_SmlSimulateComb( pMan, nWords, fMiter );
+ else
+ pSml = Fra_SmlSimulateSeq( pMan, 0, nFrames, nWords, fMiter );
if ( pSml->fNonConstOut )
{
pCex = Fra_SmlGetCounterExample( pSml );
if ( pCex )
{
- Abc_Print( 1, "Simulation of %d frames with %d words asserted output %d in frame %d. ",
- nFrames, nWords, pCex->iPo, pCex->iFrame );
+ Abc_Print( 1, "Simulation of %d frame%s with %d word%s asserted output %d in frame %d. ",
+ pSml->nFrames, pSml->nFrames == 1 ? "": "s",
+ pSml->nWordsFrame, pSml->nWordsFrame == 1 ? "": "s",
+ pCex->iPo, pCex->iFrame );
status = Saig_ManVerifyCex( pMan, pCex );
if ( status == 0 )
Abc_Print( 1, "Abc_NtkDarSeqSim(): Counter-example verification has FAILED.\n" );
@@ -3159,29 +3086,6 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in
nFrames, nWords );
}
Fra_SmlStop( pSml );
-/*
- if ( Raig_ManSimulate( pMan, nWords, nFrames, TimeOut, fMiter, fVerbose ) )
- {
- if ( (pCex = pMan->pSeqModel) )
- {
- Abc_Print( 1, "Simulation of %d frames with %d words asserted output %d in frame %d. ",
- nFrames, nWords, pCex->iPo, pCex->iFrame );
- status = Saig_ManVerifyCex( pMan, pCex );
- if ( status == 0 )
- Abc_Print( 1, "Abc_NtkDarSeqSim(): Counter-example verification has FAILED.\n" );
- }
- ABC_FREE( pNtk->pModel );
- ABC_FREE( pNtk->pSeqModel );
- pNtk->pSeqModel = pCex; pMan->pSeqModel = NULL;
- RetValue = 1;
- }
- else
- {
- RetValue = 0;
- Abc_Print( 1, "Simulation of %d frames with %d words did not assert the outputs. ",
- nFrames, nWords );
- }
-*/
}
ABC_PRT( "Time", clock() - clk );
Aig_ManStop( pMan );