diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2014-10-21 10:51:41 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2014-10-21 10:51:41 -0700 |
commit | 7592aa8a3e4bce6a28fddeea87e90cd3f2fb02a6 (patch) | |
tree | 4744f12a5db70912d64790bb85a7eea273b5521f /src | |
parent | 83bc1148a2c0a96e60de7d65f85f3edce9029254 (diff) | |
download | abc-7592aa8a3e4bce6a28fddeea87e90cd3f2fb02a6.tar.gz abc-7592aa8a3e4bce6a28fddeea87e90cd3f2fb02a6.tar.bz2 abc-7592aa8a3e4bce6a28fddeea87e90cd3f2fb02a6.zip |
Adding commands backup/restore.
Diffstat (limited to 'src')
-rw-r--r-- | src/base/abci/abc.c | 82 | ||||
-rw-r--r-- | src/base/main/mainFrame.c | 1 | ||||
-rw-r--r-- | src/base/main/mainInt.h | 1 |
3 files changed, 84 insertions, 0 deletions
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 55c523c1..7fa843a5 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -187,6 +187,9 @@ static int Abc_CommandNpnSave ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandSendAig ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandSendStatus ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandBackup ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandRestore ( Abc_Frame_t * pAbc, int argc, char ** argv ); + static int Abc_CommandIStrash ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandICut ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandIRewrite ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -785,6 +788,9 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "Various", "send_aig", Abc_CommandSendAig, 0 ); Cmd_CommandAdd( pAbc, "Various", "send_status", Abc_CommandSendStatus, 0 ); + Cmd_CommandAdd( pAbc, "Various", "backup", Abc_CommandBackup, 0 ); + Cmd_CommandAdd( pAbc, "Various", "restore", Abc_CommandRestore, 0 ); + Cmd_CommandAdd( pAbc, "New AIG", "istrash", Abc_CommandIStrash, 1 ); Cmd_CommandAdd( pAbc, "New AIG", "icut", Abc_CommandICut, 0 ); Cmd_CommandAdd( pAbc, "New AIG", "irw", Abc_CommandIRewrite, 1 ); @@ -13178,6 +13184,82 @@ usage: SeeAlso [] ***********************************************************************/ +int Abc_CommandBackup( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc); + int c; + // set defaults + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + { + switch ( c ) + { + case 'h': + goto usage; + default: + goto usage; + } + } + + if ( pNtk == NULL ) + { + Abc_Print( -1, "Empty network.\n" ); + return 1; + } + if ( pAbc->pNtkBackup ) + Abc_NtkDelete( pAbc->pNtkBackup ); + pAbc->pNtkBackup = Abc_NtkDup( pNtk ); + return 0; + +usage: + Abc_Print( -2, "usage: backup [-h]\n" ); + Abc_Print( -2, "\t backs up the current network\n" ); + Abc_Print( -2, "\t-h : print the command usage\n"); + return 1; +} +int Abc_CommandRestore( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + int c; + // set defaults + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + { + switch ( c ) + { + case 'h': + goto usage; + default: + goto usage; + } + } + + if ( pAbc->pNtkBackup == NULL ) + { + Abc_Print( -1, "There is no backup network.\n" ); + return 1; + } + Abc_FrameReplaceCurrentNetwork( pAbc, Abc_NtkDup(pAbc->pNtkBackup) ); + return 0; + +usage: + Abc_Print( -2, "usage: restore [-h]\n" ); + Abc_Print( -2, "\t restores the current network\n" ); + Abc_Print( -2, "\t-h : print the command usage\n"); + return 1; +} + + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ int Abc_CommandFraig( Abc_Frame_t * pAbc, int argc, char ** argv ) { char Buffer[100]; diff --git a/src/base/main/mainFrame.c b/src/base/main/mainFrame.c index 06159427..42a1da81 100644 --- a/src/base/main/mainFrame.c +++ b/src/base/main/mainFrame.c @@ -198,6 +198,7 @@ void Abc_FrameDeallocate( Abc_Frame_t * p ) if ( p->pSave4 ) Aig_ManStop( (Aig_Man_t *)p->pSave4 ); if ( p->pManDsd ) If_DsdManFree( (If_DsdMan_t *)p->pManDsd, 0 ); if ( p->pManDsd2 ) If_DsdManFree( (If_DsdMan_t *)p->pManDsd2, 0 ); + if ( p->pNtkBackup) Abc_NtkDelete( p->pNtkBackup ); if ( p->vPlugInComBinPairs ) { char * pTemp; diff --git a/src/base/main/mainInt.h b/src/base/main/mainInt.h index 9d67b2d7..8bccc632 100644 --- a/src/base/main/mainInt.h +++ b/src/base/main/mainInt.h @@ -68,6 +68,7 @@ struct Abc_Frame_t_ Abc_Ntk_t * pNtkCur; // the current network Abc_Ntk_t * pNtkBestDelay; // the current network Abc_Ntk_t * pNtkBestArea; // the current network + Abc_Ntk_t * pNtkBackup; // the current network int nSteps; // the counter of different network processed int fSource; // marks the source mode int fAutoexac; // marks the autoexec mode |