diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2007-02-16 08:01:00 -0800 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2007-02-16 08:01:00 -0800 |
commit | 607c253cd2712bacce21ca9b98a848f331ea03a9 (patch) | |
tree | f1189c20d24fec46f4fef155de11d347144c59f3 /src/base/io | |
parent | 5f3e4c0fe21ba5e24db0c187a616a28afc0dabae (diff) | |
download | abc-607c253cd2712bacce21ca9b98a848f331ea03a9.tar.gz abc-607c253cd2712bacce21ca9b98a848f331ea03a9.tar.bz2 abc-607c253cd2712bacce21ca9b98a848f331ea03a9.zip |
Version abc70216
Diffstat (limited to 'src/base/io')
-rw-r--r-- | src/base/io/io.c | 62 | ||||
-rw-r--r-- | src/base/io/io.h | 1 | ||||
-rw-r--r-- | src/base/io/ioReadBlifMv.c | 5 | ||||
-rw-r--r-- | src/base/io/ioReadVerilog.c | 11 | ||||
-rw-r--r-- | src/base/io/ioUtil.c | 73 | ||||
-rw-r--r-- | src/base/io/ioWriteAiger.c | 2 | ||||
-rw-r--r-- | src/base/io/ioWriteBlif.c | 46 | ||||
-rw-r--r-- | src/base/io/ioWriteBlifMv.c | 2 |
8 files changed, 128 insertions, 74 deletions
diff --git a/src/base/io/io.c b/src/base/io/io.c index e79e1857..2267d4e7 100644 --- a/src/base/io/io.c +++ b/src/base/io/io.c @@ -26,7 +26,6 @@ //////////////////////////////////////////////////////////////////////// static int IoCommandRead ( Abc_Frame_t * pAbc, int argc, char **argv ); -static int IoCommandReadHie ( Abc_Frame_t * pAbc, int argc, char **argv ); static int IoCommandReadAiger ( Abc_Frame_t * pAbc, int argc, char **argv ); static int IoCommandReadBaf ( Abc_Frame_t * pAbc, int argc, char **argv ); static int IoCommandReadBlif ( Abc_Frame_t * pAbc, int argc, char **argv ); @@ -76,7 +75,6 @@ extern Abc_Lib_t * Ver_ParseFile( char * pFileName, Abc_Lib_t * pGateLib, int fC void Io_Init( Abc_Frame_t * pAbc ) { Cmd_CommandAdd( pAbc, "I/O", "read", IoCommandRead, 1 ); - Cmd_CommandAdd( pAbc, "I/O", "read_hie", IoCommandReadHie, 1 ); Cmd_CommandAdd( pAbc, "I/O", "read_aiger", IoCommandReadAiger, 1 ); Cmd_CommandAdd( pAbc, "I/O", "read_baf", IoCommandReadBaf, 1 ); Cmd_CommandAdd( pAbc, "I/O", "read_blif", IoCommandReadBlif, 1 ); @@ -189,61 +187,6 @@ usage: SeeAlso [] ***********************************************************************/ -int IoCommandReadHie( Abc_Frame_t * pAbc, int argc, char ** argv ) -{ - Abc_Ntk_t * pNtk; - char * pFileName; - int fCheck; - int c; - - fCheck = 1; - Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF ) - { - switch ( c ) - { - case 'c': - fCheck ^= 1; - break; - case 'h': - goto usage; - default: - goto usage; - } - } - if ( argc != globalUtilOptind + 1 ) - goto usage; - // get the input file name - pFileName = argv[globalUtilOptind]; - // read the file using the corresponding file reader - pNtk = Io_ReadHie( pFileName, Io_ReadFileType(pFileName), fCheck ); - if ( pNtk == NULL ) - return 0; - // replace the current network - Abc_FrameReplaceCurrentNetwork( pAbc, pNtk ); - return 0; - -usage: - fprintf( pAbc->Err, "usage: read_hie [-ch] <file>\n" ); - fprintf( pAbc->Err, "\t reads hierarchical design represented in BLIF or BLIF-MV\n" ); - fprintf( pAbc->Err, "\t by calling the parser that matches the extension of <file>\n" ); - fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "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; -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ int IoCommandReadAiger( Abc_Frame_t * pAbc, int argc, char ** argv ) { Abc_Ntk_t * pNtk; @@ -388,7 +331,8 @@ int IoCommandReadBlif( Abc_Frame_t * pAbc, int argc, char ** argv ) if ( fReadAsAig ) pNtk = Io_ReadBlifAsAig( pFileName, fCheck ); else - pNtk = Io_Read( pFileName, IO_FILE_BLIF, fCheck ); +// pNtk = Io_Read( pFileName, IO_FILE_BLIF, fCheck ); + pNtk = Io_ReadBlif( pFileName, fCheck ); if ( pNtk == NULL ) return 1; // replace the current network @@ -1704,7 +1648,7 @@ int IoCommandWriteVerLib( Abc_Frame_t * pAbc, int argc, char **argv ) fprintf( pAbc->Out, "Verilog library is not specified.\n" ); return 0; } - Io_WriteVerilogLibrary( pLibrary, pFileName ); +// Io_WriteVerilogLibrary( pLibrary, pFileName ); return 0; usage: diff --git a/src/base/io/io.h b/src/base/io/io.h index 8ce7c690..472e7b2d 100644 --- a/src/base/io/io.h +++ b/src/base/io/io.h @@ -119,7 +119,6 @@ extern void Io_WriteVerilog( Abc_Ntk_t * pNtk, char * FileName ); extern Io_FileType_t Io_ReadFileType( 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_ReadHie( char * pFileName, Io_FileType_t FileType, int fCheck ); 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/ioReadBlifMv.c b/src/base/io/ioReadBlifMv.c index 99656422..46a202e1 100644 --- a/src/base/io/ioReadBlifMv.c +++ b/src/base/io/ioReadBlifMv.c @@ -186,9 +186,10 @@ Abc_Ntk_t * Io_ReadBlifMv( char * pFileName, int fBlifMv, int fCheck ) assert( Vec_PtrSize(pDesign->vModules) > 0 ); if ( Vec_PtrSize(pDesign->vModules) == 1 ) { - printf( "Warning: The design is not hierarchical.\n" ); +// printf( "Warning: The design is not hierarchical.\n" ); Abc_LibFree( pDesign, pNtk ); pNtk->pDesign = NULL; + pNtk->pSpec = Extra_UtilStrsav( pFileName ); } else Abc_NtkIsAcyclicHierarchy( pNtk ); @@ -1303,7 +1304,7 @@ static int Io_MvParseLineNamesMv( Io_MvMod_t * p, char * pLine, int fReset ) // split names line into tokens Io_MvSplitIntoTokens( vTokens, pLine, '\0' ); if ( fReset ) - assert( !strcmp(Vec_PtrEntry(vTokens,0), "r") ); + assert( !strcmp(Vec_PtrEntry(vTokens,0), "r") || !strcmp(Vec_PtrEntry(vTokens,0), "reset") ); else assert( !strcmp(Vec_PtrEntry(vTokens,0), "names") || !strcmp(Vec_PtrEntry(vTokens,0), "table") ); // find the number of inputs and outputs diff --git a/src/base/io/ioReadVerilog.c b/src/base/io/ioReadVerilog.c index eda2d0b0..5956a9bc 100644 --- a/src/base/io/ioReadVerilog.c +++ b/src/base/io/ioReadVerilog.c @@ -45,6 +45,7 @@ Abc_Ntk_t * Io_ReadVerilog( char * pFileName, int fCheck ) { Abc_Ntk_t * pNtk; Abc_Lib_t * pDesign; + int i; // parse the verilog file pDesign = Ver_ParseFile( pFileName, NULL, 1, fCheck ); @@ -60,12 +61,20 @@ Abc_Ntk_t * Io_ReadVerilog( char * pFileName, int fCheck ) assert( Vec_PtrSize(pDesign->vModules) > 0 ); if ( Vec_PtrSize(pDesign->vModules) == 1 ) { - printf( "Warning: The design is not hierarchical.\n" ); +// printf( "Warning: The design is not hierarchical.\n" ); Abc_LibFree( pDesign, pNtk ); pNtk->pDesign = NULL; + pNtk->pSpec = Extra_UtilStrsav( pFileName ); } else + { + // bring the root model to the beginning + for ( i = Vec_PtrSize(pDesign->vModules) - 2; i >= 0; i-- ) + Vec_PtrWriteEntry(pDesign->vModules, i+1, Vec_PtrEntry(pDesign->vModules, i) ); + Vec_PtrWriteEntry(pDesign->vModules, 0, pNtk ); + // check that there is no cyclic dependency Abc_NtkIsAcyclicHierarchy( pNtk ); + } return pNtk; } diff --git a/src/base/io/ioUtil.c b/src/base/io/ioUtil.c index 7b4c7c76..2de93ddf 100644 --- a/src/base/io/ioUtil.c +++ b/src/base/io/ioUtil.c @@ -123,7 +123,10 @@ Abc_Ntk_t * Io_ReadNetlist( char * pFileName, Io_FileType_t FileType, int fCheck } // read the new netlist if ( FileType == IO_FILE_BLIF ) - pNtk = Io_ReadBlif( pFileName, fCheck ); +// pNtk = Io_ReadBlif( pFileName, fCheck ); + pNtk = Io_ReadBlifMv( pFileName, 0, fCheck ); + else if ( Io_ReadFileType(pFileName) == IO_FILE_BLIFMV ) + pNtk = Io_ReadBlifMv( pFileName, 1, fCheck ); else if ( FileType == IO_FILE_BENCH ) pNtk = Io_ReadBench( pFileName, fCheck ); else if ( FileType == IO_FILE_EDIF ) @@ -144,16 +147,12 @@ Abc_Ntk_t * Io_ReadNetlist( char * pFileName, Io_FileType_t FileType, int fCheck fprintf( stdout, "Reading network from file has failed.\n" ); return NULL; } - if ( Abc_NtkBlackboxNum(pNtk) || Abc_NtkBlackboxNum(pNtk) ) - { - fprintf( stdout, "The network contains hierarchy. Use \"read_hie\".\n" ); - Abc_NtkDelete( pNtk ); - return NULL; - } + if ( Abc_NtkBlackboxNum(pNtk) || Abc_NtkWhiteboxNum(pNtk) ) + fprintf( stdout, "Warning: The network contains hierarchy.\n" ); return pNtk; } - + /**Function************************************************************* Synopsis [Read the network from a file.] @@ -174,6 +173,51 @@ Abc_Ntk_t * Io_Read( char * pFileName, Io_FileType_t FileType, int fCheck ) return NULL; if ( !Abc_NtkIsNetlist(pNtk) ) return pNtk; + // consider the case of BLIF-MV + if ( Io_ReadFileType(pFileName) == IO_FILE_BLIFMV ) + { + extern Abc_Ntk_t * Abc_NtkConvertBlifMv( Abc_Ntk_t * pNtk ); +Abc_NtkPrintStats( stdout, pNtk, 0 ); +/* +{ + FILE * pFile = fopen( "_temp_.mv", "w" ); + Io_NtkWriteBlifMv( pFile, pNtk ); + fclose( pFile ); +} +*/ + pNtk = Abc_NtkConvertBlifMv( pTemp = pNtk ); + Abc_NtkDelete( pTemp ); + if ( pNtk == NULL ) + { + fprintf( stdout, "Converting BLIF-MV has failed.\n" ); + return NULL; + } + return pNtk; + } + // flatten logic hierarchy + assert( Abc_NtkIsNetlist(pNtk) ); + if ( Abc_NtkWhiteboxNum(pNtk) > 0 ) + { + pNtk = Abc_NtkFlattenLogicHierarchy( pTemp = pNtk ); + Abc_NtkDelete( pTemp ); + if ( pNtk == NULL ) + { + fprintf( stdout, "Flattening logic hierarchy has failed.\n" ); + return NULL; + } + } + // convert blackboxes + if ( Abc_NtkBlackboxNum(pNtk) > 0 ) + { + printf( "Hierarchy reader converted %d blackboxes.\n", Abc_NtkBlackboxNum(pNtk) ); + pNtk = Abc_NtkConvertBlackboxes( pTemp = pNtk ); + Abc_NtkDelete( pTemp ); + if ( pNtk == NULL ) + { + fprintf( stdout, "Converting blackboxes has failed.\n" ); + return NULL; + } + } // convert the netlist into the logic network pNtk = Abc_NtkNetlistToLogic( pTemp = pNtk ); Abc_NtkDelete( pTemp ); @@ -230,7 +274,7 @@ Abc_Ntk_t * Io_ReadHie( char * pFileName, Io_FileType_t FileType, int fCheck ) // convert blackboxes if ( Abc_NtkBlackboxNum(pNtk) > 0 ) { - printf( "Hierarchical parser converted %d blackboxes.\n", Abc_NtkBlackboxNum(pNtk) ); + printf( "Hierarchy reader converted %d blackboxes.\n", Abc_NtkBlackboxNum(pNtk) ); pNtk = Abc_NtkConvertBlackboxes( pTemp = pNtk ); Abc_NtkDelete( pTemp ); if ( pNtk == NULL ) @@ -389,6 +433,8 @@ void Io_WriteHie( Abc_Ntk_t * pNtk, char * pBaseName, char * pFileName ) assert( Abc_NtkIsStrash(pNtk) || Abc_NtkIsLogic(pNtk) ); if ( Io_ReadFileType(pBaseName) == IO_FILE_BLIF ) pNtkBase = Io_ReadBlifMv( pBaseName, 0, 1 ); + else if ( Io_ReadFileType(pBaseName) == IO_FILE_VERILOG ) + pNtkBase = Io_ReadVerilog( pBaseName, 1 ); else fprintf( stderr, "Unknown input file format.\n" ); if ( pNtkBase == NULL ) @@ -405,6 +451,15 @@ void Io_WriteHie( Abc_Ntk_t * pNtk, char * pBaseName, char * pFileName ) // reintroduce the boxes into the netlist if ( Abc_NtkBlackboxNum(pNtkBase) > 0 ) { + // bring the current network to the same representation + if ( Abc_NtkIsLogic(pNtk) ) + { + if ( Abc_NtkIsSopNetlist(pNtkBase) ) + Abc_NtkLogicToSop( pNtk, 0 ); + else if ( Abc_NtkIsAigNetlist(pNtkBase) ) + Abc_NtkLogicToAig( pNtk ); + } + // derive the netlist pNtkResult = Abc_NtkLogicToNetlist( pNtk, 0 ); pNtkResult = Abc_NtkInsertNewLogic( pNtkBase, pNtkTemp = pNtkResult ); Abc_NtkDelete( pNtkTemp ); diff --git a/src/base/io/ioWriteAiger.c b/src/base/io/ioWriteAiger.c index 2bc2ded3..3b7d78ca 100644 --- a/src/base/io/ioWriteAiger.c +++ b/src/base/io/ioWriteAiger.c @@ -160,7 +160,7 @@ void Io_WriteAiger( Abc_Ntk_t * pNtk, char * pFileName ) pFile = fopen( pFileName, "wb" ); if ( pFile == NULL ) { - fprintf( stdout, "Io_WriteBaf(): Cannot open the output file \"%s\".\n", pFileName ); + fprintf( stdout, "Io_WriteAiger(): Cannot open the output file \"%s\".\n", pFileName ); return; } diff --git a/src/base/io/ioWriteBlif.c b/src/base/io/ioWriteBlif.c index 94580e33..e48d0be8 100644 --- a/src/base/io/ioWriteBlif.c +++ b/src/base/io/ioWriteBlif.c @@ -30,6 +30,7 @@ static void Io_NtkWrite( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches ); static void Io_NtkWriteOne( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches ); static void Io_NtkWritePis( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches ); static void Io_NtkWritePos( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches ); +static void Io_NtkWriteSubckt( FILE * pFile, Abc_Obj_t * pNode ); static void Io_NtkWriteAsserts( FILE * pFile, Abc_Ntk_t * pNtk ); static void Io_NtkWriteNodeGate( FILE * pFile, Abc_Obj_t * pNode ); static void Io_NtkWriteNodeFanins( FILE * pFile, Abc_Obj_t * pNode ); @@ -194,6 +195,16 @@ void Io_NtkWriteOne( FILE * pFile, Abc_Ntk_t * pNtk, int fWriteLatches ) fprintf( pFile, "\n" ); } + // write the subcircuits + assert( Abc_NtkWhiteboxNum(pNtk) == 0 ); + if ( Abc_NtkBlackboxNum(pNtk) > 0 ) + { + fprintf( pFile, "\n" ); + Abc_NtkForEachBlackbox( pNtk, pNode, i ) + Io_NtkWriteSubckt( pFile, pNode ); + fprintf( pFile, "\n" ); + } + // write each internal node pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) ); Abc_NtkForEachNode( pNtk, pNode, i ) @@ -382,6 +393,41 @@ void Io_NtkWriteAsserts( FILE * pFile, Abc_Ntk_t * pNtk ) SeeAlso [] ***********************************************************************/ +void Io_NtkWriteSubckt( FILE * pFile, Abc_Obj_t * pNode ) +{ + Abc_Ntk_t * pModel = pNode->pData; + Abc_Obj_t * pTerm; + int i; + // write the subcircuit +// fprintf( pFile, ".subckt %s %s", Abc_NtkName(pModel), Abc_ObjName(pNode) ); + fprintf( pFile, ".subckt %s", Abc_NtkName(pModel) ); + // write pairs of the formal=actual names + Abc_NtkForEachPi( pModel, pTerm, i ) + { + fprintf( pFile, " %s", Abc_ObjName(Abc_ObjFanout0(pTerm)) ); + pTerm = Abc_ObjFanin( pNode, i ); + fprintf( pFile, "=%s", Abc_ObjName(Abc_ObjFanin0(pTerm)) ); + } + Abc_NtkForEachPo( pModel, pTerm, i ) + { + fprintf( pFile, " %s", Abc_ObjName(Abc_ObjFanin0(pTerm)) ); + pTerm = Abc_ObjFanout( pNode, i ); + fprintf( pFile, "=%s", Abc_ObjName(Abc_ObjFanout0(pTerm)) ); + } + fprintf( pFile, "\n" ); +} + +/**Function************************************************************* + + Synopsis [Write the latch into a file.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ void Io_NtkWriteLatch( FILE * pFile, Abc_Obj_t * pLatch ) { Abc_Obj_t * pNetLi, * pNetLo; diff --git a/src/base/io/ioWriteBlifMv.c b/src/base/io/ioWriteBlifMv.c index 1c7e7bed..597ca945 100644 --- a/src/base/io/ioWriteBlifMv.c +++ b/src/base/io/ioWriteBlifMv.c @@ -26,7 +26,7 @@ /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// -static void Io_NtkWriteBlifMv( FILE * pFile, Abc_Ntk_t * pNtk ); +void Io_NtkWriteBlifMv( FILE * pFile, Abc_Ntk_t * pNtk ); static void Io_NtkWriteBlifMvOne( FILE * pFile, Abc_Ntk_t * pNtk ); static void Io_NtkWriteBlifMvPis( FILE * pFile, Abc_Ntk_t * pNtk ); static void Io_NtkWriteBlifMvPos( FILE * pFile, Abc_Ntk_t * pNtk ); |