diff options
Diffstat (limited to 'src/base/io/io.c')
-rw-r--r-- | src/base/io/io.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/src/base/io/io.c b/src/base/io/io.c index b7c3234c..466a563a 100644 --- a/src/base/io/io.c +++ b/src/base/io/io.c @@ -1654,9 +1654,10 @@ int IoCommandWriteBlif( Abc_Frame_t * pAbc, int argc, char **argv ) char * pFileName; char * pLutStruct = NULL; int c, fSpecial = 0; + int fUseHie = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "Sjh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "Sjah" ) ) != EOF ) { switch ( c ) { @@ -1677,6 +1678,9 @@ int IoCommandWriteBlif( Abc_Frame_t * pAbc, int argc, char **argv ) case 'j': fSpecial ^= 1; break; + case 'a': + fUseHie ^= 1; + break; case 'h': goto usage; default: @@ -1694,16 +1698,17 @@ int IoCommandWriteBlif( Abc_Frame_t * pAbc, int argc, char **argv ) pFileName = argv[globalUtilOptind]; // call the corresponding file writer if ( fSpecial || pLutStruct ) - Io_WriteBlifSpecial( pAbc->pNtkCur, pFileName, pLutStruct ); + Io_WriteBlifSpecial( pAbc->pNtkCur, pFileName, pLutStruct, fUseHie ); else Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_BLIF ); return 0; usage: - fprintf( pAbc->Err, "usage: write_blif [-S str] [-jh] <file>\n" ); + fprintf( pAbc->Err, "usage: write_blif [-S str] [-jah] <file>\n" ); fprintf( pAbc->Err, "\t writes the network into a BLIF file\n" ); fprintf( pAbc->Err, "\t-S str : string representing the LUT structure [default = %s]\n", pLutStruct ? pLutStruct : "not used" ); fprintf( pAbc->Err, "\t-j : enables special BLIF writing [default = %s]\n", fSpecial? "yes" : "no" );; + fprintf( pAbc->Err, "\t-a : enables hierarchical BLIF writing for LUT structures [default = %s]\n", fUseHie? "yes" : "no" );; fprintf( pAbc->Err, "\t-h : print the help massage\n" ); fprintf( pAbc->Err, "\tfile : the name of the file to write (extension .blif)\n" ); return 1; @@ -2734,17 +2739,22 @@ int IoCommandWriteTruths( Abc_Frame_t * pAbc, int argc, char **argv ) char * pFileName; FILE * pFile; unsigned * pTruth; + int nBytes; int fReverse = 0; + int fBinary = 0; int c, i; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "rh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "rbh" ) ) != EOF ) { switch ( c ) { case 'r': fReverse ^= 1; break; + case 'b': + fBinary ^= 1; + break; case 'h': goto usage; default: @@ -2761,30 +2771,39 @@ int IoCommandWriteTruths( Abc_Frame_t * pAbc, int argc, char **argv ) Abc_Print( -1, "IoCommandWriteTruths(): Can write truth tables up to 16 inputs.\n" ); return 0; } + if ( Gia_ManPiNum(pAbc->pGia) < 3 ) + { + Abc_Print( -1, "IoCommandWriteTruths(): Can write truth tables for 3 inputs or more.\n" ); + return 0; + } if ( argc != globalUtilOptind + 1 ) goto usage; // get the input file name pFileName = argv[globalUtilOptind]; // convert to logic - pFile = fopen( pFileName, "w" ); + pFile = fopen( pFileName, "wb" ); if ( pFile == NULL ) { printf( "Cannot open file \"%s\" for writing.\n", pFileName ); return 0; } + nBytes = 8 * Abc_Truth6WordNum( Gia_ManPiNum(pAbc->pGia) ); Gia_ManForEachCo( pAbc->pGia, pObj, i ) { pTruth = Gia_ObjComputeTruthTable( pAbc->pGia, pObj ); - Extra_PrintHex( pFile, pTruth, Gia_ManPiNum(pAbc->pGia) ); - fprintf( pFile, "\n" ); + if ( fBinary ) + fwrite( pTruth, nBytes, 1, pFile ); + else + Extra_PrintHex( pFile, pTruth, Gia_ManPiNum(pAbc->pGia) ), fprintf( pFile, "\n" ); } fclose( pFile ); return 0; usage: - fprintf( pAbc->Err, "usage: &write_truths [-rh] <file>\n" ); + fprintf( pAbc->Err, "usage: &write_truths [-rbh] <file>\n" ); fprintf( pAbc->Err, "\t writes truth tables of each PO of GIA manager into a file\n" ); fprintf( pAbc->Err, "\t-r : toggle reversing bits in the truth table [default = %s]\n", fReverse? "yes":"no" ); + fprintf( pAbc->Err, "\t-b : toggle using binary format [default = %s]\n", fBinary? "yes":"no" ); fprintf( pAbc->Err, "\t-h : print the help massage\n" ); fprintf( pAbc->Err, "\tfile : the name of the file to write\n" ); return 1; |