abc/src/base/io/io.c

1866 lines
50 KiB
C
Raw Normal View History

2005-07-29 17:01:00 +02:00
/**CFile****************************************************************
FileName [io.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Command processing package.]
Synopsis [Command file.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: io.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "io.h"
#include "mainInt.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
static int IoCommandRead ( Abc_Frame_t * pAbc, int argc, char **argv );
2005-10-10 17:01:00 +02:00
static int IoCommandReadBaf ( Abc_Frame_t * pAbc, int argc, char **argv );
2005-07-29 17:01:00 +02:00
static int IoCommandReadBlif ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandReadBench ( Abc_Frame_t * pAbc, int argc, char **argv );
2005-08-14 17:01:00 +02:00
static int IoCommandReadEdif ( Abc_Frame_t * pAbc, int argc, char **argv );
2005-08-31 17:01:00 +02:00
static int IoCommandReadEqn ( Abc_Frame_t * pAbc, int argc, char **argv );
2006-10-07 17:01:00 +02:00
//static int IoCommandReadVerilog ( Abc_Frame_t * pAbc, int argc, char **argv );
2006-08-20 17:01:00 +02:00
static int IoCommandReadVer ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandReadVerLib ( Abc_Frame_t * pAbc, int argc, char **argv );
2005-07-29 17:01:00 +02:00
static int IoCommandReadPla ( Abc_Frame_t * pAbc, int argc, char **argv );
2005-10-05 17:01:00 +02:00
static int IoCommandReadTruth ( Abc_Frame_t * pAbc, int argc, char **argv );
2005-07-29 17:01:00 +02:00
2005-10-10 17:01:00 +02:00
static int IoCommandWriteBaf ( Abc_Frame_t * pAbc, int argc, char **argv );
2005-07-29 17:01:00 +02:00
static int IoCommandWriteBlif ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandWriteBench ( Abc_Frame_t * pAbc, int argc, char **argv );
2006-11-11 17:01:00 +01:00
static int IoCommandWriteCellNet( Abc_Frame_t * pAbc, int argc, char **argv );
2005-07-29 17:01:00 +02:00
static int IoCommandWriteCnf ( Abc_Frame_t * pAbc, int argc, char **argv );
2005-08-31 17:01:00 +02:00
static int IoCommandWriteDot ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandWriteEqn ( Abc_Frame_t * pAbc, int argc, char **argv );
static int IoCommandWriteGml ( Abc_Frame_t * pAbc, int argc, char **argv );
2005-11-14 17:01:00 +01:00
static int IoCommandWriteList ( Abc_Frame_t * pAbc, int argc, char **argv );
2005-08-09 17:01:00 +02:00
static int IoCommandWritePla ( Abc_Frame_t * pAbc, int argc, char **argv );
2005-12-22 17:01:00 +01:00
static int IoCommandWriteVerilog( Abc_Frame_t * pAbc, int argc, char **argv );
2006-08-20 17:01:00 +02:00
static int IoCommandWriteVerLib ( Abc_Frame_t * pAbc, int argc, char **argv );
2006-03-03 17:01:00 +01:00
static int IoCommandWriteCounter( Abc_Frame_t * pAbc, int argc, char **argv );
2005-07-29 17:01:00 +02:00
2006-08-23 17:01:00 +02:00
extern Abc_Lib_t * Ver_ParseFile( char * pFileName, Abc_Lib_t * pGateLib, int fCheck, int fUseMemMan );
2005-07-29 17:01:00 +02:00
////////////////////////////////////////////////////////////////////////
2005-10-12 17:01:00 +02:00
/// FUNCTION DEFINITIONS ///
2005-07-29 17:01:00 +02:00
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Io_Init( Abc_Frame_t * pAbc )
{
Cmd_CommandAdd( pAbc, "I/O", "read", IoCommandRead, 1 );
2005-10-10 17:01:00 +02:00
Cmd_CommandAdd( pAbc, "I/O", "read_baf", IoCommandReadBaf, 1 );
2005-07-29 17:01:00 +02:00
Cmd_CommandAdd( pAbc, "I/O", "read_blif", IoCommandReadBlif, 1 );
Cmd_CommandAdd( pAbc, "I/O", "read_bench", IoCommandReadBench, 1 );
2005-08-14 17:01:00 +02:00
Cmd_CommandAdd( pAbc, "I/O", "read_edif", IoCommandReadEdif, 1 );
2005-08-31 17:01:00 +02:00
Cmd_CommandAdd( pAbc, "I/O", "read_eqn", IoCommandReadEqn, 1 );
2006-10-07 17:01:00 +02:00
// Cmd_CommandAdd( pAbc, "I/O", "read_verilog", IoCommandReadVerilog, 1 );
2006-08-20 17:01:00 +02:00
Cmd_CommandAdd( pAbc, "I/O", "read_ver", IoCommandReadVer, 1 );
Cmd_CommandAdd( pAbc, "I/O", "read_verlib", IoCommandReadVerLib, 0 );
2005-07-29 17:01:00 +02:00
Cmd_CommandAdd( pAbc, "I/O", "read_pla", IoCommandReadPla, 1 );
2005-10-05 17:01:00 +02:00
Cmd_CommandAdd( pAbc, "I/O", "read_truth", IoCommandReadTruth, 1 );
2005-07-29 17:01:00 +02:00
2005-10-10 17:01:00 +02:00
Cmd_CommandAdd( pAbc, "I/O", "write_baf", IoCommandWriteBaf, 0 );
2005-07-29 17:01:00 +02:00
Cmd_CommandAdd( pAbc, "I/O", "write_blif", IoCommandWriteBlif, 0 );
Cmd_CommandAdd( pAbc, "I/O", "write_bench", IoCommandWriteBench, 0 );
2006-11-11 17:01:00 +01:00
Cmd_CommandAdd( pAbc, "I/O", "write_cellnet", IoCommandWriteCellNet, 0 );
2005-07-29 17:01:00 +02:00
Cmd_CommandAdd( pAbc, "I/O", "write_cnf", IoCommandWriteCnf, 0 );
2005-08-31 17:01:00 +02:00
Cmd_CommandAdd( pAbc, "I/O", "write_dot", IoCommandWriteDot, 0 );
Cmd_CommandAdd( pAbc, "I/O", "write_eqn", IoCommandWriteEqn, 0 );
Cmd_CommandAdd( pAbc, "I/O", "write_gml", IoCommandWriteGml, 0 );
2005-11-14 17:01:00 +01:00
Cmd_CommandAdd( pAbc, "I/O", "write_list", IoCommandWriteList, 0 );
2005-08-09 17:01:00 +02:00
Cmd_CommandAdd( pAbc, "I/O", "write_pla", IoCommandWritePla, 0 );
2005-12-22 17:01:00 +01:00
Cmd_CommandAdd( pAbc, "I/O", "write_verilog", IoCommandWriteVerilog, 0 );
2006-08-20 17:01:00 +02:00
Cmd_CommandAdd( pAbc, "I/O", "write_verlib", IoCommandWriteVerLib, 0 );
2006-03-03 17:01:00 +01:00
Cmd_CommandAdd( pAbc, "I/O", "write_counter", IoCommandWriteCounter, 0 );
2005-07-29 17:01:00 +02:00
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Io_End()
{
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandRead( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk;
char * FileName;
FILE * pFile;
int fCheck;
int c;
fCheck = 1;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
2005-07-29 17:01:00 +02:00
{
switch ( c )
{
case 'c':
fCheck ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-07-29 17:01:00 +02:00
{
goto usage;
}
// get the input file name
2006-02-20 17:01:00 +01:00
FileName = argv[globalUtilOptind];
2005-07-29 17:01:00 +02:00
if ( (pFile = fopen( FileName, "r" )) == NULL )
{
fprintf( pAbc->Err, "Cannot open input file \"%s\". ", FileName );
2005-08-31 17:01:00 +02:00
if ( FileName = Extra_FileGetSimilarName( FileName, ".mv", ".blif", ".pla", ".eqn", ".bench" ) )
2005-07-29 17:01:00 +02:00
fprintf( pAbc->Err, "Did you mean \"%s\"?", FileName );
fprintf( pAbc->Err, "\n" );
return 1;
}
fclose( pFile );
// set the new network
pNtk = Io_Read( FileName, fCheck );
if ( pNtk == NULL )
{
fprintf( pAbc->Err, "Reading network from file has failed.\n" );
return 1;
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
return 0;
usage:
fprintf( pAbc->Err, "usage: read [-ch] <file>\n" );
fprintf( pAbc->Err, "\t read the network from file in Verilog/BLIF/BENCH format\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;
}
2005-10-10 17:01:00 +02:00
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandReadBaf( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk;
char * FileName;
FILE * pFile;
int fCheck;
int c;
fCheck = 1;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
2005-10-10 17:01:00 +02:00
{
switch ( c )
{
case 'c':
fCheck ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-10-10 17:01:00 +02:00
{
goto usage;
}
// get the input file name
2006-02-20 17:01:00 +01:00
FileName = argv[globalUtilOptind];
2005-10-10 17:01:00 +02:00
if ( (pFile = fopen( FileName, "r" )) == NULL )
{
fprintf( pAbc->Err, "Cannot open input file \"%s\". ", FileName );
if ( FileName = Extra_FileGetSimilarName( FileName, ".mv", ".blif", ".pla", ".eqn", ".bench" ) )
fprintf( pAbc->Err, "Did you mean \"%s\"?", FileName );
fprintf( pAbc->Err, "\n" );
return 1;
}
fclose( pFile );
// set the new network
pNtk = Io_ReadBaf( FileName, fCheck );
if ( pNtk == NULL )
{
fprintf( pAbc->Err, "Reading network from BAF file has failed.\n" );
return 1;
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
return 0;
usage:
fprintf( pAbc->Err, "usage: read_baf [-ch] <file>\n" );
fprintf( pAbc->Err, "\t read the network in Binary Aig Format (BAF)\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;
}
2005-07-29 17:01:00 +02:00
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandReadBlif( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk, * pTemp;
char * FileName;
FILE * pFile;
int fCheck;
int c;
fCheck = 1;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
2005-07-29 17:01:00 +02:00
{
switch ( c )
{
case 'c':
fCheck ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-07-29 17:01:00 +02:00
{
goto usage;
}
// get the input file name
2006-02-20 17:01:00 +01:00
FileName = argv[globalUtilOptind];
2005-07-29 17:01:00 +02:00
if ( (pFile = fopen( FileName, "r" )) == NULL )
{
fprintf( pAbc->Err, "Cannot open input file \"%s\". ", FileName );
2005-08-31 17:01:00 +02:00
if ( FileName = Extra_FileGetSimilarName( FileName, ".mv", ".blif", ".pla", ".eqn", ".bench" ) )
2005-07-29 17:01:00 +02:00
fprintf( pAbc->Err, "Did you mean \"%s\"?", FileName );
fprintf( pAbc->Err, "\n" );
return 1;
}
fclose( pFile );
// set the new network
pNtk = Io_ReadBlif( FileName, fCheck );
if ( pNtk == NULL )
{
fprintf( pAbc->Err, "Reading network from BLIF file has failed.\n" );
return 1;
}
2005-08-12 17:01:00 +02:00
pNtk = Abc_NtkNetlistToLogic( pTemp = pNtk );
2005-07-29 17:01:00 +02:00
Abc_NtkDelete( pTemp );
if ( pNtk == NULL )
{
fprintf( pAbc->Err, "Converting to logic network after reading has failed.\n" );
return 1;
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
return 0;
usage:
fprintf( pAbc->Err, "usage: read_blif [-ch] <file>\n" );
fprintf( pAbc->Err, "\t read the network in binary BLIF format\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;
}
2005-08-14 17:01:00 +02:00
2005-07-29 17:01:00 +02:00
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandReadBench( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk, * pTemp;
char * FileName;
FILE * pFile;
int fCheck;
int c;
fCheck = 1;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
2005-07-29 17:01:00 +02:00
{
switch ( c )
{
case 'c':
fCheck ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-07-29 17:01:00 +02:00
{
goto usage;
}
// get the input file name
2006-02-20 17:01:00 +01:00
FileName = argv[globalUtilOptind];
2005-07-29 17:01:00 +02:00
if ( (pFile = fopen( FileName, "r" )) == NULL )
{
fprintf( pAbc->Err, "Cannot open input file \"%s\". ", FileName );
2005-08-31 17:01:00 +02:00
if ( FileName = Extra_FileGetSimilarName( FileName, ".mv", ".blif", ".pla", ".eqn", ".bench" ) )
2005-07-29 17:01:00 +02:00
fprintf( pAbc->Err, "Did you mean \"%s\"?", FileName );
fprintf( pAbc->Err, "\n" );
return 1;
}
fclose( pFile );
// set the new network
pNtk = Io_ReadBench( FileName, fCheck );
if ( pNtk == NULL )
{
fprintf( pAbc->Err, "Reading network from BENCH file has failed.\n" );
return 1;
}
2005-08-12 17:01:00 +02:00
pNtk = Abc_NtkNetlistToLogic( pTemp = pNtk );
2005-07-29 17:01:00 +02:00
Abc_NtkDelete( pTemp );
if ( pNtk == NULL )
{
fprintf( pAbc->Err, "Converting to logic network after reading has failed.\n" );
return 1;
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
return 0;
usage:
fprintf( pAbc->Err, "usage: read_bench [-ch] <file>\n" );
fprintf( pAbc->Err, "\t read the network in BENCH format\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;
}
2005-08-14 17:01:00 +02:00
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandReadEdif( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk, * pTemp;
char * FileName;
FILE * pFile;
int fCheck;
int c;
fCheck = 1;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
2005-08-14 17:01:00 +02:00
{
switch ( c )
{
case 'c':
fCheck ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-08-14 17:01:00 +02:00
{
goto usage;
}
// get the input file name
2006-02-20 17:01:00 +01:00
FileName = argv[globalUtilOptind];
2005-08-14 17:01:00 +02:00
if ( (pFile = fopen( FileName, "r" )) == NULL )
{
fprintf( pAbc->Err, "Cannot open input file \"%s\". ", FileName );
2005-08-31 17:01:00 +02:00
if ( FileName = Extra_FileGetSimilarName( FileName, ".mv", ".blif", ".pla", ".eqn", ".bench" ) )
2005-08-14 17:01:00 +02:00
fprintf( pAbc->Err, "Did you mean \"%s\"?", FileName );
fprintf( pAbc->Err, "\n" );
return 1;
}
fclose( pFile );
// set the new network
pNtk = Io_ReadEdif( FileName, fCheck );
if ( pNtk == NULL )
{
fprintf( pAbc->Err, "Reading network from EDIF file has failed.\n" );
return 1;
}
pNtk = Abc_NtkNetlistToLogic( pTemp = pNtk );
Abc_NtkDelete( pTemp );
if ( pNtk == NULL )
{
fprintf( pAbc->Err, "Converting to logic network after reading has failed.\n" );
return 1;
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
return 0;
usage:
fprintf( pAbc->Err, "usage: read_edif [-ch] <file>\n" );
fprintf( pAbc->Err, "\t read the network in EDIF (works only for ISCAS benchmarks)\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;
}
2005-08-31 17:01:00 +02:00
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandReadEqn( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk, * pTemp;
char * FileName;
FILE * pFile;
int fCheck;
int c;
fCheck = 1;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
2005-08-31 17:01:00 +02:00
{
switch ( c )
{
case 'c':
fCheck ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-08-31 17:01:00 +02:00
{
goto usage;
}
// get the input file name
2006-02-20 17:01:00 +01:00
FileName = argv[globalUtilOptind];
2005-08-31 17:01:00 +02:00
if ( (pFile = fopen( FileName, "r" )) == NULL )
{
fprintf( pAbc->Err, "Cannot open input file \"%s\". ", FileName );
if ( FileName = Extra_FileGetSimilarName( FileName, ".mv", ".blif", ".pla", ".eqn", ".bench" ) )
fprintf( pAbc->Err, "Did you mean \"%s\"?", FileName );
fprintf( pAbc->Err, "\n" );
return 1;
}
fclose( pFile );
// set the new network
pNtk = Io_ReadEqn( FileName, fCheck );
if ( pNtk == NULL )
{
fprintf( pAbc->Err, "Reading network from the equation file has failed.\n" );
return 1;
}
pNtk = Abc_NtkNetlistToLogic( pTemp = pNtk );
Abc_NtkDelete( pTemp );
if ( pNtk == NULL )
{
fprintf( pAbc->Err, "Converting to logic network after reading has failed.\n" );
return 1;
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
return 0;
usage:
fprintf( pAbc->Err, "usage: read_eqn [-ch] <file>\n" );
fprintf( pAbc->Err, "\t read the network in equation format\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;
}
2005-07-29 17:01:00 +02:00
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandReadVerilog( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk, * pTemp;
char * FileName;
FILE * pFile;
int fCheck;
int c;
2006-08-24 17:01:00 +02:00
printf( "Stand-alone structural Verilog reader is now available as command \"read_ver\".\n" );
return 0;
2005-07-29 17:01:00 +02:00
fCheck = 1;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
2005-07-29 17:01:00 +02:00
{
switch ( c )
{
case 'c':
fCheck ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-07-29 17:01:00 +02:00
{
goto usage;
}
// get the input file name
2006-02-20 17:01:00 +01:00
FileName = argv[globalUtilOptind];
2005-07-29 17:01:00 +02:00
if ( (pFile = fopen( FileName, "r" )) == NULL )
{
fprintf( pAbc->Err, "Cannot open input file \"%s\". ", FileName );
2005-08-31 17:01:00 +02:00
if ( FileName = Extra_FileGetSimilarName( FileName, ".mv", ".blif", ".pla", ".eqn", ".bench" ) )
2005-07-29 17:01:00 +02:00
fprintf( pAbc->Err, "Did you mean \"%s\"?", FileName );
fprintf( pAbc->Err, "\n" );
return 1;
}
fclose( pFile );
// set the new network
2006-08-24 17:01:00 +02:00
// pNtk = Io_ReadVerilog( FileName, fCheck );
pNtk = NULL;
2005-07-29 17:01:00 +02:00
if ( pNtk == NULL )
{
2005-08-31 17:01:00 +02:00
fprintf( pAbc->Err, "Reading network from the verilog file has failed.\n" );
2005-07-29 17:01:00 +02:00
return 1;
}
2005-08-12 17:01:00 +02:00
pNtk = Abc_NtkNetlistToLogic( pTemp = pNtk );
2005-07-29 17:01:00 +02:00
Abc_NtkDelete( pTemp );
if ( pNtk == NULL )
{
fprintf( pAbc->Err, "Converting to logic network after reading has failed.\n" );
return 1;
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
return 0;
usage:
fprintf( pAbc->Err, "usage: read_verilog [-ch] <file>\n" );
fprintf( pAbc->Err, "\t read the network in Verilog (IWLS 2005 subset)\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;
}
2006-08-20 17:01:00 +02:00
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandReadVer( Abc_Frame_t * pAbc, int argc, char ** argv )
{
2006-08-23 17:01:00 +02:00
Abc_Ntk_t * pNtk, * pNtkNew;
2006-08-22 17:01:00 +02:00
Abc_Lib_t * pDesign;
2006-08-20 17:01:00 +02:00
char * FileName;
FILE * pFile;
int fCheck;
int c;
2006-08-23 17:01:00 +02:00
extern Abc_Ntk_t * Abc_LibDeriveAig( Abc_Ntk_t * pNtk, Abc_Lib_t * pLib );
2006-08-20 17:01:00 +02:00
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
FileName = argv[globalUtilOptind];
if ( (pFile = fopen( FileName, "r" )) == NULL )
{
fprintf( pAbc->Err, "Cannot open input file \"%s\". ", FileName );
if ( FileName = Extra_FileGetSimilarName( FileName, ".mv", ".blif", ".pla", ".eqn", ".bench" ) )
fprintf( pAbc->Err, "Did you mean \"%s\"?", FileName );
fprintf( pAbc->Err, "\n" );
return 1;
}
fclose( pFile );
// set the new network
2006-08-23 17:01:00 +02:00
pDesign = Ver_ParseFile( FileName, Abc_FrameReadLibVer(), fCheck, 1 );
2006-08-22 17:01:00 +02:00
if ( pDesign == NULL )
2006-08-20 17:01:00 +02:00
{
fprintf( pAbc->Err, "Reading network from the verilog file has failed.\n" );
return 1;
}
2006-08-23 17:01:00 +02:00
2006-08-22 17:01:00 +02:00
// derive root design
pNtk = Abc_LibDeriveRoot( pDesign );
2006-08-23 17:01:00 +02:00
Abc_LibFree( pDesign );
2006-08-22 17:01:00 +02:00
if ( pNtk == NULL )
2006-08-20 17:01:00 +02:00
{
2006-08-22 17:01:00 +02:00
fprintf( pAbc->Err, "Deriving root module has failed.\n" );
return 1;
2006-08-20 17:01:00 +02:00
}
2006-08-23 17:01:00 +02:00
// derive the AIG network from this design
pNtkNew = Abc_LibDeriveAig( pNtk, Abc_FrameReadLibVer() );
Abc_NtkDelete( pNtk );
if ( pNtkNew == NULL )
{
fprintf( pAbc->Err, "Converting root module to AIG has failed.\n" );
return 1;
}
2006-08-22 17:01:00 +02:00
// replace the current network
2006-08-23 17:01:00 +02:00
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew );
2006-08-20 17:01:00 +02:00
return 0;
usage:
fprintf( pAbc->Err, "usage: read_ver [-ch] <file>\n" );
fprintf( pAbc->Err, "\t read a network in structural verilog (using current library)\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 IoCommandReadVerLib( Abc_Frame_t * pAbc, int argc, char ** argv )
{
2006-08-22 17:01:00 +02:00
Abc_Lib_t * pLibrary;
2006-08-20 17:01:00 +02:00
char * FileName;
FILE * pFile;
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
FileName = argv[globalUtilOptind];
if ( (pFile = fopen( FileName, "r" )) == NULL )
{
fprintf( pAbc->Err, "Cannot open input file \"%s\". ", FileName );
if ( FileName = Extra_FileGetSimilarName( FileName, ".mv", ".blif", ".pla", ".eqn", ".bench" ) )
fprintf( pAbc->Err, "Did you mean \"%s\"?", FileName );
fprintf( pAbc->Err, "\n" );
return 1;
}
fclose( pFile );
// set the new network
2006-08-23 17:01:00 +02:00
pLibrary = Ver_ParseFile( FileName, NULL, fCheck, 0 );
2006-08-22 17:01:00 +02:00
if ( pLibrary == NULL )
2006-08-20 17:01:00 +02:00
{
fprintf( pAbc->Err, "Reading library from the verilog file has failed.\n" );
return 1;
}
2006-08-22 17:01:00 +02:00
printf( "The library contains %d gates.\n", st_count(pLibrary->tModules) );
// free old library
if ( Abc_FrameReadLibVer() )
Abc_LibFree( Abc_FrameReadLibVer() );
// read new library
Abc_FrameSetLibVer( pLibrary );
2006-08-20 17:01:00 +02:00
return 0;
usage:
fprintf( pAbc->Err, "usage: read_verlib [-ch] <file>\n" );
fprintf( pAbc->Err, "\t read a gate library in structural verilog\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;
}
2005-07-29 17:01:00 +02:00
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandReadPla( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk, * pTemp;
char * FileName;
FILE * pFile;
int fCheck;
int c;
fCheck = 1;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
2005-07-29 17:01:00 +02:00
{
switch ( c )
{
case 'c':
fCheck ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-07-29 17:01:00 +02:00
{
goto usage;
}
// get the input file name
2006-02-20 17:01:00 +01:00
FileName = argv[globalUtilOptind];
2005-07-29 17:01:00 +02:00
if ( (pFile = fopen( FileName, "r" )) == NULL )
{
fprintf( pAbc->Err, "Cannot open input file \"%s\". ", FileName );
2005-08-31 17:01:00 +02:00
if ( FileName = Extra_FileGetSimilarName( FileName, ".mv", ".blif", ".pla", ".eqn", ".bench" ) )
2005-07-29 17:01:00 +02:00
fprintf( pAbc->Err, "Did you mean \"%s\"?", FileName );
fprintf( pAbc->Err, "\n" );
return 1;
}
fclose( pFile );
// set the new network
2005-08-09 17:01:00 +02:00
pNtk = Io_ReadPla( FileName, fCheck );
2005-07-29 17:01:00 +02:00
if ( pNtk == NULL )
{
fprintf( pAbc->Err, "Reading network from PLA file has failed.\n" );
return 1;
}
2005-08-12 17:01:00 +02:00
pNtk = Abc_NtkNetlistToLogic( pTemp = pNtk );
2005-07-29 17:01:00 +02:00
Abc_NtkDelete( pTemp );
if ( pNtk == NULL )
{
fprintf( pAbc->Err, "Converting to logic network after reading has failed.\n" );
return 1;
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
return 0;
usage:
fprintf( pAbc->Err, "usage: read_pla [-ch] <file>\n" );
fprintf( pAbc->Err, "\t read the network in PLA\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;
}
2005-10-05 17:01:00 +02:00
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandReadTruth( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk;
char * pSopCover;
int fHex;
int c;
fHex = 0;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "xh" ) ) != EOF )
2005-10-05 17:01:00 +02:00
{
switch ( c )
{
case 'x':
fHex ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-10-05 17:01:00 +02:00
{
goto usage;
}
// convert truth table to SOP
if ( fHex )
2006-02-20 17:01:00 +01:00
pSopCover = Abc_SopFromTruthHex(argv[globalUtilOptind]);
2005-10-05 17:01:00 +02:00
else
2006-02-20 17:01:00 +01:00
pSopCover = Abc_SopFromTruthBin(argv[globalUtilOptind]);
2005-10-05 17:01:00 +02:00
if ( pSopCover == NULL )
{
fprintf( pAbc->Err, "Reading truth table has failed.\n" );
return 1;
}
pNtk = Abc_NtkCreateWithNode( pSopCover );
free( pSopCover );
if ( pNtk == NULL )
{
fprintf( pAbc->Err, "Deriving the network has failed.\n" );
return 1;
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
return 0;
usage:
fprintf( pAbc->Err, "usage: read_truth [-xh] <truth>\n" );
fprintf( pAbc->Err, "\t creates network with node having given truth table\n" );
fprintf( pAbc->Err, "\t-x : toggles between bin and hex representation [default = %s]\n", fHex? "hex":"bin" );
fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
fprintf( pAbc->Err, "\ttruth : truth table with most signficant bit first (e.g. 1000 for AND(a,b))\n" );
return 1;
}
2005-07-29 17:01:00 +02:00
2005-10-10 17:01:00 +02:00
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandWriteBaf( Abc_Frame_t * pAbc, int argc, char **argv )
{
Abc_Ntk_t * pNtk;
char * FileName;
int c;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "lh" ) ) != EOF )
2005-10-10 17:01:00 +02:00
{
switch ( c )
{
case 'h':
goto usage;
default:
goto usage;
}
}
pNtk = pAbc->pNtkCur;
if ( pNtk == NULL )
{
fprintf( pAbc->Out, "Empty network.\n" );
return 0;
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-10-10 17:01:00 +02:00
{
goto usage;
}
2006-02-20 17:01:00 +01:00
FileName = argv[globalUtilOptind];
2005-10-10 17:01:00 +02:00
// check the network type
if ( !Abc_NtkIsStrash(pNtk) )
{
fprintf( pAbc->Out, "Currently can only write strashed combinational AIGs.\n" );
return 0;
}
Io_WriteBaf( pNtk, FileName );
return 0;
usage:
fprintf( pAbc->Err, "usage: write_baf [-lh] <file>\n" );
fprintf( pAbc->Err, "\t write the network into a BLIF file\n" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
return 1;
}
2005-07-29 17:01:00 +02:00
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandWriteBlif( Abc_Frame_t * pAbc, int argc, char **argv )
{
2005-08-12 17:01:00 +02:00
Abc_Ntk_t * pNtk;
2005-07-29 17:01:00 +02:00
char * FileName;
int fWriteLatches;
int c;
fWriteLatches = 1;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "lh" ) ) != EOF )
2005-07-29 17:01:00 +02:00
{
switch ( c )
{
case 'l':
fWriteLatches ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
2005-08-12 17:01:00 +02:00
pNtk = pAbc->pNtkCur;
if ( pNtk == NULL )
2005-07-29 17:01:00 +02:00
{
fprintf( pAbc->Out, "Empty network.\n" );
return 0;
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-07-29 17:01:00 +02:00
{
goto usage;
}
2006-02-20 17:01:00 +01:00
FileName = argv[globalUtilOptind];
2005-08-12 17:01:00 +02:00
// check the network type
2005-08-29 17:01:00 +02:00
if ( !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) && !Abc_NtkIsSeq(pNtk) )
2005-07-29 17:01:00 +02:00
{
2005-08-14 17:01:00 +02:00
fprintf( pAbc->Out, "Currently can only write logic networks, AIGs, and seq AIGs.\n" );
2005-08-12 17:01:00 +02:00
return 0;
2005-07-29 17:01:00 +02:00
}
2005-08-12 17:01:00 +02:00
Io_WriteBlifLogic( pNtk, FileName, fWriteLatches );
2006-04-12 17:01:00 +02:00
// Io_WriteBlifNetlist( pNtk, FileName, fWriteLatches );
2005-07-29 17:01:00 +02:00
return 0;
usage:
fprintf( pAbc->Err, "usage: write_blif [-lh] <file>\n" );
fprintf( pAbc->Err, "\t write the network into a BLIF file\n" );
fprintf( pAbc->Err, "\t-l : toggle writing latches [default = %s]\n", fWriteLatches? "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;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
2005-08-12 17:01:00 +02:00
int IoCommandWriteBench( Abc_Frame_t * pAbc, int argc, char **argv )
2005-07-29 17:01:00 +02:00
{
2005-08-12 17:01:00 +02:00
Abc_Ntk_t * pNtk, * pNtkTemp;
2005-07-29 17:01:00 +02:00
char * FileName;
int fWriteLatches;
int c;
fWriteLatches = 1;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "lh" ) ) != EOF )
2005-07-29 17:01:00 +02:00
{
switch ( c )
{
case 'l':
fWriteLatches ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
2005-08-12 17:01:00 +02:00
pNtk = pAbc->pNtkCur;
2005-07-29 17:01:00 +02:00
if ( pNtk == NULL )
{
fprintf( pAbc->Out, "Empty network.\n" );
return 0;
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-07-29 17:01:00 +02:00
{
goto usage;
}
// get the input file name
2006-02-20 17:01:00 +01:00
FileName = argv[globalUtilOptind];
2005-07-29 17:01:00 +02:00
2005-08-29 17:01:00 +02:00
if ( !Abc_NtkIsStrash(pNtk) )
2005-07-29 17:01:00 +02:00
{
fprintf( pAbc->Out, "The network should be an AIG.\n" );
return 0;
}
2005-08-12 17:01:00 +02:00
// derive the netlist
pNtkTemp = Abc_NtkLogicToNetlistBench(pNtk);
if ( pNtkTemp == NULL )
2005-07-29 17:01:00 +02:00
{
2005-08-12 17:01:00 +02:00
fprintf( pAbc->Out, "Writing BENCH has failed.\n" );
return 0;
2005-07-29 17:01:00 +02:00
}
2005-08-12 17:01:00 +02:00
Io_WriteBench( pNtkTemp, FileName );
Abc_NtkDelete( pNtkTemp );
2005-07-29 17:01:00 +02:00
return 0;
usage:
fprintf( pAbc->Err, "usage: write_bench [-h] <file>\n" );
fprintf( pAbc->Err, "\t write the network in BENCH format\n" );
// fprintf( pAbc->Err, "\t-l : toggle writing latches [default = %s]\n", fWriteLatches? "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;
}
2006-11-11 17:01:00 +01:00
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandWriteCellNet( Abc_Frame_t * pAbc, int argc, char **argv )
{
Abc_Ntk_t * pNtk;
char * FileName;
int c;
extern void Io_WriteCellNet( Abc_Ntk_t * pNtk, char * pFileName );
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
{
switch ( c )
{
case 'h':
goto usage;
default:
goto usage;
}
}
pNtk = pAbc->pNtkCur;
if ( pNtk == NULL )
{
fprintf( pAbc->Out, "Empty network.\n" );
return 0;
}
if ( argc != globalUtilOptind + 1 )
{
goto usage;
}
// get the input file name
FileName = argv[globalUtilOptind];
if ( !Abc_NtkIsLogic(pNtk) )
{
fprintf( pAbc->Out, "The network should be a logic network (if it an AIG, use command \"logic\")\n" );
return 0;
}
// derive the netlist
Io_WriteCellNet( pNtk, FileName );
return 0;
usage:
fprintf( pAbc->Err, "usage: write_cellnet [-h] <file>\n" );
fprintf( pAbc->Err, "\t write the network is the cellnet format\n" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
return 1;
}
2005-07-29 17:01:00 +02:00
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandWriteCnf( Abc_Frame_t * pAbc, int argc, char **argv )
{
char * FileName;
int c;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
2005-07-29 17:01:00 +02:00
{
switch ( c )
{
case 'h':
goto usage;
default:
goto usage;
}
}
if ( pAbc->pNtkCur == NULL )
{
2006-02-20 17:01:00 +01:00
printf( "Empty network.\n" );
2005-07-29 17:01:00 +02:00
return 0;
}
2006-02-20 17:01:00 +01:00
if ( !Abc_NtkIsStrash(pAbc->pNtkCur) )
{
printf( "This command can only be applied to an AIG (run \"strash\").\n" );
return 1;
}
2005-07-29 17:01:00 +02:00
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-07-29 17:01:00 +02:00
{
goto usage;
}
// get the input file name
2006-02-20 17:01:00 +01:00
FileName = argv[globalUtilOptind];
2005-07-29 17:01:00 +02:00
// write the file
if ( !Io_WriteCnf( pAbc->pNtkCur, FileName ) )
{
printf( "Writing CNF has failed.\n" );
return 1;
}
return 0;
usage:
fprintf( pAbc->Err, "usage: write_cnf [-h] <file>\n" );
fprintf( pAbc->Err, "\t write the miter cone into a CNF file\n" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
2005-08-31 17:01:00 +02:00
return 1;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandWriteDot( Abc_Frame_t * pAbc, int argc, char **argv )
{
char * FileName;
Vec_Ptr_t * vNodes;
int c;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
2005-08-31 17:01:00 +02:00
{
switch ( c )
{
case 'h':
goto usage;
default:
goto usage;
}
}
if ( pAbc->pNtkCur == NULL )
{
fprintf( pAbc->Out, "Empty network.\n" );
return 0;
}
2005-09-15 17:01:00 +02:00
if ( !Abc_NtkHasAig(pAbc->pNtkCur) )
2005-08-31 17:01:00 +02:00
{
2005-09-15 17:01:00 +02:00
fprintf( stdout, "IoCommandWriteDot(): Currently can only process AIGs.\n" );
2005-08-31 17:01:00 +02:00
return 0;
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-08-31 17:01:00 +02:00
{
goto usage;
}
// get the input file name
2006-02-20 17:01:00 +01:00
FileName = argv[globalUtilOptind];
2005-08-31 17:01:00 +02:00
// write the file
vNodes = Abc_NtkCollectObjects( pAbc->pNtkCur );
2005-11-27 17:01:00 +01:00
Io_WriteDotAig( pAbc->pNtkCur, vNodes, NULL, FileName, 0 );
2005-08-31 17:01:00 +02:00
Vec_PtrFree( vNodes );
return 0;
usage:
fprintf( pAbc->Err, "usage: write_dot [-h] <file>\n" );
fprintf( pAbc->Err, "\t write the AIG into a DOT file\n" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
return 1;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandWriteEqn( Abc_Frame_t * pAbc, int argc, char **argv )
{
Abc_Ntk_t * pNtk, * pNtkTemp;
char * FileName;
int c;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
2005-08-31 17:01:00 +02:00
{
switch ( c )
{
case 'h':
goto usage;
default:
goto usage;
}
}
pNtk = pAbc->pNtkCur;
if ( pNtk == NULL )
{
fprintf( pAbc->Out, "Empty network.\n" );
return 0;
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-08-31 17:01:00 +02:00
{
goto usage;
}
if ( !Abc_NtkIsLogic(pNtk) && !Abc_NtkIsStrash(pNtk) )
{
fprintf( stdout, "IoCommandWriteGml(): Currently can only process logic networks with BDDs.\n" );
return 0;
}
// get the input file name
2006-02-20 17:01:00 +01:00
FileName = argv[globalUtilOptind];
2005-08-31 17:01:00 +02:00
// write the file
// get rid of complemented covers if present
if ( Abc_NtkIsSopLogic(pNtk) )
Abc_NtkLogicMakeDirectSops(pNtk);
// derive the netlist
2006-03-03 17:01:00 +01:00
pNtkTemp = Abc_NtkLogicToNetlist(pNtk,1);
2005-08-31 17:01:00 +02:00
if ( pNtkTemp == NULL )
{
fprintf( pAbc->Out, "Writing BENCH has failed.\n" );
return 0;
}
Io_WriteEqn( pNtkTemp, FileName );
Abc_NtkDelete( pNtkTemp );
return 0;
usage:
fprintf( pAbc->Err, "usage: write_eqn [-h] <file>\n" );
fprintf( pAbc->Err, "\t write the current network in the equation format\n" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
return 1;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandWriteGml( Abc_Frame_t * pAbc, int argc, char **argv )
{
char * FileName;
int c;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
2005-08-31 17:01:00 +02:00
{
switch ( c )
{
case 'h':
goto usage;
default:
goto usage;
}
}
if ( pAbc->pNtkCur == NULL )
{
fprintf( pAbc->Out, "Empty network.\n" );
return 0;
}
if ( !Abc_NtkIsLogic(pAbc->pNtkCur) && !Abc_NtkIsStrash(pAbc->pNtkCur) )
{
fprintf( stdout, "IoCommandWriteGml(): Currently can only process logic networks with BDDs.\n" );
return 0;
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-08-31 17:01:00 +02:00
{
goto usage;
}
// get the input file name
2006-02-20 17:01:00 +01:00
FileName = argv[globalUtilOptind];
2005-08-31 17:01:00 +02:00
// write the file
Io_WriteGml( pAbc->pNtkCur, FileName );
return 0;
usage:
fprintf( pAbc->Err, "usage: write_gml [-h] <file>\n" );
fprintf( pAbc->Err, "\t write network using graph representation formal GML\n" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
2005-11-14 17:01:00 +01:00
return 1;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandWriteList( Abc_Frame_t * pAbc, int argc, char **argv )
{
char * FileName;
int fUseHost;
int c;
fUseHost = 1;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "nh" ) ) != EOF )
2005-11-14 17:01:00 +01:00
{
switch ( c )
{
case 'n':
fUseHost ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
if ( pAbc->pNtkCur == NULL )
{
fprintf( pAbc->Out, "Empty network.\n" );
return 0;
}
if ( !Abc_NtkIsSeq(pAbc->pNtkCur) )
{
fprintf( stdout, "IoCommandWriteList(): Can write adjacency list for sequential AIGs only.\n" );
return 0;
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-11-14 17:01:00 +01:00
{
goto usage;
}
// get the input file name
2006-02-20 17:01:00 +01:00
FileName = argv[globalUtilOptind];
2005-11-14 17:01:00 +01:00
// write the file
Io_WriteList( pAbc->pNtkCur, FileName, fUseHost );
return 0;
usage:
fprintf( pAbc->Err, "usage: write_list [-nh] <file>\n" );
fprintf( pAbc->Err, "\t write network using graph representation formal GML\n" );
fprintf( pAbc->Err, "\t-n : toggle writing host node [default = %s]\n", fUseHost? "yes":"no" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
2005-07-29 17:01:00 +02:00
return 1;
}
2005-08-09 17:01:00 +02:00
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandWritePla( Abc_Frame_t * pAbc, int argc, char **argv )
{
2005-08-12 17:01:00 +02:00
Abc_Ntk_t * pNtk, * pNtkTemp;
2005-08-09 17:01:00 +02:00
char * FileName;
int c;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
2005-08-09 17:01:00 +02:00
{
switch ( c )
{
case 'h':
goto usage;
default:
goto usage;
}
}
2005-08-12 17:01:00 +02:00
pNtk = pAbc->pNtkCur;
if ( pNtk == NULL )
2005-08-09 17:01:00 +02:00
{
fprintf( pAbc->Out, "Empty network.\n" );
return 0;
}
2005-08-12 17:01:00 +02:00
if ( Abc_NtkGetLevelNum(pNtk) > 1 )
2005-08-09 17:01:00 +02:00
{
fprintf( pAbc->Out, "PLA writing is available for collapsed networks.\n" );
return 0;
}
2006-03-03 17:01:00 +01:00
if ( Abc_NtkGetLevelNum(pNtk) > 1 )
{
fprintf( pAbc->Out, "PLA writing is available for collapsed networks.\n" );
return 0;
}
2005-08-12 17:01:00 +02:00
if ( Abc_NtkLatchNum(pNtk) > 0 )
{
fprintf( pAbc->Out, "Latches are writed at PI/PO pairs in the PLA file.\n" );
return 0;
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-08-09 17:01:00 +02:00
{
goto usage;
}
2006-03-03 17:01:00 +01:00
2005-08-09 17:01:00 +02:00
// get the input file name
2006-02-20 17:01:00 +01:00
FileName = argv[globalUtilOptind];
2005-08-12 17:01:00 +02:00
// derive the netlist
2006-03-03 17:01:00 +01:00
pNtkTemp = Abc_NtkLogicToNetlist(pNtk,1);
2005-08-12 17:01:00 +02:00
if ( pNtkTemp == NULL )
2005-08-09 17:01:00 +02:00
{
2005-08-12 17:01:00 +02:00
fprintf( pAbc->Out, "Writing PLA has failed.\n" );
return 0;
2005-08-09 17:01:00 +02:00
}
2005-08-12 17:01:00 +02:00
Io_WritePla( pNtkTemp, FileName );
Abc_NtkDelete( pNtkTemp );
2005-08-09 17:01:00 +02:00
return 0;
usage:
fprintf( pAbc->Err, "usage: write_pla [-h] <file>\n" );
fprintf( pAbc->Err, "\t write the collapsed network into a PLA file\n" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
return 1;
}
2005-12-22 17:01:00 +01:00
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandWriteVerilog( Abc_Frame_t * pAbc, int argc, char **argv )
{
Abc_Ntk_t * pNtk, * pNtkTemp;
char * FileName;
int c;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
2005-12-22 17:01:00 +01:00
{
switch ( c )
{
case 'h':
goto usage;
default:
goto usage;
}
}
pNtk = pAbc->pNtkCur;
if ( pNtk == NULL )
{
fprintf( pAbc->Out, "Empty network.\n" );
return 0;
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-12-22 17:01:00 +01:00
{
goto usage;
}
// get the input file name
2006-02-20 17:01:00 +01:00
FileName = argv[globalUtilOptind];
2005-12-22 17:01:00 +01:00
2006-10-07 17:01:00 +02:00
if ( Abc_NtkLatchNum(pNtk) > 0 )
{
fprintf( pAbc->Out, "Currently cannot write verilog for sequential networks.\n" );
return 0;
}
2005-12-22 17:01:00 +01:00
// derive the netlist
2006-03-03 17:01:00 +01:00
pNtkTemp = Abc_NtkLogicToNetlist(pNtk,0);
2006-10-07 17:01:00 +02:00
Abc_NtkSopToAig( pNtkTemp );
2005-12-22 17:01:00 +01:00
if ( pNtkTemp == NULL )
{
fprintf( pAbc->Out, "Writing PLA has failed.\n" );
return 0;
}
2006-10-07 17:01:00 +02:00
Io_WriteVerilog( pNtkTemp, FileName, 1 );
2005-12-22 17:01:00 +01:00
Abc_NtkDelete( pNtkTemp );
return 0;
usage:
fprintf( pAbc->Err, "usage: write_verilog [-h] <file>\n" );
2006-10-07 17:01:00 +02:00
fprintf( pAbc->Err, "\t write the current network in Verilog format\n" );
2005-12-22 17:01:00 +01:00
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
return 1;
}
2006-08-20 17:01:00 +02:00
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandWriteVerLib( Abc_Frame_t * pAbc, int argc, char **argv )
{
2006-08-23 17:01:00 +02:00
Abc_Lib_t * pLibrary;
2006-08-20 17:01:00 +02:00
char * FileName;
int c;
2006-08-23 17:01:00 +02:00
extern void Io_WriteVerilogLibrary( Abc_Lib_t * pLibrary, char * pFileName );
2006-08-20 17:01:00 +02:00
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
FileName = argv[globalUtilOptind];
// derive the netlist
2006-08-23 17:01:00 +02:00
pLibrary = Abc_FrameReadLibVer();
if ( pLibrary == NULL )
2006-08-20 17:01:00 +02:00
{
fprintf( pAbc->Out, "Verilog library is not specified.\n" );
return 0;
}
2006-08-23 17:01:00 +02:00
Io_WriteVerilogLibrary( pLibrary, FileName );
2006-08-20 17:01:00 +02:00
return 0;
usage:
fprintf( pAbc->Err, "usage: write_verlib [-h] <file>\n" );
fprintf( pAbc->Err, "\t write the current verilog library\n" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
return 1;
}
2006-03-03 17:01:00 +01:00
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandWriteCounter( Abc_Frame_t * pAbc, int argc, char **argv )
{
Abc_Ntk_t * pNtk;
char * FileName;
int c;
int fNames;
fNames = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "nh" ) ) != EOF )
{
switch ( c )
{
case 'n':
fNames ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
pNtk = pAbc->pNtkCur;
if ( pNtk == NULL )
{
fprintf( pAbc->Out, "Empty network.\n" );
return 0;
}
if ( argc != globalUtilOptind + 1 )
{
goto usage;
}
// get the input file name
FileName = argv[globalUtilOptind];
if ( pNtk->pModel == NULL )
{
fprintf( pAbc->Out, "Counter-example is not available.\n" );
return 0;
}
// write the counter-example into the file
{
Abc_Obj_t * pObj;
FILE * pFile = fopen( FileName, "w" );
int i;
if ( pFile == NULL )
{
2006-08-23 17:01:00 +02:00
fprintf( stdout, "IoCommandWriteCounter(): Cannot open the output file \"%s\".\n", FileName );
2006-03-03 17:01:00 +01:00
return 1;
}
if ( fNames )
{
Abc_NtkForEachPi( pNtk, pObj, i )
fprintf( pFile, "%s=%c ", Abc_ObjName(pObj), '0'+(pNtk->pModel[i]==1) );
}
else
{
Abc_NtkForEachPi( pNtk, pObj, i )
fprintf( pFile, "%c", '0'+(pNtk->pModel[i]==1) );
}
fprintf( pFile, "\n" );
fclose( pFile );
}
return 0;
usage:
fprintf( pAbc->Err, "usage: write_counter [-nh] <file>\n" );
fprintf( pAbc->Err, "\t writes the counter-example derived by \"prove\" or \"sat\"\n" );
fprintf( pAbc->Err, "\t the file contains values for each PI in the natural order\n" );
fprintf( pAbc->Err, "\t-n : write input names into the file [default = %s]\n", fNames? "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;
}
2005-12-22 17:01:00 +01:00
2005-07-29 17:01:00 +02:00
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////