abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cmd.c File Reference
#include <unistd.h>
#include "base/abc/abc.h"
#include "base/main/mainInt.h"
#include "cmdInt.h"
#include "misc/util/utilSignal.h"

Go to the source code of this file.

Functions

static ABC_NAMESPACE_IMPL_START int CmdCommandTime (Abc_Frame_t *pAbc, int argc, char **argv)
 DECLARATIONS ///. More...
 
static int CmdCommandEcho (Abc_Frame_t *pAbc, int argc, char **argv)
 
static int CmdCommandQuit (Abc_Frame_t *pAbc, int argc, char **argv)
 
static int CmdCommandWhich (Abc_Frame_t *pAbc, int argc, char **argv)
 
static int CmdCommandHistory (Abc_Frame_t *pAbc, int argc, char **argv)
 
static int CmdCommandAlias (Abc_Frame_t *pAbc, int argc, char **argv)
 
static int CmdCommandUnalias (Abc_Frame_t *pAbc, int argc, char **argv)
 
static int CmdCommandHelp (Abc_Frame_t *pAbc, int argc, char **argv)
 
static int CmdCommandSource (Abc_Frame_t *pAbc, int argc, char **argv)
 
static int CmdCommandSetVariable (Abc_Frame_t *pAbc, int argc, char **argv)
 
static int CmdCommandUnsetVariable (Abc_Frame_t *pAbc, int argc, char **argv)
 
static int CmdCommandUndo (Abc_Frame_t *pAbc, int argc, char **argv)
 
static int CmdCommandRecall (Abc_Frame_t *pAbc, int argc, char **argv)
 
static int CmdCommandEmpty (Abc_Frame_t *pAbc, int argc, char **argv)
 
static int CmdCommandVersion (Abc_Frame_t *pAbc, int argc, char **argv)
 
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)
 
static int CmdCommandStarter (Abc_Frame_t *pAbc, int argc, char **argv)
 
int Cmd_CommandAbcLoadPlugIn (Abc_Frame_t *pAbc, int argc, char **argv)
 
void Cmd_Init (Abc_Frame_t *pAbc)
 FUNCTION DEFINITIONS ///. More...
 
void Cmd_End (Abc_Frame_t *pAbc)
 
void Gia_ManGnuplotShow (char *pPlotFileName)
 

Function Documentation

int Cmd_CommandAbcLoadPlugIn ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 642 of file cmdPlugin.c.

