summaryrefslogtreecommitdiffstats
path: root/src/base/abci
diff options
context:
space:
mode:
Diffstat (limited to 'src/base/abci')
-rw-r--r--src/base/abci/abc.c13
-rw-r--r--src/base/abci/abcDec.c12
-rw-r--r--src/base/abci/abcNpn.c15
3 files changed, 25 insertions, 15 deletions
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index 1b935fbd..b49a9ea0 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.c
@@ -4846,15 +4846,16 @@ usage:
***********************************************************************/
int Abc_CommandTestNpn( Abc_Frame_t * pAbc, int argc, char ** argv )
{
- extern int Abc_NpnTest( char * pFileName, int NpnType, int nVarNum, int fDumpRes, int fVerbose );
+ extern int Abc_NpnTest( char * pFileName, int NpnType, int nVarNum, int fDumpRes, int fBinary, int fVerbose );
char * pFileName;
int c;
int fVerbose = 0;
int NpnType = 0;
int nVarNum = -1;
int fDumpRes = 0;
+ int fBinary = 0;
Extra_UtilGetoptReset();
- while ( ( c = Extra_UtilGetopt( argc, argv, "ANdvh" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "ANdbvh" ) ) != EOF )
{
switch ( c )
{
@@ -4883,6 +4884,9 @@ int Abc_CommandTestNpn( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'd':
fDumpRes ^= 1;
break;
+ case 'b':
+ fBinary ^= 1;
+ break;
case 'v':
fVerbose ^= 1;
break;
@@ -4905,11 +4909,11 @@ int Abc_CommandTestNpn( Abc_Frame_t * pAbc, int argc, char ** argv )
// get the output file name
pFileName = argv[globalUtilOptind];
// call the testbench
- Abc_NpnTest( pFileName, NpnType, nVarNum, fDumpRes, fVerbose );
+ Abc_NpnTest( pFileName, NpnType, nVarNum, fDumpRes, fBinary, fVerbose );
return 0;
usage:
- Abc_Print( -2, "usage: testnpn [-AN <num>] [-dvh] <file>\n" );
+ Abc_Print( -2, "usage: testnpn [-AN <num>] [-dbvh] <file>\n" );
Abc_Print( -2, "\t testbench for computing (semi-)canonical forms\n" );
Abc_Print( -2, "\t of completely-specified Boolean functions up to 16 varibles\n" );
Abc_Print( -2, "\t-A <num> : semi-caninical form computation algorithm [default = %d]\n", NpnType );
@@ -4920,6 +4924,7 @@ usage:
Abc_Print( -2, "\t 4: Jake's hybrid semi-canonical form (high-effort)\n" );
Abc_Print( -2, "\t-N <num> : the number of support variables (binary files only) [default = unused]\n" );
Abc_Print( -2, "\t-d : toggle dumping resulting functions into a file [default = %s]\n", fDumpRes? "yes": "no" );
+ Abc_Print( -2, "\t-b : toggle dumping in binary format [default = %s]\n", fBinary? "yes": "no" );
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<file> : a text file with truth tables in hexadecimal, listed one per line,\n");
diff --git a/src/base/abci/abcDec.c b/src/base/abci/abcDec.c
index 309c6a50..776ecda1 100644
--- a/src/base/abci/abcDec.c
+++ b/src/base/abci/abcDec.c
@@ -353,10 +353,10 @@ void Abc_TruthStoreRead( char * pFileName, Abc_TtStore_t * p )
SeeAlso []
***********************************************************************/
-void Abc_TtStoreWrite( char * pFileName, Abc_TtStore_t * p )
+void Abc_TtStoreWrite( char * pFileName, Abc_TtStore_t * p, int fBinary )
{
FILE * pFile;
- int i;
+ int i, nBytes = 8 * Abc_Truth6WordNum( p->nVars );
pFile = fopen( pFileName, "wb" );
if ( pFile == NULL )
{
@@ -365,8 +365,10 @@ void Abc_TtStoreWrite( char * pFileName, Abc_TtStore_t * p )
}
for ( i = 0; i < p->nFuncs; i++ )
{
- Abc_TruthWriteHex( pFile, p->pFuncs[i], p->nVars );
- fprintf( pFile, "\n" );
+ if ( fBinary )
+ fwrite( p->pFuncs[i], nBytes, 1, pFile );
+ else
+ Abc_TruthWriteHex( pFile, p->pFuncs[i], p->nVars ), fprintf( pFile, "\n" );
}
fclose( pFile );
}
@@ -441,7 +443,7 @@ void Abc_TtStoreTest( char * pFileName )
return;
// write into another file
- Abc_TtStoreWrite( pFileOutput, p );
+ Abc_TtStoreWrite( pFileOutput, p, 0 );
// delete data-structure
Abc_TtStoreFree( p, -1 );
diff --git a/src/base/abci/abcNpn.c b/src/base/abci/abcNpn.c
index 9494cba2..0e3f41f9 100644
--- a/src/base/abci/abcNpn.c
+++ b/src/base/abci/abcNpn.c
@@ -49,7 +49,7 @@ struct Abc_TtStore_t_
extern Abc_TtStore_t * Abc_TtStoreLoad( char * pFileName, int nVarNum );
extern void Abc_TtStoreFree( Abc_TtStore_t * p, int nVarNum );
-extern void Abc_TtStoreWrite( char * pFileName, Abc_TtStore_t * p );
+extern void Abc_TtStoreWrite( char * pFileName, Abc_TtStore_t * p, int fBinary );
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -276,7 +276,7 @@ void Abc_TruthNpnPerform( Abc_TtStore_t * p, int NpnType, int fVerbose )
SeeAlso []
***********************************************************************/
-void Abc_TruthNpnTest( char * pFileName, int NpnType, int nVarNum, int fDumpRes, int fVerbose )
+void Abc_TruthNpnTest( char * pFileName, int NpnType, int nVarNum, int fDumpRes, int fBinary, int fVerbose )
{
Abc_TtStore_t * p;
char * pFileNameOut;
@@ -292,8 +292,11 @@ void Abc_TruthNpnTest( char * pFileName, int NpnType, int nVarNum, int fDumpRes,
// write the result
if ( fDumpRes )
{
- pFileNameOut = Extra_FileNameGenericAppend( pFileName, "_out.txt" );
- Abc_TtStoreWrite( pFileNameOut, p );
+ if ( fBinary )
+ pFileNameOut = Extra_FileNameGenericAppend( pFileName, "_out.tt" );
+ else
+ pFileNameOut = Extra_FileNameGenericAppend( pFileName, "_out.txt" );
+ Abc_TtStoreWrite( pFileNameOut, p, fBinary );
if ( fVerbose )
printf( "The resulting functions are written into file \"%s\".\n", pFileNameOut );
}
@@ -315,12 +318,12 @@ void Abc_TruthNpnTest( char * pFileName, int NpnType, int nVarNum, int fDumpRes,
SeeAlso []
***********************************************************************/
-int Abc_NpnTest( char * pFileName, int NpnType, int nVarNum, int fDumpRes, int fVerbose )
+int Abc_NpnTest( char * pFileName, int NpnType, int nVarNum, int fDumpRes, int fBinary, int fVerbose )
{
if ( fVerbose )
printf( "Using truth tables from file \"%s\"...\n", pFileName );
if ( NpnType >= 0 && NpnType <= 4 )
- Abc_TruthNpnTest( pFileName, NpnType, nVarNum, fDumpRes, fVerbose );
+ Abc_TruthNpnTest( pFileName, NpnType, nVarNum, fDumpRes, fBinary, fVerbose );
else
printf( "Unknown canonical form value (%d).\n", NpnType );
fflush( stdout );