summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2019-04-17 17:38:22 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2019-04-17 17:38:22 -0700
commitbe3a8c398087493adb5510c94807706e3a07a288 (patch)
treef3bf1f063b20aa8fc0ecff4a70f8bd5434fd9f7e
parent3e9bc99e2451104886f9f7f2fd92b83d0eece98d (diff)
downloadabc-be3a8c398087493adb5510c94807706e3a07a288.tar.gz
abc-be3a8c398087493adb5510c94807706e3a07a288.tar.bz2
abc-be3a8c398087493adb5510c94807706e3a07a288.zip
Enabling dumping of the library of minimum circuits.
-rw-r--r--src/base/abci/abc.c24
-rw-r--r--src/opt/dau/dauNpn2.c12
2 files changed, 24 insertions, 12 deletions
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index 6461d4f4..08c9ca49 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.c
@@ -23230,11 +23230,12 @@ usage:
***********************************************************************/
int Abc_CommandFunEnum( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- extern void Dtt_EnumerateLf( int nVars, int nNodeMax, int fDelay, int fMulti, int fVerbose );
+ extern void Dtt_EnumerateLf( int nVars, int nNodeMax, int fDelay, int fMulti, int fVerbose, char* pFileName );
extern void Dau_FunctionEnum( int nInputs, int nVars, int nNodeMax, int fUseTwo, int fReduce, int fVerbose );
- int c, nInputs = 4, nVars = 4, nNodeMax = 32, fUseTwo = 0, fReduce = 0, fSimple = 0, fDelay = 0, fMulti = 0, fVerbose = 0;
+ extern Gia_Man_t * Dau_ConstructAigFromFile( char * pFileName );
+ int c, nInputs = 4, nVars = 4, nNodeMax = 32, fUseTwo = 0, fReduce = 0, fSimple = 0, fDelay = 0, fMulti = 0, fDump = 0, fVerbose = 0;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "SIMtrldmvh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "SIMtrldmpvh" ) ) != EOF )
{
switch ( c )
{
@@ -23286,6 +23287,9 @@ int Abc_CommandFunEnum( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'm':
fMulti ^= 1;
break;
+ case 'p':
+ fDump ^= 1;
+ break;
case 'v':
fVerbose ^= 1;
break;
@@ -23298,12 +23302,21 @@ int Abc_CommandFunEnum( Abc_Frame_t * pAbc, int argc, char ** argv )
}
if ( fSimple || fDelay )
{
+ char Buffer[100];
if ( nVars < 3 || nVars > 5 )
{
Abc_Print( -1, "The number of inputs should be 3 <= I <= 5.\n" );
goto usage;
}
- Dtt_EnumerateLf( nVars, nNodeMax, fDelay, fMulti, fVerbose );
+ sprintf( Buffer, "Lflib%d.txt", nVars );
+ Dtt_EnumerateLf( nVars, nNodeMax, fDelay, fMulti, fVerbose, fDump?Buffer:NULL );
+ if ( fDump )
+ {
+ Gia_Man_t * pTemp;
+ pTemp = Dau_ConstructAigFromFile( Buffer );
+ Abc_FrameUpdateGia( pAbc, pTemp );
+ Gia_DumpAiger( pTemp, "Lflib", nVars, 1 );
+ }
}
else
{
@@ -23322,7 +23335,7 @@ int Abc_CommandFunEnum( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0;
usage:
- Abc_Print( -2, "usage: funenum [-SIM num] [-trldmvh]\n" );
+ Abc_Print( -2, "usage: funenum [-SIM num] [-trldmvph]\n" );
Abc_Print( -2, "\t enumerates minimum 2-input-gate implementations\n" );
Abc_Print( -2, "\t-S num : the maximum intermediate support size [default = %d]\n", nInputs );
Abc_Print( -2, "\t-I num : the number of inputs of Boolean functions [default = %d]\n", nVars );
@@ -23333,6 +23346,7 @@ usage:
Abc_Print( -2, "\t-d : toggle generating D(f) rather than C(f) [default = %s]\n", fDelay? "yes": "no" );
Abc_Print( -2, "\t-m : toggle generating multiplicity statistics [default = %s]\n", fMulti? "yes": "no" );
Abc_Print( -2, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
+ Abc_Print( -2, "\t-p : toggle dumping result library (formula and AIG) [default = %s]\n",fDump?"yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
diff --git a/src/opt/dau/dauNpn2.c b/src/opt/dau/dauNpn2.c
index d5fdd1c7..7bf5e099 100644
--- a/src/opt/dau/dauNpn2.c
+++ b/src/opt/dau/dauNpn2.c
@@ -916,10 +916,10 @@ void Dtt_FindNP( Dtt_Man_t * p, unsigned tFun, unsigned tGoal, unsigned tNpn, in
assert(0);
}
-void Dtt_DumpLibrary( Dtt_Man_t * p )
+void Dtt_DumpLibrary( Dtt_Man_t * p, char* FileName )
{
FILE * pFile;
- char FileName[100], str[100], sFI1[50], sFI2[50];
+ char str[100], sFI1[50], sFI2[50];
int i, j, Entry, fRepeat;
Dtt_FunImpl_t * pFun, * pFun2;
Vec_Int_t * vLibFun = Vec_IntDup( p->vTruthNpns ); // none-duplicating vector of NPN representitives
@@ -962,7 +962,6 @@ void Dtt_DumpLibrary( Dtt_Man_t * p )
}
// print to file
- sprintf( FileName, "lib%dvar.txt", p->nVars );
pFile = fopen( FileName, "wb" );
if (0)
@@ -996,9 +995,8 @@ void Dtt_DumpLibrary( Dtt_Man_t * p )
fflush( stdout );
}
-void Dtt_EnumerateLf( int nVars, int nNodeMax, int fDelay, int fMulti, int fVerbose )
+void Dtt_EnumerateLf( int nVars, int nNodeMax, int fDelay, int fMulti, int fVerbose, char* pFileName )
{
- int fDump = 1;
abctime clk = Abc_Clock(); word nSteps = 0, nMultis = 0;
Dtt_Man_t * p = Dtt_ManAlloc( nVars, fMulti ); int n, i, j;
@@ -1068,8 +1066,8 @@ void Dtt_EnumerateLf( int nVars, int nNodeMax, int fDelay, int fMulti, int fVerb
Dtt_PrintDistrib( p );
//if ( p->pTable )
//Dtt_PrintMulti( p );
- if ( !fDelay && fDump )
- Dtt_DumpLibrary( p );
+ if ( !fDelay && pFileName!=NULL )
+ Dtt_DumpLibrary( p, pFileName );
Dtt_ManFree( p );
}