From 41fa9a1016d27bd6385e5b49969394d75bba99fd Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 8 Aug 2012 01:42:14 -0700 Subject: New command 'testnpn' to compare semi-canonical forms. --- src/base/abci/abc.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'src/base/abci/abc.c') diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 7461f443..dede6c51 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -109,6 +109,7 @@ static int Abc_CommandPowerdown ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandAddBuffs ( Abc_Frame_t * pAbc, int argc, char ** argv ); //static int Abc_CommandMerge ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandTestDec ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandTestNpn ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandRewrite ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandRefactor ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -571,6 +572,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "Synthesis", "addbuffs", Abc_CommandAddBuffs, 1 ); // Cmd_CommandAdd( pAbc, "Synthesis", "merge", Abc_CommandMerge, 1 ); Cmd_CommandAdd( pAbc, "Synthesis", "testdec", Abc_CommandTestDec, 0 ); + Cmd_CommandAdd( pAbc, "Synthesis", "testnpn", Abc_CommandTestNpn, 0 ); Cmd_CommandAdd( pAbc, "Synthesis", "rewrite", Abc_CommandRewrite, 1 ); Cmd_CommandAdd( pAbc, "Synthesis", "refactor", Abc_CommandRefactor, 1 ); @@ -4865,6 +4867,73 @@ usage: return 1; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandTestNpn( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern int Abc_NpnTest( char * pFileName, int NpnType, int fVerbose ); + char * pFileName; + int c; + int fVerbose = 0; + int NpnType = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "Avh" ) ) != EOF ) + { + switch ( c ) + { + case 'A': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-A\" should be followed by an integer.\n" ); + goto usage; + } + NpnType = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( NpnType < 0 ) + goto usage; + break; + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + if ( argc != globalUtilOptind + 1 ) + { + printf( "Input file is not given.\n" ); + goto usage; + } + // get the output file name + pFileName = argv[globalUtilOptind]; + // call the testbench + Abc_NpnTest( pFileName, NpnType, fVerbose ); + return 0; + +usage: + Abc_Print( -2, "usage: testnpn [-A ] [-vh] \n" ); + Abc_Print( -2, "\t testbench for computing semi-canonical forms of Boolean functions\n" ); + Abc_Print( -2, "\t-A : semi-caninical form computation algorithm [default = %d]\n", NpnType ); + Abc_Print( -2, "\t 0: none (reading and writing the file)\n" ); + Abc_Print( -2, "\t 1: semi-canonical form by counting 1s in cofactors\n" ); + Abc_Print( -2, "\t 2: semi-canonical form by minimizing truth table value\n" ); + Abc_Print( -2, "\t 3: exact canonical form (slow for more than 6 variables)\n" ); + Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" ); + Abc_Print( -2, "\t-h : print the command usage\n"); + return 1; +} + /**Function************************************************************* -- cgit v1.2.3