Commit ada07311 by Alan Mishchenko

New command 'read_sf'.

parent f1eb9339
...@@ -24,6 +24,10 @@ ...@@ -24,6 +24,10 @@
#include "proof/abs/abs.h" #include "proof/abs/abs.h"
#include "sat/bmc/bmc.h" #include "sat/bmc/bmc.h"
#ifdef WIN32
#define unlink _unlink
#endif
ABC_NAMESPACE_IMPL_START ABC_NAMESPACE_IMPL_START
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -49,6 +53,7 @@ static int IoCommandReadVerilog ( Abc_Frame_t * pAbc, int argc, char **argv ); ...@@ -49,6 +53,7 @@ static int IoCommandReadVerilog ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandReadStatus ( Abc_Frame_t * pAbc, int argc, char **argv ); static int IoCommandReadStatus ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandReadGig ( Abc_Frame_t * pAbc, int argc, char **argv ); static int IoCommandReadGig ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandReadJson ( Abc_Frame_t * pAbc, int argc, char **argv ); static int IoCommandReadJson ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandReadSF ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandWrite ( Abc_Frame_t * pAbc, int argc, char **argv ); static int IoCommandWrite ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandWriteHie ( Abc_Frame_t * pAbc, int argc, char **argv ); static int IoCommandWriteHie ( Abc_Frame_t * pAbc, int argc, char **argv );
...@@ -118,6 +123,7 @@ void Io_Init( Abc_Frame_t * pAbc ) ...@@ -118,6 +123,7 @@ void Io_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "I/O", "read_status", IoCommandReadStatus, 0 ); Cmd_CommandAdd( pAbc, "I/O", "read_status", IoCommandReadStatus, 0 );
Cmd_CommandAdd( pAbc, "I/O", "&read_gig", IoCommandReadGig, 0 ); Cmd_CommandAdd( pAbc, "I/O", "&read_gig", IoCommandReadGig, 0 );
Cmd_CommandAdd( pAbc, "I/O", "read_json", IoCommandReadJson, 0 ); Cmd_CommandAdd( pAbc, "I/O", "read_json", IoCommandReadJson, 0 );
Cmd_CommandAdd( pAbc, "I/O", "read_sf", IoCommandReadSF, 0 );
Cmd_CommandAdd( pAbc, "I/O", "write", IoCommandWrite, 0 ); Cmd_CommandAdd( pAbc, "I/O", "write", IoCommandWrite, 0 );
Cmd_CommandAdd( pAbc, "I/O", "write_hie", IoCommandWriteHie, 0 ); Cmd_CommandAdd( pAbc, "I/O", "write_hie", IoCommandWriteHie, 0 );
...@@ -1415,6 +1421,73 @@ usage: ...@@ -1415,6 +1421,73 @@ usage:
return 1; return 1;
} }
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandReadSF( Abc_Frame_t * pAbc, int argc, char ** argv )
{
extern void Io_TransformSF2PLA( char * pNameIn, char * pNameOut );
Abc_Ntk_t * pNtk;
FILE * pFile;
char * pFileName, * pFileTemp = "_temp_sf_.pla";
int c;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
{
switch ( c )
{
case 'h':
goto usage;
default:
goto usage;
}
}
if ( argc != globalUtilOptind + 1 )
{
goto usage;
}
// get the input file name
pFileName = argv[globalUtilOptind];
if ( (pFile = fopen( pFileName, "r" )) == NULL )
{
fprintf( pAbc->Err, "Cannot open input file \"%s\". \n", pFileName );
return 1;
}
fclose( pFile );
Io_TransformSF2PLA( pFileName, pFileTemp );
pNtk = Io_Read( pFileTemp, IO_FILE_PLA, 1, 0 );
unlink( pFileTemp );
if ( pNtk == NULL )
return 1;
ABC_FREE( pNtk->pName );
pNtk->pName = Extra_FileNameGeneric( pFileName );
ABC_FREE( pNtk->pSpec );
pNtk->pSpec = Abc_UtilStrsav( pFileName );
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
Abc_FrameClearVerifStatus( pAbc );
return 0;
usage:
fprintf( pAbc->Err, "usage: read_sf [-h] <file>\n" );
fprintf( pAbc->Err, "\t reads file in SF format\n" );
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************************************************************* /**Function*************************************************************
......
...@@ -862,6 +862,61 @@ FILE * Io_FileOpen( const char * FileName, const char * PathVar, const char * Mo ...@@ -862,6 +862,61 @@ FILE * Io_FileOpen( const char * FileName, const char * PathVar, const char * Mo
} }
} }
/**Function*************************************************************
Synopsis [Tranform SF into PLA.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Io_TransformSF2PLA( char * pNameIn, char * pNameOut )
{
int fStart = 0, Size = 1000000;
char * pBuffer, * pToken;
FILE * pFileIn = fopen( pNameIn, "rb" );
FILE * pFileOut = fopen( pNameOut, "wb" );
if ( pFileIn == NULL )
{
if ( pFileOut ) fclose( pFileOut );
printf( "Cannot open file \"%s\" for reading.\n", pNameIn );
return;
}
if ( pFileOut == NULL )
{
if ( pFileIn ) fclose( pFileIn );
printf( "Cannot open file \"%s\" for reading.\n", pNameOut );
return;
}
pBuffer = ABC_ALLOC( char, Size );
fprintf( pFileOut, ".type fd\n" );
while ( fgets(pBuffer, Size, pFileIn) )
{
if ( strstr(pBuffer, "END_SDF") )
break;
if ( strstr(pBuffer, "SDF") )
{
fgets(pBuffer, Size, pFileIn);
if ( (pToken = strtok( pBuffer, " \t\r\n" )) )
fprintf( pFileOut, ".i %d\n", atoi(pToken) );
if ( (pToken = strtok( NULL, " \t\r\n" )) )
fprintf( pFileOut, ".o %d\n", atoi(pToken) );
if ( (pToken = strtok( NULL, " \t\r\n" )) )
fprintf( pFileOut, ".p %d\n", atoi(pToken) );
fStart = 1;
}
else if ( fStart )
fprintf( pFileOut, "%s", pBuffer );
}
fprintf( pFileOut, ".e\n" );
fclose( pFileIn );
fclose( pFileOut );
ABC_FREE( pBuffer );
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment