abc/src/base/io/io.c

1669 lines
48 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 );
2007-01-10 17:01:00 +01:00
static int IoCommandReadHie ( Abc_Frame_t * pAbc, int argc, char **argv );
2006-12-16 17:01:00 +01:00
static int IoCommandReadAiger ( 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 );
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 );
2007-01-10 17:01:00 +01:00
static int IoCommandReadVerilog ( Abc_Frame_t * pAbc, int argc, char **argv );
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
2007-01-10 17:01:00 +01:00
static int IoCommandWrite ( Abc_Frame_t * pAbc, int argc, char **argv );
2006-12-16 17:01:00 +01:00
static int IoCommandWriteAiger ( Abc_Frame_t * pAbc, int argc, char **argv );
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 );
2007-01-10 17:01:00 +01:00
static int IoCommandWriteCounter( 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 );
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 );
2007-01-10 17:01:00 +01:00
Cmd_CommandAdd( pAbc, "I/O", "rh", IoCommandReadHie, 1 );
2006-12-16 17:01:00 +01:00
Cmd_CommandAdd( pAbc, "I/O", "read_aiger", IoCommandReadAiger, 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 );
2007-01-10 17:01:00 +01: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 );
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 );
2007-01-10 17:01:00 +01:00
// Cmd_CommandAdd( pAbc, "I/O", "read_verilog", IoCommandReadVerilog, 1 );
// 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
2007-01-10 17:01:00 +01:00
Cmd_CommandAdd( pAbc, "I/O", "write", IoCommandWrite, 0 );
2006-12-16 17:01:00 +01:00
Cmd_CommandAdd( pAbc, "I/O", "write_aiger", IoCommandWriteAiger, 0 );
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 );
2007-01-10 17:01:00 +01:00
Cmd_CommandAdd( pAbc, "I/O", "write_counter", IoCommandWriteCounter, 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 );
2007-01-10 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 );
2007-01-10 17:01:00 +01:00
// Cmd_CommandAdd( pAbc, "I/O", "write_verilog", IoCommandWriteVerilog, 0 );
// Cmd_CommandAdd( pAbc, "I/O", "write_verlib", IoCommandWriteVerLib, 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;
2007-01-10 17:01:00 +01:00
char * pFileName;
2005-07-29 17:01:00 +02:00
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
2007-01-10 17:01:00 +01:00
pFileName = argv[globalUtilOptind];
// read the file using the corresponding file reader
pNtk = Io_Read( pFileName, Io_ReadFileType(pFileName), fCheck );
2005-07-29 17:01:00 +02:00
if ( pNtk == NULL )
return 1;
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
return 0;
usage:
fprintf( pAbc->Err, "usage: read [-ch] <file>\n" );
2007-01-10 17:01:00 +01:00
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" );
2006-12-16 17:01:00 +01:00
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 []
***********************************************************************/
2007-01-10 17:01:00 +01:00
int IoCommandReadHie( Abc_Frame_t * pAbc, int argc, char ** argv )
2006-12-16 17:01:00 +01:00
{
Abc_Ntk_t * pNtk;
2007-01-10 17:01:00 +01:00
char * pFileName;
int fCheck, fBlifMv;
2006-12-16 17:01:00 +01:00
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
2007-01-10 17:01:00 +01:00
pFileName = argv[globalUtilOptind];
// read the file using the corresponding file reader
// pNtk = Io_Read( pFileName, Io_ReadFileType(pFileName), fCheck );
if ( Io_ReadFileType(pFileName) == IO_FILE_BLIFMV )
fBlifMv = 1;
else if ( Io_ReadFileType(pFileName) == IO_FILE_BLIF )
fBlifMv = 0;
else
2006-12-16 17:01:00 +01:00
{
2007-01-10 17:01:00 +01:00
printf( "Wrong file type.\n" );
2006-12-16 17:01:00 +01:00
return 1;
}
2007-01-10 17:01:00 +01:00
Io_ReadBlifMv( pFileName, fBlifMv, fCheck );
pNtk = NULL;
2006-12-16 17:01:00 +01:00
if ( pNtk == NULL )
2007-01-10 17:01:00 +01:00
return 0;
2006-12-16 17:01:00 +01:00
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
return 0;
usage:
2007-01-10 17:01:00 +01:00
fprintf( pAbc->Err, "usage: rh [-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" );
2005-07-29 17:01:00 +02:00
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 []
***********************************************************************/
2007-01-10 17:01:00 +01:00
int IoCommandReadAiger( Abc_Frame_t * pAbc, int argc, char ** argv )
2005-10-10 17:01:00 +02:00
{
Abc_Ntk_t * pNtk;
2007-01-10 17:01:00 +01:00
char * pFileName;
2005-10-10 17:01:00 +02:00
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
2007-01-10 17:01:00 +01:00
pFileName = argv[globalUtilOptind];
// read the file using the corresponding file reader
pNtk = Io_Read( pFileName, IO_FILE_AIGER, fCheck );
2005-10-10 17:01:00 +02:00
if ( pNtk == NULL )
return 1;
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
return 0;
usage:
2007-01-10 17:01:00 +01:00
fprintf( pAbc->Err, "usage: read_aiger [-ch] <file>\n" );
fprintf( pAbc->Err, "\t read the network in the AIGER format (http://fmv.jku.at/aiger)\n" );
2005-10-10 17:01:00 +02:00
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 []
***********************************************************************/
2007-01-10 17:01:00 +01:00
int IoCommandReadBaf( Abc_Frame_t * pAbc, int argc, char ** argv )
2005-07-29 17:01:00 +02:00
{
2007-01-10 17:01:00 +01:00
Abc_Ntk_t * pNtk;
char * pFileName;
2005-07-29 17:01:00 +02:00
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
2007-01-10 17:01:00 +01:00
pFileName = argv[globalUtilOptind];
// read the file using the corresponding file reader
pNtk = Io_Read( pFileName, IO_FILE_BAF, fCheck );
2005-07-29 17:01:00 +02:00
if ( pNtk == NULL )
return 1;
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
return 0;
usage:
2007-01-10 17:01:00 +01:00
fprintf( pAbc->Err, "usage: read_baf [-ch] <file>\n" );
fprintf( pAbc->Err, "\t read the network in Binary Aig Format (BAF)\n" );
2005-07-29 17:01:00 +02:00
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 []
***********************************************************************/
2007-01-10 17:01:00 +01:00
int IoCommandReadBlif( Abc_Frame_t * pAbc, int argc, char ** argv )
2005-07-29 17:01:00 +02:00
{
2007-01-10 17:01:00 +01:00
Abc_Ntk_t * pNtk;
char * pFileName;
int fReadAsAig;
2005-07-29 17:01:00 +02:00
int fCheck;
int c;
2007-01-10 17:01:00 +01:00
extern Abc_Ntk_t * Io_ReadBlifAsAig( char * pFileName, int fCheck );
2005-07-29 17:01:00 +02:00
fCheck = 1;
2007-01-10 17:01:00 +01:00
fReadAsAig = 0;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
2007-01-10 17:01:00 +01:00
while ( ( c = Extra_UtilGetopt( argc, argv, "ach" ) ) != EOF )
2005-07-29 17:01:00 +02:00
{
switch ( c )
{
2007-01-10 17:01:00 +01:00
case 'a':
fReadAsAig ^= 1;
break;
2005-07-29 17:01:00 +02:00
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
2007-01-10 17:01:00 +01:00
pFileName = argv[globalUtilOptind];
// read the file using the corresponding file reader
if ( fReadAsAig )
pNtk = Io_ReadBlifAsAig( pFileName, fCheck );
else
pNtk = Io_Read( pFileName, IO_FILE_BLIF, fCheck );
2005-07-29 17:01:00 +02:00
if ( pNtk == NULL )
return 1;
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
return 0;
usage:
2007-01-10 17:01:00 +01:00
fprintf( pAbc->Err, "usage: read_blif [-ach] <file>\n" );
fprintf( pAbc->Err, "\t read the network in binary BLIF format\n" );
fprintf( pAbc->Err, "\t-a : toggle creating AIG while reading the file [default = %s]\n", fReadAsAig? "yes":"no" );
2005-07-29 17:01:00 +02:00
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 []
***********************************************************************/
2007-01-10 17:01:00 +01:00
int IoCommandReadBench( Abc_Frame_t * pAbc, int argc, char ** argv )
2005-08-14 17:01:00 +02:00
{
2007-01-10 17:01:00 +01:00
Abc_Ntk_t * pNtk;
char * pFileName;
2005-08-14 17:01:00 +02:00
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
2007-01-10 17:01:00 +01:00
pFileName = argv[globalUtilOptind];
// read the file using the corresponding file reader
pNtk = Io_Read( pFileName, IO_FILE_BENCH, fCheck );
2005-08-14 17:01:00 +02:00
if ( pNtk == NULL )
return 1;
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
return 0;
usage:
2007-01-10 17:01:00 +01:00
fprintf( pAbc->Err, "usage: read_bench [-ch] <file>\n" );
fprintf( pAbc->Err, "\t read the network in BENCH format\n" );
2005-08-14 17:01:00 +02:00
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 []
***********************************************************************/
2007-01-10 17:01:00 +01:00
int IoCommandReadEdif( Abc_Frame_t * pAbc, int argc, char ** argv )
2005-08-31 17:01:00 +02:00
{
2007-01-10 17:01:00 +01:00
Abc_Ntk_t * pNtk;
char * pFileName;
2005-08-31 17:01:00 +02:00
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
2007-01-10 17:01:00 +01:00
pFileName = argv[globalUtilOptind];
// read the file using the corresponding file reader
pNtk = Io_Read( pFileName, IO_FILE_EDIF, fCheck );
2005-08-31 17:01:00 +02:00
if ( pNtk == NULL )
return 1;
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
return 0;
usage:
2007-01-10 17:01:00 +01:00
fprintf( pAbc->Err, "usage: read_edif [-ch] <file>\n" );
fprintf( pAbc->Err, "\t read the network in EDIF (works only for ISCAS benchmarks)\n" );
2005-08-31 17:01:00 +02:00
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 []
***********************************************************************/
2007-01-10 17:01:00 +01:00
int IoCommandReadEqn( Abc_Frame_t * pAbc, int argc, char ** argv )
2005-07-29 17:01:00 +02:00
{
2007-01-10 17:01:00 +01:00
Abc_Ntk_t * pNtk;
char * pFileName;
2005-07-29 17:01:00 +02:00
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
2007-01-10 17:01:00 +01:00
pFileName = argv[globalUtilOptind];
// read the file using the corresponding file reader
pNtk = Io_Read( pFileName, IO_FILE_EQN, fCheck );
2005-07-29 17:01:00 +02:00
if ( pNtk == NULL )
return 1;
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
return 0;
usage:
2007-01-10 17:01:00 +01:00
fprintf( pAbc->Err, "usage: read_eqn [-ch] <file>\n" );
fprintf( pAbc->Err, "\t read the network in equation format\n" );
2005-07-29 17:01:00 +02:00
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 []
***********************************************************************/
2007-01-10 17:01:00 +01:00
int IoCommandReadPla( Abc_Frame_t * pAbc, int argc, char ** argv )
2006-08-20 17:01:00 +02:00
{
2007-01-10 17:01:00 +01:00
Abc_Ntk_t * pNtk;
char * pFileName;
2006-08-20 17:01:00 +02:00
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
2007-01-10 17:01:00 +01:00
pFileName = argv[globalUtilOptind];
// read the file using the corresponding file reader
pNtk = Io_Read( pFileName, IO_FILE_PLA, fCheck );
2006-08-22 17:01:00 +02:00
if ( pNtk == NULL )
2006-08-23 17:01:00 +02:00
return 1;
2006-08-22 17:01:00 +02:00
// replace the current network
2007-01-10 17:01:00 +01:00
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
2006-08-20 17:01:00 +02:00
return 0;
usage:
2007-01-10 17:01:00 +01:00
fprintf( pAbc->Err, "usage: read_pla [-ch] <file>\n" );
fprintf( pAbc->Err, "\t read the network in PLA\n" );
2006-08-20 17:01:00 +02:00
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 []
***********************************************************************/
2007-01-10 17:01:00 +01:00
int IoCommandReadTruth( Abc_Frame_t * pAbc, int argc, char ** argv )
2006-08-20 17:01:00 +02:00
{
2007-01-10 17:01:00 +01:00
Abc_Ntk_t * pNtk;
char * pSopCover;
int fHex;
2006-08-20 17:01:00 +02:00
int c;
2007-01-10 17:01:00 +01:00
fHex = 0;
2006-08-20 17:01:00 +02:00
Extra_UtilGetoptReset();
2007-01-10 17:01:00 +01:00
while ( ( c = Extra_UtilGetopt( argc, argv, "xh" ) ) != EOF )
2006-08-20 17:01:00 +02:00
{
switch ( c )
{
2007-01-10 17:01:00 +01:00
case 'x':
fHex ^= 1;
2006-08-20 17:01:00 +02:00
break;
case 'h':
goto usage;
default:
goto usage;
}
}
if ( argc != globalUtilOptind + 1 )
{
goto usage;
}
2007-01-10 17:01:00 +01:00
// convert truth table to SOP
if ( fHex )
pSopCover = Abc_SopFromTruthHex(argv[globalUtilOptind]);
else
pSopCover = Abc_SopFromTruthBin(argv[globalUtilOptind]);
if ( pSopCover == NULL )
2006-08-20 17:01:00 +02:00
{
2007-01-10 17:01:00 +01:00
fprintf( pAbc->Err, "Reading truth table has failed.\n" );
2006-08-20 17:01:00 +02:00
return 1;
}
2007-01-10 17:01:00 +01:00
pNtk = Abc_NtkCreateWithNode( pSopCover );
free( pSopCover );
if ( pNtk == NULL )
2006-08-20 17:01:00 +02:00
{
2007-01-10 17:01:00 +01:00
fprintf( pAbc->Err, "Deriving the network has failed.\n" );
2006-08-20 17:01:00 +02:00
return 1;
}
2007-01-10 17:01:00 +01:00
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
2006-08-20 17:01:00 +02:00
return 0;
usage:
2007-01-10 17:01:00 +01:00
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;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandReadVerilog( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk;
char * pFileName;
int fCheck;
int c;
printf( "Stand-alone structural Verilog reader is now available as command \"read_ver\".\n" );
return 0;
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_Read( pFileName, IO_FILE_VERILOG, fCheck );
if ( pNtk == NULL )
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" );
2006-08-20 17:01:00 +02:00
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 []
***********************************************************************/
2007-01-10 17:01:00 +01:00
int IoCommandReadVer( Abc_Frame_t * pAbc, int argc, char ** argv )
2005-07-29 17:01:00 +02:00
{
2007-01-10 17:01:00 +01:00
Abc_Ntk_t * pNtk, * pNtkNew;
Abc_Lib_t * pDesign;
char * pFileName;
2005-07-29 17:01:00 +02:00
FILE * pFile;
int fCheck;
int c;
2007-01-10 17:01:00 +01:00
extern Abc_Ntk_t * Abc_LibDeriveAig( Abc_Ntk_t * pNtk, Abc_Lib_t * pLib );
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
2007-01-10 17:01:00 +01:00
pFileName = argv[globalUtilOptind];
if ( (pFile = fopen( pFileName, "r" )) == NULL )
2005-07-29 17:01:00 +02:00
{
2007-01-10 17:01:00 +01:00
fprintf( pAbc->Err, "Cannot open input file \"%s\". ", pFileName );
if ( pFileName = Extra_FileGetSimilarName( pFileName, ".blif", ".bench", ".pla", ".baf", ".aig" ) )
fprintf( pAbc->Err, "Did you mean \"%s\"?", pFileName );
2005-07-29 17:01:00 +02:00
fprintf( pAbc->Err, "\n" );
return 1;
}
fclose( pFile );
// set the new network
2007-01-10 17:01:00 +01:00
pDesign = Ver_ParseFile( pFileName, Abc_FrameReadLibVer(), fCheck, 1 );
if ( pDesign == NULL )
2005-07-29 17:01:00 +02:00
{
2007-01-10 17:01:00 +01:00
fprintf( pAbc->Err, "Reading network from the verilog file has failed.\n" );
2005-07-29 17:01:00 +02:00
return 1;
}
2007-01-10 17:01:00 +01:00
// derive root design
pNtk = Abc_LibDeriveRoot( pDesign );
Abc_LibFree( pDesign );
2005-07-29 17:01:00 +02:00
if ( pNtk == NULL )
{
2007-01-10 17:01:00 +01:00
fprintf( pAbc->Err, "Deriving root module has failed.\n" );
return 1;
}
// 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" );
2005-07-29 17:01:00 +02:00
return 1;
}
// replace the current network
2007-01-10 17:01:00 +01:00
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew );
2005-07-29 17:01:00 +02:00
return 0;
usage:
2007-01-10 17:01:00 +01:00
fprintf( pAbc->Err, "usage: read_ver [-ch] <file>\n" );
fprintf( pAbc->Err, "\t read a network in structural verilog (using current library)\n" );
2005-07-29 17:01:00 +02:00
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 []
***********************************************************************/
2007-01-10 17:01:00 +01:00
int IoCommandReadVerLib( Abc_Frame_t * pAbc, int argc, char ** argv )
2005-10-05 17:01:00 +02:00
{
2007-01-10 17:01:00 +01:00
Abc_Lib_t * pLibrary;
char * pFileName;
FILE * pFile;
int fCheck;
2005-10-05 17:01:00 +02:00
int c;
2007-01-10 17:01:00 +01:00
fCheck = 1;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
2007-01-10 17:01:00 +01:00
while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
2005-10-05 17:01:00 +02:00
{
switch ( c )
{
2007-01-10 17:01:00 +01:00
case 'c':
fCheck ^= 1;
2005-10-05 17:01:00 +02:00
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;
}
2007-01-10 17:01:00 +01:00
// get the input file name
pFileName = argv[globalUtilOptind];
if ( (pFile = fopen( pFileName, "r" )) == NULL )
2005-10-05 17:01:00 +02:00
{
2007-01-10 17:01:00 +01:00
fprintf( pAbc->Err, "Cannot open input file \"%s\". ", pFileName );
if ( pFileName = Extra_FileGetSimilarName( pFileName, ".blif", ".bench", ".pla", ".baf", ".aig" ) )
fprintf( pAbc->Err, "Did you mean \"%s\"?", pFileName );
fprintf( pAbc->Err, "\n" );
2005-10-05 17:01:00 +02:00
return 1;
}
2007-01-10 17:01:00 +01:00
fclose( pFile );
2005-10-05 17:01:00 +02:00
2007-01-10 17:01:00 +01:00
// set the new network
pLibrary = Ver_ParseFile( pFileName, NULL, fCheck, 0 );
if ( pLibrary == NULL )
2005-10-05 17:01:00 +02:00
{
2007-01-10 17:01:00 +01:00
fprintf( pAbc->Err, "Reading library from the verilog file has failed.\n" );
2005-10-05 17:01:00 +02:00
return 1;
}
2007-01-10 17:01:00 +01: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 );
2005-10-05 17:01:00 +02:00
return 0;
usage:
2007-01-10 17:01:00 +01:00
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" );
2005-10-05 17:01:00 +02:00
fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
2007-01-10 17:01:00 +01:00
fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
2005-10-05 17:01:00 +02:00
return 1;
}
2005-07-29 17:01:00 +02:00
2006-12-16 17:01:00 +01:00
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
2007-01-10 17:01:00 +01:00
int IoCommandWrite( Abc_Frame_t * pAbc, int argc, char **argv )
2006-12-16 17:01:00 +01:00
{
2007-01-10 17:01:00 +01:00
char * pFileName;
2006-12-16 17:01:00 +01:00
int c;
Extra_UtilGetoptReset();
2007-01-10 17:01:00 +01:00
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
2006-12-16 17:01:00 +01:00
{
switch ( c )
{
case 'h':
goto usage;
default:
goto usage;
}
}
if ( argc != globalUtilOptind + 1 )
goto usage;
2007-01-10 17:01:00 +01:00
// get the output file name
pFileName = argv[globalUtilOptind];
// call the corresponding file writer
Io_Write( pAbc->pNtkCur, pFileName, Io_ReadFileType(pFileName) );
return 0;
usage:
fprintf( pAbc->Err, "usage: write [-h] <file>\n" );
fprintf( pAbc->Err, "\t writes the current network into <file> by calling\n" );
fprintf( pAbc->Err, "\t the writer that matches the extension of <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*************************************************************
2006-12-16 17:01:00 +01:00
2007-01-10 17:01:00 +01:00
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandWriteAiger( Abc_Frame_t * pAbc, int argc, char **argv )
{
char * pFileName;
int c;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
2006-12-16 17:01:00 +01:00
{
2007-01-10 17:01:00 +01:00
switch ( c )
{
case 'h':
goto usage;
default:
goto usage;
}
2006-12-16 17:01:00 +01:00
}
2007-01-10 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
goto usage;
// get the output file name
pFileName = argv[globalUtilOptind];
// call the corresponding file writer
Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_AIGER );
2006-12-16 17:01:00 +01:00
return 0;
usage:
2007-01-10 17:01:00 +01:00
fprintf( pAbc->Err, "usage: write_aiger [-h] <file>\n" );
2006-12-16 17:01:00 +01:00
fprintf( pAbc->Err, "\t write the network in the AIGER format (http://fmv.jku.at/aiger)\n" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
fprintf( pAbc->Err, "\tfile : the name of the file to write (extension .aig)\n" );
return 1;
}
2005-10-10 17:01:00 +02:00
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int IoCommandWriteBaf( Abc_Frame_t * pAbc, int argc, char **argv )
{
2007-01-10 17:01:00 +01:00
char * pFileName;
2005-10-10 17:01:00 +02:00
int c;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
2007-01-10 17:01:00 +01:00
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
2005-10-10 17:01:00 +02:00
{
switch ( c )
{
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;
2007-01-10 17:01:00 +01:00
// get the output file name
pFileName = argv[globalUtilOptind];
// call the corresponding file writer
Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_BAF );
2005-10-10 17:01:00 +02:00
return 0;
usage:
2007-01-10 17:01:00 +01:00
fprintf( pAbc->Err, "usage: write_baf [-h] <file>\n" );
2005-10-10 17:01:00 +02:00
fprintf( pAbc->Err, "\t write the network into a BLIF file\n" );
fprintf( pAbc->Err, "\t-h : print the help massage\n" );
2006-12-16 17:01:00 +01:00
fprintf( pAbc->Err, "\tfile : the name of the file to write (extension .baf)\n" );
2005-10-10 17:01:00 +02:00
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 )
{
2007-01-10 17:01:00 +01:00
char * pFileName;
2005-07-29 17:01:00 +02:00
int c;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
2007-01-10 17:01:00 +01:00
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;
}
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-07-29 17:01:00 +02:00
goto usage;
2007-01-10 17:01:00 +01:00
// get the output file name
pFileName = argv[globalUtilOptind];
// call the corresponding file writer
Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_BLIF );
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-h : print the help massage\n" );
2006-12-16 17:01:00 +01:00
fprintf( pAbc->Err, "\tfile : the name of the file to write (extension .blif)\n" );
2005-07-29 17:01:00 +02:00
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
{
2007-01-10 17:01:00 +01:00
char * pFileName;
2005-07-29 17:01:00 +02:00
int c;
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 '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;
2007-01-10 17:01:00 +01:00
// get the output file name
pFileName = argv[globalUtilOptind];
// call the corresponding file writer
Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_BENCH );
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-h : print the help massage\n" );
2006-12-16 17:01:00 +01:00
fprintf( pAbc->Err, "\tfile : the name of the file to write (extension .bench)\n" );
2005-07-29 17:01:00 +02:00
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;
2007-01-10 17:01:00 +01:00
char * pFileName;
2006-11-11 17:01:00 +01:00
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;
}
}
2007-01-10 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
goto usage;
2006-11-11 17:01:00 +01:00
pNtk = pAbc->pNtkCur;
if ( pNtk == NULL )
{
fprintf( pAbc->Out, "Empty network.\n" );
return 0;
}
2007-01-10 17:01:00 +01:00
// get the output file name
pFileName = argv[globalUtilOptind];
// call the corresponding file writer
2006-11-11 17:01:00 +01:00
if ( !Abc_NtkIsLogic(pNtk) )
{
fprintf( pAbc->Out, "The network should be a logic network (if it an AIG, use command \"logic\")\n" );
return 0;
}
2007-01-10 17:01:00 +01:00
Io_WriteCellNet( pNtk, pFileName );
2006-11-11 17:01:00 +01:00
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 )
{
2007-01-10 17:01:00 +01:00
char * pFileName;
2005-07-29 17:01:00 +02:00
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;
}
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-07-29 17:01:00 +02:00
goto usage;
2007-01-10 17:01:00 +01:00
// get the output file name
pFileName = argv[globalUtilOptind];
// call the corresponding file writer
Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_CNF );
2005-07-29 17:01:00 +02:00
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 )
{
2007-01-10 17:01:00 +01:00
char * pFileName;
2005-08-31 17:01:00 +02:00
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;
}
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-08-31 17:01:00 +02:00
goto usage;
2007-01-10 17:01:00 +01:00
// get the output file name
pFileName = argv[globalUtilOptind];
// call the corresponding file writer
Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_DOT );
2005-08-31 17:01:00 +02:00
return 0;
usage:
fprintf( pAbc->Err, "usage: write_dot [-h] <file>\n" );
2006-11-22 17:01:00 +01:00
fprintf( pAbc->Err, "\t write the current network into a DOT file\n" );
2005-08-31 17:01:00 +02: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;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
2007-01-10 17:01:00 +01:00
int IoCommandWriteCounter( Abc_Frame_t * pAbc, int argc, char **argv )
2005-08-31 17:01:00 +02:00
{
2007-01-10 17:01:00 +01:00
Abc_Ntk_t * pNtk;
char * pFileName;
2005-08-31 17:01:00 +02:00
int c;
2007-01-10 17:01:00 +01:00
int fNames;
2005-08-31 17:01:00 +02:00
2007-01-10 17:01:00 +01:00
fNames = 0;
2006-02-20 17:01:00 +01:00
Extra_UtilGetoptReset();
2007-01-10 17:01:00 +01:00
while ( ( c = Extra_UtilGetopt( argc, argv, "nh" ) ) != EOF )
2005-08-31 17:01:00 +02:00
{
switch ( c )
{
2007-01-10 17:01:00 +01:00
case 'n':
fNames ^= 1;
break;
2005-08-31 17:01:00 +02:00
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;
}
2007-01-10 17:01:00 +01:00
// get the input file name
pFileName = argv[globalUtilOptind];
2005-08-31 17:01:00 +02:00
2007-01-10 17:01:00 +01:00
if ( pNtk->pModel == NULL )
2005-08-31 17:01:00 +02:00
{
2007-01-10 17:01:00 +01:00
fprintf( pAbc->Out, "Counter-example is not available.\n" );
2005-08-31 17:01:00 +02:00
return 0;
}
2007-01-10 17:01:00 +01:00
// write the counter-example into the file
2005-08-31 17:01:00 +02:00
{
2007-01-10 17:01:00 +01:00
Abc_Obj_t * pObj;
FILE * pFile = fopen( pFileName, "w" );
int i;
if ( pFile == NULL )
{
fprintf( stdout, "IoCommandWriteCounter(): Cannot open the output file \"%s\".\n", pFileName );
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 );
2005-08-31 17:01:00 +02:00
}
2007-01-10 17:01:00 +01:00
2005-08-31 17:01:00 +02:00
return 0;
usage:
2007-01-10 17:01:00 +01:00
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" );
2005-08-31 17:01:00 +02: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;
}
2007-01-10 17:01:00 +01:00
2005-08-31 17:01:00 +02:00
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
2007-01-10 17:01:00 +01:00
int IoCommandWriteEqn( Abc_Frame_t * pAbc, int argc, char **argv )
2005-08-31 17:01:00 +02:00
{
2007-01-10 17:01:00 +01:00
char * pFileName;
2005-08-31 17:01:00 +02:00
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;
}
}
2007-01-10 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
goto usage;
// get the output file name
pFileName = argv[globalUtilOptind];
// call the corresponding file writer
Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_EQN );
return 0;
2005-08-31 17:01:00 +02:00
2007-01-10 17:01:00 +01:00
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 * pFileName;
int c;
2005-08-31 17:01:00 +02:00
2007-01-10 17:01:00 +01:00
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
2005-08-31 17:01:00 +02:00
{
2007-01-10 17:01:00 +01:00
switch ( c )
{
case 'h':
goto usage;
default:
goto usage;
}
2005-08-31 17:01:00 +02:00
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-08-31 17:01:00 +02:00
goto usage;
2007-01-10 17:01:00 +01:00
// get the output file name
pFileName = argv[globalUtilOptind];
// call the corresponding file writer
Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_GML );
2005-08-31 17:01:00 +02:00
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 )
{
2007-01-10 17:01:00 +01:00
char * pFileName;
2005-11-14 17:01:00 +01:00
int fUseHost;
int c;
2007-01-10 17:01:00 +01:00
printf( "This command currently does not work.\n" );
return 0;
2005-11-14 17:01:00 +01:00
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;
}
}
2007-01-10 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
goto usage;
2005-11-14 17:01:00 +01:00
if ( pAbc->pNtkCur == NULL )
{
fprintf( pAbc->Out, "Empty network.\n" );
return 0;
}
2007-01-10 17:01:00 +01:00
/*
2005-11-14 17:01:00 +01:00
if ( !Abc_NtkIsSeq(pAbc->pNtkCur) )
{
fprintf( stdout, "IoCommandWriteList(): Can write adjacency list for sequential AIGs only.\n" );
return 0;
}
2007-01-10 17:01:00 +01:00
*/
2005-11-14 17:01:00 +01:00
// get the input file name
2007-01-10 17:01:00 +01:00
pFileName = argv[globalUtilOptind];
2005-11-14 17:01:00 +01:00
// write the file
2007-01-10 17:01:00 +01:00
Io_WriteList( pAbc->pNtkCur, pFileName, fUseHost );
2005-11-14 17:01:00 +01:00
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 )
{
2007-01-10 17:01:00 +01:00
char * pFileName;
2005-08-09 17:01:00 +02:00
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;
}
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-08-09 17:01:00 +02:00
goto usage;
2007-01-10 17:01:00 +01:00
// get the output file name
pFileName = argv[globalUtilOptind];
// call the corresponding file writer
Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_PLA );
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 )
{
2007-01-10 17:01:00 +01:00
char * pFileName;
2005-12-22 17:01:00 +01:00
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;
}
}
2006-02-20 17:01:00 +01:00
if ( argc != globalUtilOptind + 1 )
2005-12-22 17:01:00 +01:00
goto usage;
2007-01-10 17:01:00 +01:00
// get the output file name
pFileName = argv[globalUtilOptind];
// call the corresponding file writer
Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_VERILOG );
2005-12-22 17:01:00 +01:00
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;
2007-01-10 17:01:00 +01:00
char * pFileName;
2006-08-20 17:01:00 +02:00
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
2007-01-10 17:01:00 +01:00
pFileName = argv[globalUtilOptind];
2006-08-20 17:01:00 +02:00
// 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;
}
2007-01-10 17:01:00 +01:00
Io_WriteVerilogLibrary( pLibrary, pFileName );
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;
}
2005-07-29 17:01:00 +02:00
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////