diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2011-07-21 17:55:44 +0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2011-07-21 17:55:44 +0700 |
commit | 9a2a0f2912e296e866ba220dce6ccf25018cf29b (patch) | |
tree | 54ea0dae7c4d13a67db0a7b509e738d1e50acb17 /src/base | |
parent | 515835579ede817bcab09ee67b32ff4f7acaae32 (diff) | |
download | abc-9a2a0f2912e296e866ba220dce6ccf25018cf29b.tar.gz abc-9a2a0f2912e296e866ba220dce6ccf25018cf29b.tar.bz2 abc-9a2a0f2912e296e866ba220dce6ccf25018cf29b.zip |
Changes to enable smarter simulation.
Diffstat (limited to 'src/base')
-rw-r--r-- | src/base/abci/abc.c | 153 | ||||
-rw-r--r-- | src/base/abci/abcDar.c | 46 |
2 files changed, 188 insertions, 11 deletions
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 209433df..c7bd3634 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -247,6 +247,7 @@ static int Abc_CommandSeqCleanup ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandCycle ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandXsim ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandSim ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandSim2 ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandDarPhase ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandSynch ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandClockGate ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -666,6 +667,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "Sequential", "cycle", Abc_CommandCycle, 1 ); Cmd_CommandAdd( pAbc, "Sequential", "xsim", Abc_CommandXsim, 0 ); Cmd_CommandAdd( pAbc, "Sequential", "sim", Abc_CommandSim, 0 ); + Cmd_CommandAdd( pAbc, "Sequential", "sim2", Abc_CommandSim2, 0 ); Cmd_CommandAdd( pAbc, "Sequential", "phase", Abc_CommandDarPhase, 1 ); Cmd_CommandAdd( pAbc, "Sequential", "synch", Abc_CommandSynch, 1 ); Cmd_CommandAdd( pAbc, "Sequential", "clockgate", Abc_CommandClockGate, 1 ); @@ -15764,6 +15766,135 @@ usage: return 1; } + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandSim2( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc); + int c; + int nFrames; + int nWords; + int nBinSize; + int nRounds; + int TimeOut; + int fVerbose; + extern int Abc_NtkDarSeqSim2( Abc_Ntk_t * pNtk, int nFrames, int nWords, int nBinSize, int nRounds, int TimeOut, int fVerbose ); + // set defaults + nFrames = 20; + nWords = 50; + nBinSize = 8; + nRounds = 80; + TimeOut = 0; + fVerbose = 1; + // parse command line + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "FWBRTvh" ) ) != EOF ) + { + switch ( c ) + { + case 'F': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" ); + goto usage; + } + nFrames = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nFrames < 0 ) + goto usage; + break; + case 'W': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" ); + goto usage; + } + nWords = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nWords < 0 ) + goto usage; + break; + case 'B': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-B\" should be followed by an integer.\n" ); + goto usage; + } + nBinSize = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nBinSize < 0 ) + goto usage; + break; + case 'R': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" ); + goto usage; + } + nRounds = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nRounds < 0 ) + goto usage; + break; + case 'T': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" ); + goto usage; + } + TimeOut = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( TimeOut < 0 ) + goto usage; + break; + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pNtk == NULL ) + { + Abc_Print( -1, "Empty network.\n" ); + return 1; + } + if ( !Abc_NtkIsStrash(pNtk) ) + { + Abc_Print( -1, "Only works for strashed networks.\n" ); + return 1; + } + ABC_FREE( pNtk->pSeqModel ); + pAbc->Status = Abc_NtkDarSeqSim2( pNtk, nFrames, nWords, nBinSize, nRounds, TimeOut, fVerbose ); + Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel ); + return 0; + +usage: + Abc_Print( -2, "usage: sim2 [-FWBRT num] [-vh]\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-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-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-h : print the command usage\n"); + return 1; +} + + /**Function************************************************************* Synopsis [] @@ -24632,30 +24763,30 @@ int Abc_CommandAbc9Sim( Abc_Frame_t * pAbc, int argc, char ** argv ) int c; Gia_ManSimSetDefaultParams( pPars ); Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "WFRTmvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "FWRTmvh" ) ) != EOF ) { switch ( c ) { - case 'W': + case 'F': if ( globalUtilOptind >= argc ) { - Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" ); + Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" ); goto usage; } - pPars->nWords = atoi(argv[globalUtilOptind]); + pPars->nIters = atoi(argv[globalUtilOptind]); globalUtilOptind++; - if ( pPars->nWords < 0 ) + if ( pPars->nIters < 0 ) goto usage; break; - case 'F': + case 'W': if ( globalUtilOptind >= argc ) { - Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" ); + Abc_Print( -1, "Command line switch \"-W\" should be followed by an integer.\n" ); goto usage; } - pPars->nIters = atoi(argv[globalUtilOptind]); + pPars->nWords = atoi(argv[globalUtilOptind]); globalUtilOptind++; - if ( pPars->nIters < 0 ) + if ( pPars->nWords < 0 ) goto usage; break; case 'R': @@ -24713,11 +24844,11 @@ int Abc_CommandAbc9Sim( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: &sim [-WFRT num] [-mvh]\n" ); + Abc_Print( -2, "usage: &sim [-FWRT num] [-mvh]\n" ); Abc_Print( -2, "\t performs random simulation of the sequential miter\n" ); Abc_Print( -2, "\t (if candidate equivalences are defined, performs refinement)\n" ); - Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n", pPars->nWords ); Abc_Print( -2, "\t-F num : the number of frames to simulate [default = %d]\n", pPars->nIters ); + Abc_Print( -2, "\t-W num : the number of words to simulate [default = %d]\n", pPars->nWords ); Abc_Print( -2, "\t-R num : random number seed (1 <= num <= 10000) [default = %d]\n", pPars->RandSeed ); Abc_Print( -2, "\t-T num : approximate runtime limit in seconds [default = %d]\n", pPars->TimeLimit ); Abc_Print( -2, "\t-m : toggle miter vs. any circuit [default = %s]\n", pPars->fCheckMiter? "miter": "circuit" ); diff --git a/src/base/abci/abcDar.c b/src/base/abci/abcDar.c index 97ee8c42..ff8aac38 100644 --- a/src/base/abci/abcDar.c +++ b/src/base/abci/abcDar.c @@ -3009,6 +3009,52 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in /**Function************************************************************* + Synopsis [Performs random simulation.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_NtkDarSeqSim2( Abc_Ntk_t * pNtk, int nFrames, int nWords, int nBinSize, int nRounds, int TimeOut, int fVerbose ) +{ + Aig_Man_t * pMan; + int status, RetValue = -1, clk = clock(); + if ( Abc_NtkGetChoiceNum(pNtk) ) + { + printf( "Removing %d choices from the AIG.\n", Abc_NtkGetChoiceNum(pNtk) ); + Abc_AigCleanup((Abc_Aig_t *)pNtk->pManFunc); + } + pMan = Abc_NtkToDar( pNtk, 0, 1 ); + if ( Ssw_RarSimulate( pMan, nFrames, nWords, nBinSize, nRounds, TimeOut, fVerbose ) ) + { + if ( pMan->pSeqModel ) + { + printf( "Simulation of %d frames with %d words asserted output %d in frame %d. ", + nFrames, nWords, pMan->pSeqModel->iPo, pMan->pSeqModel->iFrame ); + status = Saig_ManVerifyCex( pMan, pMan->pSeqModel ); + if ( status == 0 ) + printf( "Abc_NtkDarSeqSim(): Counter-example verification has FAILED.\n" ); + } + ABC_FREE( pNtk->pModel ); + ABC_FREE( pNtk->pSeqModel ); + pNtk->pSeqModel = pMan->pSeqModel; pMan->pSeqModel = NULL; + RetValue = 0; + } + else + { + printf( "Simulation of %d frames with %d words did not assert the outputs. ", + nFrames, nWords ); + } + ABC_PRT( "Time", clock() - clk ); + Aig_ManStop( pMan ); + return RetValue; +} + +/**Function************************************************************* + Synopsis [Gives the current ABC network to AIG manager for processing.] Description [] |