diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2014-03-16 21:56:28 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2014-03-16 21:56:28 -0700 |
commit | 89eed1aaf95ae9f2682c7b801d02954e5e3b8c7b (patch) | |
tree | ce68b5961cc29b7a362892f31fdfcd0f66f499bc /src/base/io | |
parent | 7a3e57a4cb174325f7d78cedecb75da6f2b87fc5 (diff) | |
download | abc-89eed1aaf95ae9f2682c7b801d02954e5e3b8c7b.tar.gz abc-89eed1aaf95ae9f2682c7b801d02954e5e3b8c7b.tar.bz2 abc-89eed1aaf95ae9f2682c7b801d02954e5e3b8c7b.zip |
Adding barrier buffers.
Diffstat (limited to 'src/base/io')
-rw-r--r-- | src/base/io/io.c | 44 | ||||
-rw-r--r-- | src/base/io/ioAbc.h | 2 | ||||
-rw-r--r-- | src/base/io/ioUtil.c | 26 |
3 files changed, 51 insertions, 21 deletions
diff --git a/src/base/io/io.c b/src/base/io/io.c index b4fc1a00..ef17c8fd 100644 --- a/src/base/io/io.c +++ b/src/base/io/io.c @@ -172,12 +172,13 @@ int IoCommandRead( Abc_Frame_t * pAbc, int argc, char ** argv ) char Command[1000]; Abc_Ntk_t * pNtk; char * pFileName, * pTemp; - int c, fCheck; + int c, fCheck, fBarBufs; fCheck = 1; + fBarBufs = 0; glo_fMapped = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "mch" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "mcbh" ) ) != EOF ) { switch ( c ) { @@ -187,6 +188,9 @@ int IoCommandRead( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'c': fCheck ^= 1; break; + case 'b': + fBarBufs ^= 1; + break; case 'h': goto usage; default: @@ -230,7 +234,7 @@ int IoCommandRead( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; } // read the file using the corresponding file reader - pNtk = Io_Read( pFileName, Io_ReadFileType(pFileName), fCheck ); + pNtk = Io_Read( pFileName, Io_ReadFileType(pFileName), fCheck, fBarBufs ); if ( pNtk == NULL ) return 0; if ( Abc_NtkPiNum(pNtk) == 0 ) @@ -245,12 +249,13 @@ int IoCommandRead( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - fprintf( pAbc->Err, "usage: read [-mch] <file>\n" ); + fprintf( pAbc->Err, "usage: read [-mcbh] <file>\n" ); fprintf( pAbc->Err, "\t replaces the current network by the network read from <file>\n" ); fprintf( pAbc->Err, "\t by calling the parser that matches the extension of <file>\n" ); fprintf( pAbc->Err, "\t (to read a hierarchical design, use \"read_hie\")\n" ); fprintf( pAbc->Err, "\t-m : toggle reading mapped Verilog [default = %s]\n", glo_fMapped? "yes":"no" ); fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" ); + fprintf( pAbc->Err, "\t-b : toggle reading barrier buffers [default = %s]\n", fBarBufs? "yes":"no" ); fprintf( pAbc->Err, "\t-h : prints the command summary\n" ); fprintf( pAbc->Err, "\tfile : the name of a file to read\n" ); return 1; @@ -294,7 +299,7 @@ int IoCommandReadAiger( Abc_Frame_t * pAbc, int argc, char ** argv ) // get the input file name pFileName = argv[globalUtilOptind]; // read the file using the corresponding file reader - pNtk = Io_Read( pFileName, IO_FILE_AIGER, fCheck ); + pNtk = Io_Read( pFileName, IO_FILE_AIGER, fCheck, 0 ); if ( pNtk == NULL ) return 1; // replace the current network @@ -349,7 +354,7 @@ int IoCommandReadBaf( Abc_Frame_t * pAbc, int argc, char ** argv ) // get the input file name pFileName = argv[globalUtilOptind]; // read the file using the corresponding file reader - pNtk = Io_Read( pFileName, IO_FILE_BAF, fCheck ); + pNtk = Io_Read( pFileName, IO_FILE_BAF, fCheck, 0 ); if ( pNtk == NULL ) return 1; // replace the current network @@ -404,7 +409,7 @@ int IoCommandReadBblif( Abc_Frame_t * pAbc, int argc, char ** argv ) // get the input file name pFileName = argv[globalUtilOptind]; // read the file using the corresponding file reader - pNtk = Io_Read( pFileName, IO_FILE_BBLIF, fCheck ); + pNtk = Io_Read( pFileName, IO_FILE_BBLIF, fCheck, 0 ); if ( pNtk == NULL ) return 1; // replace the current network @@ -473,7 +478,7 @@ int IoCommandReadBlif( Abc_Frame_t * pAbc, int argc, char ** argv ) if ( fReadAsAig ) pNtk = Io_ReadBlifAsAig( pFileName, fCheck ); else if ( fUseNewParser ) - pNtk = Io_Read( pFileName, IO_FILE_BLIF, fCheck ); + pNtk = Io_Read( pFileName, IO_FILE_BLIF, fCheck, 0 ); else { Abc_Ntk_t * pTemp; @@ -541,7 +546,7 @@ int IoCommandReadBlifMv( Abc_Frame_t * pAbc, int argc, char ** argv ) // get the input file name pFileName = argv[globalUtilOptind]; // read the file using the corresponding file reader - pNtk = Io_Read( pFileName, IO_FILE_BLIFMV, fCheck ); + pNtk = Io_Read( pFileName, IO_FILE_BLIFMV, fCheck, 0 ); if ( pNtk == NULL ) return 1; // replace the current network @@ -597,7 +602,7 @@ int IoCommandReadBench( Abc_Frame_t * pAbc, int argc, char ** argv ) // get the input file name pFileName = argv[globalUtilOptind]; // read the file using the corresponding file reader - pNtk = Io_Read( pFileName, IO_FILE_BENCH, fCheck ); + pNtk = Io_Read( pFileName, IO_FILE_BENCH, fCheck, 0 ); if ( pNtk == NULL ) return 1; // replace the current network @@ -714,7 +719,7 @@ int IoCommandReadEdif( Abc_Frame_t * pAbc, int argc, char ** argv ) // get the input file name pFileName = argv[globalUtilOptind]; // read the file using the corresponding file reader - pNtk = Io_Read( pFileName, IO_FILE_EDIF, fCheck ); + pNtk = Io_Read( pFileName, IO_FILE_EDIF, fCheck, 0 ); if ( pNtk == NULL ) return 1; // replace the current network @@ -769,7 +774,7 @@ int IoCommandReadEqn( Abc_Frame_t * pAbc, int argc, char ** argv ) // get the input file name pFileName = argv[globalUtilOptind]; // read the file using the corresponding file reader - pNtk = Io_Read( pFileName, IO_FILE_EQN, fCheck ); + pNtk = Io_Read( pFileName, IO_FILE_EQN, fCheck, 0 ); if ( pNtk == NULL ) return 1; // replace the current network @@ -910,7 +915,7 @@ int IoCommandReadPla( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_NtkDelete( pTemp ); } else - pNtk = Io_Read( pFileName, IO_FILE_PLA, fCheck ); + pNtk = Io_Read( pFileName, IO_FILE_PLA, fCheck, 0 ); if ( pNtk == NULL ) return 1; // replace the current network @@ -1015,13 +1020,14 @@ int IoCommandReadVerilog( Abc_Frame_t * pAbc, int argc, char ** argv ) { Abc_Ntk_t * pNtk; char * pFileName; - int fCheck; + int fCheck, fBarBufs; int c; fCheck = 1; + fBarBufs = 0; glo_fMapped = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "mch" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "mcbh" ) ) != EOF ) { switch ( c ) { @@ -1031,6 +1037,9 @@ int IoCommandReadVerilog( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'c': fCheck ^= 1; break; + case 'b': + fBarBufs ^= 1; + break; case 'h': goto usage; default: @@ -1042,7 +1051,7 @@ int IoCommandReadVerilog( Abc_Frame_t * pAbc, int argc, char ** argv ) // get the input file name pFileName = argv[globalUtilOptind]; // read the file using the corresponding file reader - pNtk = Io_Read( pFileName, IO_FILE_VERILOG, fCheck ); + pNtk = Io_Read( pFileName, IO_FILE_VERILOG, fCheck, fBarBufs ); if ( pNtk == NULL ) return 1; // replace the current network @@ -1051,10 +1060,11 @@ int IoCommandReadVerilog( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - fprintf( pAbc->Err, "usage: read_verilog [-mch] <file>\n" ); + fprintf( pAbc->Err, "usage: read_verilog [-mcbh] <file>\n" ); fprintf( pAbc->Err, "\t reads the network in Verilog (IWLS 2002/2005 subset)\n" ); fprintf( pAbc->Err, "\t-m : toggle reading mapped Verilog [default = %s]\n", glo_fMapped? "yes":"no" ); fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" ); + fprintf( pAbc->Err, "\t-b : toggle reading barrier buffers [default = %s]\n", fBarBufs? "yes":"no" ); fprintf( pAbc->Err, "\t-h : prints the command summary\n" ); fprintf( pAbc->Err, "\tfile : the name of a file to read\n" ); return 1; diff --git a/src/base/io/ioAbc.h b/src/base/io/ioAbc.h index efac1212..f20f5c3d 100644 --- a/src/base/io/ioAbc.h +++ b/src/base/io/ioAbc.h @@ -136,7 +136,7 @@ extern void Io_WriteVerilog( Abc_Ntk_t * pNtk, char * FileName ); extern Io_FileType_t Io_ReadFileType( char * pFileName ); extern Io_FileType_t Io_ReadLibType( char * pFileName ); extern Abc_Ntk_t * Io_ReadNetlist( char * pFileName, Io_FileType_t FileType, int fCheck ); -extern Abc_Ntk_t * Io_Read( char * pFileName, Io_FileType_t FileType, int fCheck ); +extern Abc_Ntk_t * Io_Read( char * pFileName, Io_FileType_t FileType, int fCheck, int fBarBufs ); extern void Io_Write( Abc_Ntk_t * pNtk, char * pFileName, Io_FileType_t FileType ); extern void Io_WriteHie( Abc_Ntk_t * pNtk, char * pBaseName, char * pFileName ); extern Abc_Obj_t * Io_ReadCreatePi( Abc_Ntk_t * pNtk, char * pName ); diff --git a/src/base/io/ioUtil.c b/src/base/io/ioUtil.c index 0044f5fd..685fcf73 100644 --- a/src/base/io/ioUtil.c +++ b/src/base/io/ioUtil.c @@ -223,7 +223,7 @@ void updateLtlStoreOfNtk( Abc_Ntk_t *pNtk, Vec_Ptr_t *tempLtlStore ) SeeAlso [] ***********************************************************************/ -Abc_Ntk_t * Io_Read( char * pFileName, Io_FileType_t FileType, int fCheck ) +Abc_Ntk_t * Io_Read( char * pFileName, Io_FileType_t FileType, int fCheck, int fBarBufs ) { Abc_Ntk_t * pNtk, * pTemp; Vec_Ptr_t * vLtl; @@ -234,6 +234,14 @@ Abc_Ntk_t * Io_Read( char * pFileName, Io_FileType_t FileType, int fCheck ) vLtl = temporaryLtlStore( pNtk ); if ( !Abc_NtkIsNetlist(pNtk) ) return pNtk; + // derive barbufs + if ( fBarBufs ) + { + pNtk = Abc_NtkToBarBufs( pTemp = pNtk ); + Abc_NtkDelete( pTemp ); + assert( Abc_NtkIsLogic(pNtk) ); + return pNtk; + } // flatten logic hierarchy assert( Abc_NtkIsNetlist(pNtk) ); if ( Abc_NtkWhiteboxNum(pNtk) > 0 ) @@ -481,13 +489,22 @@ void Io_WriteHie( Abc_Ntk_t * pNtk, char * pBaseName, char * pFileName ) if ( Abc_NtkWhiteboxNum(pNtkBase) > 0 ) { pNtkBase = Abc_NtkFlattenLogicHierarchy( pNtkTemp = pNtkBase ); + Abc_NtkDelete( pNtkTemp ); if ( pNtkBase == NULL ) return; - Abc_NtkDelete( pNtkTemp ); } // reintroduce the boxes into the netlist - if ( Io_ReadFileType(pBaseName) == IO_FILE_BLIFMV ) + if ( pNtk->nBarBufs > 0 ) + { + // derive the netlist + pNtkResult = Abc_NtkToNetlist( pNtk ); + pNtkResult = Abc_NtkFromBarBufs( pNtkBase, pNtkTemp = pNtkResult ); + Abc_NtkDelete( pNtkTemp ); + if ( pNtkResult ) + printf( "Hierarchy writer reintroduced %d barbufs.\n", pNtk->nBarBufs ); + } + else if ( Io_ReadFileType(pBaseName) == IO_FILE_BLIFMV ) { if ( Abc_NtkBlackboxNum(pNtkBase) > 0 ) { @@ -499,7 +516,10 @@ void Io_WriteHie( Abc_Ntk_t * pNtk, char * pBaseName, char * pFileName ) assert( !Abc_NtkIsNetlist(pNtk) ); pNtkResult = Abc_NtkToNetlist( pNtk ); if ( !Abc_NtkConvertToBlifMv( pNtkResult ) ) + { + Abc_NtkDelete( pNtkBase ); return; + } // reintroduce the network pNtkResult = Abc_NtkInsertBlifMv( pNtkBase, pNtkTemp = pNtkResult ); Abc_NtkDelete( pNtkTemp ); |