summaryrefslogtreecommitdiffstats
path: root/src/base/abci/abc.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2012-03-25 16:49:29 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2012-03-25 16:49:29 -0700
commitb4df114e4a84e56f9cd1b865d685852045b16937 (patch)
tree6b20f1673f1f9057523b059d8f1c0c1673c1a315 /src/base/abci/abc.c
parent309bcf2dec92b745c3ec0078691997823317c58b (diff)
downloadabc-b4df114e4a84e56f9cd1b865d685852045b16937.tar.gz
abc-b4df114e4a84e56f9cd1b865d685852045b16937.tar.bz2
abc-b4df114e4a84e56f9cd1b865d685852045b16937.zip
Logic sharing for multi-input gates.
Diffstat (limited to 'src/base/abci/abc.c')
-rw-r--r--src/base/abci/abc.c95
1 files changed, 92 insertions, 3 deletions
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index 55208cad..f8fe22a4 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.c
@@ -115,6 +115,7 @@ static int Abc_CommandRestructure ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandResubstitute ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandRr ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandCascade ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandExtract ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandLogic ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandComb ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -560,6 +561,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "Synthesis", "resub", Abc_CommandResubstitute, 1 );
// Cmd_CommandAdd( pAbc, "Synthesis", "rr", Abc_CommandRr, 1 );
Cmd_CommandAdd( pAbc, "Synthesis", "cascade", Abc_CommandCascade, 1 );
+ Cmd_CommandAdd( pAbc, "Synthesis", "extract", Abc_CommandExtract, 1 );
Cmd_CommandAdd( pAbc, "Various", "logic", Abc_CommandLogic, 1 );
Cmd_CommandAdd( pAbc, "Various", "comb", Abc_CommandComb, 1 );
@@ -2805,7 +2807,6 @@ int Abc_CommandBalance( Abc_Frame_t * pAbc, int argc, char ** argv )
int fUpdateLevel;
int fExor;
int fVerbose;
- extern Abc_Ntk_t * Abc_NtkBalanceExor( Abc_Ntk_t * pNtk, int fUpdateLevel, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
// set defaults
@@ -5381,6 +5382,88 @@ usage:
return 1;
}
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandExtract( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ extern Abc_Ntk_t * Abc_NtkShareXor( Abc_Ntk_t * pNtk, int nMultiSize, int fAnd, int fVerbose );
+ Abc_Ntk_t * pNtk, * pNtkRes;
+ int c, nMultiSize, fAnd, fVerbose;
+ pNtk = Abc_FrameReadNtk(pAbc);
+
+ // set defaults
+ nMultiSize = 3;
+ fAnd = 0;
+ fVerbose = 0;
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "Kavh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'K':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ nMultiSize = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( nMultiSize < 0 )
+ goto usage;
+ break;
+ case 'a':
+ fAnd ^= 1;
+ 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, "Can only collapse a logic network or an AIG.\n" );
+ return 1;
+ }
+ // get the new network
+ pNtkRes = Abc_NtkShareXor( pNtk, nMultiSize, fAnd, fVerbose );
+ if ( pNtkRes == NULL )
+ {
+ Abc_Print( -1, "Cascade synthesis has failed.\n" );
+ return 1;
+ }
+ // replace the current network
+ Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+ return 0;
+
+usage:
+ Abc_Print( -2, "usage: extract [-K <num>] [-vh]\n" );
+ Abc_Print( -2, "\t extracts logic sharing from multi-input XOR gates\n" );
+ Abc_Print( -2, "\t-K <num> : the min gate size to consider for extraction [default = %d]\n", nMultiSize );
+// Abc_Print( -2, "\t-a : toggle multi-input XOR vs multi-input AND [default = %s]\n", fAnd? "AND": "XOR" );
+ Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\t \n");
+ return 1;
+}
+
/**Function*************************************************************
@@ -9020,8 +9103,14 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
}
Aig_ManStop( pAig );
*/
- extern void Abc_NtkShareXor( Abc_Ntk_t * pNtk );
- Abc_NtkShareXor( pNtk );
+/*
+ extern Abc_Ntk_t * Abc_NtkShareXor( Abc_Ntk_t * pNtk );
+ Abc_Ntk_t * pNtkRes = Abc_NtkShareXor( pNtk );
+ if ( pNtkRes == NULL )
+ printf( "Transformation has failed.\n" );
+ else
+ Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+*/
}
// Abc2_NtkTestGia( "", 1 );