abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cmd.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [cmd.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Command processing package.]
8 
9  Synopsis [Command file.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: cmd.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #ifdef WIN32
22 #include <process.h>
23 #else
24 #include <unistd.h>
25 #endif
26 
27 #include "base/abc/abc.h"
28 #include "base/main/mainInt.h"
29 #include "cmdInt.h"
30 #include "misc/util/utilSignal.h"
31 
33 
34 ////////////////////////////////////////////////////////////////////////
35 /// DECLARATIONS ///
36 ////////////////////////////////////////////////////////////////////////
37 
38 static int CmdCommandTime ( Abc_Frame_t * pAbc, int argc, char ** argv );
39 static int CmdCommandEcho ( Abc_Frame_t * pAbc, int argc, char ** argv );
40 static int CmdCommandQuit ( Abc_Frame_t * pAbc, int argc, char ** argv );
41 static int CmdCommandWhich ( Abc_Frame_t * pAbc, int argc, char ** argv );
42 static int CmdCommandHistory ( Abc_Frame_t * pAbc, int argc, char ** argv );
43 static int CmdCommandAlias ( Abc_Frame_t * pAbc, int argc, char ** argv );
44 static int CmdCommandUnalias ( Abc_Frame_t * pAbc, int argc, char ** argv );
45 static int CmdCommandHelp ( Abc_Frame_t * pAbc, int argc, char ** argv );
46 static int CmdCommandSource ( Abc_Frame_t * pAbc, int argc, char ** argv );
47 static int CmdCommandSetVariable ( Abc_Frame_t * pAbc, int argc, char ** argv );
48 static int CmdCommandUnsetVariable ( Abc_Frame_t * pAbc, int argc, char ** argv );
49 static int CmdCommandUndo ( Abc_Frame_t * pAbc, int argc, char ** argv );
50 static int CmdCommandRecall ( Abc_Frame_t * pAbc, int argc, char ** argv );
51 static int CmdCommandEmpty ( Abc_Frame_t * pAbc, int argc, char ** argv );
52 #if defined(WIN32) && !defined(__cplusplus)
53 static int CmdCommandScanDir ( Abc_Frame_t * pAbc, int argc, char ** argv );
54 static int CmdCommandRenameFiles ( Abc_Frame_t * pAbc, int argc, char ** argv );
55 static int CmdCommandLs ( Abc_Frame_t * pAbc, int argc, char ** argv );
56 static int CmdCommandScrGen ( Abc_Frame_t * pAbc, int argc, char ** argv );
57 #endif
58 static int CmdCommandVersion ( Abc_Frame_t * pAbc, int argc, char ** argv );
59 static int CmdCommandSis ( Abc_Frame_t * pAbc, int argc, char ** argv );
60 static int CmdCommandMvsis ( Abc_Frame_t * pAbc, int argc, char ** argv );
61 static int CmdCommandCapo ( Abc_Frame_t * pAbc, int argc, char ** argv );
62 static int CmdCommandStarter ( Abc_Frame_t * pAbc, int argc, char ** argv );
63 
64 extern int Cmd_CommandAbcLoadPlugIn( Abc_Frame_t * pAbc, int argc, char ** argv );
65 
66 ////////////////////////////////////////////////////////////////////////
67 /// FUNCTION DEFINITIONS ///
68 ////////////////////////////////////////////////////////////////////////
69 
70 /**Function********************************************************************
71 
72  Synopsis [Initializes the command package.]
73 
74  SideEffects [Commands are added to the command table.]
75 
76  SeeAlso [Cmd_End]
77 
78 ******************************************************************************/
79 void Cmd_Init( Abc_Frame_t * pAbc )
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 }
115 
116 /**Function********************************************************************
117 
118  Synopsis [Ends the command package.]
119 
120  Description [Ends the command package. Tables are freed.]
121 
122  SideEffects []
123 
124  SeeAlso []
125 
126 ******************************************************************************/
127 void Cmd_End( Abc_Frame_t * pAbc )
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 }
151 
152 
153 
154 /**Function********************************************************************
155 
156  Synopsis []
157 
158  Description []
159 
160  SideEffects []
161 
162  SeeAlso []
163 
164 ******************************************************************************/
165 int CmdCommandTime( Abc_Frame_t * pAbc, int argc, char **argv )
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 }
220 
221 /**Function********************************************************************
222 
223  Synopsis []
224 
225  Description []
226 
227  SideEffects []
228 
229  SeeAlso []
230 
231 ******************************************************************************/
232 int CmdCommandEcho( Abc_Frame_t * pAbc, int argc, char **argv )
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 }
276 
277 /**Function********************************************************************
278 
279  Synopsis []
280 
281  Description []
282 
283  SideEffects []
284 
285  SeeAlso []
286 
287 ******************************************************************************/
288 int CmdCommandQuit( Abc_Frame_t * pAbc, int argc, char **argv )
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 }
319 
320 /**Function********************************************************************
321 
322  Synopsis []
323 
324  Description []
325 
326  SideEffects []
327 
328  SeeAlso []
329 
330 ******************************************************************************/
331 int CmdCommandWhich( Abc_Frame_t * pAbc, int argc, char **argv )
332 {
333  return 0;
334 }
335 
336 /**Function********************************************************************
337 
338  Synopsis []
339 
340  Description []
341 
342  SideEffects []
343 
344  SeeAlso []
345 
346 ******************************************************************************/
347 int CmdCommandHistory( Abc_Frame_t * pAbc, int argc, char **argv )
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 }
380 
381 /**Function********************************************************************
382 
383  Synopsis []
384 
385  Description []
386 
387  SideEffects []
388 
389  SeeAlso []
390 
391 ******************************************************************************/
392 int CmdCommandAlias( Abc_Frame_t * pAbc, int argc, char **argv )
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 }
437 
438 /**Function********************************************************************
439 
440  Synopsis []
441 
442  Description []
443 
444  SideEffects []
445 
446  SeeAlso []
447 
448 ******************************************************************************/
449 int CmdCommandUnalias( Abc_Frame_t * pAbc, int argc, char **argv )
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 }
489 
490 /**Function********************************************************************
491 
492  Synopsis []
493 
494  Description []
495 
496  SideEffects []
497 
498  SeeAlso []
499 
500 ******************************************************************************/
501 int CmdCommandHelp( Abc_Frame_t * pAbc, int argc, char **argv )
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 }
543 
544 /**Function********************************************************************
545 
546  Synopsis []
547 
548  Description []
549 
550  SideEffects []
551 
552  SeeAlso []
553 
554 ******************************************************************************/
555 int CmdCommandSource( Abc_Frame_t * pAbc, int argc, char **argv )
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 }
726 
727 /**Function********************************************************************
728 
729  Synopsis []
730 
731  Description []
732 
733  SideEffects []
734 
735  SeeAlso []
736 
737 ******************************************************************************/
738 int CmdCommandSetVariable( Abc_Frame_t * pAbc, int argc, char **argv )
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 }
826 
827 /**Function********************************************************************
828 
829  Synopsis []
830 
831  Description []
832 
833  SideEffects []
834 
835  SeeAlso []
836 
837 ******************************************************************************/
838 int CmdCommandUnsetVariable( Abc_Frame_t * pAbc, int argc, char **argv )
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 }
881 
882 /**Function********************************************************************
883 
884  Synopsis []
885 
886  Description []
887 
888  SideEffects []
889 
890  SeeAlso []
891 
892 ******************************************************************************/
893 int CmdCommandUndo( Abc_Frame_t * pAbc, int argc, char **argv )
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 }
915 
916 /**Function********************************************************************
917 
918  Synopsis []
919 
920  Description []
921 
922  SideEffects []
923 
924  SeeAlso []
925 
926 ******************************************************************************/
927 int CmdCommandRecall( Abc_Frame_t * pAbc, int argc, char **argv )
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 }
1030 
1031 
1032 /**Function********************************************************************
1033 
1034  Synopsis []
1035 
1036  Description []
1037 
1038  SideEffects []
1039 
1040  SeeAlso []
1041 
1042 ******************************************************************************/
1043 int CmdCommandEmpty( Abc_Frame_t * pAbc, int argc, char **argv )
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 }
1075 
1076 
1077 #if 0
1078 
1079 /**Function********************************************************************
1080 
1081  Synopsis [Donald's version.]
1082 
1083  Description []
1084 
1085  SideEffects []
1086 
1087  SeeAlso []
1088 
1089 ******************************************************************************/
1090 int CmdCommandUndo( Abc_Frame_t * pAbc, int argc, char **argv )
1091 {
1092  Abc_Ntk_t * pNtkTemp;
1093  int id, c;
1094 
1095  while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
1096  {
1097  switch ( c )
1098  {
1099  case 'h':
1100  goto usage;
1101  break;
1102  default:
1103  goto usage;
1104  }
1105  }
1106  if (globalUtilOptind <= argc) {
1107  pNtkTemp = pAbc->pNtk;
1108  pAbc->pNtk = pAbc->pNtkSaved;
1109  pAbc->pNtkSaved = pNtkTemp;
1110  }
1111  id = atoi(argv[globalUtilOptind]);
1112  pNtkTemp = Cmd_HistoryGetSnapshot(pAbc, id);
1113  if (!pNtkTemp)
1114  fprintf( pAbc->Err, "Snapshot %d does not exist\n", id);
1115  else
1116  pAbc->pNtk = Abc_NtkDup(pNtkTemp, Abc_NtkMan(pNtkTemp));
1117 
1118  return 0;
1119 usage:
1120  fprintf( pAbc->Err, "usage: undo\n" );
1121  fprintf( pAbc->Err, " swaps the current network and the backup network\n" );
1122  return 1;
1123 }
1124 
1125 #endif
1126 
1127 
1128 #if defined(WIN32) && !defined(__cplusplus)
1129 #include <direct.h>
1130 
1131 // these structures are defined in <io.h> but are for some reason invisible
1132 typedef unsigned long _fsize_t; // Could be 64 bits for Win32
1133 
1134 struct _finddata_t {
1135  unsigned attrib;
1136  time_t time_create; // -1 for FAT file systems
1137  time_t time_access; // -1 for FAT file systems
1138  time_t time_write;
1139  _fsize_t size;
1140  char name[260];
1141 };
1142 
1143 extern long _findfirst( char *filespec, struct _finddata_t *fileinfo );
1144 extern int _findnext( long handle, struct _finddata_t *fileinfo );
1145 extern int _findclose( long handle );
1146 
1147 //extern char * _getcwd( char * buffer, int maxlen );
1148 //extern int _chdir( const char *dirname );
1149 
1150 
1151 /**Function*************************************************************
1152 
1153  Synopsis [Command to print the contents of the current directory (Windows).]
1154 
1155  Description []
1156 
1157  SideEffects []
1158 
1159  SeeAlso []
1160 
1161 ***********************************************************************/
1162 int CmdCommandScanDir( Abc_Frame_t * pAbc, int argc, char **argv )
1163 {
1164  struct _finddata_t c_file;
1165  char * pDirStr = NULL;
1166  char* pDirCur = NULL;
1167  long hFile;
1168  char c;
1169 
1171  while ( (c = Extra_UtilGetopt(argc, argv, "D") ) != EOF )
1172  {
1173  switch (c)
1174  {
1175  case 'D':
1176  if ( globalUtilOptind >= argc )
1177  {
1178  fprintf( pAbc->Err, "Command line switch \"-D\" should be followed by a string.\n" );
1179  goto usage;
1180  }
1181  pDirStr = argv[globalUtilOptind];
1182  globalUtilOptind++;
1183  break;
1184  default:
1185  goto usage;
1186  }
1187  }
1188 
1189 
1190  if ( pDirStr )
1191  {
1192  if( (pDirCur = _getcwd( NULL, 0 )) == NULL )
1193  {
1194  printf( "Cannot read current directory\n" );
1195  return 0;
1196  }
1197  if ( _chdir(pDirStr) )
1198  {
1199  printf( "Cannot change to directory: %s\n", pDirStr );
1200  return 0;
1201  }
1202  }
1203 
1204  if( (hFile = _findfirst( "*.txt", &c_file )) == -1L )
1205  {
1206  if ( pDirStr )
1207  printf( "No .txt files in the current directory.\n" );
1208  else
1209  printf( "No .txt files in directory: %s\n", pDirStr );
1210  }
1211  else
1212  {
1213  do
1214  {
1215  FILE * pFile = fopen( c_file.name, "rb" );
1216  char * pStr1 = "Property UNDECIDED. Time =";
1217  char * pStr2 = "Property proved. Time =";
1218  char * pStr3 = "Time =";
1219  char * pBuffer, * pPlace, * pThis, * pThat;
1220  char FileName[100];
1221  float Time = 0;
1222  // get the file name
1223  sprintf( FileName, "%s", c_file.name );
1224  pThis = strrchr( FileName, '_' );
1225  pThat = strchr( FileName, '.' );
1226  if ( pThis == NULL || pThat == NULL || pThis >= pThat )
1227  {
1228 // printf( "Something is wrong with the file name %s\n", c_file.name );
1229  continue;
1230  }
1231  *pThat = 0;
1232  pThis++;
1233  // get the time
1234  if ( pFile == NULL )
1235  {
1236  printf( "Cannot open file %s\n", c_file.name );
1237  continue;
1238  }
1239  fclose( pFile );
1240  pBuffer = Extra_FileReadContents( c_file.name );
1241  pPlace = strstr( pBuffer, pStr1 );
1242  if ( pPlace == NULL )
1243  {
1244  pPlace = strstr( pBuffer, pStr2 );
1245  if ( pPlace == NULL )
1246  {
1247  pPlace = strstr( pBuffer, pStr3 );
1248  if ( pPlace == NULL )
1249  {
1250 // printf( "Cannot find substrings in file %s\n", c_file.name );
1251  ABC_FREE( pBuffer );
1252  continue;
1253  }
1254  else
1255  pPlace += strlen( pStr3 );
1256  }
1257  else
1258  pPlace += strlen( pStr2 );
1259  }
1260  else
1261  pPlace += strlen( pStr1 );
1262  sscanf( pPlace, "%f", &Time );
1263  printf( "%s %.2f\n", pThis, Time );
1264  ABC_FREE( pBuffer );
1265  }
1266  while( _findnext( hFile, &c_file ) == 0 );
1267  _findclose( hFile );
1268  }
1269  if ( pDirStr )
1270  {
1271  if ( _chdir(pDirCur) )
1272  {
1273  ABC_FREE( pDirCur );
1274  printf( "Cannot change to directory: %s\n", pDirCur );
1275  return 0;
1276  }
1277  ABC_FREE( pDirCur );
1278  }
1279  return 0;
1280 
1281 usage:
1282  fprintf( pAbc->Err, "usage: scandir [-D string]\n" );
1283  fprintf( pAbc->Err, " performs custom scanning of the files in the given directory\n" );
1284  fprintf( pAbc->Err, "\t-D str : the directory to read files from [default = current]\n" );
1285  return 1;
1286 }
1287 
1288 
1289 
1290 /**Function*************************************************************
1291 
1292  Synopsis []
1293 
1294  Description []
1295 
1296  SideEffects []
1297 
1298  SeeAlso []
1299 
1300 ***********************************************************************/
1301 int CmfFindNumber( char * pName )
1302 {
1303  char * pTemp;
1304  for ( pTemp = pName; *pTemp; pTemp++ )
1305  if ( *pTemp == '.' )
1306  break;
1307  if ( *pTemp == 0 )
1308  return -1;
1309  for ( --pTemp; pTemp > pName; pTemp-- )
1310  if ( *pTemp < '0' || *pTemp > '9' )
1311  {
1312  pTemp++;
1313  break;
1314  }
1315  if ( *pTemp == '.' )
1316  return -2;
1317  return atoi( pTemp );
1318 }
1319 
1320 /**Function*************************************************************
1321 
1322  Synopsis []
1323 
1324  Description []
1325 
1326  SideEffects []
1327 
1328  SeeAlso []
1329 
1330 ***********************************************************************/
1331 void CnfDupFileUnzip( char * pOldName )
1332 {
1333  extern char * Io_MvLoadFileBz2( char * pFileName, int * pnFileSize );
1334  char pNewName[1000];
1335  FILE * pFile;
1336  int nFileSize;
1337  char * pBuffer = Io_MvLoadFileBz2( pOldName, &nFileSize );
1338  assert( strlen(pOldName) < 1000 );
1339  sprintf( pNewName, "%s.v", pOldName );
1340  pFile = fopen( pNewName, "wb" );
1341  fwrite( pBuffer, nFileSize, 1, pFile );
1342  fclose( pFile );
1343  ABC_FREE( pBuffer );
1344 }
1345 
1346 /**Function*************************************************************
1347 
1348  Synopsis [Command to print the contents of the current directory (Windows).]
1349 
1350  Description []
1351 
1352  SideEffects []
1353 
1354  SeeAlso []
1355 
1356 ***********************************************************************/
1357 int CmdCommandRenameFiles( Abc_Frame_t * pAbc, int argc, char **argv )
1358 {
1359  struct _finddata_t c_file;
1360  long hFile;
1361  char pNewName[1000];
1362  char * pDirStr = NULL;
1363  char * pDirCur = NULL;
1364  char * pNameNew = NULL;
1365  char * pNameExt = NULL;
1366  int c, i, nBase = 0;
1368  while ( (c = Extra_UtilGetopt(argc, argv, "DENB") ) != EOF )
1369  {
1370  switch (c)
1371  {
1372  case 'D':
1373  if ( globalUtilOptind >= argc )
1374  {
1375  fprintf( pAbc->Err, "Command line switch \"-D\" should be followed by a string.\n" );
1376  goto usage;
1377  }
1378  pDirStr = argv[globalUtilOptind];
1379  globalUtilOptind++;
1380  break;
1381  case 'E':
1382  if ( globalUtilOptind >= argc )
1383  {
1384  fprintf( pAbc->Err, "Command line switch \"-E\" should be followed by a string.\n" );
1385  goto usage;
1386  }
1387  pNameExt = argv[globalUtilOptind];
1388  globalUtilOptind++;
1389  break;
1390  case 'N':
1391  if ( globalUtilOptind >= argc )
1392  {
1393  fprintf( pAbc->Err, "Command line switch \"-N\" should be followed by a string.\n" );
1394  goto usage;
1395  }
1396  pNameNew = argv[globalUtilOptind];
1397  globalUtilOptind++;
1398  break;
1399  case 'B':
1400  if ( globalUtilOptind >= argc )
1401  {
1402  fprintf( pAbc->Err, "Command line switch \"-B\" should be followed by a positive integer.\n" );
1403  goto usage;
1404  }
1405  nBase = atoi(argv[globalUtilOptind]);
1406  globalUtilOptind++;
1407  if ( nBase < 0 )
1408  goto usage;
1409  break;
1410  default:
1411  goto usage;
1412  }
1413  }
1414 
1415  if ( pNameExt == NULL )
1416  {
1417  printf( "Extension of the files should be given on the command line.\n" );
1418  return 0;
1419  }
1420 
1421  if ( pDirStr )
1422  {
1423  if( (pDirCur = _getcwd( NULL, 0 )) == NULL )
1424  {
1425  printf( "Cannot read current directory\n" );
1426  return 0;
1427  }
1428  if ( _chdir(pDirStr) )
1429  {
1430  printf( "Cannot change to directory: %s\n", pDirStr );
1431  return 0;
1432  }
1433  }
1434 
1435  sprintf( pNewName, "*.%s", pNameExt );
1436  if( (hFile = _findfirst( pNewName, &c_file )) == -1L )
1437  {
1438  if ( pDirStr )
1439  printf( "No .aig files in the current directory.\n" );
1440  else
1441  printf( "No .aig files in directory: %s\n", pDirStr );
1442  }
1443  else
1444  {
1445  char * pName, * pOldName;
1446  int nDigits, * pOrder;
1447  Vec_Ptr_t * vNames = Vec_PtrAlloc( 1000 );
1448  Vec_Int_t * vNums = Vec_IntAlloc( 1000 );
1449  // collect names
1450  do {
1451  Vec_PtrPush( vNames, Abc_UtilStrsav(c_file.name) );
1452  } while( _findnext( hFile, &c_file ) == 0 );
1453  _findclose( hFile );
1454  // sort files by number
1455  Vec_PtrForEachEntry( char *, vNames, pName, i )
1456  {
1457  Vec_IntPush( vNums, CmfFindNumber(pName) );
1458  if ( Vec_IntEntryLast(vNums) < 0 )
1459  {
1460  printf( "Directory \"%s\" contains file (%s) with extension %s without number\n", pDirStr, pName, pNameExt );
1461  Vec_PtrFreeFree( vNames );
1462  Vec_IntFree( vNums );
1463  return 0;
1464  }
1465  }
1466  // sort by number
1467  pOrder = Abc_QuickSortCost( Vec_IntArray(vNums), Vec_IntSize(vNums), 0 );
1468  // rename files in that order
1469 // nDigits = Abc_Base10Log( nBase + Vec_IntSize(vNums) );
1470  nDigits = Abc_Base10Log( nBase + Vec_IntEntry(vNums, pOrder[Vec_IntSize(vNums)-1]) + 1 );
1471  for ( i = 0; i < Vec_IntSize(vNums); i++ )
1472  {
1473  pOldName = (char *)Vec_PtrEntry( vNames, pOrder[i] );
1474  sprintf( pNewName, "%s%0*d.%s", pNameNew ? pNameNew : "", nDigits, nBase+Vec_IntEntry(vNums, pOrder[i]), pNameExt );
1475  rename( pOldName, pNewName );
1476  printf( "%s -> %s\n", pOldName, pNewName );
1477 // CnfDupFileUnzip( pOldName );
1478  }
1479  // cleanup
1480  Vec_PtrFreeFree( vNames );
1481  Vec_IntFree( vNums );
1482  ABC_FREE( pOrder );
1483  }
1484  if ( pDirStr )
1485  {
1486  if ( _chdir(pDirCur) )
1487  {
1488  ABC_FREE( pDirCur );
1489  printf( "Cannot change to directory: %s\n", pDirCur );
1490  return 0;
1491  }
1492  ABC_FREE( pDirCur );
1493  }
1494  return 0;
1495 
1496 usage:
1497  fprintf( pAbc->Err, "usage: renamefiles [-DEN str] [-B num]\n" );
1498  fprintf( pAbc->Err, " performs renaming of files in the given directory\n" );
1499  fprintf( pAbc->Err, "\t-D str : the directory to read files from [default = current]\n" );
1500  fprintf( pAbc->Err, "\t-E str : the extension of files to look for [default = none]\n" );
1501  fprintf( pAbc->Err, "\t-N str : the root of the resulting files [default = none]\n" );
1502  fprintf( pAbc->Err, "\t-B num : the base number for all files [default = %d]\n", nBase );
1503  return 1;
1504 }
1505 
1506 
1507 /**Function*************************************************************
1508 
1509  Synopsis [Command to print the contents of the current directory (Windows).]
1510 
1511  Description []
1512 
1513  SideEffects []
1514 
1515  SeeAlso []
1516 
1517 ***********************************************************************/
1518 int CmdCommandLs( Abc_Frame_t * pAbc, int argc, char **argv )
1519 {
1520  struct _finddata_t c_file;
1521  long hFile;
1522  int fLong = 0;
1523  int fOnlyBLIF = 0;
1524  char Buffer[25];
1525  int Counter = 0;
1526  int fPrintedNewLine;
1527  char c;
1528 
1530  while ( (c = Extra_UtilGetopt(argc, argv, "lb") ) != EOF )
1531  {
1532  switch (c)
1533  {
1534  case 'l':
1535  fLong = 1;
1536  break;
1537  case 'b':
1538  fOnlyBLIF = 1;
1539  break;
1540  default:
1541  goto usage;
1542  }
1543  }
1544 
1545  // find first .mv file in current directory
1546  if( (hFile = _findfirst( ((fOnlyBLIF)? "*.mv": "*.*"), &c_file )) == -1L )
1547  {
1548  if ( fOnlyBLIF )
1549  fprintf( pAbc->Out, "No *.mv files in the current directory.\n" );
1550  else
1551  fprintf( pAbc->Out, "No files in the current directory.\n" );
1552  }
1553  else
1554  {
1555  if ( fLong )
1556  {
1557  fprintf( pAbc->Out, " File Date Size | File Date Size \n" );
1558  fprintf( pAbc->Out, " ----------------------------------------------------------------------------- \n" );
1559  do
1560  {
1561  strcpy( Buffer, ctime( &(c_file.time_write) ) );
1562  Buffer[16] = 0;
1563  fprintf( pAbc->Out, " %-17s %.24s%7ld", c_file.name, Buffer+4, c_file.size );
1564  if ( ++Counter % 2 == 0 )
1565  {
1566  fprintf( pAbc->Out, "\n" );
1567  fPrintedNewLine = 1;
1568  }
1569  else
1570  {
1571  fprintf( pAbc->Out, " |" );
1572  fPrintedNewLine = 0;
1573  }
1574  }
1575  while( _findnext( hFile, &c_file ) == 0 );
1576  }
1577  else
1578  {
1579  do
1580  {
1581  fprintf( pAbc->Out, " %-18s", c_file.name );
1582  if ( ++Counter % 4 == 0 )
1583  {
1584  fprintf( pAbc->Out, "\n" );
1585  fPrintedNewLine = 1;
1586  }
1587  else
1588  {
1589  fprintf( pAbc->Out, " " );
1590  fPrintedNewLine = 0;
1591  }
1592  }
1593  while( _findnext( hFile, &c_file ) == 0 );
1594  }
1595  if ( !fPrintedNewLine )
1596  fprintf( pAbc->Out, "\n" );
1597  _findclose( hFile );
1598  }
1599  return 0;
1600 
1601 usage:
1602  fprintf( pAbc->Err, "usage: ls [-l] [-b]\n" );
1603  fprintf( pAbc->Err, " print the file names in the current directory\n" );
1604  fprintf( pAbc->Err, " -l : print in the long format [default = short]\n" );
1605  fprintf( pAbc->Err, " -b : print only .mv files [default = all]\n" );
1606  return 1;
1607 }
1608 
1609 
1610 /**Function*************************************************************
1611 
1612  Synopsis [Generates the script for running ABC.]
1613 
1614  Description []
1615 
1616  SideEffects []
1617 
1618  SeeAlso []
1619 
1620 ***********************************************************************/
1621 int CmdCommandScrGen( Abc_Frame_t * pAbc, int argc, char **argv )
1622 {
1623  struct _finddata_t c_file;
1624  long hFile;
1625  FILE * pFile = NULL;
1626  char * pFileStr = "test.s";
1627  char * pDirStr = NULL;
1628  char * pComStr = "ps";
1629  char * pWriteStr = NULL;
1630  char Buffer[1000], Line[2000];
1631  int nFileNameMax, nFileNameCur;
1632  int Counter = 0;
1633  int fUseCurrent;
1634  char c;
1635 
1636  fUseCurrent = 0;
1638  while ( (c = Extra_UtilGetopt(argc, argv, "FDCWch") ) != EOF )
1639  {
1640  switch (c)
1641  {
1642  case 'F':
1643  if ( globalUtilOptind >= argc )
1644  {
1645  fprintf( pAbc->Err, "Command line switch \"-F\" should be followed by a string.\n" );
1646  goto usage;
1647  }
1648  pFileStr = argv[globalUtilOptind];
1649  globalUtilOptind++;
1650  break;
1651  case 'D':
1652  if ( globalUtilOptind >= argc )
1653  {
1654  fprintf( pAbc->Err, "Command line switch \"-D\" should be followed by a string.\n" );
1655  goto usage;
1656  }
1657  pDirStr = argv[globalUtilOptind];
1658  globalUtilOptind++;
1659  break;
1660  case 'C':
1661  if ( globalUtilOptind >= argc )
1662  {
1663  fprintf( pAbc->Err, "Command line switch \"-C\" should be followed by a string.\n" );
1664  goto usage;
1665  }
1666  pComStr = argv[globalUtilOptind];
1667  globalUtilOptind++;
1668  break;
1669  case 'W':
1670  if ( globalUtilOptind >= argc )
1671  {
1672  fprintf( pAbc->Err, "Command line switch \"-W\" should be followed by a string.\n" );
1673  goto usage;
1674  }
1675  pWriteStr = argv[globalUtilOptind];
1676  globalUtilOptind++;
1677  break;
1678  case 'c':
1679  fUseCurrent ^= 1;
1680  break;
1681  default:
1682  goto usage;
1683  }
1684  }
1685 
1686 // printf( "File = %s.\n", pFileStr );
1687 // printf( "Dir = %s.\n", pDirStr );
1688 // printf( "Com = %s.\n", pComStr );
1689  if ( pDirStr == NULL )
1690  fUseCurrent = 1;
1691 
1692  if ( _getcwd( Buffer, 1000 ) == NULL )
1693  {
1694  printf( "Cannot get the current directory.\n" );
1695  return 0;
1696  }
1697  if ( fUseCurrent )
1698  pFile = fopen( pFileStr, "w" );
1699  if ( pDirStr )
1700  {
1701  if ( _chdir(pDirStr) )
1702  {
1703  printf( "Cannot change to directory: %s\n", pDirStr );
1704  return 0;
1705  }
1706  }
1707  if ( !fUseCurrent )
1708  pFile = fopen( pFileStr, "w" );
1709  if ( pFile == NULL )
1710  {
1711  printf( "Cannot open file %s.\n", pFileStr );
1712  if ( pDirStr && _chdir(Buffer) )
1713  {
1714  printf( "Cannot change to the current directory: %s\n", Buffer );
1715  return 0;
1716  }
1717  return 0;
1718  }
1719 
1720  // find the first file in the directory
1721  if( (hFile = _findfirst( "*.*", &c_file )) == -1L )
1722  {
1723  if ( pDirStr )
1724  printf( "No files in the current directory.\n" );
1725  else
1726  printf( "No files in directory: %s\n", pDirStr );
1727  if ( pDirStr && _chdir(Buffer) )
1728  {
1729  printf( "Cannot change to the current directory: %s\n", Buffer );
1730  return 0;
1731  }
1732  }
1733 
1734  // get the longest file name
1735  {
1736  nFileNameMax = 0;
1737  do
1738  {
1739  // skip script and txt files
1740  nFileNameCur = strlen(c_file.name);
1741  if ( c_file.name[nFileNameCur-1] == '.' )
1742  continue;
1743  if ( nFileNameCur > 2 &&
1744  c_file.name[nFileNameCur-1] == 's' &&
1745  c_file.name[nFileNameCur-2] == '.' )
1746  continue;
1747  if ( nFileNameCur > 4 &&
1748  c_file.name[nFileNameCur-1] == 't' &&
1749  c_file.name[nFileNameCur-2] == 'x' &&
1750  c_file.name[nFileNameCur-3] == 't' &&
1751  c_file.name[nFileNameCur-4] == '.' )
1752  continue;
1753  if ( nFileNameMax < nFileNameCur )
1754  nFileNameMax = nFileNameCur;
1755  }
1756  while( _findnext( hFile, &c_file ) == 0 );
1757  _findclose( hFile );
1758  }
1759 
1760  // print the script file
1761  {
1762  if( (hFile = _findfirst( "*.*", &c_file )) == -1L )
1763  {
1764  if ( pDirStr )
1765  printf( "No files in the current directory.\n" );
1766  else
1767  printf( "No files in directory: %s\n", pDirStr );
1768  }
1769  fprintf( pFile, "# Script file produced by ABC on %s\n", Extra_TimeStamp() );
1770  fprintf( pFile, "# Command line was: scrgen -F %s -D %s -C \"%s\"%s%s\n",
1771  pFileStr, pDirStr, pComStr, pWriteStr?" -W ":"", pWriteStr?pWriteStr:"" );
1772  do
1773  {
1774  // skip script and txt files
1775  nFileNameCur = strlen(c_file.name);
1776  if ( c_file.name[nFileNameCur-1] == '.' )
1777  continue;
1778  if ( nFileNameCur > 2 &&
1779  c_file.name[nFileNameCur-1] == 's' &&
1780  c_file.name[nFileNameCur-2] == '.' )
1781  continue;
1782  if ( nFileNameCur > 4 &&
1783  c_file.name[nFileNameCur-1] == 't' &&
1784  c_file.name[nFileNameCur-2] == 'x' &&
1785  c_file.name[nFileNameCur-3] == 't' &&
1786  c_file.name[nFileNameCur-4] == '.' )
1787  continue;
1788  sprintf( Line, "r %s%s%-*s ; %s", pDirStr?pDirStr:"", pDirStr?"/":"", nFileNameMax, c_file.name, pComStr );
1789  for ( c = (int)strlen(Line)-1; c >= 0; c-- )
1790  if ( Line[c] == '\\' )
1791  Line[c] = '/';
1792  fprintf( pFile, "%s", Line );
1793  if ( pWriteStr )
1794  {
1795  sprintf( Line, " ; w %s/%-*s", pWriteStr, nFileNameMax, c_file.name );
1796  for ( c = (int)strlen(Line)-1; c >= 0; c-- )
1797  if ( Line[c] == '\\' )
1798  Line[c] = '/';
1799  fprintf( pFile, "%s", Line );
1800  }
1801  fprintf( pFile, "\n", Line );
1802  }
1803  while( _findnext( hFile, &c_file ) == 0 );
1804  _findclose( hFile );
1805  }
1806  fclose( pFile );
1807  if ( pDirStr && _chdir(Buffer) )
1808  {
1809  printf( "Cannot change to the current directory: %s\n", Buffer );
1810  return 0;
1811  }
1812 
1813  // report
1814  if ( fUseCurrent )
1815  printf( "Script file \"%s\" was saved in the current directory.\n", pFileStr );
1816  else
1817  printf( "Script file \"%s\" was saved in directory: %s\n", pFileStr, pDirStr );
1818  return 0;
1819 
1820 usage:
1821  fprintf( pAbc->Err, "usage: scrgen -F <str> -D <str> -C <str> -W <str> -ch\n" );
1822  fprintf( pAbc->Err, "\t generates script for running ABC\n" );
1823  fprintf( pAbc->Err, "\t-F str : the name of the script file [default = \"test.s\"]\n" );
1824  fprintf( pAbc->Err, "\t-D str : the directory to read files from [default = current]\n" );
1825  fprintf( pAbc->Err, "\t-C str : the sequence of commands to run [default = \"ps\"]\n" );
1826  fprintf( pAbc->Err, "\t-W str : the directory to write the resulting files [default = no writing]\n" );
1827  fprintf( pAbc->Err, "\t-c : toggle placing file in current/target dir [default = %s]\n", fUseCurrent? "current": "target" );
1828  fprintf( pAbc->Err, "\t-h : print the command usage\n\n");
1829  fprintf( pAbc->Err, "\tExample : scrgen -F test1.s -D a/in -C \"ps; st; ps\" -W a/out\n" );
1830  return 1;
1831 }
1832 #endif
1833 
1834 
1835 #ifdef WIN32
1836 #define unlink _unlink
1837 #endif
1838 
1839 /**Function********************************************************************
1840 
1841  Synopsis [Calls SIS internally.]
1842 
1843  Description []
1844 
1845  SideEffects []
1846 
1847  SeeAlso []
1848 
1849 ******************************************************************************/
1850 int CmdCommandSis( Abc_Frame_t * pAbc, int argc, char **argv )
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 }
1979 
1980 
1981 /**Function********************************************************************
1982 
1983  Synopsis [Calls SIS internally.]
1984 
1985  Description []
1986 
1987  SideEffects []
1988 
1989  SeeAlso []
1990 
1991 ******************************************************************************/
1992 int CmdCommandMvsis( Abc_Frame_t * pAbc, int argc, char **argv )
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 }
2121 
2122 
2123 /**Function*************************************************************
2124 
2125  Synopsis [Computes dimentions of the graph.]
2126 
2127  Description []
2128 
2129  SideEffects []
2130 
2131  SeeAlso []
2132 
2133 ***********************************************************************/
2134 void Gia_ManGnuplotShow( char * pPlotFileName )
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 }
2189 
2190 /**Function********************************************************************
2191 
2192  Synopsis [Calls Capo internally.]
2193 
2194  Description []
2195 
2196  SideEffects []
2197 
2198  SeeAlso []
2199 
2200 ******************************************************************************/
2201 int CmdCommandCapo( Abc_Frame_t * pAbc, int argc, char **argv )
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 }
2372 
2373 /**Function*************************************************************
2374 
2375  Synopsis []
2376 
2377  Description []
2378 
2379  SideEffects []
2380 
2381  SeeAlso []
2382 
2383 ***********************************************************************/
2384 int CmdCommandStarter( Abc_Frame_t * pAbc, int argc, char ** argv )
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 }
2457 
2458 /**Function********************************************************************
2459 
2460  Synopsis [Print the version string.]
2461 
2462  Description []
2463 
2464  SideEffects []
2465 
2466  SeeAlso []
2467 
2468 ******************************************************************************/
2469 int CmdCommandVersion( Abc_Frame_t * pAbc, int argc, char **argv )
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 }
2494 
2495 
2496 ////////////////////////////////////////////////////////////////////////
2497 /// END OF FILE ///
2498 ////////////////////////////////////////////////////////////////////////
2499 
2500 
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
void st__free_table(st__table *table)
Definition: st.c:81
void Cmd_Init(Abc_Frame_t *pAbc)
FUNCTION DEFINITIONS ///.
Definition: cmd.c:79
ABC_DLL void Abc_FrameReplaceCurrentNetwork(Abc_Frame_t *p, Abc_Ntk_t *pNet)
Definition: mainFrame.c:493
static ABC_NAMESPACE_IMPL_START int CmdCommandTime(Abc_Frame_t *pAbc, int argc, char **argv)
DECLARATIONS ///.
Definition: cmd.c:165
int * Abc_QuickSortCost(int *pCosts, int nSize, int fDecrease)
Definition: utilSort.c:719
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
typedefABC_NAMESPACE_HEADER_START struct MvCommand Abc_Command
INCLUDES ///.
Definition: cmd.h:39
FILE * Io_FileOpen(const char *FileName, const char *PathVar, const char *Mode, int fVerbose)
Definition: ioUtil.c:819
static int CmdCommandSource(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:555
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int CmdCommandRecall(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:927
ABC_DLL void Abc_FrameDeleteAllNetworks(Abc_Frame_t *p)
Definition: mainFrame.c:551
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition: vecPtr.h:57
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int Cmd_CommandExecute(void *pAbc, char *pCommandLine)
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 * CmdHistorySubstitution(Abc_Frame_t *pAbc, char *line, int *changed)
Definition: cmdUtils.c:390
ABC_DLL void Abc_FrameSetCurrentNetwork(Abc_Frame_t *p, Abc_Ntk_t *pNet)
Definition: mainFrame.c:396
void Gia_ManGnuplotShow(char *pPlotFileName)
Definition: cmd.c:2134
Definition: cmdInt.h:51
char * Extra_FileGetSimilarName(char *pFileNameWrong, char *pS1, char *pS2, char *pS3, char *pS4, char *pS5)
Definition: extraUtilFile.c:71
void CmdCommandAliasFree(Abc_Alias *pAlias)
Definition: cmdAlias.c:113
static void Vec_PtrFreeFree(Vec_Ptr_t *p)
Definition: vecPtr.h:569
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:419
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
static int CmdCommandWhich(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:331
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
static int CmdCommandSetVariable(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:738
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 Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
int Cmd_CommandAbcLoadPlugIn(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmdPlugin.c:642
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
ABC_NAMESPACE_IMPL_START void Cmd_RunStarter(char *pFileName, char *pBinary, char *pCommand, int nCores)
DECLARATIONS ///.
Definition: cmdStarter.c:47
int strcmp()
void Cmd_HistoryAddCommand(Abc_Frame_t *pAbc, const char *command)
DECLARATIONS ///.
Definition: cmdHist.c:48
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
VOID_HACK clearerr()
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
ABC_DLL void Extra_UtilGetoptReset()
Definition: extraUtilUtil.c:80
ABC_DLL int Abc_NtkMapToSop(Abc_Ntk_t *pNtk)
Definition: abcFunc.c:1073
#define ABC_MAX_STR
Definition: mainInt.h:50
static int CmdCommandHelp(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:501
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
char * strstr()
ABC_DLL int Abc_NtkToSop(Abc_Ntk_t *pNtk, int fDirect)
Definition: abcFunc.c:1124
char * strchr()
char * name
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Abc_Base10Log(unsigned n)
Definition: abc_global.h:252
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
void * Abc_FrameGetGlobalFrame()
Definition: mainFrame.c:593
int globalUtilOptind
Definition: extraUtilUtil.c:45
static int size
Definition: cuddSign.c:86
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int CmdCommandCapo(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:2201
char * sprintf()
void CmdPrintTable(st__table *tTable, int fAliases)
Definition: cmdUtils.c:722
static int Counter
void CmdCommandPrint(Abc_Frame_t *pAbc, int fPrintAll, int fDetails)
Definition: cmdUtils.c:554
void Cmd_End(Abc_Frame_t *pAbc)
Definition: cmd.c:127
static int CmdCommandQuit(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:288
ABC_DLL char * Abc_UtilsGetVersion(Abc_Frame_t *pAbc)
FUNCTION DEFINITIONS ///.
Definition: mainUtils.c:52
static int CmdCommandMvsis(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:1992
static void Abc_Print(int level, const char *format,...)
Definition: abc_global.h:313
static int CmdCommandEmpty(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:1043
int system()
char * strcpy()
void Cmd_HistoryRead(Abc_Frame_t *p)
Definition: cmdHist.c:100
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
ABC_DLL Abc_Ntk_t * Abc_FrameReadNtk(Abc_Frame_t *p)
Definition: mainFrame.c:282
void CmdCommandAliasPrint(Abc_Frame_t *pAbc, Abc_Alias *pAlias)
Definition: cmdAlias.c:72
char * pSpec
Definition: abc.h:159
static int Vec_IntEntryLast(Vec_Int_t *p)
Definition: bblif.c:319
FILE * CmdFileOpen(Abc_Frame_t *pAbc, char *sFileName, char *sMode, char **pFileNameReal, int silent)
Definition: cmdUtils.c:408
int st__lookup(st__table *table, const char *key, char **value)
Definition: st.c:114
static int CmdCommandUnalias(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:449
static int Abc_NtkIsMappedLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:267
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
void CmdCommandFree(Abc_Command *pCommand)
Definition: cmdUtils.c:535
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 Abc_NtkStep(Abc_Ntk_t *pNtk)
Definition: abc.h:274
#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
char * Extra_TimeStamp()
static int CmdCommandSis(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:1850
char * strcat()
static int CmdCommandUnsetVariable(Abc_Frame_t *pAbc, int argc, char **argv)
Definition: cmd.c:838
int value
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
#define st__foreach_item(table, gen, key, value)
Definition: st.h:107
ABC_DLL FILE * Abc_FrameReadErr(Abc_Frame_t *p)
Definition: mainFrame.c:330
#define assert(ex)
Definition: util_old.h:213
int strlen()
ABC_DLL FILE * Abc_FrameReadOut(Abc_Frame_t *p)
Definition: mainFrame.c:314
char * Io_MvLoadFileBz2(char *pFileName, int *pnFileSize)
Definition: ioReadBlifMv.c:551
ABC_NAMESPACE_IMPL_START int Util_SignalSystem(const char *cmd)
DECLARATIONS ///.
Definition: utilSignal.c:46
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
void Cmd_HistoryWrite(Abc_Frame_t *p, int Limit)
Definition: cmdHist.c:131
ABC_NAMESPACE_IMPL_START void CmdCommandAliasAdd(Abc_Frame_t *pAbc, char *sName, int argc, char **argv)
DECLARATIONS ///.
Definition: cmdAlias.c:46
char * strrchr()
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
ABC_DLL void Abc_FrameRestart(Abc_Frame_t *p)
Definition: mainFrame.c:232
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
char * Extra_FileReadContents(char *pFileName)
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