diff options
Diffstat (limited to 'src/base')
-rw-r--r-- | src/base/abci/abc.c | 79 | ||||
-rw-r--r-- | src/base/abci/abcDar.c | 48 |
2 files changed, 124 insertions, 3 deletions
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 1108238c..0a27ee15 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -104,6 +104,7 @@ static int Abc_CommandEspresso ( Abc_Frame_t * pAbc, int argc, char ** arg static int Abc_CommandGen ( Abc_Frame_t * pAbc, int argc, char ** argv ); //static int Abc_CommandXyz ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandDouble ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandInter ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandTest ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandQuaVar ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -281,6 +282,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "Various", "gen", Abc_CommandGen, 0 ); // Cmd_CommandAdd( pAbc, "Various", "xyz", Abc_CommandXyz, 1 ); Cmd_CommandAdd( pAbc, "Various", "double", Abc_CommandDouble, 1 ); + Cmd_CommandAdd( pAbc, "Various", "inter", Abc_CommandInter, 1 ); Cmd_CommandAdd( pAbc, "Various", "test", Abc_CommandTest, 0 ); Cmd_CommandAdd( pAbc, "Various", "qvar", Abc_CommandQuaVar, 1 ); @@ -6209,6 +6211,77 @@ usage: SeeAlso [] ***********************************************************************/ +int Abc_CommandInter( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + FILE * pOut, * pErr; + Abc_Ntk_t * pNtk, * pNtkRes, * pNtk1, * pNtk2; + char ** pArgvNew; + int nArgcNew; + int c, fDelete1, fDelete2; + int fVerbose; + extern Abc_Ntk_t * Abc_NtkInter( Abc_Ntk_t * pNtkOn, Abc_Ntk_t * pNtkOff, int fVerbose ); + + pNtk = Abc_FrameReadNtk(pAbc); + pOut = Abc_FrameReadOut(pAbc); + pErr = Abc_FrameReadErr(pAbc); + + // set defaults + fVerbose = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) + { + switch ( c ) + { + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + + pArgvNew = argv + globalUtilOptind; + nArgcNew = argc - globalUtilOptind; + if ( !Abc_NtkPrepareTwoNtks( pErr, pNtk, pArgvNew, nArgcNew, &pNtk1, &pNtk2, &fDelete1, &fDelete2 ) ) + return 1; + if ( nArgcNew == 0 ) + { + printf( "Deriving new circuit structure for the current network.\n" ); + Abc_ObjXorFaninC( Abc_NtkPo(pNtk2,0), 0 ); + } + pNtkRes = Abc_NtkInter( pNtk1, pNtk2, fVerbose ); + if ( fDelete1 ) Abc_NtkDelete( pNtk1 ); + if ( fDelete2 ) Abc_NtkDelete( pNtk2 ); + + if ( pNtkRes == NULL ) + { + fprintf( pErr, "Command has failed.\n" ); + return 0; + } + Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); + return 0; + +usage: + fprintf( pErr, "usage: inter [-vh] <fileOnSet> <fileOffSet>\n" ); + fprintf( pErr, "\t derives interpolant of two networks (onset and offset)\n" ); + fprintf( pErr, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); + fprintf( pErr, "\t-h : print the command usage\n"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ int Abc_CommandDouble( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; @@ -6311,7 +6384,7 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) extern Abc_Ntk_t * Abc_NtkDarToCnf( Abc_Ntk_t * pNtk, char * pFileName ); extern Abc_Ntk_t * Abc_NtkFilter( Abc_Ntk_t * pNtk ); // extern Abc_Ntk_t * Abc_NtkDarRetime( Abc_Ntk_t * pNtk, int nStepsMax, int fVerbose ); - extern Abc_Ntk_t * Abc_NtkPcmTest( Abc_Ntk_t * pNtk, int fVerbose ); +// extern Abc_Ntk_t * Abc_NtkPcmTest( Abc_Ntk_t * pNtk, int fVerbose ); extern Abc_NtkDarHaigRecord( Abc_Ntk_t * pNtk ); extern void Abc_NtkDarTestBlif( char * pFileName ); @@ -6464,7 +6537,7 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; } */ - +/* if ( Abc_NtkIsStrash(pNtk) ) { fprintf( stdout, "Currently only works for logic circuits.\n" ); @@ -6482,7 +6555,7 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) } // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); - +*/ // Abc_NtkDarHaigRecord( pNtk ); // Abc_NtkDarClau( pNtk, nFrames, nLevels, fBmc, fVerbose, fVeryVerbose ); diff --git a/src/base/abci/abcDar.c b/src/base/abci/abcDar.c index 439c3383..16a772ce 100644 --- a/src/base/abci/abcDar.c +++ b/src/base/abci/abcDar.c @@ -1482,6 +1482,54 @@ Abc_Ntk_t * Abc_NtkDarEnlarge( Abc_Ntk_t * pNtk, int nFrames, int fVerbose ) return pNtkAig; } +/**Function************************************************************* + + Synopsis [Interplates two networks.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Abc_Ntk_t * Abc_NtkInter( Abc_Ntk_t * pNtkOn, Abc_Ntk_t * pNtkOff, int fVerbose ) +{ + extern Aig_Man_t * Aig_ManInter( Aig_Man_t * pManOn, Aig_Man_t * pManOff, int fVerbose ); + Abc_Ntk_t * pNtkAig; + Aig_Man_t * pManOn, * pManOff, * pManAig; + if ( Abc_NtkCoNum(pNtkOn) != 1 || Abc_NtkCoNum(pNtkOff) != 1 ) + { + printf( "Currently works only for single output networks.\n" ); + return NULL; + } + if ( Abc_NtkCiNum(pNtkOn) != Abc_NtkCiNum(pNtkOff) ) + { + printf( "The number of PIs should be the same.\n" ); + return NULL; + } + // create internal AIGs + pManOn = Abc_NtkToDar( pNtkOn, 0 ); + if ( pManOn == NULL ) + return NULL; + pManOff = Abc_NtkToDar( pNtkOff, 0 ); + if ( pManOff == NULL ) + return NULL; + // derive the interpolant + pManAig = Aig_ManInter( pManOn, pManOff, fVerbose ); + if ( pManAig == NULL ) + { + printf( "Interpolant computation failed.\n" ); + return NULL; + } + Aig_ManStop( pManOn ); + Aig_ManStop( pManOff ); + // create logic network + pNtkAig = Abc_NtkFromDar( pNtkOn, pManAig ); + Aig_ManStop( pManAig ); + return pNtkAig; +} + #include "ntl.h" |