00001
00021 #ifdef WIN32
00022 #include <process.h>
00023 #endif
00024
00025 #include "mainInt.h"
00026 #include "cmdInt.h"
00027 #include "abc.h"
00028
00032
00033 static int CmdCommandTime ( Abc_Frame_t * pAbc, int argc, char ** argv );
00034 static int CmdCommandEcho ( Abc_Frame_t * pAbc, int argc, char ** argv );
00035 static int CmdCommandQuit ( Abc_Frame_t * pAbc, int argc, char ** argv );
00036 static int CmdCommandWhich ( Abc_Frame_t * pAbc, int argc, char ** argv );
00037 static int CmdCommandHistory ( Abc_Frame_t * pAbc, int argc, char ** argv );
00038 static int CmdCommandAlias ( Abc_Frame_t * pAbc, int argc, char ** argv );
00039 static int CmdCommandUnalias ( Abc_Frame_t * pAbc, int argc, char ** argv );
00040 static int CmdCommandHelp ( Abc_Frame_t * pAbc, int argc, char ** argv );
00041 static int CmdCommandSource ( Abc_Frame_t * pAbc, int argc, char ** argv );
00042 static int CmdCommandSetVariable ( Abc_Frame_t * pAbc, int argc, char ** argv );
00043 static int CmdCommandUnsetVariable ( Abc_Frame_t * pAbc, int argc, char ** argv );
00044 static int CmdCommandUndo ( Abc_Frame_t * pAbc, int argc, char ** argv );
00045 static int CmdCommandRecall ( Abc_Frame_t * pAbc, int argc, char ** argv );
00046 static int CmdCommandEmpty ( Abc_Frame_t * pAbc, int argc, char ** argv );
00047 #ifdef WIN32
00048 static int CmdCommandLs ( Abc_Frame_t * pAbc, int argc, char ** argv );
00049 #endif
00050 static int CmdCommandSis ( Abc_Frame_t * pAbc, int argc, char ** argv );
00051 static int CmdCommandMvsis ( Abc_Frame_t * pAbc, int argc, char ** argv );
00052 static int CmdCommandCapo ( Abc_Frame_t * pAbc, int argc, char ** argv );
00053
00057
00067 void Cmd_Init( Abc_Frame_t * pAbc )
00068 {
00069 pAbc->tCommands = st_init_table(strcmp, st_strhash);
00070 pAbc->tAliases = st_init_table(strcmp, st_strhash);
00071 pAbc->tFlags = st_init_table(strcmp, st_strhash);
00072 pAbc->aHistory = Vec_PtrAlloc( 100 );
00073
00074 Cmd_CommandAdd( pAbc, "Basic", "time", CmdCommandTime, 0);
00075 Cmd_CommandAdd( pAbc, "Basic", "echo", CmdCommandEcho, 0);
00076 Cmd_CommandAdd( pAbc, "Basic", "quit", CmdCommandQuit, 0);
00077 Cmd_CommandAdd( pAbc, "Basic", "history", CmdCommandHistory, 0);
00078 Cmd_CommandAdd( pAbc, "Basic", "alias", CmdCommandAlias, 0);
00079 Cmd_CommandAdd( pAbc, "Basic", "unalias", CmdCommandUnalias, 0);
00080 Cmd_CommandAdd( pAbc, "Basic", "help", CmdCommandHelp, 0);
00081 Cmd_CommandAdd( pAbc, "Basic", "source", CmdCommandSource, 0);
00082 Cmd_CommandAdd( pAbc, "Basic", "set", CmdCommandSetVariable, 0);
00083 Cmd_CommandAdd( pAbc, "Basic", "unset", CmdCommandUnsetVariable, 0);
00084 Cmd_CommandAdd( pAbc, "Basic", "undo", CmdCommandUndo, 0);
00085 Cmd_CommandAdd( pAbc, "Basic", "recall", CmdCommandRecall, 0);
00086 Cmd_CommandAdd( pAbc, "Basic", "empty", CmdCommandEmpty, 0);
00087 #ifdef WIN32
00088 Cmd_CommandAdd( pAbc, "Basic", "ls", CmdCommandLs, 0 );
00089 #endif
00090
00091 Cmd_CommandAdd( pAbc, "Various", "sis", CmdCommandSis, 1);
00092 Cmd_CommandAdd( pAbc, "Various", "mvsis", CmdCommandMvsis, 1);
00093 Cmd_CommandAdd( pAbc, "Various", "capo", CmdCommandCapo, 0);
00094 }
00095
00107 void Cmd_End( Abc_Frame_t * pAbc )
00108 {
00109 st_generator * gen;
00110 char * pKey, * pValue;
00111 int i;
00112
00113
00114
00115
00116
00117 st_foreach_item( pAbc->tCommands, gen, (char **)&pKey, (char **)&pValue )
00118 CmdCommandFree( (Abc_Command *)pValue );
00119 st_free_table( pAbc->tCommands );
00120
00121 st_foreach_item( pAbc->tAliases, gen, (char **)&pKey, (char **)&pValue )
00122 CmdCommandAliasFree( (Abc_Alias *)pValue );
00123 st_free_table( pAbc->tAliases );
00124
00125 st_foreach_item( pAbc->tFlags, gen, (char **)&pKey, (char **)&pValue )
00126 free( pKey ), free( pValue );
00127 st_free_table( pAbc->tFlags );
00128
00129 for ( i = 0; i < pAbc->aHistory->nSize; i++ )
00130 free( pAbc->aHistory->pArray[i] );
00131 Vec_PtrFree( pAbc->aHistory );
00132 }
00133
00134
00135
00147 int CmdCommandTime( Abc_Frame_t * pAbc, int argc, char **argv )
00148 {
00149 int c;
00150
00151 Extra_UtilGetoptReset();
00152 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
00153 {
00154 switch ( c )
00155 {
00156 case 'h':
00157 goto usage;
00158 default:
00159 goto usage;
00160 }
00161 }
00162
00163 if ( argc != globalUtilOptind )
00164 {
00165 goto usage;
00166 }
00167
00168 pAbc->TimeTotal += pAbc->TimeCommand;
00169 fprintf( pAbc->Out, "elapse: %3.2f seconds, total: %3.2f seconds\n",
00170 (float)pAbc->TimeCommand / CLOCKS_PER_SEC, (float)pAbc->TimeTotal / CLOCKS_PER_SEC );
00171
00172
00173
00174
00175
00176
00177
00178
00179 pAbc->TimeCommand = 0;
00180 return 0;
00181
00182 usage:
00183 fprintf( pAbc->Err, "usage: time [-h]\n" );
00184 fprintf( pAbc->Err, " -h \t\tprint the command usage\n" );
00185 return 1;
00186 }
00187
00199 int CmdCommandEcho( Abc_Frame_t * pAbc, int argc, char **argv )
00200 {
00201 int i;
00202 int c;
00203 int n = 1;
00204
00205 Extra_UtilGetoptReset();
00206 while ( ( c = Extra_UtilGetopt( argc, argv, "hn" ) ) != EOF )
00207 {
00208 switch ( c )
00209 {
00210 case 'n':
00211 n = 0;
00212 break;
00213 case 'h':
00214 goto usage;
00215 break;
00216 default:
00217 goto usage;
00218 }
00219 }
00220
00221 for ( i = globalUtilOptind; i < argc; i++ )
00222 fprintf( pAbc->Out, "%s ", argv[i] );
00223 if ( n )
00224 fprintf( pAbc->Out, "\n" );
00225 else
00226 fflush ( pAbc->Out );
00227 return 0;
00228
00229 usage:
00230 fprintf( pAbc->Err, "usage: echo [-h] string \n" );
00231 fprintf( pAbc->Err, " -n \t\tsuppress newline at the end\n" );
00232 fprintf( pAbc->Err, " -h \t\tprint the command usage\n" );
00233 return ( 1 );
00234 }
00235
00247 int CmdCommandQuit( Abc_Frame_t * pAbc, int argc, char **argv )
00248 {
00249 int c;
00250
00251 Extra_UtilGetoptReset();
00252 while ( ( c = Extra_UtilGetopt( argc, argv, "hs" ) ) != EOF )
00253 {
00254 switch ( c )
00255 {
00256 case 'h':
00257 goto usage;
00258 break;
00259 case 's':
00260 return -2;
00261 break;
00262 default:
00263 goto usage;
00264 }
00265 }
00266
00267 if ( argc != globalUtilOptind )
00268 goto usage;
00269 return -1;
00270
00271 usage:
00272 fprintf( pAbc->Err, "usage: quit [-h] [-s]\n" );
00273 fprintf( pAbc->Err, " -h print the command usage\n" );
00274 fprintf( pAbc->Err,
00275 " -s frees all the memory before quitting\n" );
00276 return 1;
00277 }
00278
00290 int CmdCommandWhich( Abc_Frame_t * pAbc, int argc, char **argv )
00291 {
00292 return 0;
00293 }
00294
00306 int CmdCommandHistory( Abc_Frame_t * pAbc, int argc, char **argv )
00307 {
00308 int i, c, num, size;
00309
00310 num = 20;
00311 Extra_UtilGetoptReset();
00312 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
00313 {
00314 switch ( c )
00315 {
00316 case 'h':
00317 goto usage;
00318 default :
00319 goto usage;
00320 }
00321 }
00322 if ( argc > 2 )
00323 goto usage;
00324
00325
00326 if ( argc == globalUtilOptind + 1 )
00327 num = atoi(argv[globalUtilOptind]);
00328
00329 size = pAbc->aHistory->nSize;
00330 num = ( num < size ) ? num : size;
00331 for ( i = size - num; i < size; i++ )
00332 fprintf( pAbc->Out, "%s", pAbc->aHistory->pArray[i] );
00333 return 0;
00334
00335 usage:
00336 fprintf( pAbc->Err, "usage: history [-h] <num>\n" );
00337 fprintf( pAbc->Err, " prints the latest command entered on the command line\n" );
00338 fprintf( pAbc->Err, " -h : print the command usage\n" );
00339 fprintf( pAbc->Err, "num : print the last num commands\n" );
00340 return ( 1 );
00341 }
00342
00354 int CmdCommandAlias( Abc_Frame_t * pAbc, int argc, char **argv )
00355 {
00356 char *key, *value;
00357 int c;
00358
00359 Extra_UtilGetoptReset();
00360 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
00361 {
00362 switch ( c )
00363 {
00364 case 'h':
00365 goto usage;
00366 break;
00367 default:
00368 goto usage;
00369 }
00370 }
00371
00372
00373 if ( argc == 1 )
00374 {
00375 CmdPrintTable( pAbc->tAliases, 1 );
00376 return 0;
00377
00378 }
00379 else if ( argc == 2 )
00380 {
00381 if ( st_lookup( pAbc->tAliases, argv[1], &value ) )
00382 CmdCommandAliasPrint( pAbc, ( Abc_Alias * ) value );
00383 return 0;
00384 }
00385
00386
00387 key = argv[1];
00388 if ( st_delete( pAbc->tAliases, &key, &value ) )
00389 CmdCommandAliasFree( ( Abc_Alias * ) value );
00390 CmdCommandAliasAdd( pAbc, argv[1], argc - 2, argv + 2 );
00391 return 0;
00392
00393 usage:
00394 fprintf( pAbc->Err, "usage: alias [-h] [command [string]]\n" );
00395 fprintf( pAbc->Err, " -h \t\tprint the command usage\n" );
00396 return ( 1 );
00397 }
00398
00410 int CmdCommandUnalias( Abc_Frame_t * pAbc, int argc, char **argv )
00411 {
00412 int i;
00413 char *key, *value;
00414 int c;
00415
00416 Extra_UtilGetoptReset();
00417 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
00418 {
00419 switch ( c )
00420 {
00421 case 'h':
00422 goto usage;
00423 break;
00424 default:
00425 goto usage;
00426 }
00427 }
00428
00429 if ( argc < 2 )
00430 {
00431 goto usage;
00432 }
00433
00434 for ( i = 1; i < argc; i++ )
00435 {
00436 key = argv[i];
00437 if ( st_delete( pAbc->tAliases, &key, &value ) )
00438 {
00439 CmdCommandAliasFree( ( Abc_Alias * ) value );
00440 }
00441 }
00442 return 0;
00443
00444 usage:
00445 fprintf( pAbc->Err, "usage: unalias [-h] alias_names\n" );
00446 fprintf( pAbc->Err, " -h \t\tprint the command usage\n" );
00447 return 1;
00448 }
00449
00461 int CmdCommandHelp( Abc_Frame_t * pAbc, int argc, char **argv )
00462 {
00463 bool fPrintAll;
00464 int c;
00465
00466 fPrintAll = 0;
00467 Extra_UtilGetoptReset();
00468 while ( ( c = Extra_UtilGetopt( argc, argv, "ah" ) ) != EOF )
00469 {
00470 switch ( c )
00471 {
00472 case 'a':
00473 case 'v':
00474 fPrintAll ^= 1;
00475 break;
00476 break;
00477 case 'h':
00478 goto usage;
00479 break;
00480 default:
00481 goto usage;
00482 }
00483 }
00484
00485 if ( argc != globalUtilOptind )
00486 goto usage;
00487
00488 CmdCommandPrint( pAbc, fPrintAll );
00489 return 0;
00490
00491 usage:
00492 fprintf( pAbc->Err, "usage: help [-a] [-h]\n" );
00493 fprintf( pAbc->Err, " prints the list of available commands by group\n" );
00494 fprintf( pAbc->Err, " -a toggle printing hidden commands [default = %s]\n", fPrintAll? "yes": "no" );
00495 fprintf( pAbc->Err, " -h print the command usage\n" );
00496 return 1;
00497 }
00498
00510 int CmdCommandSource( Abc_Frame_t * pAbc, int argc, char **argv )
00511 {
00512 int c, echo, prompt, silent, interactive, quit_count, lp_count;
00513 int status = 0;
00514 int lp_file_index, did_subst;
00515 char *prompt_string, *real_filename, line[MAX_STR], *command;
00516 FILE *fp;
00517
00518 interactive = silent = prompt = echo = 0;
00519
00520 Extra_UtilGetoptReset();
00521 while ( ( c = Extra_UtilGetopt( argc, argv, "ipsxh" ) ) != EOF )
00522 {
00523 switch ( c )
00524 {
00525 case 'i':
00526 interactive = 1;
00527 break;
00528 case 'p':
00529 prompt ^= 1;
00530 break;
00531 case 's':
00532 silent ^= 1;
00533 break;
00534 case 'x':
00535 echo ^= 1;
00536 break;
00537 case 'h':
00538 goto usage;
00539 default:
00540 goto usage;
00541 }
00542 }
00543
00544
00545 if ( argc == globalUtilOptind )
00546 {
00547 goto usage;
00548 }
00549
00550 lp_file_index = globalUtilOptind;
00551 lp_count = 0;
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561 do
00562 {
00563 lp_count++;
00564
00565 fp = CmdFileOpen( pAbc, argv[lp_file_index], "r", &real_filename, silent );
00566 if ( fp == NULL )
00567 {
00568 FREE( real_filename );
00569 return !silent;
00570 }
00571
00572 quit_count = 0;
00573 do
00574 {
00575 if ( prompt )
00576 {
00577 prompt_string = Cmd_FlagReadByName( pAbc, "prompt" );
00578 if ( prompt_string == NULL )
00579 prompt_string = "abc> ";
00580
00581 }
00582 else
00583 {
00584 prompt_string = NULL;
00585 }
00586
00587
00588 clearerr( fp );
00589
00590
00591
00592
00593
00594 if ( fgets( line, MAX_STR, fp ) == NULL )
00595 {
00596 if ( interactive )
00597 {
00598 if ( quit_count++ < 5 )
00599 {
00600 fprintf( pAbc->Err, "\nUse \"quit\" to leave ABC.\n" );
00601 continue;
00602 }
00603 status = -1;
00604 }
00605 else
00606 {
00607 status = 0;
00608 }
00609 break;
00610 }
00611 quit_count = 0;
00612
00613 if ( echo )
00614 {
00615 fprintf( pAbc->Out, "abc - > %s", line );
00616 }
00617 command = CmdHistorySubstitution( pAbc, line, &did_subst );
00618 if ( command == NULL )
00619 {
00620 status = 1;
00621 break;
00622 }
00623 if ( did_subst )
00624 {
00625 if ( interactive )
00626 {
00627 fprintf( pAbc->Out, "%s\n", command );
00628 }
00629 }
00630 if ( command != line )
00631 {
00632 ( void ) strcpy( line, command );
00633 }
00634 if ( interactive && *line != '\0' )
00635 {
00636 Cmd_HistoryAddCommand( pAbc, Extra_UtilStrsav(line) );
00637 if ( pAbc->Hst != NULL )
00638 {
00639 fprintf( pAbc->Hst, "%s\n", line );
00640 ( void ) fflush( pAbc->Hst );
00641 }
00642 }
00643
00644 status = Cmd_CommandExecute( pAbc, line );
00645 }
00646 while ( status == 0 );
00647
00648 if ( fp != stdin )
00649 {
00650 if ( status > 0 )
00651 {
00652 fprintf( pAbc->Err,
00653 "** cmd error: aborting 'source %s'\n",
00654 real_filename );
00655 }
00656 ( void ) fclose( fp );
00657 }
00658 FREE( real_filename );
00659
00660 }
00661 while ( ( status == 0 ) && ( lp_count <= 0 ) );
00662
00663 return status;
00664
00665 usage:
00666 fprintf( pAbc->Err, "usage: source [-psxh] <file_name>\n" );
00667 fprintf( pAbc->Err, "\t-p supply prompt before reading each line [default = %s]\n", prompt? "yes": "no" );
00668 fprintf( pAbc->Err, "\t-s silently ignore nonexistant file [default = %s]\n", silent? "yes": "no" );
00669 fprintf( pAbc->Err, "\t-x echo each line as it is executed [default = %s]\n", echo? "yes": "no" );
00670 fprintf( pAbc->Err, "\t-h print the command usage\n" );
00671 return 1;
00672 }
00673
00685 int CmdCommandSetVariable( Abc_Frame_t * pAbc, int argc, char **argv )
00686 {
00687 char *flag_value, *key, *value;
00688 int c;
00689
00690 Extra_UtilGetoptReset();
00691 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
00692 {
00693 switch ( c )
00694 {
00695 case 'h':
00696 goto usage;
00697 default:
00698 goto usage;
00699 }
00700 }
00701 if ( argc == 0 || argc > 3 )
00702 {
00703 goto usage;
00704 }
00705 else if ( argc == 1 )
00706 {
00707 CmdPrintTable( pAbc->tFlags, 0 );
00708 return 0;
00709 }
00710 else
00711 {
00712 key = argv[1];
00713 if ( st_delete( pAbc->tFlags, &key, &value ) )
00714 {
00715 FREE( key );
00716 FREE( value );
00717 }
00718
00719 flag_value = argc == 2 ? Extra_UtilStrsav( "" ) : Extra_UtilStrsav( argv[2] );
00720
00721 st_insert( pAbc->tFlags, Extra_UtilStrsav(argv[1]), flag_value );
00722
00723 if ( strcmp( argv[1], "abcout" ) == 0 )
00724 {
00725 if ( pAbc->Out != stdout )
00726 fclose( pAbc->Out );
00727 if ( strcmp( flag_value, "" ) == 0 )
00728 flag_value = "-";
00729 pAbc->Out = CmdFileOpen( pAbc, flag_value, "w", NULL, 0 );
00730 if ( pAbc->Out == NULL )
00731 pAbc->Out = stdout;
00732 #if HAVE_SETVBUF
00733 setvbuf( pAbc->Out, ( char * ) NULL, _IOLBF, 0 );
00734 #endif
00735 }
00736 if ( strcmp( argv[1], "abcerr" ) == 0 )
00737 {
00738 if ( pAbc->Err != stderr )
00739 fclose( pAbc->Err );
00740 if ( strcmp( flag_value, "" ) == 0 )
00741 flag_value = "-";
00742 pAbc->Err = CmdFileOpen( pAbc, flag_value, "w", NULL, 0 );
00743 if ( pAbc->Err == NULL )
00744 pAbc->Err = stderr;
00745 #if HAVE_SETVBUF
00746 setvbuf( pAbc->Err, ( char * ) NULL, _IOLBF, 0 );
00747 #endif
00748 }
00749 if ( strcmp( argv[1], "history" ) == 0 )
00750 {
00751 if ( pAbc->Hst != NULL )
00752 fclose( pAbc->Hst );
00753 if ( strcmp( flag_value, "" ) == 0 )
00754 pAbc->Hst = NULL;
00755 else
00756 {
00757 pAbc->Hst = CmdFileOpen( pAbc, flag_value, "w", NULL, 0 );
00758 if ( pAbc->Hst == NULL )
00759 pAbc->Hst = NULL;
00760 }
00761 }
00762 return 0;
00763 }
00764
00765 usage:
00766 fprintf( pAbc->Err, "usage: set [-h] <name> <value>\n" );
00767 fprintf( pAbc->Err, "\t sets the value of parameter <name>\n" );
00768 fprintf( pAbc->Err, "\t-h : print the command usage\n" );
00769 return 1;
00770
00771 }
00772
00784 int CmdCommandUnsetVariable( Abc_Frame_t * pAbc, int argc, char **argv )
00785 {
00786 int i;
00787 char *key, *value;
00788 int c;
00789
00790 Extra_UtilGetoptReset();
00791 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
00792 {
00793 switch ( c )
00794 {
00795 case 'h':
00796 goto usage;
00797 break;
00798 default:
00799 goto usage;
00800 }
00801 }
00802
00803 if ( argc < 2 )
00804 {
00805 goto usage;
00806 }
00807
00808 for ( i = 1; i < argc; i++ )
00809 {
00810 key = argv[i];
00811 if ( st_delete( pAbc->tFlags, &key, &value ) )
00812 {
00813 FREE( key );
00814 FREE( value );
00815 }
00816 }
00817 return 0;
00818
00819
00820 usage:
00821 fprintf( pAbc->Err, "usage: unset [-h] <name> \n" );
00822 fprintf( pAbc->Err, "\t removes the value of parameter <name>\n" );
00823 fprintf( pAbc->Err, "\t-h : print the command usage\n" );
00824 return 1;
00825 }
00826
00838 int CmdCommandUndo( Abc_Frame_t * pAbc, int argc, char **argv )
00839 {
00840 if ( pAbc->pNtkCur == NULL )
00841 {
00842 fprintf( pAbc->Out, "Empty network.\n" );
00843 return 0;
00844 }
00845
00846
00847
00848 if ( argc == 1 )
00849 return CmdCommandRecall( pAbc, argc, argv );
00850
00851 fprintf( pAbc->Err, "usage: undo\n" );
00852 fprintf( pAbc->Err, " sets the current network to be the previously saved network\n" );
00853 return 1;
00854
00855 }
00856
00868 int CmdCommandRecall( Abc_Frame_t * pAbc, int argc, char **argv )
00869 {
00870 Abc_Ntk_t * pNtk;
00871 int iStep, iStepFound;
00872 int nNetsToSave, c;
00873 char * pValue;
00874 int iStepStart, iStepStop;
00875
00876 if ( pAbc->pNtkCur == NULL )
00877 {
00878 fprintf( pAbc->Out, "Empty network.\n" );
00879 return 0;
00880 }
00881
00882
00883 Extra_UtilGetoptReset();
00884 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
00885 {
00886 switch ( c )
00887 {
00888 case 'h':
00889 goto usage;
00890 default:
00891 goto usage;
00892 }
00893 }
00894
00895
00896 pValue = Cmd_FlagReadByName( pAbc, "savesteps" );
00897
00898 if ( pValue == NULL )
00899 nNetsToSave = 1;
00900 else
00901 nNetsToSave = atoi(pValue);
00902
00903
00904
00905 if ( argc == 1 )
00906 {
00907
00908 pNtk = Abc_NtkBackup(pAbc->pNtkCur);
00909 if ( pNtk == NULL )
00910 fprintf( pAbc->Out, "There is no previously saved network.\n" );
00911 else
00912 Abc_FrameSetCurrentNetwork( pAbc, Abc_NtkDup(pNtk) );
00913 return 0;
00914 }
00915 if ( argc == 2 )
00916 {
00917
00918 iStep = atoi(argv[1]);
00919
00920 if ( iStep >= pAbc->nSteps )
00921 {
00922 iStepStart = pAbc->nSteps - nNetsToSave;
00923 if ( iStepStart <= 0 )
00924 iStepStart = 1;
00925 iStepStop = pAbc->nSteps;
00926 if ( iStepStop <= 0 )
00927 iStepStop = 1;
00928 if ( iStepStart == iStepStop )
00929 fprintf( pAbc->Out, "Can only recall step %d.\n", iStepStop );
00930 else
00931 fprintf( pAbc->Out, "Can only recall steps %d-%d.\n", iStepStart, iStepStop );
00932 }
00933 else if ( iStep < 0 )
00934 fprintf( pAbc->Out, "Cannot recall step %d.\n", iStep );
00935 else if ( iStep == 0 )
00936 Abc_FrameDeleteAllNetworks( pAbc );
00937 else
00938 {
00939
00940
00941 iStepFound = 0;
00942 for ( pNtk = pAbc->pNtkCur; pNtk; pNtk = Abc_NtkBackup(pNtk) )
00943 if ( (iStepFound = Abc_NtkStep(pNtk)) == iStep )
00944 break;
00945 if ( pNtk == NULL )
00946 {
00947 iStepStart = iStepFound;
00948 if ( iStepStart <= 0 )
00949 iStepStart = 1;
00950 iStepStop = pAbc->nSteps;
00951 if ( iStepStop <= 0 )
00952 iStepStop = 1;
00953 if ( iStepStart == iStepStop )
00954 fprintf( pAbc->Out, "Can only recall step %d.\n", iStepStop );
00955 else
00956 fprintf( pAbc->Out, "Can only recall steps %d-%d.\n", iStepStart, iStepStop );
00957 }
00958 else
00959 Abc_FrameSetCurrentNetwork( pAbc, Abc_NtkDup(pNtk) );
00960 }
00961 return 0;
00962 }
00963
00964 usage:
00965
00966 fprintf( pAbc->Err, "usage: recall -h <num>\n" );
00967 fprintf( pAbc->Err, " set the current network to be one of the previous networks\n" );
00968 fprintf( pAbc->Err, "<num> : level to return to [default = previous]\n" );
00969 fprintf( pAbc->Err, " -h : print the command usage\n");
00970 return 1;
00971 }
00972
00973
00985 int CmdCommandEmpty( Abc_Frame_t * pAbc, int argc, char **argv )
00986 {
00987 int c;
00988
00989 if ( pAbc->pNtkCur == NULL )
00990 {
00991 fprintf( pAbc->Out, "Empty network.\n" );
00992 return 0;
00993 }
00994
00995 Extra_UtilGetoptReset();
00996 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
00997 {
00998 switch ( c )
00999 {
01000 case 'h':
01001 goto usage;
01002 default:
01003 goto usage;
01004 }
01005 }
01006
01007 Abc_FrameDeleteAllNetworks( pAbc );
01008 Abc_FrameRestart( pAbc );
01009 return 0;
01010 usage:
01011
01012 fprintf( pAbc->Err, "usage: empty [-h]\n" );
01013 fprintf( pAbc->Err, " removes all the currently stored networks\n" );
01014 fprintf( pAbc->Err, " -h : print the command usage\n");
01015 return 1;
01016 }
01017
01018
01019 #if 0
01020
01032 int CmdCommandUndo( Abc_Frame_t * pAbc, int argc, char **argv )
01033 {
01034 Abc_Ntk_t * pNtkTemp;
01035 int id, c;
01036
01037 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
01038 {
01039 switch ( c )
01040 {
01041 case 'h':
01042 goto usage;
01043 break;
01044 default:
01045 goto usage;
01046 }
01047 }
01048 if (globalUtilOptind <= argc) {
01049 pNtkTemp = pAbc->pNtk;
01050 pAbc->pNtk = pAbc->pNtkSaved;
01051 pAbc->pNtkSaved = pNtkTemp;
01052 }
01053 id = atoi(argv[globalUtilOptind]);
01054 pNtkTemp = Cmd_HistoryGetSnapshot(pAbc, id);
01055 if (!pNtkTemp)
01056 fprintf( pAbc->Err, "Snapshot %d does not exist\n", id);
01057 else
01058 pAbc->pNtk = Abc_NtkDup(pNtkTemp, Abc_NtkMan(pNtkTemp));
01059
01060 return 0;
01061 usage:
01062 fprintf( pAbc->Err, "usage: undo\n" );
01063 fprintf( pAbc->Err, " swaps the current network and the backup network\n" );
01064 return 1;
01065 }
01066
01067 #endif
01068
01069
01070 #ifdef WIN32
01071
01082 #include <io.h>
01083
01084
01085 typedef unsigned long _fsize_t;
01086
01087 struct _finddata_t {
01088 unsigned attrib;
01089 time_t time_create;
01090 time_t time_access;
01091 time_t time_write;
01092 _fsize_t size;
01093 char name[260];
01094 };
01095
01096 extern long _findfirst( char *filespec, struct _finddata_t *fileinfo );
01097 extern int _findnext( long handle, struct _finddata_t *fileinfo );
01098 extern int _findclose( long handle );
01099
01100 int CmdCommandLs( Abc_Frame_t * pAbc, int argc, char **argv )
01101 {
01102 struct _finddata_t c_file;
01103 long hFile;
01104 int fLong = 0;
01105 int fOnlyBLIF = 0;
01106 char Buffer[25];
01107 int Counter = 0;
01108 int fPrintedNewLine;
01109 char c;
01110
01111 Extra_UtilGetoptReset();
01112 while ( (c = Extra_UtilGetopt(argc, argv, "lb") ) != EOF )
01113 {
01114 switch (c)
01115 {
01116 case 'l':
01117 fLong = 1;
01118 break;
01119 case 'b':
01120 fOnlyBLIF = 1;
01121 break;
01122 default:
01123 goto usage;
01124 }
01125 }
01126
01127
01128 if( (hFile = _findfirst( ((fOnlyBLIF)? "*.mv": "*.*"), &c_file )) == -1L )
01129 {
01130 if ( fOnlyBLIF )
01131 fprintf( pAbc->Out, "No *.mv files in the current directory.\n" );
01132 else
01133 fprintf( pAbc->Out, "No files in the current directory.\n" );
01134 }
01135 else
01136 {
01137 if ( fLong )
01138 {
01139 fprintf( pAbc->Out, " File Date Size | File Date Size \n" );
01140 fprintf( pAbc->Out, " ----------------------------------------------------------------------------- \n" );
01141 do
01142 {
01143 strcpy( Buffer, ctime( &(c_file.time_write) ) );
01144 Buffer[16] = 0;
01145 fprintf( pAbc->Out, " %-17s %.24s%7ld", c_file.name, Buffer+4, c_file.size );
01146 if ( ++Counter % 2 == 0 )
01147 {
01148 fprintf( pAbc->Out, "\n" );
01149 fPrintedNewLine = 1;
01150 }
01151 else
01152 {
01153 fprintf( pAbc->Out, " |" );
01154 fPrintedNewLine = 0;
01155 }
01156 }
01157 while( _findnext( hFile, &c_file ) == 0 );
01158 }
01159 else
01160 {
01161 do
01162 {
01163 fprintf( pAbc->Out, " %-18s", c_file.name );
01164 if ( ++Counter % 4 == 0 )
01165 {
01166 fprintf( pAbc->Out, "\n" );
01167 fPrintedNewLine = 1;
01168 }
01169 else
01170 {
01171 fprintf( pAbc->Out, " " );
01172 fPrintedNewLine = 0;
01173 }
01174 }
01175 while( _findnext( hFile, &c_file ) == 0 );
01176 }
01177 if ( !fPrintedNewLine )
01178 fprintf( pAbc->Out, "\n" );
01179 _findclose( hFile );
01180 }
01181 return 0;
01182
01183 usage:
01184 fprintf( pAbc->Err, "Usage: ls [-l] [-b]\n" );
01185 fprintf( pAbc->Err, " print the file names in the current directory\n" );
01186 fprintf( pAbc->Err, " -l : print in the long format [default = short]\n" );
01187 fprintf( pAbc->Err, " -b : print only .mv files [default = all]\n" );
01188 return 1;
01189 }
01190 #endif
01191
01192
01193
01194 #ifdef WIN32
01195 #define unlink _unlink
01196 #endif
01197
01209 int CmdCommandSis( Abc_Frame_t * pAbc, int argc, char **argv )
01210 {
01211 FILE * pFile;
01212 FILE * pOut, * pErr;
01213 Abc_Ntk_t * pNtk, * pNtkNew, * pNetlist;
01214 char * pNameWin = "sis.exe";
01215 char * pNameUnix = "sis";
01216 char Command[1000], Buffer[100];
01217 char * pSisName;
01218 int i;
01219
01220 pNtk = Abc_FrameReadNtk(pAbc);
01221 pOut = Abc_FrameReadOut(pAbc);
01222 pErr = Abc_FrameReadErr(pAbc);
01223
01224 if ( pNtk == NULL )
01225 {
01226 fprintf( pErr, "Empty network.\n" );
01227 goto usage;
01228 }
01229
01230 if ( strcmp( argv[0], "sis" ) != 0 )
01231 {
01232 fprintf( pErr, "Wrong command: \"%s\".\n", argv[0] );
01233 goto usage;
01234 }
01235
01236 if ( argc == 1 )
01237 goto usage;
01238 if ( strcmp( argv[1], "-h" ) == 0 )
01239 goto usage;
01240 if ( strcmp( argv[1], "-?" ) == 0 )
01241 goto usage;
01242
01243
01244 if ( Cmd_FlagReadByName(pAbc, "siswin") )
01245 pNameWin = Cmd_FlagReadByName(pAbc, "siswin");
01246 if ( Cmd_FlagReadByName(pAbc, "sisunix") )
01247 pNameUnix = Cmd_FlagReadByName(pAbc, "sisunix");
01248
01249
01250 if ( (pFile = fopen( pNameWin, "r" )) )
01251 pSisName = pNameWin;
01252 else if ( (pFile = fopen( pNameUnix, "r" )) )
01253 pSisName = pNameUnix;
01254 else if ( pFile == NULL )
01255 {
01256 fprintf( pErr, "Cannot find \"%s\" or \"%s\" in the current directory.\n", pNameWin, pNameUnix );
01257 goto usage;
01258 }
01259 fclose( pFile );
01260
01261 if ( Abc_NtkIsMappedLogic(pNtk) )
01262 {
01263 Abc_NtkMapToSop(pNtk);
01264 printf( "The current network is unmapped before calling SIS.\n" );
01265 }
01266
01267
01268 if ( Abc_NtkIsLogic(pNtk) )
01269 Abc_NtkToSop(pNtk, 0);
01270 pNetlist = Abc_NtkToNetlist(pNtk);
01271 if ( pNetlist == NULL )
01272 {
01273 fprintf( pErr, "Cannot produce the intermediate network.\n" );
01274 goto usage;
01275 }
01276 Io_WriteBlif( pNetlist, "_sis_in.blif", 1 );
01277 Abc_NtkDelete( pNetlist );
01278
01279
01280 sprintf( Command, "%s -x -c ", pSisName );
01281 strcat ( Command, "\"" );
01282 strcat ( Command, "read_blif _sis_in.blif" );
01283 strcat ( Command, "; " );
01284 for ( i = 1; i < argc; i++ )
01285 {
01286 sprintf( Buffer, " %s", argv[i] );
01287 strcat( Command, Buffer );
01288 }
01289 strcat( Command, "; " );
01290 strcat( Command, "write_blif _sis_out.blif" );
01291 strcat( Command, "\"" );
01292
01293
01294 if ( system( Command ) )
01295 {
01296 fprintf( pErr, "The following command has returned non-zero exit status:\n" );
01297 fprintf( pErr, "\"%s\"\n", Command );
01298 unlink( "_sis_in.blif" );
01299 goto usage;
01300 }
01301
01302
01303 if ( (pFile = fopen( "_sis_out.blif", "r" )) == NULL )
01304 {
01305 fprintf( pErr, "Cannot open SIS output file \"%s\".\n", "_sis_out.blif" );
01306 unlink( "_sis_in.blif" );
01307 goto usage;
01308 }
01309 fclose( pFile );
01310
01311
01312 pNtkNew = Io_Read( "_sis_out.blif", IO_FILE_BLIF, 1 );
01313
01314 if ( pNtk->pSpec )
01315 {
01316 FREE( pNtkNew->pSpec );
01317 pNtkNew->pSpec = Extra_UtilStrsav( pNtk->pSpec );
01318 }
01319
01320 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew );
01321
01322
01323 unlink( "_sis_in.blif" );
01324 unlink( "_sis_out.blif" );
01325 return 0;
01326
01327 usage:
01328 fprintf( pErr, "\n" );
01329 fprintf( pErr, "Usage: sis [-h] <com>\n");
01330 fprintf( pErr, " invokes SIS command for the current ABC network\n" );
01331 fprintf( pErr, " (the executable of SIS should be in the same directory)\n" );
01332 fprintf( pErr, " -h : print the command usage\n" );
01333 fprintf( pErr, " <com> : a SIS command (or a semicolon-separated list of commands in quotes)\n" );
01334 fprintf( pErr, " Example 1: sis eliminate 0\n" );
01335 fprintf( pErr, " Example 2: sis \"ps; rd; fx; ps\"\n" );
01336 fprintf( pErr, " Example 3: sis source script.rugged\n" );
01337 return 1;
01338 }
01339
01340
01352 int CmdCommandMvsis( Abc_Frame_t * pAbc, int argc, char **argv )
01353 {
01354 FILE * pFile;
01355 FILE * pOut, * pErr;
01356 Abc_Ntk_t * pNtk, * pNtkNew, * pNetlist;
01357 char Command[1000], Buffer[100];
01358 char * pNameWin = "mvsis.exe";
01359 char * pNameUnix = "mvsis";
01360 char * pMvsisName;
01361 int i;
01362
01363 pNtk = Abc_FrameReadNtk(pAbc);
01364 pOut = Abc_FrameReadOut(pAbc);
01365 pErr = Abc_FrameReadErr(pAbc);
01366
01367 if ( pNtk == NULL )
01368 {
01369 fprintf( pErr, "Empty network.\n" );
01370 goto usage;
01371 }
01372
01373 if ( strcmp( argv[0], "mvsis" ) != 0 )
01374 {
01375 fprintf( pErr, "Wrong command: \"%s\".\n", argv[0] );
01376 goto usage;
01377 }
01378
01379 if ( argc == 1 )
01380 goto usage;
01381 if ( strcmp( argv[1], "-h" ) == 0 )
01382 goto usage;
01383 if ( strcmp( argv[1], "-?" ) == 0 )
01384 goto usage;
01385
01386
01387 if ( Cmd_FlagReadByName(pAbc, "mvsiswin") )
01388 pNameWin = Cmd_FlagReadByName(pAbc, "mvsiswin");
01389 if ( Cmd_FlagReadByName(pAbc, "mvsisunix") )
01390 pNameUnix = Cmd_FlagReadByName(pAbc, "mvsisunix");
01391
01392
01393 if ( (pFile = fopen( pNameWin, "r" )) )
01394 pMvsisName = pNameWin;
01395 else if ( (pFile = fopen( pNameUnix, "r" )) )
01396 pMvsisName = pNameUnix;
01397 else if ( pFile == NULL )
01398 {
01399 fprintf( pErr, "Cannot find \"%s\" or \"%s\" in the current directory.\n", pNameWin, pNameUnix );
01400 goto usage;
01401 }
01402 fclose( pFile );
01403
01404 if ( Abc_NtkIsMappedLogic(pNtk) )
01405 {
01406 Abc_NtkMapToSop(pNtk);
01407 printf( "The current network is unmapped before calling MVSIS.\n" );
01408 }
01409
01410
01411 if ( Abc_NtkIsLogic(pNtk) )
01412 Abc_NtkToSop(pNtk, 0);
01413 pNetlist = Abc_NtkToNetlist(pNtk);
01414 if ( pNetlist == NULL )
01415 {
01416 fprintf( pErr, "Cannot produce the intermediate network.\n" );
01417 goto usage;
01418 }
01419 Io_WriteBlif( pNetlist, "_mvsis_in.blif", 1 );
01420 Abc_NtkDelete( pNetlist );
01421
01422
01423 sprintf( Command, "%s -x -c ", pMvsisName );
01424 strcat ( Command, "\"" );
01425 strcat ( Command, "read_blif _mvsis_in.blif" );
01426 strcat ( Command, "; " );
01427 for ( i = 1; i < argc; i++ )
01428 {
01429 sprintf( Buffer, " %s", argv[i] );
01430 strcat( Command, Buffer );
01431 }
01432 strcat( Command, "; " );
01433 strcat( Command, "write_blif _mvsis_out.blif" );
01434 strcat( Command, "\"" );
01435
01436
01437 if ( system( Command ) )
01438 {
01439 fprintf( pErr, "The following command has returned non-zero exit status:\n" );
01440 fprintf( pErr, "\"%s\"\n", Command );
01441 unlink( "_mvsis_in.blif" );
01442 goto usage;
01443 }
01444
01445
01446 if ( (pFile = fopen( "_mvsis_out.blif", "r" )) == NULL )
01447 {
01448 fprintf( pErr, "Cannot open MVSIS output file \"%s\".\n", "_mvsis_out.blif" );
01449 unlink( "_mvsis_in.blif" );
01450 goto usage;
01451 }
01452 fclose( pFile );
01453
01454
01455 pNtkNew = Io_Read( "_mvsis_out.blif", IO_FILE_BLIF, 1 );
01456
01457 if ( pNtk->pSpec )
01458 {
01459 FREE( pNtkNew->pSpec );
01460 pNtkNew->pSpec = Extra_UtilStrsav( pNtk->pSpec );
01461 }
01462
01463 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew );
01464
01465
01466 unlink( "_mvsis_in.blif" );
01467 unlink( "_mvsis_out.blif" );
01468 return 0;
01469
01470 usage:
01471 fprintf( pErr, "\n" );
01472 fprintf( pErr, "Usage: mvsis [-h] <com>\n");
01473 fprintf( pErr, " invokes MVSIS command for the current ABC network\n" );
01474 fprintf( pErr, " (the executable of MVSIS should be in the same directory)\n" );
01475 fprintf( pErr, " -h : print the command usage\n" );
01476 fprintf( pErr, " <com> : a MVSIS command (or a semicolon-separated list of commands in quotes)\n" );
01477 fprintf( pErr, " Example 1: mvsis fraig_sweep\n" );
01478 fprintf( pErr, " Example 2: mvsis \"ps; fxu; ps\"\n" );
01479 fprintf( pErr, " Example 3: mvsis source mvsis.rugged\n" );
01480 return 1;
01481 }
01482
01483
01495 int CmdCommandCapo( Abc_Frame_t * pAbc, int argc, char **argv )
01496 {
01497 FILE * pFile;
01498 FILE * pOut, * pErr;
01499 Abc_Ntk_t * pNtk, * pNetlist;
01500 char Command[1000], Buffer[100];
01501 char * pProgNameCapoWin = "capo.exe";
01502 char * pProgNameCapoUnix = "capo";
01503 char * pProgNameGnuplotWin = "wgnuplot.exe";
01504 char * pProgNameGnuplotUnix = "gnuplot";
01505 char * pProgNameCapo;
01506 char * pProgNameGnuplot;
01507 char * pPlotFileName;
01508 int i;
01509
01510 pNtk = Abc_FrameReadNtk(pAbc);
01511 pOut = Abc_FrameReadOut(pAbc);
01512 pErr = Abc_FrameReadErr(pAbc);
01513
01514 if ( pNtk == NULL )
01515 {
01516 fprintf( pErr, "Empty network.\n" );
01517 goto usage;
01518 }
01519
01520 if ( strcmp( argv[0], "capo" ) != 0 )
01521 {
01522 fprintf( pErr, "Wrong command: \"%s\".\n", argv[0] );
01523 goto usage;
01524 }
01525
01526 if ( argc > 1 )
01527 {
01528 if ( strcmp( argv[1], "-h" ) == 0 )
01529 goto usage;
01530 if ( strcmp( argv[1], "-?" ) == 0 )
01531 goto usage;
01532 }
01533
01534
01535 if ( Cmd_FlagReadByName(pAbc, "capowin") )
01536 pProgNameCapoWin = Cmd_FlagReadByName(pAbc, "capowin");
01537 if ( Cmd_FlagReadByName(pAbc, "capounix") )
01538 pProgNameCapoUnix = Cmd_FlagReadByName(pAbc, "capounix");
01539
01540
01541 if ( (pFile = fopen( pProgNameCapoWin, "r" )) )
01542 pProgNameCapo = pProgNameCapoWin;
01543 else if ( (pFile = fopen( pProgNameCapoUnix, "r" )) )
01544 pProgNameCapo = pProgNameCapoUnix;
01545 else if ( pFile == NULL )
01546 {
01547 fprintf( pErr, "Cannot find \"%s\" or \"%s\" in the current directory.\n", pProgNameCapoWin, pProgNameCapoUnix );
01548 goto usage;
01549 }
01550 fclose( pFile );
01551
01552 if ( Abc_NtkIsMappedLogic(pNtk) )
01553 {
01554 Abc_NtkMapToSop(pNtk);
01555 printf( "The current network is unmapped before calling Capo.\n" );
01556 }
01557
01558
01559 if ( Abc_NtkIsLogic(pNtk) )
01560 Abc_NtkToSop(pNtk, 0);
01561 pNetlist = Abc_NtkToNetlist(pNtk);
01562 if ( pNetlist == NULL )
01563 {
01564 fprintf( pErr, "Cannot produce the intermediate network.\n" );
01565 goto usage;
01566 }
01567 Io_WriteBlif( pNetlist, "_capo_in.blif", 1 );
01568 Abc_NtkDelete( pNetlist );
01569
01570
01571 sprintf( Command, "%s -f _capo_in.blif -log out.txt ", pProgNameCapo );
01572 pPlotFileName = NULL;
01573 for ( i = 1; i < argc; i++ )
01574 {
01575 sprintf( Buffer, " %s", argv[i] );
01576 strcat( Command, Buffer );
01577 if ( !strcmp( argv[i], "-plot" ) )
01578 pPlotFileName = argv[i+1];
01579 }
01580
01581
01582 if ( system( Command ) )
01583 {
01584 fprintf( pErr, "The following command has returned non-zero exit status:\n" );
01585 fprintf( pErr, "\"%s\"\n", Command );
01586 unlink( "_capo_in.blif" );
01587 goto usage;
01588 }
01589
01590 unlink( "_capo_in.blif" );
01591 if ( pPlotFileName == NULL )
01592 return 0;
01593
01594
01595 sprintf( Buffer, "%s.plt", pPlotFileName );
01596 pPlotFileName = Buffer;
01597
01598
01599 if ( (pFile = fopen( pPlotFileName, "r" )) == NULL )
01600 {
01601 fprintf( pErr, "Cannot open the plot file \"%s\".\n\n", pPlotFileName );
01602 goto usage;
01603 }
01604 fclose( pFile );
01605
01606
01607 if ( Cmd_FlagReadByName(pAbc, "gnuplotwin") )
01608 pProgNameGnuplotWin = Cmd_FlagReadByName(pAbc, "gnuplotwin");
01609 if ( Cmd_FlagReadByName(pAbc, "gnuplotunix") )
01610 pProgNameGnuplotUnix = Cmd_FlagReadByName(pAbc, "gnuplotunix");
01611
01612
01613 if ( (pFile = fopen( pProgNameGnuplotWin, "r" )) )
01614 pProgNameGnuplot = pProgNameGnuplotWin;
01615 else if ( (pFile = fopen( pProgNameGnuplotUnix, "r" )) )
01616 pProgNameGnuplot = pProgNameGnuplotUnix;
01617 else if ( pFile == NULL )
01618 {
01619 fprintf( pErr, "Cannot find \"%s\" or \"%s\" in the current directory.\n", pProgNameGnuplotWin, pProgNameGnuplotUnix );
01620 goto usage;
01621 }
01622 fclose( pFile );
01623
01624
01625 #ifdef WIN32
01626 if ( _spawnl( _P_NOWAIT, pProgNameGnuplot, pProgNameGnuplot, pPlotFileName, NULL ) == -1 )
01627 {
01628 fprintf( stdout, "Cannot find \"%s\".\n", pProgNameGnuplot );
01629 goto usage;
01630 }
01631 #else
01632 {
01633 sprintf( Command, "%s %s ", pProgNameGnuplot, pPlotFileName );
01634 if ( system( Command ) == -1 )
01635 {
01636 fprintf( stdout, "Cannot execute \"%s\".\n", Command );
01637 goto usage;
01638 }
01639 }
01640 #endif
01641
01642
01643
01644 return 0;
01645
01646 usage:
01647 fprintf( pErr, "\n" );
01648 fprintf( pErr, "Usage: capo [-h] <com>\n");
01649 fprintf( pErr, " peforms placement of the current network using Capo\n" );
01650 fprintf( pErr, " a Capo binary should be present in the same directory\n" );
01651 fprintf( pErr, " (if plotting, the Gnuplot binary should also be present)\n" );
01652 fprintf( pErr, " -h : print the command usage\n" );
01653 fprintf( pErr, " <com> : a Capo command\n" );
01654 fprintf( pErr, " Example 1: capo\n" );
01655 fprintf( pErr, " (performs placement with default options)\n" );
01656 fprintf( pErr, " Example 2: capo -AR <aspec_ratio> -WS <whitespace_percentage> -save\n" );
01657 fprintf( pErr, " (specifies the aspect ratio [default = 1.0] and\n" );
01658 fprintf( pErr, " the whitespace percentage [0%%; 100%%) [default = 15%%])\n" );
01659 fprintf( pErr, " Example 3: capo -plot <base_fileName>\n" );
01660 fprintf( pErr, " (produces <base_fileName.plt> and visualize it using Gnuplot)\n" );
01661 fprintf( pErr, " Example 4: capo -help\n" );
01662 fprintf( pErr, " (prints the default usage message of the Capo binary)\n" );
01663 fprintf( pErr, " Please refer to the Capo webpage for additional information:\n" );
01664 fprintf( pErr, " http://vlsicad.eecs.umich.edu/BK/PDtools/\n" );
01665 return 1;
01666 }
01667
01668
01669
01673
01674