643 {
644  FILE * pFile;
645  char pBuffer[1000];
646  char * pCommandLine;
647  char * pTempFile;
648  char * pStrDirBin, * pStrSection;
649  int fd, RetValue;
650 
651  if ( argc != 3 )
652  {
653  Abc_Print( -1, "Wrong number of arguments.\n" );
654  goto usage;
655  }
656  // collect arguments
657  pStrDirBin = argv[argc-2];
658  pStrSection = argv[argc-1];
659 
660  // check if the file exists
661  if ( (pFile = fopen( pStrDirBin, "r" )) == NULL )
662  {
663 // Abc_Print( -1, "Cannot run the binary \"%s\".\n", pStrDirBin );
664 // goto usage;
665  return 0;
666  }
667  fclose( pFile );
668 
669  // create temp file
670  fd = Util_SignalTmpFile( "__abctmp_", ".txt", &pTempFile );
671  if ( fd == -1 )
672  {
673  Abc_Print( -1, "Cannot create a temporary file.\n" );
674  goto usage;
675  }
676 #ifdef WIN32
677  _close( fd );
678 #else
679  close( fd );
680 #endif
681 
682  // get command list
683  pCommandLine = ABC_ALLOC( char, 100 + strlen(pStrDirBin) + strlen(pTempFile) );
684 // sprintf( pCommandLine, "%s -abc -list-commands > %s", pStrDirBin, pTempFile );
685  sprintf( pCommandLine, "%s -abc -list-commands > %s", pStrDirBin, pTempFile );
686  RetValue = Util_SignalSystem( pCommandLine );
687  if ( RetValue == -1 )
688  {
689  Abc_Print( -1, "Command \"%s\" did not succeed.\n", pCommandLine );
690  ABC_FREE( pCommandLine );
691  ABC_FREE( pTempFile );
692  goto usage;
693  }
694  ABC_FREE( pCommandLine );
695 
696  // create commands
697  pFile = fopen( pTempFile, "r" );
698  if ( pFile == NULL )
699  {
700  Abc_Print( -1, "Cannot open file with the list of commands.\n" );
701  ABC_FREE( pTempFile );
702  goto usage;
703  }
704  while ( fgets( pBuffer, 1000, pFile ) != NULL )
705  {
706  if ( pBuffer[strlen(pBuffer)-1] == '\n' )
707  pBuffer[strlen(pBuffer)-1] = 0;
708  Cmd_CommandAdd( pAbc, pStrSection, pBuffer, Cmd_CommandAbcPlugIn, 1 );
709 // plugin_commands.push(Pair(cmd_name, binary_name));
710  Vec_PtrPush( pAbc->vPlugInComBinPairs, Extra_UtilStrsav(pBuffer) );
711  Vec_PtrPush( pAbc->vPlugInComBinPairs, Extra_UtilStrsav(pStrDirBin) );
712 // printf( "Creating command %s with binary %s\n", pBuffer, pStrDirBin );
713  }
714  fclose( pFile );
715  Util_SignalTmpFileRemove( pTempFile, 0 );
716  ABC_FREE( pTempFile );
717  return 0;
718 usage:
719  Abc_Print( -2, "usage: load_plugin <plugin_dir\\binary_name> <section_name>\n" );
720  Abc_Print( -2, "\t loads external binary as a plugin\n" );
721  Abc_Print( -2, "\t-h : print the command usage\n");
722  return 1;
723 }
int Util_SignalTmpFile(const char *prefix, const char *suffix, char **out_name)
INCLUDES ///.
Definition: utilSignal.c:53
int Cmd_CommandAbcPlugIn(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmdPlugin.c:412
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
void Cmd_CommandAdd(Abc_Frame_t *pAbc, const char *sGroup, const char *sName, Cmd_CommandFuncType pFunc, int fChanges)
Definition: cmdApi.c:63
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
char * Extra_UtilStrsav(const char *s)
void Util_SignalTmpFileRemove(const char *fname, int fLeave)
Definition: utilSignal.c:58
char * sprintf()
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
#define ABC_FREE(obj)
Definition: abc_global.h:232
int strlen()
ABC_NAMESPACE_IMPL_START int Util_SignalSystem(const char *cmd)
DECLARATIONS ///.
Definition: utilSignal.c:46
void Cmd_End ( Abc_Frame_t pAbc)

Function********************************************************************

Synopsis [Ends the command package.]

Description [Ends the command package. Tables are freed.]

SideEffects []

SeeAlso []

Definition at line 127 of file cmd.c.

128 {
129  st__generator * gen;
130  char * pKey, * pValue;
132 
133 // st__free_table( pAbc->tCommands, (void (*)()) 0, CmdCommandFree );
134 // st__free_table( pAbc->tAliases, (void (*)()) 0, CmdCommandAliasFree );
135 // st__free_table( pAbc->tFlags, free, free );
136 
137  st__foreach_item( pAbc->tCommands, gen, (const char **)&pKey, (char **)&pValue )
138  CmdCommandFree( (Abc_Command *)pValue );
139  st__free_table( pAbc->tCommands );
140 
141  st__foreach_item( pAbc->tAliases, gen, (const char **)&pKey, (char **)&pValue )
142  CmdCommandAliasFree( (Abc_Alias *)pValue );
143  st__free_table( pAbc->tAliases );
144 
145  st__foreach_item( pAbc->tFlags, gen, (const char **)&pKey, (char **)&pValue )
146  ABC_FREE( pKey ), ABC_FREE( pValue );
147  st__free_table( pAbc->tFlags );
148 
149  Vec_PtrFreeFree( pAbc->aHistory );
150 }
void st__free_table(st__table *table)
Definition: st.c:81
typedefABC_NAMESPACE_HEADER_START struct MvCommand Abc_Command
INCLUDES ///.
Definition: cmd.h:39
Definition: cmdInt.h:51
void CmdCommandAliasFree(Abc_Alias *pAlias)
Definition: cmdAlias.c:113
static void Vec_PtrFreeFree(Vec_Ptr_t *p)
Definition: vecPtr.h:569
void CmdCommandFree(Abc_Command *pCommand)
Definition: cmdUtils.c:535
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
#define st__foreach_item(table, gen, key, value)
Definition: st.h:107
#define const
Definition: zconf.h:196
void Cmd_HistoryWrite(Abc_Frame_t *p, int Limit)
Definition: cmdHist.c:131
void Cmd_Init ( Abc_Frame_t pAbc)

FUNCTION DEFINITIONS ///.

MACRO DEFINITIONS ///.

Function********************************************************************

Synopsis [Initializes the command package.]

SideEffects [Commands are added to the command table.]

SeeAlso [Cmd_End]

Definition at line 79 of file cmd.c.

80 {
81  pAbc->tCommands = st__init_table(strcmp, st__strhash);
82  pAbc->tAliases = st__init_table(strcmp, st__strhash);
83  pAbc->tFlags = st__init_table(strcmp, st__strhash);
84  pAbc->aHistory = Vec_PtrAlloc( 100 );
85  Cmd_HistoryRead( pAbc );
86 
87  Cmd_CommandAdd( pAbc, "Basic", "time", CmdCommandTime, 0 );
88  Cmd_CommandAdd( pAbc, "Basic", "echo", CmdCommandEcho, 0 );
89  Cmd_CommandAdd( pAbc, "Basic", "quit", CmdCommandQuit, 0 );
90  Cmd_CommandAdd( pAbc, "Basic", "history", CmdCommandHistory, 0 );
91  Cmd_CommandAdd( pAbc, "Basic", "alias", CmdCommandAlias, 0 );
92  Cmd_CommandAdd( pAbc, "Basic", "unalias", CmdCommandUnalias, 0 );
93  Cmd_CommandAdd( pAbc, "Basic", "help", CmdCommandHelp, 0 );
94  Cmd_CommandAdd( pAbc, "Basic", "source", CmdCommandSource, 0 );
95  Cmd_CommandAdd( pAbc, "Basic", "set", CmdCommandSetVariable, 0 );
96  Cmd_CommandAdd( pAbc, "Basic", "unset", CmdCommandUnsetVariable, 0 );
97  Cmd_CommandAdd( pAbc, "Basic", "undo", CmdCommandUndo, 0 );
98  Cmd_CommandAdd( pAbc, "Basic", "recall", CmdCommandRecall, 0 );
99  Cmd_CommandAdd( pAbc, "Basic", "empty", CmdCommandEmpty, 0 );
100 #if defined(WIN32) && !defined(__cplusplus)
101  Cmd_CommandAdd( pAbc, "Basic", "scandir", CmdCommandScanDir, 0 );
102  Cmd_CommandAdd( pAbc, "Basic", "renamefiles", CmdCommandRenameFiles, 0 );
103  Cmd_CommandAdd( pAbc, "Basic", "ls", CmdCommandLs, 0 );
104  Cmd_CommandAdd( pAbc, "Basic", "scrgen", CmdCommandScrGen, 0 );
105 #endif
106  Cmd_CommandAdd( pAbc, "Basic", "version", CmdCommandVersion, 0 );
107 
108  Cmd_CommandAdd( pAbc, "Various", "sis", CmdCommandSis, 1 );
109  Cmd_CommandAdd( pAbc, "Various", "mvsis", CmdCommandMvsis, 1 );
110  Cmd_CommandAdd( pAbc, "Various", "capo", CmdCommandCapo, 0 );
111  Cmd_CommandAdd( pAbc, "Various", "starter", CmdCommandStarter, 0 );
112 
113  Cmd_CommandAdd( pAbc, "Various", "load_plugin", Cmd_CommandAbcLoadPlugIn, 0 );
114 }
static ABC_NAMESPACE_IMPL_START int CmdCommandTime(Abc_Frame_t *pAbc, int argc, char **argv)
DECLARATIONS ///.
Definition: cmd.c:165
static int CmdCommandSource(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:555
static int CmdCommandRecall(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:927
void Cmd_CommandAdd(Abc_Frame_t *pAbc, const char *sGroup, const char *sName, Cmd_CommandFuncType pFunc, int fChanges)
Definition: cmdApi.c:63
static int CmdCommandSetVariable(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:738
int Cmd_CommandAbcLoadPlugIn(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmdPlugin.c:642
int strcmp()
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
static int CmdCommandVersion(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:2469
int st__strhash(const char *string, int modulus)
Definition: st.c:449
static int CmdCommandHelp(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:501
static int CmdCommandCapo(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:2201
static int CmdCommandQuit(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:288
static int CmdCommandMvsis(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:1992
static int CmdCommandEmpty(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:1043
void Cmd_HistoryRead(Abc_Frame_t *p)
Definition: cmdHist.c:100
static int CmdCommandUnalias(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:449
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
static int CmdCommandEcho(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:232
static int CmdCommandAlias(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:392
static int CmdCommandSis(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:1850
static int CmdCommandUnsetVariable(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:838
static int CmdCommandHistory(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:347
static int CmdCommandStarter(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:2384
static int CmdCommandUndo(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:893
int CmdCommandAlias ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

Function********************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 392 of file cmd.c.

393 {
394  const char *key;
395  char *value;
396  int c;
397 
399  while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
400  {
401  switch ( c )
402  {
403  case 'h':
404  goto usage;
405  break;
406  default:
407  goto usage;
408  }
409  }
410 
411 
412  if ( argc == 1 )
413  {
414  CmdPrintTable( pAbc->tAliases, 1 );
415  return 0;
416 
417  }
418  else if ( argc == 2 )
419  {
420  if ( st__lookup( pAbc->tAliases, argv[1], &value ) )
421  CmdCommandAliasPrint( pAbc, ( Abc_Alias * ) value );
422  return 0;
423  }
424 
425  // delete any existing alias
426  key = argv[1];
427  if ( st__delete( pAbc->tAliases, &key, &value ) )
428  CmdCommandAliasFree( ( Abc_Alias * ) value );
429  CmdCommandAliasAdd( pAbc, argv[1], argc - 2, argv + 2 );
430  return 0;
431 
432 usage:
433  fprintf( pAbc->Err, "usage: alias [-h] [command [string]]\n" );
434  fprintf( pAbc->Err, " -h \t\tprint the command usage\n" );
435  return ( 1 );
436 }
int st__delete(st__table *table, const char **keyp, char **value)
Definition: st.c:375
Definition: cmdInt.h:51
void CmdCommandAliasFree(Abc_Alias *pAlias)
Definition: cmdAlias.c:113
ABC_DLL void Extra_UtilGetoptReset()
Definition: extraUtilUtil.c:80
void CmdPrintTable(st__table *tTable, int fAliases)
Definition: cmdUtils.c:722
void CmdCommandAliasPrint(Abc_Frame_t *pAbc, Abc_Alias *pAlias)
Definition: cmdAlias.c:72
int st__lookup(st__table *table, const char *key, char **value)
Definition: st.c:114
int Extra_UtilGetopt(int argc, char *argv[], const char *optstring)
Definition: extraUtilUtil.c:98
enum keys key
int value
ABC_NAMESPACE_IMPL_START void CmdCommandAliasAdd(Abc_Frame_t *pAbc, char *sName, int argc, char **argv)
DECLARATIONS ///.
Definition: cmdAlias.c:46
int CmdCommandCapo ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

Function********************************************************************

Synopsis [Calls Capo internally.]

Description []

SideEffects []

SeeAlso []

Definition at line 2201 of file cmd.c.

2202 {
2203  FILE * pFile;
2204  FILE * pOut, * pErr;
2205  Abc_Ntk_t * pNtk, * pNetlist;
2206  char Command[1000], Buffer[100];
2207  char * pProgNameCapoWin = "capo.exe";
2208  char * pProgNameCapoUnix = "capo";
2209  char * pProgNameGnuplotWin = "wgnuplot.exe";
2210  char * pProgNameGnuplotUnix = "gnuplot";
2211  char * pProgNameCapo;
2212  char * pProgNameGnuplot;
2213  char * pPlotFileName;
2214  int i;
2215 
2216  pNtk = Abc_FrameReadNtk(pAbc);
2217  pOut = Abc_FrameReadOut(pAbc);
2218  pErr = Abc_FrameReadErr(pAbc);
2219 
2220  if ( argc > 1 )
2221  {
2222  if ( strcmp( argv[1], "-h" ) == 0 )
2223  goto usage;
2224  if ( strcmp( argv[1], "-?" ) == 0 )
2225  goto usage;
2226  }
2227 
2228  if ( pNtk == NULL )
2229  {
2230  fprintf( pErr, "Empty network.\n" );
2231  goto usage;
2232  }
2233 
2234  if ( strcmp( argv[0], "capo" ) != 0 )
2235  {
2236  fprintf( pErr, "Wrong command: \"%s\".\n", argv[0] );
2237  goto usage;
2238  }
2239 
2240  // get the names from the resource file
2241  if ( Cmd_FlagReadByName(pAbc, "capowin") )
2242  pProgNameCapoWin = Cmd_FlagReadByName(pAbc, "capowin");
2243  if ( Cmd_FlagReadByName(pAbc, "capounix") )
2244  pProgNameCapoUnix = Cmd_FlagReadByName(pAbc, "capounix");
2245 
2246  // check if capo is available
2247  if ( (pFile = fopen( pProgNameCapoWin, "r" )) )
2248  pProgNameCapo = pProgNameCapoWin;
2249  else if ( (pFile = fopen( pProgNameCapoUnix, "r" )) )
2250  pProgNameCapo = pProgNameCapoUnix;
2251  else if ( pFile == NULL )
2252  {
2253  fprintf( pErr, "Cannot find \"%s\" or \"%s\" in the current directory.\n", pProgNameCapoWin, pProgNameCapoUnix );
2254  goto usage;
2255  }
2256  fclose( pFile );
2257 
2258  if ( Abc_NtkIsMappedLogic(pNtk) )
2259  {
2260  Abc_NtkMapToSop(pNtk);
2261  printf( "The current network is unmapped before calling Capo.\n" );
2262  }
2263 
2264  // write out the current network
2265  if ( Abc_NtkIsLogic(pNtk) )
2266  Abc_NtkToSop(pNtk, 0);
2267  pNetlist = Abc_NtkToNetlist(pNtk);
2268  if ( pNetlist == NULL )
2269  {
2270  fprintf( pErr, "Cannot produce the intermediate network.\n" );
2271  goto usage;
2272  }
2273  Io_WriteBlif( pNetlist, "_capo_in.blif", 1, 0, 0 );
2274  Abc_NtkDelete( pNetlist );
2275 
2276  // create the file for Capo
2277  sprintf( Command, "%s -f _capo_in.blif -log out.txt ", pProgNameCapo );
2278  pPlotFileName = NULL;
2279  for ( i = 1; i < argc; i++ )
2280  {
2281  sprintf( Buffer, " %s", argv[i] );
2282  strcat( Command, Buffer );
2283  if ( !strcmp( argv[i], "-plot" ) )
2284  pPlotFileName = argv[i+1];
2285  }
2286 
2287  // call Capo
2288  if ( Util_SignalSystem( Command ) )
2289  {
2290  fprintf( pErr, "The following command has returned non-zero exit status:\n" );
2291  fprintf( pErr, "\"%s\"\n", Command );
2292  unlink( "_capo_in.blif" );
2293  goto usage;
2294  }
2295  // remove temporary networks
2296  unlink( "_capo_in.blif" );
2297  if ( pPlotFileName == NULL )
2298  return 0;
2299 
2300  // get the file name
2301  sprintf( Buffer, "%s.plt", pPlotFileName );
2302  pPlotFileName = Buffer;
2303 
2304  // read in the Capo plotting output
2305  if ( (pFile = fopen( pPlotFileName, "r" )) == NULL )
2306  {
2307  fprintf( pErr, "Cannot open the plot file \"%s\".\n\n", pPlotFileName );
2308  goto usage;
2309  }
2310  fclose( pFile );
2311 
2312  // get the names from the plotting software
2313  if ( Cmd_FlagReadByName(pAbc, "gnuplotwin") )
2314  pProgNameGnuplotWin = Cmd_FlagReadByName(pAbc, "gnuplotwin");
2315  if ( Cmd_FlagReadByName(pAbc, "gnuplotunix") )
2316  pProgNameGnuplotUnix = Cmd_FlagReadByName(pAbc, "gnuplotunix");
2317 
2318  // check if Gnuplot is available
2319  if ( (pFile = fopen( pProgNameGnuplotWin, "r" )) )
2320  pProgNameGnuplot = pProgNameGnuplotWin;
2321  else if ( (pFile = fopen( pProgNameGnuplotUnix, "r" )) )
2322  pProgNameGnuplot = pProgNameGnuplotUnix;
2323  else if ( pFile == NULL )
2324  {
2325  fprintf( pErr, "Cannot find \"%s\" or \"%s\" in the current directory.\n", pProgNameGnuplotWin, pProgNameGnuplotUnix );
2326  goto usage;
2327  }
2328  fclose( pFile );
2329 
2330  // spawn the viewer
2331 #ifdef WIN32
2332  if ( _spawnl( _P_NOWAIT, pProgNameGnuplot, pProgNameGnuplot, pPlotFileName, NULL ) == -1 )
2333  {
2334  fprintf( stdout, "Cannot find \"%s\".\n", pProgNameGnuplot );
2335  goto usage;
2336  }
2337 #else
2338  {
2339  sprintf( Command, "%s %s ", pProgNameGnuplot, pPlotFileName );
2340  if ( Util_SignalSystem( Command ) == -1 )
2341  {
2342  fprintf( stdout, "Cannot execute \"%s\".\n", Command );
2343  goto usage;
2344  }
2345  }
2346 #endif
2347 
2348  // remove temporary networks
2349 // unlink( pPlotFileName );
2350  return 0;
2351 
2352 usage:
2353  fprintf( pErr, "Usage: capo [-h] <com>\n");
2354  fprintf( pErr, " peforms placement of the current network using Capo\n" );
2355  fprintf( pErr, " a Capo binary should be present in the same directory\n" );
2356  fprintf( pErr, " (if plotting, the Gnuplot binary should also be present)\n" );
2357  fprintf( pErr, " -h : print the command usage\n" );
2358  fprintf( pErr, " <com> : a Capo command\n" );
2359  fprintf( pErr, " Example 1: capo\n" );
2360  fprintf( pErr, " (performs placement with default options)\n" );
2361  fprintf( pErr, " Example 2: capo -AR <aspec_ratio> -WS <whitespace_percentage> -save\n" );
2362  fprintf( pErr, " (specifies the aspect ratio [default = 1.0] and\n" );
2363  fprintf( pErr, " the whitespace percentage [0%%; 100%%) [default = 15%%])\n" );
2364  fprintf( pErr, " Example 3: capo -plot <base_fileName>\n" );
2365  fprintf( pErr, " (produces <base_fileName.plt> and visualize it using Gnuplot)\n" );
2366  fprintf( pErr, " Example 4: capo -help\n" );
2367  fprintf( pErr, " (prints the default usage message of the Capo binary)\n" );
2368  fprintf( pErr, " Please refer to the Capo webpage for additional information:\n" );
2369  fprintf( pErr, " http://vlsicad.eecs.umich.edu/BK/PDtools/\n" );
2370  return 1; // error exit
2371 }
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
ABC_DLL Abc_Ntk_t * Abc_NtkToNetlist(Abc_Ntk_t *pNtk)
Definition: abcNetlist.c:97
void Io_WriteBlif(Abc_Ntk_t *pNtk, char *pFileName, int fWriteLatches, int fBb2Wb, int fSeq)
Definition: ioWriteBlif.c:84
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
int strcmp()
ABC_DLL int Abc_NtkMapToSop(Abc_Ntk_t *pNtk)
Definition: abcFunc.c:1073
ABC_DLL int Abc_NtkToSop(Abc_Ntk_t *pNtk, int fDirect)
Definition: abcFunc.c:1124
char * sprintf()
ABC_DLL Abc_Ntk_t * Abc_FrameReadNtk(Abc_Frame_t *p)
Definition: mainFrame.c:282
static int Abc_NtkIsMappedLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:267
char * strcat()
ABC_DLL FILE * Abc_FrameReadErr(Abc_Frame_t *p)
Definition: mainFrame.c:330
ABC_DLL FILE * Abc_FrameReadOut(Abc_Frame_t *p)
Definition: mainFrame.c:314
ABC_NAMESPACE_IMPL_START int Util_SignalSystem(const char *cmd)
DECLARATIONS ///.
Definition: utilSignal.c:46
char * Cmd_FlagReadByName(Abc_Frame_t *pAbc, char *flag)
DECLARATIONS ///.
Definition: cmdFlag.c:47
int CmdCommandEcho ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

Function********************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 232 of file cmd.c.

233 {
234  int i;
235  int c;
236  int n = 1;
237 
239  while ( ( c = Extra_UtilGetopt( argc, argv, "hn" ) ) != EOF )
240  {
241  switch ( c )
242  {
243  case 'n':
244  n = 0;
245  break;
246  case 'h':
247  goto usage;
248  break;
249  default:
250  goto usage;
251  }
252  }
253 
254  if (pAbc->Out == stdout){
255  for ( i = globalUtilOptind; i < argc; i++ )
256  Abc_Print( 1, "%s ", argv[i] );
257  if ( n )
258  Abc_Print( 1, "\n" );
259 
260  }else{
261  for ( i = globalUtilOptind; i < argc; i++ )
262  fprintf( pAbc->Out, "%s ", argv[i] );
263  if ( n )
264  fprintf( pAbc->Out, "\n" );
265 
266  fflush ( pAbc->Out );
267  }
268  return 0;
269 
270  usage:
271  fprintf( pAbc->Err, "usage: echo [-h] string \n" );
272  fprintf( pAbc->Err, " -n \t\tsuppress newline at the end\n" );
273  fprintf( pAbc->Err, " -h \t\tprint the command usage\n" );
274  return ( 1 );
275 }
ABC_DLL void Extra_UtilGetoptReset()
Definition: extraUtilUtil.c:80
int globalUtilOptind
Definition: extraUtilUtil.c:45
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
int Extra_UtilGetopt(int argc, char *argv[], const char *optstring)
Definition: extraUtilUtil.c:98
int CmdCommandEmpty ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

Function********************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 1043 of file cmd.c.

1044 {
1045  int c;
1046 
1048  while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
1049  {
1050  switch ( c )
1051  {
1052  case 'h':
1053  goto usage;
1054  default:
1055  goto usage;
1056  }
1057  }
1058 
1059  if ( pAbc->pNtkCur == NULL )
1060  {
1061  fprintf( pAbc->Out, "Empty network.\n" );
1062  return 0;
1063  }
1064 
1066  Abc_FrameRestart( pAbc );
1067  return 0;
1068 usage:
1069 
1070  fprintf( pAbc->Err, "usage: empty [-h]\n" );
1071  fprintf( pAbc->Err, " removes all the currently stored networks\n" );
1072  fprintf( pAbc->Err, " -h : print the command usage\n");
1073  return 1;
1074 }
ABC_DLL void Abc_FrameDeleteAllNetworks(Abc_Frame_t *p)
Definition: mainFrame.c:551
ABC_DLL void Extra_UtilGetoptReset()
Definition: extraUtilUtil.c:80
int Extra_UtilGetopt(int argc, char *argv[], const char *optstring)
Definition: extraUtilUtil.c:98
ABC_DLL void Abc_FrameRestart(Abc_Frame_t *p)
Definition: mainFrame.c:232
int CmdCommandHelp ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

Function********************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 501 of file cmd.c.

502 {
503  int fPrintAll, fDetails;
504  int c;
505 
506  fPrintAll = 0;
507  fDetails = 0;
509  while ( ( c = Extra_UtilGetopt( argc, argv, "adh" ) ) != EOF )
510  {
511  switch ( c )
512  {
513  case 'a':
514  case 'v':
515  fPrintAll ^= 1;
516  break;
517  break;
518  case 'd':
519  fDetails ^= 1;
520  break;
521  case 'h':
522  goto usage;
523  break;
524  default:
525  goto usage;
526  }
527  }
528 
529  if ( argc != globalUtilOptind )
530  goto usage;
531 
532  CmdCommandPrint( pAbc, fPrintAll, fDetails );
533  return 0;
534 
535 usage:
536  fprintf( pAbc->Err, "usage: help [-a] [-d] [-h]\n" );
537  fprintf( pAbc->Err, " prints the list of available commands by group\n" );
538  fprintf( pAbc->Err, " -a toggle printing hidden commands [default = %s]\n", fPrintAll? "yes": "no" );
539  fprintf( pAbc->Err, " -d print usage details to all commands [default = %s]\n", fDetails? "yes": "no" );
540  fprintf( pAbc->Err, " -h print the command usage\n" );
541  return 1;
542 }
ABC_DLL void Extra_UtilGetoptReset()
Definition: extraUtilUtil.c:80
int globalUtilOptind
Definition: extraUtilUtil.c:45
void CmdCommandPrint(Abc_Frame_t *pAbc, int fPrintAll, int fDetails)
Definition: cmdUtils.c:554
int Extra_UtilGetopt(int argc, char *argv[], const char *optstring)
Definition: extraUtilUtil.c:98
int CmdCommandHistory ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

Function********************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 347 of file cmd.c.

348 {
349  char * pName;
350  int i, c;
351  int nPrints = 20;
353  while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
354  {
355  switch ( c )
356  {
357  case 'h':
358  goto usage;
359  default :
360  goto usage;
361  }
362  }
363  if ( argc > globalUtilOptind + 1 )
364  goto usage;
365  // get the number from the command line
366  if ( argc == globalUtilOptind + 1 )
367  nPrints = atoi(argv[globalUtilOptind]);
368  // print the commands
369  Vec_PtrForEachEntryStart( char *, pAbc->aHistory, pName, i, Abc_MaxInt(0, Vec_PtrSize(pAbc->aHistory)-nPrints) )
370  fprintf( pAbc->Out, "%2d : %s\n", Vec_PtrSize(pAbc->aHistory)-i, pName );
371  return 0;
372 
373 usage:
374  fprintf( pAbc->Err, "usage: history [-h] <num>\n" );
375  fprintf( pAbc->Err, "\t lists the last commands entered on the command line\n" );
376  fprintf( pAbc->Err, "\t-h : print the command usage\n" );
377  fprintf( pAbc->Err, "\t<num> : the maximum number of entries to show [default = %d]\n", nPrints );
378  return ( 1 );
379 }
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition: vecPtr.h:57
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
ABC_DLL void Extra_UtilGetoptReset()
Definition: extraUtilUtil.c:80
int globalUtilOptind
Definition: extraUtilUtil.c:45
int Extra_UtilGetopt(int argc, char *argv[], const char *optstring)
Definition: extraUtilUtil.c:98
int CmdCommandMvsis ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

Function********************************************************************

Synopsis [Calls SIS internally.]

Description []

SideEffects []

SeeAlso []

Definition at line 1992 of file cmd.c.

1993 {
1994  FILE * pFile;
1995  FILE * pOut, * pErr;
1996  Abc_Ntk_t * pNtk, * pNtkNew, * pNetlist;
1997  char Command[1000], Buffer[100];
1998  char * pNameWin = "mvsis.exe";
1999  char * pNameUnix = "mvsis";
2000  char * pMvsisName;
2001  int i;
2002 
2003  pNtk = Abc_FrameReadNtk(pAbc);
2004  pOut = Abc_FrameReadOut(pAbc);
2005  pErr = Abc_FrameReadErr(pAbc);
2006 
2007  if ( argc == 1 )
2008  goto usage;
2009  if ( strcmp( argv[1], "-h" ) == 0 )
2010  goto usage;
2011  if ( strcmp( argv[1], "-?" ) == 0 )
2012  goto usage;
2013 
2014  if ( pNtk == NULL )
2015  {
2016  fprintf( pErr, "Empty network.\n" );
2017  goto usage;
2018  }
2019 
2020  if ( strcmp( argv[0], "mvsis" ) != 0 )
2021  {
2022  fprintf( pErr, "Wrong command: \"%s\".\n", argv[0] );
2023  goto usage;
2024  }
2025 
2026  // get the names from the resource file
2027  if ( Cmd_FlagReadByName(pAbc, "mvsiswin") )
2028  pNameWin = Cmd_FlagReadByName(pAbc, "mvsiswin");
2029  if ( Cmd_FlagReadByName(pAbc, "mvsisunix") )
2030  pNameUnix = Cmd_FlagReadByName(pAbc, "mvsisunix");
2031 
2032  // check if MVSIS is available
2033  if ( (pFile = fopen( pNameWin, "r" )) )
2034  pMvsisName = pNameWin;
2035  else if ( (pFile = fopen( pNameUnix, "r" )) )
2036  pMvsisName = pNameUnix;
2037  else if ( pFile == NULL )
2038  {
2039  fprintf( pErr, "Cannot find \"%s\" or \"%s\" in the current directory.\n", pNameWin, pNameUnix );
2040  goto usage;
2041  }
2042  fclose( pFile );
2043 
2044  if ( Abc_NtkIsMappedLogic(pNtk) )
2045  {
2046  Abc_NtkMapToSop(pNtk);
2047  printf( "The current network is unmapped before calling MVSIS.\n" );
2048  }
2049 
2050  // write out the current network
2051  if ( Abc_NtkIsLogic(pNtk) )
2052  Abc_NtkToSop(pNtk, 0);
2053  pNetlist = Abc_NtkToNetlist(pNtk);
2054  if ( pNetlist == NULL )
2055  {
2056  fprintf( pErr, "Cannot produce the intermediate network.\n" );
2057  goto usage;
2058  }
2059  Io_WriteBlif( pNetlist, "_mvsis_in.blif", 1, 0, 0 );
2060  Abc_NtkDelete( pNetlist );
2061 
2062  // create the file for MVSIS
2063  sprintf( Command, "%s -x -c ", pMvsisName );
2064  strcat ( Command, "\"" );
2065  strcat ( Command, "read_blif _mvsis_in.blif" );
2066  strcat ( Command, "; " );
2067  for ( i = 1; i < argc; i++ )
2068  {
2069  sprintf( Buffer, " %s", argv[i] );
2070  strcat( Command, Buffer );
2071  }
2072  strcat( Command, "; " );
2073  strcat( Command, "write_blif _mvsis_out.blif" );
2074  strcat( Command, "\"" );
2075 
2076  // call MVSIS
2077  if ( Util_SignalSystem( Command ) )
2078  {
2079  fprintf( pErr, "The following command has returned non-zero exit status:\n" );
2080  fprintf( pErr, "\"%s\"\n", Command );
2081  unlink( "_mvsis_in.blif" );
2082  goto usage;
2083  }
2084 
2085  // read in the MVSIS output
2086  if ( (pFile = fopen( "_mvsis_out.blif", "r" )) == NULL )
2087  {
2088  fprintf( pErr, "Cannot open MVSIS output file \"%s\".\n", "_mvsis_out.blif" );
2089  unlink( "_mvsis_in.blif" );
2090  goto usage;
2091  }
2092  fclose( pFile );
2093 
2094  // set the new network
2095  pNtkNew = Io_Read( "_mvsis_out.blif", IO_FILE_BLIF, 1, 0 );
2096  // set the original spec of the new network
2097  if ( pNtk->pSpec )
2098  {
2099  ABC_FREE( pNtkNew->pSpec );
2100  pNtkNew->pSpec = Extra_UtilStrsav( pNtk->pSpec );
2101  }
2102  // replace the current network
2103  Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew );
2104 
2105  // remove temporary networks
2106  unlink( "_mvsis_in.blif" );
2107  unlink( "_mvsis_out.blif" );
2108  return 0;
2109 
2110 usage:
2111  fprintf( pErr, "Usage: mvsis [-h] <com>\n");
2112  fprintf( pErr, " invokes MVSIS command for the current ABC network\n" );
2113  fprintf( pErr, " (the executable of MVSIS should be in the same directory)\n" );
2114  fprintf( pErr, " -h : print the command usage\n" );
2115  fprintf( pErr, " <com> : a MVSIS command (or a semicolon-separated list of commands in quotes)\n" );
2116  fprintf( pErr, " Example 1: mvsis fraig_sweep\n" );
2117  fprintf( pErr, " Example 2: mvsis \"ps; fxu; ps\"\n" );
2118  fprintf( pErr, " Example 3: mvsis source mvsis.rugged\n" );
2119  return 1; // error exit
2120 }
ABC_DLL void Abc_FrameReplaceCurrentNetwork(Abc_Frame_t *p, Abc_Ntk_t *pNet)
Definition: mainFrame.c:493
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
ABC_DLL Abc_Ntk_t * Abc_NtkToNetlist(Abc_Ntk_t *pNtk)
Definition: abcNetlist.c:97
void Io_WriteBlif(Abc_Ntk_t *pNtk, char *pFileName, int fWriteLatches, int fBb2Wb, int fSeq)
Definition: ioWriteBlif.c:84
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
char * Extra_UtilStrsav(const char *s)
Abc_Ntk_t * Io_Read(char *pFileName, Io_FileType_t FileType, int fCheck, int fBarBufs)
Definition: ioUtil.c:238
int strcmp()
ABC_DLL int Abc_NtkMapToSop(Abc_Ntk_t *pNtk)
Definition: abcFunc.c:1073
ABC_DLL int Abc_NtkToSop(Abc_Ntk_t *pNtk, int fDirect)
Definition: abcFunc.c:1124
char * sprintf()
ABC_DLL Abc_Ntk_t * Abc_FrameReadNtk(Abc_Frame_t *p)
Definition: mainFrame.c:282
char * pSpec
Definition: abc.h:159
static int Abc_NtkIsMappedLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:267
#define ABC_FREE(obj)
Definition: abc_global.h:232
char * strcat()
ABC_DLL FILE * Abc_FrameReadErr(Abc_Frame_t *p)
Definition: mainFrame.c:330
ABC_DLL FILE * Abc_FrameReadOut(Abc_Frame_t *p)
Definition: mainFrame.c:314
ABC_NAMESPACE_IMPL_START int Util_SignalSystem(const char *cmd)
DECLARATIONS ///.
Definition: utilSignal.c:46
char * Cmd_FlagReadByName(Abc_Frame_t *pAbc, char *flag)
DECLARATIONS ///.
Definition: cmdFlag.c:47
int CmdCommandQuit ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

Function********************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 288 of file cmd.c.

289 {
290  int c;
291 
293  while ( ( c = Extra_UtilGetopt( argc, argv, "hs" ) ) != EOF )
294  {
295  switch ( c )
296  {
297  case 'h':
298  goto usage;
299  break;
300  case 's':
301  return -2;
302  break;
303  default:
304  goto usage;
305  }
306  }
307 
308  if ( argc != globalUtilOptind )
309  goto usage;
310  return -1;
311 
312  usage:
313  fprintf( pAbc->Err, "usage: quit [-h] [-s]\n" );
314  fprintf( pAbc->Err, " -h print the command usage\n" );
315  fprintf( pAbc->Err,
316  " -s frees all the memory before quitting\n" );
317  return 1;
318 }
ABC_DLL void Extra_UtilGetoptReset()
Definition: extraUtilUtil.c:80
int globalUtilOptind
Definition: extraUtilUtil.c:45
int Extra_UtilGetopt(int argc, char *argv[], const char *optstring)
Definition: extraUtilUtil.c:98
int CmdCommandRecall ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

Function********************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 927 of file cmd.c.

928 {
929  Abc_Ntk_t * pNtk;
930  int iStep, iStepFound;
931  int nNetsToSave, c;
932  char * pValue;
933  int iStepStart, iStepStop;
934 
936  while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
937  {
938  switch ( c )
939  {
940  case 'h':
941  goto usage;
942  default:
943  goto usage;
944  }
945  }
946 
947  if ( pAbc->pNtkCur == NULL )
948  {
949  fprintf( pAbc->Out, "Empty network.\n" );
950  return 0;
951  }
952 
953  // get the number of networks to save
954  pValue = Cmd_FlagReadByName( pAbc, "savesteps" );
955  // if the value of steps to save is not set, assume 1-level undo
956  if ( pValue == NULL )
957  nNetsToSave = 1;
958  else
959  nNetsToSave = atoi(pValue);
960 
961  // if there are no arguments on the command line
962  // set the current network to be the network from the previous step
963  if ( argc == 1 )
964  {
965  // get the previously saved network
966  pNtk = Abc_NtkBackup(pAbc->pNtkCur);
967  if ( pNtk == NULL )
968  fprintf( pAbc->Out, "There is no previously saved network.\n" );
969  else // set the current network to be the copy of the previous one
970  Abc_FrameSetCurrentNetwork( pAbc, Abc_NtkDup(pNtk) );
971  return 0;
972  }
973  if ( argc == 2 ) // the second argument is the number of the step to return to
974  {
975  // read the number of the step to return to
976  iStep = atoi(argv[1]);
977  // check whether it is reasonable
978  if ( iStep >= pAbc->nSteps )
979  {
980  iStepStart = pAbc->nSteps - nNetsToSave;
981  if ( iStepStart <= 0 )
982  iStepStart = 1;
983  iStepStop = pAbc->nSteps;
984  if ( iStepStop <= 0 )
985  iStepStop = 1;
986  if ( iStepStart == iStepStop )
987  fprintf( pAbc->Out, "Can only recall step %d.\n", iStepStop );
988  else
989  fprintf( pAbc->Out, "Can only recall steps %d-%d.\n", iStepStart, iStepStop );
990  }
991  else if ( iStep < 0 )
992  fprintf( pAbc->Out, "Cannot recall step %d.\n", iStep );
993  else if ( iStep == 0 )
995  else
996  {
997  // scroll backward through the list of networks
998  // to determine if such a network exist
999  iStepFound = 0;
1000  for ( pNtk = pAbc->pNtkCur; pNtk; pNtk = Abc_NtkBackup(pNtk) )
1001  if ( (iStepFound = Abc_NtkStep(pNtk)) == iStep )
1002  break;
1003  if ( pNtk == NULL )
1004  {
1005  iStepStart = iStepFound;
1006  if ( iStepStart <= 0 )
1007  iStepStart = 1;
1008  iStepStop = pAbc->nSteps;
1009  if ( iStepStop <= 0 )
1010  iStepStop = 1;
1011  if ( iStepStart == iStepStop )
1012  fprintf( pAbc->Out, "Can only recall step %d.\n", iStepStop );
1013  else
1014  fprintf( pAbc->Out, "Can only recall steps %d-%d.\n", iStepStart, iStepStop );
1015  }
1016  else
1017  Abc_FrameSetCurrentNetwork( pAbc, Abc_NtkDup(pNtk) );
1018  }
1019  return 0;
1020  }
1021 
1022 usage:
1023 
1024  fprintf( pAbc->Err, "usage: recall -h <num>\n" );
1025  fprintf( pAbc->Err, " set the current network to be one of the previous networks\n" );
1026  fprintf( pAbc->Err, "<num> : level to return to [default = previous]\n" );
1027  fprintf( pAbc->Err, " -h : print the command usage\n");
1028  return 1;
1029 }
ABC_DLL void Abc_FrameDeleteAllNetworks(Abc_Frame_t *p)
Definition: mainFrame.c:551
ABC_DLL void Abc_FrameSetCurrentNetwork(Abc_Frame_t *p, Abc_Ntk_t *pNet)
Definition: mainFrame.c:396
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:419
ABC_DLL void Extra_UtilGetoptReset()
Definition: extraUtilUtil.c:80
static int Abc_NtkStep(Abc_Ntk_t *pNtk)
Definition: abc.h:274
int Extra_UtilGetopt(int argc, char *argv[], const char *optstring)
Definition: extraUtilUtil.c:98
char * Cmd_FlagReadByName(Abc_Frame_t *pAbc, char *flag)
DECLARATIONS ///.
Definition: cmdFlag.c:47
static Abc_Ntk_t * Abc_NtkBackup(Abc_Ntk_t *pNtk)
Definition: abc.h:273
int CmdCommandSetVariable ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

Function********************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 738 of file cmd.c.

739 {
740  char *flag_value, *value;
741  const char* key;
742  int c;
743 
745  while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
746  {
747  switch ( c )
748  {
749  case 'h':
750  goto usage;
751  default:
752  goto usage;
753  }
754  }
755  if ( argc == 0 || argc > 3 )
756  {
757  goto usage;
758  }
759  else if ( argc == 1 )
760  {
761  CmdPrintTable( pAbc->tFlags, 0 );
762  return 0;
763  }
764  else
765  {
766  key = argv[1];
767  if ( st__delete( pAbc->tFlags, &key, &value ) )
768  {
769  ABC_FREE( key );
770  ABC_FREE( value );
771  }
772 
773  flag_value = argc == 2 ? Extra_UtilStrsav( "" ) : Extra_UtilStrsav( argv[2] );
774 // flag_value = argc == 2 ? NULL : Extra_UtilStrsav(argv[2]);
775  st__insert( pAbc->tFlags, Extra_UtilStrsav(argv[1]), flag_value );
776 
777  if ( strcmp( argv[1], "abcout" ) == 0 )
778  {
779  if ( pAbc->Out != stdout )
780  fclose( pAbc->Out );
781  if ( strcmp( flag_value, "" ) == 0 )
782  flag_value = "-";
783  pAbc->Out = CmdFileOpen( pAbc, flag_value, "w", NULL, 0 );
784  if ( pAbc->Out == NULL )
785  pAbc->Out = stdout;
786 #if HAVE_SETVBUF
787  setvbuf( pAbc->Out, ( char * ) NULL, _IOLBF, 0 );
788 #endif
789  }
790  if ( strcmp( argv[1], "abcerr" ) == 0 )
791  {
792  if ( pAbc->Err != stderr )
793  fclose( pAbc->Err );
794  if ( strcmp( flag_value, "" ) == 0 )
795  flag_value = "-";
796  pAbc->Err = CmdFileOpen( pAbc, flag_value, "w", NULL, 0 );
797  if ( pAbc->Err == NULL )
798  pAbc->Err = stderr;
799 #if HAVE_SETVBUF
800  setvbuf( pAbc->Err, ( char * ) NULL, _IOLBF, 0 );
801 #endif
802  }
803  if ( strcmp( argv[1], "history" ) == 0 )
804  {
805  if ( pAbc->Hst != NULL )
806  fclose( pAbc->Hst );
807  if ( strcmp( flag_value, "" ) == 0 )
808  pAbc->Hst = NULL;
809  else
810  {
811  pAbc->Hst = CmdFileOpen( pAbc, flag_value, "w", NULL, 0 );
812  if ( pAbc->Hst == NULL )
813  pAbc->Hst = NULL;
814  }
815  }
816  return 0;
817  }
818 
819  usage:
820  fprintf( pAbc->Err, "usage: set [-h] <name> <value>\n" );
821  fprintf( pAbc->Err, "\t sets the value of parameter <name>\n" );
822  fprintf( pAbc->Err, "\t-h : print the command usage\n" );
823  return 1;
824 
825 }
int st__delete(st__table *table, const char **keyp, char **value)
Definition: st.c:375
int st__insert(st__table *table, const char *key, char *value)
Definition: st.c:171
char * Extra_UtilStrsav(const char *s)
int strcmp()
ABC_DLL void Extra_UtilGetoptReset()
Definition: extraUtilUtil.c:80
void CmdPrintTable(st__table *tTable, int fAliases)
Definition: cmdUtils.c:722
FILE * CmdFileOpen(Abc_Frame_t *pAbc, char *sFileName, char *sMode, char **pFileNameReal, int silent)
Definition: cmdUtils.c:408
#define ABC_FREE(obj)
Definition: abc_global.h:232
int Extra_UtilGetopt(int argc, char *argv[], const char *optstring)
Definition: extraUtilUtil.c:98
enum keys key
int value
int CmdCommandSis ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

Function********************************************************************

Synopsis [Calls SIS internally.]

Description []

SideEffects []

SeeAlso []

Definition at line 1850 of file cmd.c.

1851 {
1852  FILE * pFile;
1853  FILE * pOut, * pErr;
1854  Abc_Ntk_t * pNtk, * pNtkNew, * pNetlist;
1855  char * pNameWin = "sis.exe";
1856  char * pNameUnix = "sis";
1857  char Command[1000], Buffer[100];
1858  char * pSisName;
1859  int i;
1860 
1861  pNtk = Abc_FrameReadNtk(pAbc);
1862  pOut = Abc_FrameReadOut(pAbc);
1863  pErr = Abc_FrameReadErr(pAbc);
1864 
1865  if ( argc == 1 )
1866  goto usage;
1867  if ( strcmp( argv[1], "-h" ) == 0 )
1868  goto usage;
1869  if ( strcmp( argv[1], "-?" ) == 0 )
1870  goto usage;
1871 
1872  if ( pNtk == NULL )
1873  {
1874  fprintf( pErr, "Empty network.\n" );
1875  goto usage;
1876  }
1877 
1878  if ( strcmp( argv[0], "sis" ) != 0 )
1879  {
1880  fprintf( pErr, "Wrong command: \"%s\".\n", argv[0] );
1881  goto usage;
1882  }
1883 
1884  // get the names from the resource file
1885  if ( Cmd_FlagReadByName(pAbc, "siswin") )
1886  pNameWin = Cmd_FlagReadByName(pAbc, "siswin");
1887  if ( Cmd_FlagReadByName(pAbc, "sisunix") )
1888  pNameUnix = Cmd_FlagReadByName(pAbc, "sisunix");
1889 
1890  // check if SIS is available
1891  if ( (pFile = fopen( pNameWin, "r" )) )
1892  pSisName = pNameWin;
1893  else if ( (pFile = fopen( pNameUnix, "r" )) )
1894  pSisName = pNameUnix;
1895  else if ( pFile == NULL )
1896  {
1897  fprintf( pErr, "Cannot find \"%s\" or \"%s\" in the current directory.\n", pNameWin, pNameUnix );
1898  goto usage;
1899  }
1900  fclose( pFile );
1901 
1902  if ( Abc_NtkIsMappedLogic(pNtk) )
1903  {
1904  Abc_NtkMapToSop(pNtk);
1905  printf( "The current network is unmapped before calling SIS.\n" );
1906  }
1907 
1908  // write out the current network
1909  if ( Abc_NtkIsLogic(pNtk) )
1910  Abc_NtkToSop(pNtk, 0);
1911  pNetlist = Abc_NtkToNetlist(pNtk);
1912  if ( pNetlist == NULL )
1913  {
1914  fprintf( pErr, "Cannot produce the intermediate network.\n" );
1915  goto usage;
1916  }
1917  Io_WriteBlif( pNetlist, "_sis_in.blif", 1, 0, 0 );
1918  Abc_NtkDelete( pNetlist );
1919 
1920  // create the file for sis
1921  sprintf( Command, "%s -x -c ", pSisName );
1922  strcat ( Command, "\"" );
1923  strcat ( Command, "read_blif _sis_in.blif" );
1924  strcat ( Command, "; " );
1925  for ( i = 1; i < argc; i++ )
1926  {
1927  sprintf( Buffer, " %s", argv[i] );
1928  strcat( Command, Buffer );
1929  }
1930  strcat( Command, "; " );
1931  strcat( Command, "write_blif _sis_out.blif" );
1932  strcat( Command, "\"" );
1933 
1934  // call SIS
1935  if ( Util_SignalSystem( Command ) )
1936  {
1937  fprintf( pErr, "The following command has returned non-zero exit status:\n" );
1938  fprintf( pErr, "\"%s\"\n", Command );
1939  unlink( "_sis_in.blif" );
1940  goto usage;
1941  }
1942 
1943  // read in the SIS output
1944  if ( (pFile = fopen( "_sis_out.blif", "r" )) == NULL )
1945  {
1946  fprintf( pErr, "Cannot open SIS output file \"%s\".\n", "_sis_out.blif" );
1947  unlink( "_sis_in.blif" );
1948  goto usage;
1949  }
1950  fclose( pFile );
1951 
1952  // set the new network
1953  pNtkNew = Io_Read( "_sis_out.blif", IO_FILE_BLIF, 1, 0 );
1954  // set the original spec of the new network
1955  if ( pNtk->pSpec )
1956  {
1957  ABC_FREE( pNtkNew->pSpec );
1958  pNtkNew->pSpec = Extra_UtilStrsav( pNtk->pSpec );
1959  }
1960  // replace the current network
1961  Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew );
1962 
1963  // remove temporary networks
1964  unlink( "_sis_in.blif" );
1965  unlink( "_sis_out.blif" );
1966  return 0;
1967 
1968 usage:
1969  fprintf( pErr, "Usage: sis [-h] <com>\n");
1970  fprintf( pErr, " invokes SIS command for the current ABC network\n" );
1971  fprintf( pErr, " (the executable of SIS should be in the same directory)\n" );
1972  fprintf( pErr, " -h : print the command usage\n" );
1973  fprintf( pErr, " <com> : a SIS command (or a semicolon-separated list of commands in quotes)\n" );
1974  fprintf( pErr, " Example 1: sis eliminate 0\n" );
1975  fprintf( pErr, " Example 2: sis \"ps; rd; fx; ps\"\n" );
1976  fprintf( pErr, " Example 3: sis source script.rugged\n" );
1977  return 1; // error exit
1978 }
ABC_DLL void Abc_FrameReplaceCurrentNetwork(Abc_Frame_t *p, Abc_Ntk_t *pNet)
Definition: mainFrame.c:493
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
ABC_DLL Abc_Ntk_t * Abc_NtkToNetlist(Abc_Ntk_t *pNtk)
Definition: abcNetlist.c:97
void Io_WriteBlif(Abc_Ntk_t *pNtk, char *pFileName, int fWriteLatches, int fBb2Wb, int fSeq)
Definition: ioWriteBlif.c:84
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
char * Extra_UtilStrsav(const char *s)
Abc_Ntk_t * Io_Read(char *pFileName, Io_FileType_t FileType, int fCheck, int fBarBufs)
Definition: ioUtil.c:238
int strcmp()
ABC_DLL int Abc_NtkMapToSop(Abc_Ntk_t *pNtk)
Definition: abcFunc.c:1073
ABC_DLL int Abc_NtkToSop(Abc_Ntk_t *pNtk, int fDirect)
Definition: abcFunc.c:1124
char * sprintf()
ABC_DLL Abc_Ntk_t * Abc_FrameReadNtk(Abc_Frame_t *p)
Definition: mainFrame.c:282
char * pSpec
Definition: abc.h:159
static int Abc_NtkIsMappedLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:267
#define ABC_FREE(obj)
Definition: abc_global.h:232
char * strcat()
ABC_DLL FILE * Abc_FrameReadErr(Abc_Frame_t *p)
Definition: mainFrame.c:330
ABC_DLL FILE * Abc_FrameReadOut(Abc_Frame_t *p)
Definition: mainFrame.c:314
ABC_NAMESPACE_IMPL_START int Util_SignalSystem(const char *cmd)
DECLARATIONS ///.
Definition: utilSignal.c:46
char * Cmd_FlagReadByName(Abc_Frame_t *pAbc, char *flag)
DECLARATIONS ///.
Definition: cmdFlag.c:47
int CmdCommandSource ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

Function********************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 555 of file cmd.c.

556 {
557  int c, echo, prompt, silent, interactive, quit_count, lp_count;
558  int status = 0; /* initialize so that lint doesn't complain */
559  int lp_file_index, did_subst;
560  char *prompt_string, *real_filename, line[ABC_MAX_STR], *command;
561  FILE *fp;
562 
563  interactive = silent = prompt = echo = 0;
564 
566  while ( ( c = Extra_UtilGetopt( argc, argv, "ipsxh" ) ) != EOF )
567  {
568  switch ( c )
569  {
570  case 'i': /* a hack to distinguish EOF from stdin */
571  interactive = 1;
572  break;
573  case 'p':
574  prompt ^= 1;
575  break;
576  case 's':
577  silent ^= 1;
578  break;
579  case 'x':
580  echo ^= 1;
581  break;
582  case 'h':
583  goto usage;
584  default:
585  goto usage;
586  }
587  }
588 
589  /* added to avoid core-dumping when no script file is specified */
590  if ( argc == globalUtilOptind )
591  {
592  goto usage;
593  }
594 
595  lp_file_index = globalUtilOptind;
596  lp_count = 0;
597 
598  /*
599  * FIX (Tom, 5/7/95): I'm not sure what the purpose of this outer do loop
600  * is. In particular, lp_file_index is never modified in the loop, so it
601  * looks it would just read the same file over again. Also, SIS had
602  * lp_count initialized to -1, and hence, any file sourced by SIS (if -l or
603  * -t options on "source" were used in SIS) would actually be executed twice.
604  */
605  pAbc->fSource = 1;
606  do
607  {
608  char * pFileName, * pTemp;
609 
610  // get the input file name
611  pFileName = argv[lp_file_index];
612  // fix the wrong symbol
613  for ( pTemp = pFileName; *pTemp; pTemp++ )
614  if ( *pTemp == '>' )
615  *pTemp = '\\';
616 
617  lp_count++; /* increment the loop counter */
618 
619  fp = CmdFileOpen( pAbc, pFileName, "r", &real_filename, silent );
620  if ( fp == NULL )
621  {
622  pAbc->fSource = 0;
623  ABC_FREE( real_filename );
624  return !silent; /* error return if not silent */
625  }
626 
627  quit_count = 0;
628  do
629  {
630  if ( prompt )
631  {
632  prompt_string = Cmd_FlagReadByName( pAbc, "prompt" );
633  if ( prompt_string == NULL )
634  prompt_string = "abc> ";
635 
636  }
637  else
638  {
639  prompt_string = NULL;
640  }
641 
642  /* clear errors -- e.g., EOF reached from stdin */
643  clearerr( fp );
644 
645  /* read another command line */
646  if ( fgets( line, ABC_MAX_STR, fp ) == NULL )
647  {
648  if ( interactive )
649  {
650  if ( quit_count++ < 5 )
651  {
652  fprintf( pAbc->Err, "\nUse \"quit\" to leave ABC.\n" );
653  continue;
654  }
655  status = -1; /* fake a 'quit' */
656  }
657  else
658  {
659  status = 0; /* successful end of 'source' ; loop? */
660  }
661  break;
662  }
663  quit_count = 0;
664 
665  if ( echo )
666  {
667  fprintf( pAbc->Out, "abc - > %s", line );
668  }
669  command = CmdHistorySubstitution( pAbc, line, &did_subst );
670  if ( command == NULL )
671  {
672  status = 1;
673  break;
674  }
675  if ( did_subst )
676  {
677  if ( interactive )
678  {
679  fprintf( pAbc->Out, "%s\n", command );
680  }
681  }
682  if ( command != line )
683  {
684  strcpy( line, command );
685  }
686  if ( interactive && *line != '\0' )
687  {
688  Cmd_HistoryAddCommand( pAbc, line );
689  if ( pAbc->Hst != NULL )
690  {
691  fprintf( pAbc->Hst, "%s\n", line );
692  fflush( pAbc->Hst );
693  }
694  }
695 
696  fflush( pAbc->Out );
697  status = Cmd_CommandExecute( pAbc, line );
698  }
699  while ( status == 0 );
700 
701  if ( fp != stdin )
702  {
703  if ( status > 0 )
704  {
705  fprintf( pAbc->Err,
706  "** cmd error: aborting 'source %s'\n",
707  real_filename );
708  }
709  fclose( fp );
710  }
711  ABC_FREE( real_filename );
712 
713  }
714  while ( ( status == 0 ) && ( lp_count <= 0 ) );
715  pAbc->fSource = 0;
716  return status;
717 
718  usage:
719  fprintf( pAbc->Err, "usage: source [-psxh] <file_name>\n" );
720  fprintf( pAbc->Err, "\t-p supply prompt before reading each line [default = %s]\n", prompt? "yes": "no" );
721  fprintf( pAbc->Err, "\t-s silently ignore nonexistant file [default = %s]\n", silent? "yes": "no" );
722  fprintf( pAbc->Err, "\t-x echo each line as it is executed [default = %s]\n", echo? "yes": "no" );
723  fprintf( pAbc->Err, "\t-h print the command usage\n" );
724  return 1;
725 }
int Cmd_CommandExecute(void *pAbc, char *pCommandLine)
char * CmdHistorySubstitution(Abc_Frame_t *pAbc, char *line, int *changed)
Definition: cmdUtils.c:390
void Cmd_HistoryAddCommand(Abc_Frame_t *pAbc, const char *command)
DECLARATIONS ///.
Definition: cmdHist.c:48
VOID_HACK clearerr()
ABC_DLL void Extra_UtilGetoptReset()
Definition: extraUtilUtil.c:80
#define ABC_MAX_STR
Definition: mainInt.h:50
int globalUtilOptind
Definition: extraUtilUtil.c:45
char * strcpy()
FILE * CmdFileOpen(Abc_Frame_t *pAbc, char *sFileName, char *sMode, char **pFileNameReal, int silent)
Definition: cmdUtils.c:408
#define ABC_FREE(obj)
Definition: abc_global.h:232
int Extra_UtilGetopt(int argc, char *argv[], const char *optstring)
Definition: extraUtilUtil.c:98
char * Cmd_FlagReadByName(Abc_Frame_t *pAbc, char *flag)
DECLARATIONS ///.
Definition: cmdFlag.c:47
int CmdCommandStarter ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 2384 of file cmd.c.

2385 {
2386  extern void Cmd_RunStarter( char * pFileName, char * pBinary, char * pCommand, int nCores );
2387  FILE * pFile;
2388  char * pFileName;
2389  char * pCommand = NULL;
2390  int c, nCores = 3;
2391  int fVerbose = 0;
2393  while ( ( c = Extra_UtilGetopt( argc, argv, "NCvh" ) ) != EOF )
2394  {
2395  switch ( c )
2396  {
2397  case 'N':
2398  if ( globalUtilOptind >= argc )
2399  {
2400  Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
2401  goto usage;
2402  }
2403  nCores = atoi(argv[globalUtilOptind]);
2404  globalUtilOptind++;
2405  if ( nCores < 0 )
2406  goto usage;
2407  break;
2408  case 'C':
2409  if ( globalUtilOptind >= argc )
2410  {
2411  Abc_Print( -1, "Command line switch \"-C\" should be followed by a string (possibly in quotes).\n" );
2412  goto usage;
2413  }
2414  pCommand = argv[globalUtilOptind];
2415  globalUtilOptind++;
2416  break;
2417  case 'v':
2418  fVerbose ^= 1;
2419  break;
2420  case 'h':
2421  goto usage;
2422  default:
2423  goto usage;
2424  }
2425  }
2426  if ( argc != globalUtilOptind + 1 )
2427  {
2428  Abc_Print( -2, "The file name should be given on the command line.\n" );
2429  return 1;
2430  }
2431  // get the input file name
2432  pFileName = argv[globalUtilOptind];
2433  if ( (pFile = Io_FileOpen( pFileName, "open_path", "rb", 0 )) == NULL )
2434 // if ( (pFile = fopen( pFileName, "rb" )) == NULL )
2435  {
2436  Abc_Print( -2, "Cannot open input file \"%s\". ", pFileName );
2437  if (( pFileName = Extra_FileGetSimilarName( pFileName, ".c", ".s", ".scr", ".script", NULL ) ))
2438  Abc_Print( -2, "Did you mean \"%s\"?", pFileName );
2439  Abc_Print( -2, "\n" );
2440  return 1;
2441  }
2442  fclose( pFile );
2443  // run commands
2444  Cmd_RunStarter( pFileName, pAbc->sBinary, pCommand, nCores );
2445  return 0;
2446 
2447 usage:
2448  Abc_Print( -2, "usage: starter [-N num] [-C cmd] [-vh] <file>\n" );
2449  Abc_Print( -2, "\t runs command lines listed in <file> concurrently on <num> CPUs\n" );
2450  Abc_Print( -2, "\t-N num : the number of concurrent jobs including the controler [default = %d]\n", nCores );
2451  Abc_Print( -2, "\t-C cmd : (optional) ABC command line to execute on benchmarks in <file>\n" );
2452  Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
2453  Abc_Print( -2, "\t-h : print the command usage\n");
2454  Abc_Print( -2, "\t<file> : file name with ABC command lines (or benchmark names, if <cmd> is given)\n");
2455  return 1;
2456 }
FILE * Io_FileOpen(const char *FileName, const char *PathVar, const char *Mode, int fVerbose)
Definition: ioUtil.c:819
char * Extra_FileGetSimilarName(char *pFileNameWrong, char *pS1, char *pS2, char *pS3, char *pS4, char *pS5)
Definition: extraUtilFile.c:71
ABC_NAMESPACE_IMPL_START void Cmd_RunStarter(char *pFileName, char *pBinary, char *pCommand, int nCores)
DECLARATIONS ///.
Definition: cmdStarter.c:47
ABC_DLL void Extra_UtilGetoptReset()
Definition: extraUtilUtil.c:80
int globalUtilOptind
Definition: extraUtilUtil.c:45
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
int Extra_UtilGetopt(int argc, char *argv[], const char *optstring)
Definition: extraUtilUtil.c:98
int CmdCommandTime ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

DECLARATIONS ///.

CFile****************************************************************

FileName [cmd.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:
cmd.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Function********************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 165 of file cmd.c.

166 {
167  int c;
168  int fClear;
169 
170  fClear = 0;
172  while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
173  {
174  switch ( c )
175  {
176  case 'c':
177  fClear ^= 1;
178  break;
179  case 'h':
180  goto usage;
181  default:
182  goto usage;
183  }
184  }
185 
186  if ( fClear )
187  {
188  pAbc->TimeTotal += pAbc->TimeCommand;
189  pAbc->TimeCommand = 0.0;
190  return 0;
191  }
192 
193  if ( argc != globalUtilOptind )
194  {
195  goto usage;
196  }
197 
198 
199  pAbc->TimeTotal += pAbc->TimeCommand;
200  fprintf( pAbc->Out, "elapse: %3.2f seconds, total: %3.2f seconds\n",
201  pAbc->TimeCommand, pAbc->TimeTotal );
202 /*
203  {
204  FILE * pTable;
205  pTable = fopen( "runtimes.txt", "a+" );
206  fprintf( pTable, "%4.2f\n", pAbc->TimeCommand );
207  fclose( pTable );
208  }
209 */
210  pAbc->TimeCommand = 0.0;
211  return 0;
212 
213  usage:
214  fprintf( pAbc->Err, "usage: time [-ch]\n" );
215  fprintf( pAbc->Err, " \t\tprint the runtime since the last call\n" );
216  fprintf( pAbc->Err, " -c \t\tclears the elapsed time without printing it\n" );
217  fprintf( pAbc->Err, " -h \t\tprint the command usage\n" );
218  return 1;
219 }
ABC_DLL void Extra_UtilGetoptReset()
Definition: extraUtilUtil.c:80
int globalUtilOptind
Definition: extraUtilUtil.c:45
int Extra_UtilGetopt(int argc, char *argv[], const char *optstring)
Definition: extraUtilUtil.c:98
int CmdCommandUnalias ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

Function********************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 449 of file cmd.c.

450 {
451  int i;
452  const char *key;
453  char *value;
454  int c;
455 
457  while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
458  {
459  switch ( c )
460  {
461  case 'h':
462  goto usage;
463  break;
464  default:
465  goto usage;
466  }
467  }
468 
469  if ( argc < 2 )
470  {
471  goto usage;
472  }
473 
474  for ( i = 1; i < argc; i++ )
475  {
476  key = argv[i];
477  if ( st__delete( pAbc->tAliases, &key, &value ) )
478  {
479  CmdCommandAliasFree( ( Abc_Alias * ) value );
480  }
481  }
482  return 0;
483 
484  usage:
485  fprintf( pAbc->Err, "usage: unalias [-h] alias_names\n" );
486  fprintf( pAbc->Err, " -h \t\tprint the command usage\n" );
487  return 1;
488 }
int st__delete(st__table *table, const char **keyp, char **value)
Definition: st.c:375
Definition: cmdInt.h:51
void CmdCommandAliasFree(Abc_Alias *pAlias)
Definition: cmdAlias.c:113
ABC_DLL void Extra_UtilGetoptReset()
Definition: extraUtilUtil.c:80
int Extra_UtilGetopt(int argc, char *argv[], const char *optstring)
Definition: extraUtilUtil.c:98
enum keys key
int value
int CmdCommandUndo ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

Function********************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 893 of file cmd.c.

894 {
895  if ( argc == 2 && !strcmp(argv[1], "-h") )
896  goto usage;
897 
898  if ( pAbc->pNtkCur == NULL )
899  {
900  fprintf( pAbc->Out, "Empty network.\n" );
901  return 0;
902  }
903 
904  // if there are no arguments on the command line
905  // set the current network to be the network from the previous step
906  if ( argc == 1 )
907  return CmdCommandRecall( pAbc, argc, argv );
908 
909 usage:
910  fprintf( pAbc->Err, "usage: undo\n" );
911  fprintf( pAbc->Err, " sets the current network to be the previously saved network\n" );
912  return 1;
913 
914 }
static int CmdCommandRecall(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:927
int strcmp()
int CmdCommandUnsetVariable ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

Function********************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 838 of file cmd.c.

839 {
840  int i;
841  const char *key;
842  char *value;
843  int c;
844 
846  while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
847  {
848  switch ( c )
849  {
850  case 'h':
851  goto usage;
852  break;
853  default:
854  goto usage;
855  }
856  }
857 
858  if ( argc < 2 )
859  {
860  goto usage;
861  }
862 
863  for ( i = 1; i < argc; i++ )
864  {
865  key = argv[i];
866  if ( st__delete( pAbc->tFlags, &key, &value ) )
867  {
868  ABC_FREE( key );
869  ABC_FREE( value );
870  }
871  }
872  return 0;
873 
874 
875  usage:
876  fprintf( pAbc->Err, "usage: unset [-h] <name> \n" );
877  fprintf( pAbc->Err, "\t removes the value of parameter <name>\n" );
878  fprintf( pAbc->Err, "\t-h : print the command usage\n" );
879  return 1;
880 }
int st__delete(st__table *table, const char **keyp, char **value)
Definition: st.c:375
ABC_DLL void Extra_UtilGetoptReset()
Definition: extraUtilUtil.c:80
#define ABC_FREE(obj)
Definition: abc_global.h:232
int Extra_UtilGetopt(int argc, char *argv[], const char *optstring)
Definition: extraUtilUtil.c:98
enum keys key
int value
int CmdCommandVersion ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

Function********************************************************************

Synopsis [Print the version string.]

Description []

SideEffects []

SeeAlso []

Definition at line 2469 of file cmd.c.

2470 {
2471  int c;
2472 
2474  while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
2475  {
2476  switch ( c )
2477  {
2478  case 'h':
2479  goto usage;
2480  default:
2481  goto usage;
2482  }
2483  }
2484 
2485  printf("%s\n", Abc_UtilsGetVersion(pAbc));
2486  return 0;
2487 
2488 usage:
2489  fprintf( pAbc->Err, "usage: version [-h]\n" );
2490  fprintf( pAbc->Err, " print the version string\n" );
2491  fprintf( pAbc->Err, " -h : print the command usage\n");
2492  return 1;
2493 }
ABC_DLL void Extra_UtilGetoptReset()
Definition: extraUtilUtil.c:80
ABC_DLL char * Abc_UtilsGetVersion(Abc_Frame_t *pAbc)
FUNCTION DEFINITIONS ///.
Definition: mainUtils.c:52
int Extra_UtilGetopt(int argc, char *argv[], const char *optstring)
Definition: extraUtilUtil.c:98
int CmdCommandWhich ( Abc_Frame_t pAbc,
int  argc,
char **  argv 
)
static

Function********************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 331 of file cmd.c.

332 {
333  return 0;
334 }
void Gia_ManGnuplotShow ( char *  pPlotFileName)

Function*************************************************************

Synopsis [Computes dimentions of the graph.]

Description []

SideEffects []

SeeAlso []

Definition at line 2134 of file cmd.c.

2135 {
2136  FILE * pFile;
2137  void * pAbc;
2138  char * pProgNameGnuplotWin = "wgnuplot.exe";
2139  char * pProgNameGnuplotUnix = "gnuplot";
2140  char * pProgNameGnuplot = NULL;
2141 
2142  // read in the Capo plotting output
2143  if ( (pFile = fopen( pPlotFileName, "r" )) == NULL )
2144  {
2145  fprintf( stdout, "Cannot open the plot file \"%s\".\n\n", pPlotFileName );
2146  return;
2147  }
2148  fclose( pFile );
2149 
2150  pAbc = Abc_FrameGetGlobalFrame();
2151 
2152  // get the names from the plotting software
2153  if ( Cmd_FlagReadByName((Abc_Frame_t *)pAbc, "gnuplotwin") )
2154  pProgNameGnuplotWin = Cmd_FlagReadByName((Abc_Frame_t *)pAbc, "gnuplotwin");
2155  if ( Cmd_FlagReadByName((Abc_Frame_t *)pAbc, "gnuplotunix") )
2156  pProgNameGnuplotUnix = Cmd_FlagReadByName((Abc_Frame_t *)pAbc, "gnuplotunix");
2157 
2158  // check if Gnuplot is available
2159  if ( (pFile = fopen( pProgNameGnuplotWin, "r" )) )
2160  pProgNameGnuplot = pProgNameGnuplotWin;
2161  else if ( (pFile = fopen( pProgNameGnuplotUnix, "r" )) )
2162  pProgNameGnuplot = pProgNameGnuplotUnix;
2163  else if ( pFile == NULL )
2164  {
2165  fprintf( stdout, "Cannot find \"%s\" or \"%s\" in the current directory.\n", pProgNameGnuplotWin, pProgNameGnuplotUnix );
2166  return;
2167  }
2168  fclose( pFile );
2169 
2170  // spawn the viewer
2171 #ifdef WIN32
2172  if ( _spawnl( _P_NOWAIT, pProgNameGnuplot, pProgNameGnuplot, pPlotFileName, NULL ) == -1 )
2173  {
2174  fprintf( stdout, "Cannot find \"%s\".\n", pProgNameGnuplot );
2175  return;
2176  }
2177 #else
2178  {
2179  char Command[1000];
2180  sprintf( Command, "%s %s ", pProgNameGnuplot, pPlotFileName );
2181  if ( system( Command ) == -1 )
2182  {
2183  fprintf( stdout, "Cannot execute \"%s\".\n", Command );
2184  return;
2185  }
2186  }
2187 #endif
2188 }
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
void * Abc_FrameGetGlobalFrame()
Definition: mainFrame.c:593
char * sprintf()
int system()
char * Cmd_FlagReadByName(Abc_Frame_t *pAbc, char *flag)
DECLARATIONS ///.
Definition: cmdFlag.c:47