summaryrefslogtreecommitdiffstats
path: root/src/base/cmd/cmd.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2008-01-30 20:01:00 -0800
committerAlan Mishchenko <alanmi@berkeley.edu>2008-01-30 20:01:00 -0800
commit0c6505a26a537dc911b6566f82d759521e527c08 (patch)
treef2687995efd4943fe3b1307fce7ef5942d0a57b3 /src/base/cmd/cmd.c
parent4d30a1e4f1edecff86d5066ce4653a370e59e5e1 (diff)
downloadabc-0c6505a26a537dc911b6566f82d759521e527c08.tar.gz
abc-0c6505a26a537dc911b6566f82d759521e527c08.tar.bz2
abc-0c6505a26a537dc911b6566f82d759521e527c08.zip
Version abc80130_2
Diffstat (limited to 'src/base/cmd/cmd.c')
-rw-r--r--src/base/cmd/cmd.c360
1 files changed, 292 insertions, 68 deletions
diff --git a/src/base/cmd/cmd.c b/src/base/cmd/cmd.c
index 9195554a..2dc03d5c 100644
--- a/src/base/cmd/cmd.c
+++ b/src/base/cmd/cmd.c
@@ -18,6 +18,10 @@
***********************************************************************/
+#ifdef WIN32
+#include <process.h>
+#endif
+
#include "mainInt.h"
#include "cmdInt.h"
#include "abc.h"
@@ -45,9 +49,10 @@ static int CmdCommandLs ( Abc_Frame_t * pAbc, int argc, char ** argv
#endif
static int CmdCommandSis ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int CmdCommandMvsis ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int CmdCommandCapo ( Abc_Frame_t * pAbc, int argc, char ** argv );
////////////////////////////////////////////////////////////////////////
-/// FUNCTION DEFITIONS ///
+/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function********************************************************************
@@ -85,6 +90,7 @@ void Cmd_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "Various", "sis", CmdCommandSis, 1);
Cmd_CommandAdd( pAbc, "Various", "mvsis", CmdCommandMvsis, 1);
+ Cmd_CommandAdd( pAbc, "Various", "capo", CmdCommandCapo, 0);
}
/**Function********************************************************************
@@ -142,8 +148,8 @@ int CmdCommandTime( Abc_Frame_t * pAbc, int argc, char **argv )
{
int c;
- util_getopt_reset();
- while ( ( c = util_getopt( argc, argv, "h" ) ) != EOF )
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
{
switch ( c )
{
@@ -154,7 +160,7 @@ int CmdCommandTime( Abc_Frame_t * pAbc, int argc, char **argv )
}
}
- if ( argc != util_optind )
+ if ( argc != globalUtilOptind )
{
goto usage;
}
@@ -162,6 +168,14 @@ int CmdCommandTime( Abc_Frame_t * pAbc, int argc, char **argv )
pAbc->TimeTotal += pAbc->TimeCommand;
fprintf( pAbc->Out, "elapse: %3.2f seconds, total: %3.2f seconds\n",
(float)pAbc->TimeCommand / CLOCKS_PER_SEC, (float)pAbc->TimeTotal / CLOCKS_PER_SEC );
+/*
+ {
+ FILE * pTable;
+ pTable = fopen( "runtimes.txt", "a+" );
+ fprintf( pTable, "%4.2f\n", (float)pAbc->TimeCommand / CLOCKS_PER_SEC );
+ fclose( pTable );
+ }
+*/
pAbc->TimeCommand = 0;
return 0;
@@ -188,8 +202,8 @@ int CmdCommandEcho( Abc_Frame_t * pAbc, int argc, char **argv )
int c;
int n = 1;
- util_getopt_reset();
- while ( ( c = util_getopt( argc, argv, "hn" ) ) != EOF )
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "hn" ) ) != EOF )
{
switch ( c )
{
@@ -204,7 +218,7 @@ int CmdCommandEcho( Abc_Frame_t * pAbc, int argc, char **argv )
}
}
- for ( i = util_optind; i < argc; i++ )
+ for ( i = globalUtilOptind; i < argc; i++ )
fprintf( pAbc->Out, "%s ", argv[i] );
if ( n )
fprintf( pAbc->Out, "\n" );
@@ -234,8 +248,8 @@ int CmdCommandQuit( Abc_Frame_t * pAbc, int argc, char **argv )
{
int c;
- util_getopt_reset();
- while ( ( c = util_getopt( argc, argv, "hs" ) ) != EOF )
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "hs" ) ) != EOF )
{
switch ( c )
{
@@ -250,7 +264,7 @@ int CmdCommandQuit( Abc_Frame_t * pAbc, int argc, char **argv )
}
}
- if ( argc != util_optind )
+ if ( argc != globalUtilOptind )
goto usage;
return -1;
@@ -294,8 +308,8 @@ int CmdCommandHistory( Abc_Frame_t * pAbc, int argc, char **argv )
int i, c, num, size;
num = 20;
- util_getopt_reset();
- while ( ( c = util_getopt( argc, argv, "h" ) ) != EOF )
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
{
switch ( c )
{
@@ -309,8 +323,8 @@ int CmdCommandHistory( Abc_Frame_t * pAbc, int argc, char **argv )
goto usage;
// get the number of commands to print
- if ( argc == util_optind + 1 )
- num = atoi(argv[util_optind]);
+ if ( argc == globalUtilOptind + 1 )
+ num = atoi(argv[globalUtilOptind]);
// print the commands
size = pAbc->aHistory->nSize;
num = ( num < size ) ? num : size;
@@ -342,8 +356,8 @@ int CmdCommandAlias( Abc_Frame_t * pAbc, int argc, char **argv )
char *key, *value;
int c;
- util_getopt_reset();
- while ( ( c = util_getopt( argc, argv, "h" ) ) != EOF )
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
{
switch ( c )
{
@@ -399,8 +413,8 @@ int CmdCommandUnalias( Abc_Frame_t * pAbc, int argc, char **argv )
char *key, *value;
int c;
- util_getopt_reset();
- while ( ( c = util_getopt( argc, argv, "h" ) ) != EOF )
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
{
switch ( c )
{
@@ -450,8 +464,8 @@ int CmdCommandHelp( Abc_Frame_t * pAbc, int argc, char **argv )
int c;
fPrintAll = 0;
- util_getopt_reset();
- while ( ( c = util_getopt( argc, argv, "ah" ) ) != EOF )
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "ah" ) ) != EOF )
{
switch ( c )
{
@@ -468,7 +482,7 @@ int CmdCommandHelp( Abc_Frame_t * pAbc, int argc, char **argv )
}
}
- if ( argc != util_optind )
+ if ( argc != globalUtilOptind )
goto usage;
CmdCommandPrint( pAbc, fPrintAll );
@@ -503,38 +517,37 @@ int CmdCommandSource( Abc_Frame_t * pAbc, int argc, char **argv )
interactive = silent = prompt = echo = 0;
- util_getopt_reset();
- while ( ( c = util_getopt( argc, argv, "hipsx" ) ) != EOF )
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "ipsxh" ) ) != EOF )
{
switch ( c )
{
- case 'h':
- goto usage;
- break;
case 'i': /* a hack to distinguish EOF from stdin */
interactive = 1;
break;
case 'p':
- prompt = 1;
+ prompt ^= 1;
break;
case 's':
- silent = 1;
+ silent ^= 1;
break;
case 'x':
echo ^= 1;
break;
+ case 'h':
+ goto usage;
default:
goto usage;
}
}
/* added to avoid core-dumping when no script file is specified */
- if ( argc == util_optind )
+ if ( argc == globalUtilOptind )
{
goto usage;
}
- lp_file_index = util_optind;
+ lp_file_index = globalUtilOptind;
lp_count = 0;
/*
@@ -568,7 +581,7 @@ int CmdCommandSource( Abc_Frame_t * pAbc, int argc, char **argv )
}
else
{
- prompt_string = NIL( char );
+ prompt_string = NULL;
}
/* clear errors -- e.g., EOF reached from stdin */
@@ -602,7 +615,7 @@ int CmdCommandSource( Abc_Frame_t * pAbc, int argc, char **argv )
fprintf( pAbc->Out, "abc - > %s", line );
}
command = CmdHistorySubstitution( pAbc, line, &did_subst );
- if ( command == NIL( char ) )
+ if ( command == NULL )
{
status = 1;
break;
@@ -620,8 +633,8 @@ int CmdCommandSource( Abc_Frame_t * pAbc, int argc, char **argv )
}
if ( interactive && *line != '\0' )
{
- Cmd_HistoryAddCommand( pAbc, util_strsav(line) );
- if ( pAbc->Hst != NIL( FILE ) )
+ Cmd_HistoryAddCommand( pAbc, Extra_UtilStrsav(line) );
+ if ( pAbc->Hst != NULL )
{
fprintf( pAbc->Hst, "%s\n", line );
( void ) fflush( pAbc->Hst );
@@ -650,11 +663,11 @@ int CmdCommandSource( Abc_Frame_t * pAbc, int argc, char **argv )
return status;
usage:
- fprintf( pAbc->Err, "usage: source [-h] [-p] [-s] [-x] file_name\n" );
+ fprintf( pAbc->Err, "usage: source [-psxh] <file_name>\n" );
+ fprintf( pAbc->Err, "\t-p supply prompt before reading each line [default = %s]\n", prompt? "yes": "no" );
+ fprintf( pAbc->Err, "\t-s silently ignore nonexistant file [default = %s]\n", silent? "yes": "no" );
+ fprintf( pAbc->Err, "\t-x echo each line as it is executed [default = %s]\n", echo? "yes": "no" );
fprintf( pAbc->Err, "\t-h print the command usage\n" );
- fprintf( pAbc->Err, "\t-p supply prompt before reading each line\n" );
- fprintf( pAbc->Err, "\t-s silently ignore nonexistant file\n" );
- fprintf( pAbc->Err, "\t-x echo each line as it is executed\n" );
return 1;
}
@@ -674,8 +687,8 @@ int CmdCommandSetVariable( Abc_Frame_t * pAbc, int argc, char **argv )
char *flag_value, *key, *value;
int c;
- util_getopt_reset();
- while ( ( c = util_getopt( argc, argv, "h" ) ) != EOF )
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
{
switch ( c )
{
@@ -703,9 +716,9 @@ int CmdCommandSetVariable( Abc_Frame_t * pAbc, int argc, char **argv )
FREE( value );
}
- flag_value = argc == 2 ? util_strsav( "" ) : util_strsav( argv[2] );
-// flag_value = argc == 2 ? NULL : util_strsav(argv[2]);
- st_insert( pAbc->tFlags, util_strsav(argv[1]), flag_value );
+ flag_value = argc == 2 ? Extra_UtilStrsav( "" ) : Extra_UtilStrsav( argv[2] );
+// flag_value = argc == 2 ? NULL : Extra_UtilStrsav(argv[2]);
+ st_insert( pAbc->tFlags, Extra_UtilStrsav(argv[1]), flag_value );
if ( strcmp( argv[1], "abcout" ) == 0 )
{
@@ -713,7 +726,7 @@ int CmdCommandSetVariable( Abc_Frame_t * pAbc, int argc, char **argv )
fclose( pAbc->Out );
if ( strcmp( flag_value, "" ) == 0 )
flag_value = "-";
- pAbc->Out = CmdFileOpen( pAbc, flag_value, "w", NIL( char * ), 0 );
+ pAbc->Out = CmdFileOpen( pAbc, flag_value, "w", NULL, 0 );
if ( pAbc->Out == NULL )
pAbc->Out = stdout;
#if HAVE_SETVBUF
@@ -726,7 +739,7 @@ int CmdCommandSetVariable( Abc_Frame_t * pAbc, int argc, char **argv )
fclose( pAbc->Err );
if ( strcmp( flag_value, "" ) == 0 )
flag_value = "-";
- pAbc->Err = CmdFileOpen( pAbc, flag_value, "w", NIL( char * ), 0 );
+ pAbc->Err = CmdFileOpen( pAbc, flag_value, "w", NULL, 0 );
if ( pAbc->Err == NULL )
pAbc->Err = stderr;
#if HAVE_SETVBUF
@@ -735,15 +748,15 @@ int CmdCommandSetVariable( Abc_Frame_t * pAbc, int argc, char **argv )
}
if ( strcmp( argv[1], "history" ) == 0 )
{
- if ( pAbc->Hst != NIL( FILE ) )
+ if ( pAbc->Hst != NULL )
fclose( pAbc->Hst );
if ( strcmp( flag_value, "" ) == 0 )
- pAbc->Hst = NIL( FILE );
+ pAbc->Hst = NULL;
else
{
- pAbc->Hst = CmdFileOpen( pAbc, flag_value, "w", NIL( char * ), 0 );
+ pAbc->Hst = CmdFileOpen( pAbc, flag_value, "w", NULL, 0 );
if ( pAbc->Hst == NULL )
- pAbc->Hst = NIL( FILE );
+ pAbc->Hst = NULL;
}
}
return 0;
@@ -774,8 +787,8 @@ int CmdCommandUnsetVariable( Abc_Frame_t * pAbc, int argc, char **argv )
char *key, *value;
int c;
- util_getopt_reset();
- while ( ( c = util_getopt( argc, argv, "h" ) ) != EOF )
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
{
switch ( c )
{
@@ -867,8 +880,8 @@ int CmdCommandRecall( Abc_Frame_t * pAbc, int argc, char **argv )
}
- util_getopt_reset();
- while ( ( c = util_getopt( argc, argv, "h" ) ) != EOF )
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
{
switch ( c )
{
@@ -979,8 +992,8 @@ int CmdCommandEmpty( Abc_Frame_t * pAbc, int argc, char **argv )
return 0;
}
- util_getopt_reset();
- while ( ( c = util_getopt( argc, argv, "h" ) ) != EOF )
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
{
switch ( c )
{
@@ -1021,7 +1034,7 @@ int CmdCommandUndo( Abc_Frame_t * pAbc, int argc, char **argv )
Abc_Ntk_t * pNtkTemp;
int id, c;
- while ( ( c = util_getopt( argc, argv, "h" ) ) != EOF )
+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
{
switch ( c )
{
@@ -1032,12 +1045,12 @@ int CmdCommandUndo( Abc_Frame_t * pAbc, int argc, char **argv )
goto usage;
}
}
- if (util_optind <= argc) {
+ if (globalUtilOptind <= argc) {
pNtkTemp = pAbc->pNtk;
pAbc->pNtk = pAbc->pNtkSaved;
pAbc->pNtkSaved = pNtkTemp;
}
- id = atoi(argv[util_optind]);
+ id = atoi(argv[globalUtilOptind]);
pNtkTemp = Cmd_HistoryGetSnapshot(pAbc, id);
if (!pNtkTemp)
fprintf( pAbc->Err, "Snapshot %d does not exist\n", id);
@@ -1095,8 +1108,8 @@ int CmdCommandLs( Abc_Frame_t * pAbc, int argc, char **argv )
int fPrintedNewLine;
char c;
- util_getopt_reset();
- while ( (c = util_getopt(argc, argv, "lb") ) != EOF )
+ Extra_UtilGetoptReset();
+ while ( (c = Extra_UtilGetopt(argc, argv, "lb") ) != EOF )
{
switch (c)
{
@@ -1204,7 +1217,7 @@ int CmdCommandSis( Abc_Frame_t * pAbc, int argc, char **argv )
char * pSisName;
int i;
- pNtk = Abc_FrameReadNet(pAbc);
+ pNtk = Abc_FrameReadNtk(pAbc);
pOut = Abc_FrameReadOut(pAbc);
pErr = Abc_FrameReadErr(pAbc);
@@ -1245,8 +1258,21 @@ int CmdCommandSis( Abc_Frame_t * pAbc, int argc, char **argv )
}
fclose( pFile );
+ if ( Abc_NtkIsMappedLogic(pNtk) )
+ {
+ Abc_NtkMapToSop(pNtk);
+ printf( "The current network is unmapped before calling SIS.\n" );
+ }
+
// write out the current network
- pNetlist = Abc_NtkLogicToNetlist(pNtk);
+ if ( Abc_NtkIsLogic(pNtk) )
+ Abc_NtkToSop(pNtk, 0);
+ pNetlist = Abc_NtkToNetlist(pNtk);
+ if ( pNetlist == NULL )
+ {
+ fprintf( pErr, "Cannot produce the intermediate network.\n" );
+ goto usage;
+ }
Io_WriteBlif( pNetlist, "_sis_in.blif", 1 );
Abc_NtkDelete( pNetlist );
@@ -1283,12 +1309,12 @@ int CmdCommandSis( Abc_Frame_t * pAbc, int argc, char **argv )
fclose( pFile );
// set the new network
- pNtkNew = Io_Read( "_sis_out.blif", 1 );
+ pNtkNew = Io_Read( "_sis_out.blif", IO_FILE_BLIF, 1 );
// set the original spec of the new network
if ( pNtk->pSpec )
{
FREE( pNtkNew->pSpec );
- pNtkNew->pSpec = util_strsav( pNtk->pSpec );
+ pNtkNew->pSpec = Extra_UtilStrsav( pNtk->pSpec );
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew );
@@ -1334,7 +1360,7 @@ int CmdCommandMvsis( Abc_Frame_t * pAbc, int argc, char **argv )
char * pMvsisName;
int i;
- pNtk = Abc_FrameReadNet(pAbc);
+ pNtk = Abc_FrameReadNtk(pAbc);
pOut = Abc_FrameReadOut(pAbc);
pErr = Abc_FrameReadErr(pAbc);
@@ -1375,9 +1401,21 @@ int CmdCommandMvsis( Abc_Frame_t * pAbc, int argc, char **argv )
}
fclose( pFile );
+ if ( Abc_NtkIsMappedLogic(pNtk) )
+ {
+ Abc_NtkMapToSop(pNtk);
+ printf( "The current network is unmapped before calling MVSIS.\n" );
+ }
// write out the current network
- pNetlist = Abc_NtkLogicToNetlist(pNtk);
+ if ( Abc_NtkIsLogic(pNtk) )
+ Abc_NtkToSop(pNtk, 0);
+ pNetlist = Abc_NtkToNetlist(pNtk);
+ if ( pNetlist == NULL )
+ {
+ fprintf( pErr, "Cannot produce the intermediate network.\n" );
+ goto usage;
+ }
Io_WriteBlif( pNetlist, "_mvsis_in.blif", 1 );
Abc_NtkDelete( pNetlist );
@@ -1414,12 +1452,12 @@ int CmdCommandMvsis( Abc_Frame_t * pAbc, int argc, char **argv )
fclose( pFile );
// set the new network
- pNtkNew = Io_Read( "_mvsis_out.blif", 1 );
+ pNtkNew = Io_Read( "_mvsis_out.blif", IO_FILE_BLIF, 1 );
// set the original spec of the new network
if ( pNtk->pSpec )
{
FREE( pNtkNew->pSpec );
- pNtkNew->pSpec = util_strsav( pNtk->pSpec );
+ pNtkNew->pSpec = Extra_UtilStrsav( pNtk->pSpec );
}
// replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew );
@@ -1443,6 +1481,192 @@ usage:
}
+/**Function********************************************************************
+
+ Synopsis [Calls Capo internally.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+******************************************************************************/
+int CmdCommandCapo( Abc_Frame_t * pAbc, int argc, char **argv )
+{
+ FILE * pFile;
+ FILE * pOut, * pErr;
+ Abc_Ntk_t * pNtk, * pNetlist;
+ char Command[1000], Buffer[100];
+ char * pProgNameCapoWin = "capo.exe";
+ char * pProgNameCapoUnix = "capo";
+ char * pProgNameGnuplotWin = "wgnuplot.exe";
+ char * pProgNameGnuplotUnix = "gnuplot";
+ char * pProgNameCapo;
+ char * pProgNameGnuplot;
+ char * pPlotFileName;
+ int i;
+
+ pNtk = Abc_FrameReadNtk(pAbc);
+ pOut = Abc_FrameReadOut(pAbc);
+ pErr = Abc_FrameReadErr(pAbc);
+
+ if ( pNtk == NULL )
+ {
+ fprintf( pErr, "Empty network.\n" );
+ goto usage;
+ }
+
+ if ( strcmp( argv[0], "capo" ) != 0 )
+ {
+ fprintf( pErr, "Wrong command: \"%s\".\n", argv[0] );
+ goto usage;
+ }
+
+ if ( argc > 1 )
+ {
+ if ( strcmp( argv[1], "-h" ) == 0 )
+ goto usage;
+ if ( strcmp( argv[1], "-?" ) == 0 )
+ goto usage;
+ }
+
+ // get the names from the resource file
+ if ( Cmd_FlagReadByName(pAbc, "capowin") )
+ pProgNameCapoWin = Cmd_FlagReadByName(pAbc, "capowin");
+ if ( Cmd_FlagReadByName(pAbc, "capounix") )
+ pProgNameCapoUnix = Cmd_FlagReadByName(pAbc, "capounix");
+
+ // check if capo is available
+ if ( (pFile = fopen( pProgNameCapoWin, "r" )) )
+ pProgNameCapo = pProgNameCapoWin;
+ else if ( (pFile = fopen( pProgNameCapoUnix, "r" )) )
+ pProgNameCapo = pProgNameCapoUnix;
+ else if ( pFile == NULL )
+ {
+ fprintf( pErr, "Cannot find \"%s\" or \"%s\" in the current directory.\n", pProgNameCapoWin, pProgNameCapoUnix );
+ goto usage;
+ }
+ fclose( pFile );
+
+ if ( Abc_NtkIsMappedLogic(pNtk) )
+ {
+ Abc_NtkMapToSop(pNtk);
+ printf( "The current network is unmapped before calling Capo.\n" );
+ }
+
+ // write out the current network
+ if ( Abc_NtkIsLogic(pNtk) )
+ Abc_NtkToSop(pNtk, 0);
+ pNetlist = Abc_NtkToNetlist(pNtk);
+ if ( pNetlist == NULL )
+ {
+ fprintf( pErr, "Cannot produce the intermediate network.\n" );
+ goto usage;
+ }
+ Io_WriteBlif( pNetlist, "_capo_in.blif", 1 );
+ Abc_NtkDelete( pNetlist );
+
+ // create the file for Capo
+ sprintf( Command, "%s -f _capo_in.blif -log out.txt ", pProgNameCapo );
+ pPlotFileName = NULL;
+ for ( i = 1; i < argc; i++ )
+ {
+ sprintf( Buffer, " %s", argv[i] );
+ strcat( Command, Buffer );
+ if ( !strcmp( argv[i], "-plot" ) )
+ pPlotFileName = argv[i+1];
+ }
+
+ // call Capo
+ if ( system( Command ) )
+ {
+ fprintf( pErr, "The following command has returned non-zero exit status:\n" );
+ fprintf( pErr, "\"%s\"\n", Command );
+ unlink( "_capo_in.blif" );
+ goto usage;
+ }
+ // remove temporary networks
+ unlink( "_capo_in.blif" );
+ if ( pPlotFileName == NULL )
+ return 0;
+
+ // get the file name
+ sprintf( Buffer, "%s.plt", pPlotFileName );
+ pPlotFileName = Buffer;
+
+ // read in the Capo plotting output
+ if ( (pFile = fopen( pPlotFileName, "r" )) == NULL )
+ {
+ fprintf( pErr, "Cannot open the plot file \"%s\".\n\n", pPlotFileName );
+ goto usage;
+ }
+ fclose( pFile );
+
+ // get the names from the plotting software
+ if ( Cmd_FlagReadByName(pAbc, "gnuplotwin") )
+ pProgNameGnuplotWin = Cmd_FlagReadByName(pAbc, "gnuplotwin");
+ if ( Cmd_FlagReadByName(pAbc, "gnuplotunix") )
+ pProgNameGnuplotUnix = Cmd_FlagReadByName(pAbc, "gnuplotunix");
+
+ // check if Gnuplot is available
+ if ( (pFile = fopen( pProgNameGnuplotWin, "r" )) )
+ pProgNameGnuplot = pProgNameGnuplotWin;
+ else if ( (pFile = fopen( pProgNameGnuplotUnix, "r" )) )
+ pProgNameGnuplot = pProgNameGnuplotUnix;
+ else if ( pFile == NULL )
+ {
+ fprintf( pErr, "Cannot find \"%s\" or \"%s\" in the current directory.\n", pProgNameGnuplotWin, pProgNameGnuplotUnix );
+ goto usage;
+ }
+ fclose( pFile );
+
+ // spawn the viewer
+#ifdef WIN32
+ if ( _spawnl( _P_NOWAIT, pProgNameGnuplot, pProgNameGnuplot, pPlotFileName, NULL ) == -1 )
+ {
+ fprintf( stdout, "Cannot find \"%s\".\n", pProgNameGnuplot );
+ goto usage;
+ }
+#else
+ {
+ sprintf( Command, "%s %s ", pProgNameGnuplot, pPlotFileName );
+ if ( system( Command ) == -1 )
+ {
+ fprintf( stdout, "Cannot execute \"%s\".\n", Command );
+ goto usage;
+ }
+ }
+#endif
+
+ // remove temporary networks
+// unlink( pPlotFileName );
+ return 0;
+
+usage:
+ fprintf( pErr, "\n" );
+ fprintf( pErr, "Usage: capo [-h] <com>\n");
+ fprintf( pErr, " peforms placement of the current network using Capo\n" );
+ fprintf( pErr, " a Capo binary should be present in the same directory\n" );
+ fprintf( pErr, " (if plotting, the Gnuplot binary should also be present)\n" );
+ fprintf( pErr, " -h : print the command usage\n" );
+ fprintf( pErr, " <com> : a Capo command\n" );
+ fprintf( pErr, " Example 1: capo\n" );
+ fprintf( pErr, " (performs placement with default options)\n" );
+ fprintf( pErr, " Example 2: capo -AR <aspec_ratio> -WS <whitespace_percentage> -save\n" );
+ fprintf( pErr, " (specifies the aspect ratio [default = 1.0] and\n" );
+ fprintf( pErr, " the whitespace percentage [0%%; 100%%) [default = 15%%])\n" );
+ fprintf( pErr, " Example 3: capo -plot <base_fileName>\n" );
+ fprintf( pErr, " (produces <base_fileName.plt> and visualize it using Gnuplot)\n" );
+ fprintf( pErr, " Example 4: capo -help\n" );
+ fprintf( pErr, " (prints the default usage message of the Capo binary)\n" );
+ fprintf( pErr, " Please refer to the Capo webpage for additional information:\n" );
+ fprintf( pErr, " http://vlsicad.eecs.umich.edu/BK/PDtools/\n" );
+ return 1; // error exit
+}
+
+
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////