summaryrefslogtreecommitdiffstats
path: root/src/base/abci/abc.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2015-09-04 11:52:27 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2015-09-04 11:52:27 -0700
commita207f6c07117fc577076f924984a0cbad1c0b0b0 (patch)
treefe67f782b9d8664befb6d18595f94cdd94da58ff /src/base/abci/abc.c
parent1ffd9aad766b3d980b8d8a030d03e8f17371f673 (diff)
downloadabc-a207f6c07117fc577076f924984a0cbad1c0b0b0.tar.gz
abc-a207f6c07117fc577076f924984a0cbad1c0b0b0.tar.bz2
abc-a207f6c07117fc577076f924984a0cbad1c0b0b0.zip
Experiments with SAT-based collapsing.
Diffstat (limited to 'src/base/abci/abc.c')
-rw-r--r--src/base/abci/abc.c135
1 files changed, 124 insertions, 11 deletions
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index 83077cb8..1482dc8c 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.c
@@ -95,6 +95,7 @@ static int Abc_CommandShowBdd ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandShowCut ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandCollapse ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandSatClp ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandStrash ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandBalance ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandMuxStruct ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -714,6 +715,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "Printing", "show_cut", Abc_CommandShowCut, 0 );
Cmd_CommandAdd( pAbc, "Synthesis", "collapse", Abc_CommandCollapse, 1 );
+ Cmd_CommandAdd( pAbc, "Synthesis", "satclp", Abc_CommandSatClp, 1 );
Cmd_CommandAdd( pAbc, "Synthesis", "strash", Abc_CommandStrash, 1 );
Cmd_CommandAdd( pAbc, "Synthesis", "balance", Abc_CommandBalance, 1 );
Cmd_CommandAdd( pAbc, "Synthesis", "mux_struct", Abc_CommandMuxStruct, 1 );
@@ -3079,6 +3081,108 @@ usage:
SeeAlso []
***********************************************************************/
+int Abc_CommandSatClp( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc), * pNtkRes;
+ int nCubeLim = 1000;
+ int nBTLimit = 1000000;
+ int fCanon = 0;
+ int fVerbose = 0;
+ int c;
+
+ // set defaults
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "CLcvh" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'C':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ nCubeLim = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( nCubeLim < 0 )
+ goto usage;
+ break;
+ case 'L':
+ if ( globalUtilOptind >= argc )
+ {
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+ goto usage;
+ }
+ nBTLimit = atoi(argv[globalUtilOptind]);
+ globalUtilOptind++;
+ if ( nBTLimit < 0 )
+ goto usage;
+ break;
+ case 'c':
+ fCanon ^= 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_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) )
+ {
+ Abc_Print( -1, "Can only collapse a logic network or an AIG.\n" );
+ return 1;
+ }
+
+ // get the new network
+ if ( Abc_NtkIsStrash(pNtk) )
+ pNtkRes = Abc_NtkCollapseSat( pNtk, nCubeLim, nBTLimit, fCanon, fVerbose );
+ else
+ {
+ pNtk = Abc_NtkStrash( pNtk, 0, 0, 0 );
+ pNtkRes = Abc_NtkCollapseSat( pNtk, nCubeLim, nBTLimit, fCanon, fVerbose );
+ Abc_NtkDelete( pNtk );
+ }
+ if ( pNtkRes == NULL )
+ {
+ Abc_Print( -1, "Collapsing has failed.\n" );
+ return 1;
+ }
+ // replace the current network
+ Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
+ return 0;
+
+usage:
+ Abc_Print( -2, "usage: satclp [-CL num] [-cvh]\n" );
+ Abc_Print( -2, "\t performs SAT based collapsing\n" );
+ Abc_Print( -2, "\t-C num : the limit on the SOP size of one output [default = %d]\n", nCubeLim );
+ Abc_Print( -2, "\t-L num : the limit on the number of conflicts in one SAT call [default = %d]\n", nBTLimit );
+ Abc_Print( -2, "\t-c : toggles using canonical ISOP computation [default = %s]\n", fCanon? "yes": "no" );
+ Abc_Print( -2, "\t-v : toggles printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
int Abc_CommandStrash( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk, * pNtkRes;
@@ -37135,19 +37239,23 @@ usage:
***********************************************************************/
int Abc_CommandAbc9SatClp( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- extern int Bmc_CollapseOne( Gia_Man_t * p, int nCubeLim, int nBTLimit, int fVerbose );
+ extern Vec_Str_t * Bmc_CollapseOne( Gia_Man_t * p, int nCubeLim, int nBTLimit, int fCanon, int fVerbose );
int nCubeLim = 1000;
int nBTLimit = 1000000;
- int c, fVerbose = 0;
+ int fCanon = 0;
+ int fVerbose = 0;
+ int c;
+
+ Vec_Str_t * vSop;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "LCvh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "CLcvh" ) ) != EOF )
{
switch ( c )
{
- case 'L':
+ case 'C':
if ( globalUtilOptind >= argc )
{
- Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nCubeLim = atoi(argv[globalUtilOptind]);
@@ -37155,10 +37263,10 @@ int Abc_CommandAbc9SatClp( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( nCubeLim < 0 )
goto usage;
break;
- case 'C':
+ case 'L':
if ( globalUtilOptind >= argc )
{
- Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" );
+ Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage;
}
nBTLimit = atoi(argv[globalUtilOptind]);
@@ -37166,6 +37274,9 @@ int Abc_CommandAbc9SatClp( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( nBTLimit < 0 )
goto usage;
break;
+ case 'c':
+ fCanon ^= 1;
+ break;
case 'v':
fVerbose ^= 1;
break;
@@ -37180,14 +37291,16 @@ int Abc_CommandAbc9SatClp( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Abc_CommandAbc9SatClp(): There is no AIG.\n" );
return 0;
}
- Bmc_CollapseOne( pAbc->pGia, nCubeLim, nBTLimit, fVerbose );
+ vSop = Bmc_CollapseOne( pAbc->pGia, nCubeLim, nBTLimit, fCanon, fVerbose );
+ Vec_StrFree( vSop );
return 0;
usage:
- Abc_Print( -2, "usage: &satclp [-LC num] [-vh]\n" );
+ Abc_Print( -2, "usage: &satclp [-CL num] [-cvh]\n" );
Abc_Print( -2, "\t performs SAT based collapsing\n" );
- Abc_Print( -2, "\t-L num : the limit on the SOP size of one output [default = %d]\n", nCubeLim );
- Abc_Print( -2, "\t-C num : the limit on the number of conflicts in one call [default = %d]\n", nBTLimit );
+ Abc_Print( -2, "\t-C num : the limit on the SOP size of one output [default = %d]\n", nCubeLim );
+ Abc_Print( -2, "\t-L num : the limit on the number of conflicts in one SAT call [default = %d]\n", nBTLimit );
+ Abc_Print( -2, "\t-c : toggles using canonical ISOP computation [default = %s]\n", fCanon? "yes": "no" );
Abc_Print( -2, "\t-v : toggles printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n");
return 1;