ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
cmd.c
Go to the documentation of this file.
1
20
21#ifdef WIN32
22#include <process.h>
23#else
24#include <unistd.h>
25#include <dirent.h>
26#endif
27
28#include "base/abc/abc.h"
29#include "base/main/mainInt.h"
30#include "cmdInt.h"
32
34
38
39static int CmdCommandTime ( Abc_Frame_t * pAbc, int argc, char ** argv );
40static int CmdCommandSleep ( Abc_Frame_t * pAbc, int argc, char ** argv );
41static int CmdCommandEcho ( Abc_Frame_t * pAbc, int argc, char ** argv );
42static int CmdCommandQuit ( Abc_Frame_t * pAbc, int argc, char ** argv );
43static int CmdCommandAbcrc ( Abc_Frame_t * pAbc, int argc, char ** argv );
44static int CmdCommandHistory ( Abc_Frame_t * pAbc, int argc, char ** argv );
45static int CmdCommandAlias ( Abc_Frame_t * pAbc, int argc, char ** argv );
46static int CmdCommandUnalias ( Abc_Frame_t * pAbc, int argc, char ** argv );
47static int CmdCommandHelp ( Abc_Frame_t * pAbc, int argc, char ** argv );
48static int CmdCommandSource ( Abc_Frame_t * pAbc, int argc, char ** argv );
49static int CmdCommandSetVariable ( Abc_Frame_t * pAbc, int argc, char ** argv );
50static int CmdCommandUnsetVariable ( Abc_Frame_t * pAbc, int argc, char ** argv );
51static int CmdCommandUndo ( Abc_Frame_t * pAbc, int argc, char ** argv );
52static int CmdCommandRecall ( Abc_Frame_t * pAbc, int argc, char ** argv );
53static int CmdCommandEmpty ( Abc_Frame_t * pAbc, int argc, char ** argv );
54#if defined(WIN32)
55static int CmdCommandScanDir ( Abc_Frame_t * pAbc, int argc, char ** argv );
56static int CmdCommandRenameFiles ( Abc_Frame_t * pAbc, int argc, char ** argv );
57static int CmdCommandLs ( Abc_Frame_t * pAbc, int argc, char ** argv );
58static int CmdCommandScrGen ( Abc_Frame_t * pAbc, int argc, char ** argv );
59#else
60static int CmdCommandScrGenLinux ( Abc_Frame_t * pAbc, int argc, char ** argv );
61#endif
62static int CmdCommandVersion ( Abc_Frame_t * pAbc, int argc, char ** argv );
63static int CmdCommandSGen ( Abc_Frame_t * pAbc, int argc, char ** argv );
64static int CmdCommandSis ( Abc_Frame_t * pAbc, int argc, char ** argv );
65static int CmdCommandMvsis ( Abc_Frame_t * pAbc, int argc, char ** argv );
66static int CmdCommandCapo ( Abc_Frame_t * pAbc, int argc, char ** argv );
67static int CmdCommandStarter ( Abc_Frame_t * pAbc, int argc, char ** argv );
68static int CmdCommandAutoTuner ( Abc_Frame_t * pAbc, int argc, char ** argv );
69
70extern int Cmd_CommandAbcLoadPlugIn( Abc_Frame_t * pAbc, int argc, char ** argv );
71
75
85void Cmd_Init( Abc_Frame_t * pAbc )
86{
87 pAbc->tCommands = st__init_table(strcmp, st__strhash);
88 pAbc->tAliases = st__init_table(strcmp, st__strhash);
89 pAbc->tFlags = st__init_table(strcmp, st__strhash);
90 pAbc->aHistory = Vec_PtrAlloc( 100 );
91 Cmd_HistoryRead( pAbc );
92
93 Cmd_CommandAdd( pAbc, "Basic", "time", CmdCommandTime, 0 );
94 Cmd_CommandAdd( pAbc, "Basic", "sleep", CmdCommandSleep, 0 );
95 Cmd_CommandAdd( pAbc, "Basic", "echo", CmdCommandEcho, 0 );
96 Cmd_CommandAdd( pAbc, "Basic", "quit", CmdCommandQuit, 0 );
97 Cmd_CommandAdd( pAbc, "Basic", "abcrc", CmdCommandAbcrc, 0 );
98 Cmd_CommandAdd( pAbc, "Basic", "history", CmdCommandHistory, 0 );
99 Cmd_CommandAdd( pAbc, "Basic", "alias", CmdCommandAlias, 0 );
100 Cmd_CommandAdd( pAbc, "Basic", "unalias", CmdCommandUnalias, 0 );
101 Cmd_CommandAdd( pAbc, "Basic", "help", CmdCommandHelp, 0 );
102 Cmd_CommandAdd( pAbc, "Basic", "source", CmdCommandSource, 0 );
103 Cmd_CommandAdd( pAbc, "Basic", "set", CmdCommandSetVariable, 0 );
104 Cmd_CommandAdd( pAbc, "Basic", "unset", CmdCommandUnsetVariable, 0 );
105 Cmd_CommandAdd( pAbc, "Basic", "undo", CmdCommandUndo, 0 );
106 Cmd_CommandAdd( pAbc, "Basic", "recall", CmdCommandRecall, 0 );
107 Cmd_CommandAdd( pAbc, "Basic", "empty", CmdCommandEmpty, 0 );
108#if defined(WIN32)
109 Cmd_CommandAdd( pAbc, "Basic", "scandir", CmdCommandScanDir, 0 );
110 Cmd_CommandAdd( pAbc, "Basic", "renamefiles", CmdCommandRenameFiles, 0 );
111 Cmd_CommandAdd( pAbc, "Basic", "ls", CmdCommandLs, 0 );
112 Cmd_CommandAdd( pAbc, "Basic", "scrgen", CmdCommandScrGen, 0 );
113#else
114 Cmd_CommandAdd( pAbc, "Basic", "scrgen", CmdCommandScrGenLinux, 0 );
115#endif
116 Cmd_CommandAdd( pAbc, "Basic", "version", CmdCommandVersion, 0 );
117 Cmd_CommandAdd( pAbc, "Basic", "sgen", CmdCommandSGen, 0 );
118
119 Cmd_CommandAdd( pAbc, "Various", "sis", CmdCommandSis, 1 );
120 Cmd_CommandAdd( pAbc, "Various", "mvsis", CmdCommandMvsis, 1 );
121 Cmd_CommandAdd( pAbc, "Various", "capo", CmdCommandCapo, 0 );
122 Cmd_CommandAdd( pAbc, "Various", "starter", CmdCommandStarter, 0 );
123 Cmd_CommandAdd( pAbc, "Various", "autotuner", CmdCommandAutoTuner, 0 );
124
125 Cmd_CommandAdd( pAbc, "Various", "load_plugin", Cmd_CommandAbcLoadPlugIn, 0 );
126}
127
139void Cmd_End( Abc_Frame_t * pAbc )
140{
141 st__generator * gen;
142 char * pKey, * pValue;
144
145// st__free_table( pAbc->tCommands, (void (*)()) 0, CmdCommandFree );
146// st__free_table( pAbc->tAliases, (void (*)()) 0, CmdCommandAliasFree );
147// st__free_table( pAbc->tFlags, free, free );
148
149 st__foreach_item( pAbc->tCommands, gen, (const char **)&pKey, (char **)&pValue )
150 CmdCommandFree( (Abc_Command *)pValue );
151 st__free_table( pAbc->tCommands );
152
153 st__foreach_item( pAbc->tAliases, gen, (const char **)&pKey, (char **)&pValue )
154 CmdCommandAliasFree( (Abc_Alias *)pValue );
155 st__free_table( pAbc->tAliases );
156
157 st__foreach_item( pAbc->tFlags, gen, (const char **)&pKey, (char **)&pValue )
158 ABC_FREE( pKey ), ABC_FREE( pValue );
159 st__free_table( pAbc->tFlags );
160
161 Vec_PtrFreeFree( pAbc->aHistory );
162}
163
164
165
177int CmdCommandTime( Abc_Frame_t * pAbc, int argc, char **argv )
178{
179 int c;
180 int fClear;
181
182 fClear = 0;
184 while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
185 {
186 switch ( c )
187 {
188 case 'c':
189 fClear ^= 1;
190 break;
191 case 'h':
192 goto usage;
193 default:
194 goto usage;
195 }
196 }
197
198 if ( fClear )
199 {
200 pAbc->TimeTotal += pAbc->TimeCommand;
201 pAbc->TimeCommand = 0.0;
202 return 0;
203 }
204
205 if ( argc != globalUtilOptind )
206 {
207 goto usage;
208 }
209
210
211 pAbc->TimeTotal += pAbc->TimeCommand;
212 fprintf( pAbc->Out, "elapse: %3.2f seconds, total: %3.2f seconds\n",
213 pAbc->TimeCommand, pAbc->TimeTotal );
214/*
215 {
216 FILE * pTable;
217 pTable = fopen( "runtimes.txt", "a+" );
218 fprintf( pTable, "%4.2f\n", pAbc->TimeCommand );
219 fclose( pTable );
220 }
221*/
222 pAbc->TimeCommand = 0.0;
223 return 0;
224
225 usage:
226 fprintf( pAbc->Err, "usage: time [-ch]\n" );
227 fprintf( pAbc->Err, " \t\tprint the runtime since the last call\n" );
228 fprintf( pAbc->Err, " -c \t\tclears the elapsed time without printing it\n" );
229 fprintf( pAbc->Err, " -h \t\tprint the command usage\n" );
230 return 1;
231}
232
244int CmdCommandSleep( Abc_Frame_t * pAbc, int argc, char **argv )
245{
246 abctime clkStop;
247 char * pFileName = NULL;
248 int c, nSecs = 1;
250 while ( ( c = Extra_UtilGetopt( argc, argv, "Nh" ) ) != EOF )
251 {
252 switch ( c )
253 {
254 case 'N':
255 if ( globalUtilOptind >= argc )
256 {
257 Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
258 goto usage;
259 }
260 nSecs = atoi(argv[globalUtilOptind]);
262 if ( nSecs < 0 )
263 goto usage;
264 break;
265 case 'h':
266 goto usage;
267 default:
268 goto usage;
269 }
270 }
271
272 if ( argc == globalUtilOptind + 1 ) {
273 FILE * pFile = NULL;
274 pFileName = argv[globalUtilOptind];
275 while ( (pFile = fopen(pFileName, "rb")) == NULL );
276 if ( pFile != NULL )
277 fclose( pFile );
278 }
279
280 clkStop = Abc_Clock() + nSecs * CLOCKS_PER_SEC;
281 while ( Abc_Clock() < clkStop );
282 return 0;
283
284 usage:
285 fprintf( pAbc->Err, "usage: sleep [-N <num>] [-h] <file_name>\n" );
286 fprintf( pAbc->Err, "\t puts ABC to sleep for some time\n" );
287 fprintf( pAbc->Err, "\t-N num : time duration in seconds [default = %d]\n", nSecs );
288 fprintf( pAbc->Err, "\t-h : toggle printing the command usage\n" );
289 fprintf( pAbc->Err, "\t<file_name> : (optional) waiting begins after the file is created\n" );
290 return 1;
291}
303int CmdCommandEcho( Abc_Frame_t * pAbc, int argc, char **argv )
304{
305 int i;
306 int c;
307 int n = 1;
308
310 while ( ( c = Extra_UtilGetopt( argc, argv, "hn" ) ) != EOF )
311 {
312 switch ( c )
313 {
314 case 'n':
315 n = 0;
316 break;
317 case 'h':
318 goto usage;
319 break;
320 default:
321 goto usage;
322 }
323 }
324
325 if (pAbc->Out == stdout){
326 for ( i = globalUtilOptind; i < argc; i++ )
327 Abc_Print( 1, "%s ", argv[i] );
328 if ( n )
329 Abc_Print( 1, "\n" );
330
331 }else{
332 for ( i = globalUtilOptind; i < argc; i++ )
333 fprintf( pAbc->Out, "%s ", argv[i] );
334 if ( n )
335 fprintf( pAbc->Out, "\n" );
336
337 fflush ( pAbc->Out );
338 }
339 return 0;
340
341 usage:
342 fprintf( pAbc->Err, "usage: echo [-h] string \n" );
343 fprintf( pAbc->Err, " -n \t\tsuppress newline at the end\n" );
344 fprintf( pAbc->Err, " -h \t\tprint the command usage\n" );
345 return ( 1 );
346}
347
359int CmdCommandQuit( Abc_Frame_t * pAbc, int argc, char **argv )
360{
361 int c;
362
364 while ( ( c = Extra_UtilGetopt( argc, argv, "hs" ) ) != EOF )
365 {
366 switch ( c )
367 {
368 case 'h':
369 goto usage;
370 break;
371 case 's':
372 return -2;
373 break;
374 default:
375 goto usage;
376 }
377 }
378
379 if ( argc != globalUtilOptind )
380 goto usage;
381 return -1;
382
383 usage:
384 fprintf( pAbc->Err, "usage: quit [-sh]\n" );
385 fprintf( pAbc->Err, " -h print the command usage\n" );
386 fprintf( pAbc->Err, " -s frees all the memory before quitting\n" );
387 return 1;
388}
389
401int CmdCommandAbcrc( Abc_Frame_t * pAbc, int argc, char **argv )
402{
403 int c;
404
406 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
407 {
408 switch ( c )
409 {
410 case 'h':
411 goto usage;
412 break;
413 default:
414 goto usage;
415 }
416 }
417 Abc_UtilsSource( pAbc );
418 return 0;
419
420 usage:
421 fprintf( pAbc->Err, "usage: abcrc [-h]\n" );
422 fprintf( pAbc->Err, " -h sources \"abc.rc\" from the current/parent/grandparent directory\n" );
423 return 1;
424}
425
437int CmdCommandHistory( Abc_Frame_t * pAbc, int argc, char **argv )
438{
439 char * pName, * pStr = NULL;
440 int i, c;
441 int nPrints = 20;
443 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
444 {
445 switch ( c )
446 {
447 case 'h':
448 goto usage;
449 default :
450 goto usage;
451 }
452 }
453 if ( argc > globalUtilOptind + 1 )
454 goto usage;
455 // get the number from the command line
456 pStr = argc == globalUtilOptind+1 ? argv[globalUtilOptind] : NULL;
457 if ( pStr && pStr[0] >= '1' && pStr[0] <= '9' )
458 nPrints = atoi(pStr), pStr = NULL;
459 // print the commands
460 if ( pStr == NULL ) {
461 Vec_PtrForEachEntryStart( char *, pAbc->aHistory, pName, i, Abc_MaxInt(0, Vec_PtrSize(pAbc->aHistory)-nPrints) )
462 fprintf( pAbc->Out, "%2d : %s\n", Vec_PtrSize(pAbc->aHistory)-i, pName );
463 }
464 else {
465 Vec_PtrForEachEntry( char *, pAbc->aHistory, pName, i )
466 if ( strstr(pName, pStr) )
467 fprintf( pAbc->Out, "%2d : %s\n", Vec_PtrSize(pAbc->aHistory)-i, pName );
468 }
469 return 0;
470
471usage:
472 fprintf( pAbc->Err, "usage: history [-h] <num>\n" );
473 fprintf( pAbc->Err, "\t lists the last commands entered on the command line\n" );
474 fprintf( pAbc->Err, "\t-h : print the command usage\n" );
475 fprintf( pAbc->Err, "\t<num> : the maximum number of entries to show [default = %d]\n", nPrints );
476 return ( 1 );
477}
478
490int CmdCommandAlias( Abc_Frame_t * pAbc, int argc, char **argv )
491{
492 const char *key;
493 char *value;
494 int c;
495
497 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
498 {
499 switch ( c )
500 {
501 case 'h':
502 goto usage;
503 break;
504 default:
505 goto usage;
506 }
507 }
508
509
510 if ( argc == 1 )
511 {
512 CmdPrintTable( pAbc->tAliases, 1 );
513 return 0;
514
515 }
516 else if ( argc == 2 )
517 {
518 if ( st__lookup( pAbc->tAliases, argv[1], &value ) )
519 CmdCommandAliasPrint( pAbc, ( Abc_Alias * ) value );
520 return 0;
521 }
522
523 // delete any existing alias
524 key = argv[1];
525 if ( st__delete( pAbc->tAliases, &key, &value ) )
527 CmdCommandAliasAdd( pAbc, argv[1], argc - 2, argv + 2 );
528 return 0;
529
530usage:
531 fprintf( pAbc->Err, "usage: alias [-h] [command [string]]\n" );
532 fprintf( pAbc->Err, " -h \t\tprint the command usage\n" );
533 return ( 1 );
534}
535
547int CmdCommandUnalias( Abc_Frame_t * pAbc, int argc, char **argv )
548{
549 int i;
550 const char *key;
551 char *value;
552 int c;
553
555 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
556 {
557 switch ( c )
558 {
559 case 'h':
560 goto usage;
561 break;
562 default:
563 goto usage;
564 }
565 }
566
567 if ( argc < 2 )
568 {
569 goto usage;
570 }
571
572 for ( i = 1; i < argc; i++ )
573 {
574 key = argv[i];
575 if ( st__delete( pAbc->tAliases, &key, &value ) )
576 {
578 }
579 }
580 return 0;
581
582 usage:
583 fprintf( pAbc->Err, "usage: unalias [-h] alias_names\n" );
584 fprintf( pAbc->Err, " -h \t\tprint the command usage\n" );
585 return 1;
586}
587
599int CmdCommandHelp( Abc_Frame_t * pAbc, int argc, char **argv )
600{
601 int fPrintAll, fDetails;
602 int c;
603
604 fPrintAll = 0;
605 fDetails = 0;
607 while ( ( c = Extra_UtilGetopt( argc, argv, "adh" ) ) != EOF )
608 {
609 switch ( c )
610 {
611 case 'a':
612 case 'v':
613 fPrintAll ^= 1;
614 break;
615 break;
616 case 'd':
617 fDetails ^= 1;
618 break;
619 case 'h':
620 goto usage;
621 break;
622 default:
623 goto usage;
624 }
625 }
626
627 if ( argc != globalUtilOptind )
628 goto usage;
629
630 CmdCommandPrint( pAbc, fPrintAll, fDetails );
631 return 0;
632
633usage:
634 fprintf( pAbc->Err, "usage: help [-a] [-d] [-h]\n" );
635 fprintf( pAbc->Err, " prints the list of available commands by group\n" );
636 fprintf( pAbc->Err, " -a toggle printing hidden commands [default = %s]\n", fPrintAll? "yes": "no" );
637 fprintf( pAbc->Err, " -d print usage details to all commands [default = %s]\n", fDetails? "yes": "no" );
638 fprintf( pAbc->Err, " -h print the command usage\n" );
639 return 1;
640}
641
653int CmdCommandSource( Abc_Frame_t * pAbc, int argc, char **argv )
654{
655 int c, echo, prompt, silent, interactive, quit_count, lp_count;
656 int status = 0; /* initialize so that lint doesn't complain */
657 int lp_file_index, did_subst;
658 char *prompt_string, *real_filename, line[ABC_MAX_STR], *command;
659 FILE *fp;
660
661 interactive = silent = prompt = echo = 0;
662
664 while ( ( c = Extra_UtilGetopt( argc, argv, "ipsxh" ) ) != EOF )
665 {
666 switch ( c )
667 {
668 case 'i': /* a hack to distinguish EOF from stdin */
669 interactive = 1;
670 break;
671 case 'p':
672 prompt ^= 1;
673 break;
674 case 's':
675 silent ^= 1;
676 break;
677 case 'x':
678 echo ^= 1;
679 break;
680 case 'h':
681 goto usage;
682 default:
683 goto usage;
684 }
685 }
686
687 /* added to avoid core-dumping when no script file is specified */
688 if ( argc == globalUtilOptind )
689 {
690 goto usage;
691 }
692
693 lp_file_index = globalUtilOptind;
694 lp_count = 0;
695
696 /*
697 * FIX (Tom, 5/7/95): I'm not sure what the purpose of this outer do loop
698 * is. In particular, lp_file_index is never modified in the loop, so it
699 * looks it would just read the same file over again. Also, SIS had
700 * lp_count initialized to -1, and hence, any file sourced by SIS (if -l or
701 * -t options on "source" were used in SIS) would actually be executed twice.
702 */
703 pAbc->fSource = 1;
704 do
705 {
706 char * pFileName, * pTemp;
707
708 // get the input file name
709 pFileName = argv[lp_file_index];
710 // fix the wrong symbol
711 for ( pTemp = pFileName; *pTemp; pTemp++ )
712 if ( *pTemp == '>' )
713 *pTemp = '\\';
714
715 lp_count++; /* increment the loop counter */
716
717 fp = CmdFileOpen( pAbc, pFileName, "r", &real_filename, silent );
718 if ( fp == NULL )
719 {
720 pAbc->fSource = 0;
721 ABC_FREE( real_filename );
722 return !silent; /* error return if not silent */
723 }
724
725 quit_count = 0;
726 do
727 {
728 if ( prompt )
729 {
730 prompt_string = Cmd_FlagReadByName( pAbc, "prompt" );
731 if ( prompt_string == NULL )
732 prompt_string = "abc> ";
733
734 }
735 else
736 {
737 prompt_string = NULL;
738 }
739
740 /* clear errors -- e.g., EOF reached from stdin */
741 clearerr( fp );
742
743 /* read another command line */
744 if ( fgets( line, ABC_MAX_STR, fp ) == NULL )
745 {
746 if ( interactive )
747 {
748 if ( quit_count++ < 5 )
749 {
750 fprintf( pAbc->Err, "\nUse \"quit\" to leave ABC.\n" );
751 continue;
752 }
753 status = -1; /* fake a 'quit' */
754 }
755 else
756 {
757 status = 0; /* successful end of 'source' ; loop? */
758 }
759 break;
760 }
761 quit_count = 0;
762
763 if ( echo )
764 {
765 fprintf( pAbc->Out, "abc - > %s", line );
766 }
767 command = CmdHistorySubstitution( pAbc, line, &did_subst );
768 if ( command == NULL )
769 {
770 status = 1;
771 break;
772 }
773 if ( did_subst )
774 {
775 if ( interactive )
776 {
777 fprintf( pAbc->Out, "%s\n", command );
778 }
779 }
780 if ( command != line )
781 {
782 strcpy( line, command );
783 }
784 if ( interactive && *line != '\0' )
785 {
786 Cmd_HistoryAddCommand( pAbc, line );
787 if ( pAbc->Hst != NULL )
788 {
789 fprintf( pAbc->Hst, "%s\n", line );
790 fflush( pAbc->Hst );
791 }
792 }
793
794 fflush( pAbc->Out );
795 status = Cmd_CommandExecute( pAbc, line );
796 }
797 while ( status == 0 );
798
799 if ( fp != stdin )
800 {
801 if ( status > 0 )
802 {
803 fprintf( pAbc->Err,
804 "** cmd error: aborting 'source %s'\n",
805 real_filename );
806 }
807 fclose( fp );
808 }
809 ABC_FREE( real_filename );
810
811 }
812 while ( ( status == 0 ) && ( lp_count <= 0 ) );
813 pAbc->fSource = 0;
814 return status;
815
816 usage:
817 fprintf( pAbc->Err, "usage: source [-psxh] <file_name>\n" );
818 fprintf( pAbc->Err, "\t-p supply prompt before reading each line [default = %s]\n", prompt? "yes": "no" );
819 fprintf( pAbc->Err, "\t-s silently ignore nonexistent file [default = %s]\n", silent? "yes": "no" );
820 fprintf( pAbc->Err, "\t-x echo each line as it is executed [default = %s]\n", echo? "yes": "no" );
821 fprintf( pAbc->Err, "\t-h print the command usage\n" );
822 return 1;
823}
824
836int CmdCommandSetVariable( Abc_Frame_t * pAbc, int argc, char **argv )
837{
838 char *flag_value, *value;
839 const char* key;
840 int c;
841
843 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
844 {
845 switch ( c )
846 {
847 case 'h':
848 goto usage;
849 default:
850 goto usage;
851 }
852 }
853 if ( argc == 0 || argc > 3 )
854 {
855 goto usage;
856 }
857 else if ( argc == 1 )
858 {
859 CmdPrintTable( pAbc->tFlags, 0 );
860 return 0;
861 }
862 else
863 {
864 key = argv[1];
865 if ( st__delete( pAbc->tFlags, &key, &value ) )
866 {
867 ABC_FREE( key );
868 ABC_FREE( value );
869 }
870
871 flag_value = argc == 2 ? Extra_UtilStrsav( "" ) : Extra_UtilStrsav( argv[2] );
872// flag_value = argc == 2 ? NULL : Extra_UtilStrsav(argv[2]);
873 st__insert( pAbc->tFlags, Extra_UtilStrsav(argv[1]), flag_value );
874
875 if ( strcmp( argv[1], "abcout" ) == 0 )
876 {
877 if ( pAbc->Out != stdout )
878 fclose( pAbc->Out );
879 if ( strcmp( flag_value, "" ) == 0 )
880 flag_value = "-";
881 pAbc->Out = CmdFileOpen( pAbc, flag_value, "w", NULL, 0 );
882 if ( pAbc->Out == NULL )
883 pAbc->Out = stdout;
884#if HAVE_SETVBUF
885 setvbuf( pAbc->Out, ( char * ) NULL, _IOLBF, 0 );
886#endif
887 }
888 if ( strcmp( argv[1], "abcerr" ) == 0 )
889 {
890 if ( pAbc->Err != stderr )
891 fclose( pAbc->Err );
892 if ( strcmp( flag_value, "" ) == 0 )
893 flag_value = "-";
894 pAbc->Err = CmdFileOpen( pAbc, flag_value, "w", NULL, 0 );
895 if ( pAbc->Err == NULL )
896 pAbc->Err = stderr;
897#if HAVE_SETVBUF
898 setvbuf( pAbc->Err, ( char * ) NULL, _IOLBF, 0 );
899#endif
900 }
901 if ( strcmp( argv[1], "history" ) == 0 )
902 {
903 if ( pAbc->Hst != NULL )
904 fclose( pAbc->Hst );
905 if ( strcmp( flag_value, "" ) == 0 )
906 pAbc->Hst = NULL;
907 else
908 {
909 pAbc->Hst = CmdFileOpen( pAbc, flag_value, "w", NULL, 0 );
910 if ( pAbc->Hst == NULL )
911 pAbc->Hst = NULL;
912 }
913 }
914 return 0;
915 }
916
917 usage:
918 fprintf( pAbc->Err, "usage: set [-h] <name> <value>\n" );
919 fprintf( pAbc->Err, "\t sets the value of parameter <name>\n" );
920 fprintf( pAbc->Err, "\t-h : print the command usage\n" );
921 return 1;
922
923}
924
936int CmdCommandUnsetVariable( Abc_Frame_t * pAbc, int argc, char **argv )
937{
938 int i;
939 const char *key;
940 char *value;
941 int c;
942
944 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
945 {
946 switch ( c )
947 {
948 case 'h':
949 goto usage;
950 break;
951 default:
952 goto usage;
953 }
954 }
955
956 if ( argc < 2 )
957 {
958 goto usage;
959 }
960
961 for ( i = 1; i < argc; i++ )
962 {
963 key = argv[i];
964 if ( st__delete( pAbc->tFlags, &key, &value ) )
965 {
966 ABC_FREE( key );
967 ABC_FREE( value );
968 }
969 }
970 return 0;
971
972
973 usage:
974 fprintf( pAbc->Err, "usage: unset [-h] <name> \n" );
975 fprintf( pAbc->Err, "\t removes the value of parameter <name>\n" );
976 fprintf( pAbc->Err, "\t-h : print the command usage\n" );
977 return 1;
978}
979
991int CmdCommandUndo( Abc_Frame_t * pAbc, int argc, char **argv )
992{
993 if ( argc == 2 && !strcmp(argv[1], "-h") )
994 goto usage;
995
996 if ( pAbc->pNtkCur == NULL )
997 {
998 fprintf( pAbc->Out, "Empty network.\n" );
999 return 0;
1000 }
1001
1002 // if there are no arguments on the command line
1003 // set the current network to be the network from the previous step
1004 if ( argc == 1 )
1005 return CmdCommandRecall( pAbc, argc, argv );
1006
1007usage:
1008 fprintf( pAbc->Err, "usage: undo\n" );
1009 fprintf( pAbc->Err, " sets the current network to be the previously saved network\n" );
1010 return 1;
1011
1012}
1013
1025int CmdCommandRecall( Abc_Frame_t * pAbc, int argc, char **argv )
1026{
1027 Abc_Ntk_t * pNtk;
1028 int iStep, iStepFound;
1029 int nNetsToSave, c;
1030 char * pValue;
1031 int iStepStart, iStepStop;
1032
1034 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
1035 {
1036 switch ( c )
1037 {
1038 case 'h':
1039 goto usage;
1040 default:
1041 goto usage;
1042 }
1043 }
1044
1045 if ( pAbc->pNtkCur == NULL )
1046 {
1047 fprintf( pAbc->Out, "Empty network.\n" );
1048 return 0;
1049 }
1050
1051 // get the number of networks to save
1052 pValue = Cmd_FlagReadByName( pAbc, "savesteps" );
1053 // if the value of steps to save is not set, assume 1-level undo
1054 if ( pValue == NULL )
1055 nNetsToSave = 1;
1056 else
1057 nNetsToSave = atoi(pValue);
1058
1059 // if there are no arguments on the command line
1060 // set the current network to be the network from the previous step
1061 if ( argc == 1 )
1062 {
1063 // get the previously saved network
1064 pNtk = Abc_NtkBackup(pAbc->pNtkCur);
1065 if ( pNtk == NULL )
1066 fprintf( pAbc->Out, "There is no previously saved network.\n" );
1067 else // set the current network to be the copy of the previous one
1069 return 0;
1070 }
1071 if ( argc == 2 ) // the second argument is the number of the step to return to
1072 {
1073 // read the number of the step to return to
1074 iStep = atoi(argv[1]);
1075 // check whether it is reasonable
1076 if ( iStep >= pAbc->nSteps )
1077 {
1078 iStepStart = pAbc->nSteps - nNetsToSave;
1079 if ( iStepStart <= 0 )
1080 iStepStart = 1;
1081 iStepStop = pAbc->nSteps;
1082 if ( iStepStop <= 0 )
1083 iStepStop = 1;
1084 if ( iStepStart == iStepStop )
1085 fprintf( pAbc->Out, "Can only recall step %d.\n", iStepStop );
1086 else
1087 fprintf( pAbc->Out, "Can only recall steps %d-%d.\n", iStepStart, iStepStop );
1088 }
1089 else if ( iStep < 0 )
1090 fprintf( pAbc->Out, "Cannot recall step %d.\n", iStep );
1091 else if ( iStep == 0 )
1093 else
1094 {
1095 // scroll backward through the list of networks
1096 // to determine if such a network exist
1097 iStepFound = 0;
1098 for ( pNtk = pAbc->pNtkCur; pNtk; pNtk = Abc_NtkBackup(pNtk) )
1099 if ( (iStepFound = Abc_NtkStep(pNtk)) == iStep )
1100 break;
1101 if ( pNtk == NULL )
1102 {
1103 iStepStart = iStepFound;
1104 if ( iStepStart <= 0 )
1105 iStepStart = 1;
1106 iStepStop = pAbc->nSteps;
1107 if ( iStepStop <= 0 )
1108 iStepStop = 1;
1109 if ( iStepStart == iStepStop )
1110 fprintf( pAbc->Out, "Can only recall step %d.\n", iStepStop );
1111 else
1112 fprintf( pAbc->Out, "Can only recall steps %d-%d.\n", iStepStart, iStepStop );
1113 }
1114 else
1116 }
1117 return 0;
1118 }
1119
1120usage:
1121
1122 fprintf( pAbc->Err, "usage: recall -h <num>\n" );
1123 fprintf( pAbc->Err, " set the current network to be one of the previous networks\n" );
1124 fprintf( pAbc->Err, "<num> : level to return to [default = previous]\n" );
1125 fprintf( pAbc->Err, " -h : print the command usage\n");
1126 return 1;
1127}
1128
1129
1141int CmdCommandEmpty( Abc_Frame_t * pAbc, int argc, char **argv )
1142{
1143 int c;
1144
1146 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
1147 {
1148 switch ( c )
1149 {
1150 case 'h':
1151 goto usage;
1152 default:
1153 goto usage;
1154 }
1155 }
1156
1158 Abc_FrameRestart( pAbc );
1159 return 0;
1160usage:
1161
1162 fprintf( pAbc->Err, "usage: empty [-h]\n" );
1163 fprintf( pAbc->Err, " removes all the currently stored networks\n" );
1164 fprintf( pAbc->Err, " -h : print the command usage\n");
1165 return 1;
1166}
1167
1168
1169#if 0
1170
1182int CmdCommandUndo( Abc_Frame_t * pAbc, int argc, char **argv )
1183{
1184 Abc_Ntk_t * pNtkTemp;
1185 int id, c;
1186
1187 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
1188 {
1189 switch ( c )
1190 {
1191 case 'h':
1192 goto usage;
1193 break;
1194 default:
1195 goto usage;
1196 }
1197 }
1198 if (globalUtilOptind <= argc) {
1199 pNtkTemp = pAbc->pNtk;
1200 pAbc->pNtk = pAbc->pNtkSaved;
1201 pAbc->pNtkSaved = pNtkTemp;
1202 }
1203 id = atoi(argv[globalUtilOptind]);
1204 pNtkTemp = Cmd_HistoryGetSnapshot(pAbc, id);
1205 if (!pNtkTemp)
1206 fprintf( pAbc->Err, "Snapshot %d does not exist\n", id);
1207 else
1208 pAbc->pNtk = Abc_NtkDup(pNtkTemp, Abc_NtkMan(pNtkTemp));
1209
1210 return 0;
1211usage:
1212 fprintf( pAbc->Err, "usage: undo\n" );
1213 fprintf( pAbc->Err, " swaps the current network and the backup network\n" );
1214 return 1;
1215}
1216
1217#endif
1218
1219
1220#if defined(WIN32)
1221#include <direct.h>
1222#include <io.h>
1223
1235int CmdCommandScanDir( Abc_Frame_t * pAbc, int argc, char **argv )
1236{
1237 struct _finddata_t c_file;
1238 char * pDirStr = NULL;
1239 char* pDirCur = NULL;
1240 ABC_PTRINT_T hFile;
1241 char c;
1242
1244 while ( (c = Extra_UtilGetopt(argc, argv, "D") ) != EOF )
1245 {
1246 switch (c)
1247 {
1248 case 'D':
1249 if ( globalUtilOptind >= argc )
1250 {
1251 fprintf( pAbc->Err, "Command line switch \"-D\" should be followed by a string.\n" );
1252 goto usage;
1253 }
1254 pDirStr = argv[globalUtilOptind];
1256 break;
1257 default:
1258 goto usage;
1259 }
1260 }
1261
1262
1263 if ( pDirStr )
1264 {
1265 if( (pDirCur = _getcwd( NULL, 0 )) == NULL )
1266 {
1267 printf( "Cannot read current directory\n" );
1268 return 0;
1269 }
1270 if ( _chdir(pDirStr) )
1271 {
1272 printf( "Cannot change to directory: %s\n", pDirStr );
1273 return 0;
1274 }
1275 }
1276
1277 if( (hFile = _findfirst( "*.txt", &c_file )) == -1L )
1278 {
1279 if ( pDirStr )
1280 printf( "No .txt files in the current directory.\n" );
1281 else
1282 printf( "No .txt files in directory: %s\n", pDirStr );
1283 }
1284 else
1285 {
1286 do
1287 {
1288 FILE * pFile = fopen( c_file.name, "rb" );
1289 char * pStr1 = "Property UNDECIDED. Time =";
1290 char * pStr2 = "Property proved. Time =";
1291 char * pStr3 = "Time =";
1292 char * pBuffer, * pPlace, * pThis, * pThat;
1293 char FileName[100];
1294 float Time = 0;
1295 // get the file name
1296 sprintf( FileName, "%s", c_file.name );
1297 pThis = strrchr( FileName, '_' );
1298 pThat = strchr( FileName, '.' );
1299 if ( pThis == NULL || pThat == NULL || pThis >= pThat )
1300 {
1301// printf( "Something is wrong with the file name %s\n", c_file.name );
1302 continue;
1303 }
1304 *pThat = 0;
1305 pThis++;
1306 // get the time
1307 if ( pFile == NULL )
1308 {
1309 printf( "Cannot open file %s\n", c_file.name );
1310 continue;
1311 }
1312 fclose( pFile );
1313 pBuffer = Extra_FileReadContents( c_file.name );
1314 pPlace = strstr( pBuffer, pStr1 );
1315 if ( pPlace == NULL )
1316 {
1317 pPlace = strstr( pBuffer, pStr2 );
1318 if ( pPlace == NULL )
1319 {
1320 pPlace = strstr( pBuffer, pStr3 );
1321 if ( pPlace == NULL )
1322 {
1323// printf( "Cannot find substrings in file %s\n", c_file.name );
1324 ABC_FREE( pBuffer );
1325 continue;
1326 }
1327 else
1328 pPlace += strlen( pStr3 );
1329 }
1330 else
1331 pPlace += strlen( pStr2 );
1332 }
1333 else
1334 pPlace += strlen( pStr1 );
1335 sscanf( pPlace, "%f", &Time );
1336 printf( "%s %.2f\n", pThis, Time );
1337 ABC_FREE( pBuffer );
1338 }
1339 while( _findnext( hFile, &c_file ) == 0 );
1340 _findclose( hFile );
1341 }
1342 if ( pDirStr )
1343 {
1344 if ( _chdir(pDirCur) )
1345 {
1346 ABC_FREE( pDirCur );
1347 printf( "Cannot change to directory: %s\n", pDirCur );
1348 return 0;
1349 }
1350 ABC_FREE( pDirCur );
1351 }
1352 return 0;
1353
1354usage:
1355 fprintf( pAbc->Err, "usage: scandir [-D string]\n" );
1356 fprintf( pAbc->Err, " performs custom scanning of the files in the given directory\n" );
1357 fprintf( pAbc->Err, "\t-D str : the directory to read files from [default = current]\n" );
1358 return 1;
1359}
1360
1361
1362
1374int CmfFindNumber( char * pName )
1375{
1376 char * pTemp;
1377 for ( pTemp = pName; *pTemp; pTemp++ )
1378 if ( *pTemp == '.' )
1379 break;
1380 if ( *pTemp == 0 )
1381 return -1;
1382 for ( --pTemp; pTemp > pName; pTemp-- )
1383 if ( *pTemp < '0' || *pTemp > '9' )
1384 {
1385 pTemp++;
1386 break;
1387 }
1388 if ( *pTemp == '.' )
1389 return -2;
1390 return atoi( pTemp );
1391}
1392
1404void CnfDupFileUnzip( char * pOldName )
1405{
1406 extern char * Io_MvLoadFileBz2( char * pFileName, long * pnFileSize );
1407 char pNewName[1000];
1408 FILE * pFile;
1409 long nFileSize;
1410 char * pBuffer = Io_MvLoadFileBz2( pOldName, &nFileSize );
1411 assert( strlen(pOldName) < 1000 );
1412 sprintf( pNewName, "%s.v", pOldName );
1413 pFile = fopen( pNewName, "wb" );
1414 fwrite( pBuffer, nFileSize, 1, pFile );
1415 fclose( pFile );
1416 ABC_FREE( pBuffer );
1417}
1418
1430int CmdCommandRenameFiles( Abc_Frame_t * pAbc, int argc, char **argv )
1431{
1432 struct _finddata_t c_file;
1433 ABC_PTRINT_T hFile;
1434 char pNewName[1000];
1435 char * pDirStr = NULL;
1436 char * pDirCur = NULL;
1437 char * pNameNew = NULL;
1438 char * pNameExt = NULL;
1439 int c, i, nBase = 0;
1441 while ( (c = Extra_UtilGetopt(argc, argv, "DENB") ) != EOF )
1442 {
1443 switch (c)
1444 {
1445 case 'D':
1446 if ( globalUtilOptind >= argc )
1447 {
1448 fprintf( pAbc->Err, "Command line switch \"-D\" should be followed by a string.\n" );
1449 goto usage;
1450 }
1451 pDirStr = argv[globalUtilOptind];
1453 break;
1454 case 'E':
1455 if ( globalUtilOptind >= argc )
1456 {
1457 fprintf( pAbc->Err, "Command line switch \"-E\" should be followed by a string.\n" );
1458 goto usage;
1459 }
1460 pNameExt = argv[globalUtilOptind];
1462 break;
1463 case 'N':
1464 if ( globalUtilOptind >= argc )
1465 {
1466 fprintf( pAbc->Err, "Command line switch \"-N\" should be followed by a string.\n" );
1467 goto usage;
1468 }
1469 pNameNew = argv[globalUtilOptind];
1471 break;
1472 case 'B':
1473 if ( globalUtilOptind >= argc )
1474 {
1475 fprintf( pAbc->Err, "Command line switch \"-B\" should be followed by a positive integer.\n" );
1476 goto usage;
1477 }
1478 nBase = atoi(argv[globalUtilOptind]);
1480 if ( nBase < 0 )
1481 goto usage;
1482 break;
1483 default:
1484 goto usage;
1485 }
1486 }
1487
1488 if ( pNameExt == NULL )
1489 {
1490 printf( "Extension of the files should be given on the command line.\n" );
1491 return 0;
1492 }
1493
1494 if ( pDirStr )
1495 {
1496 if( (pDirCur = _getcwd( NULL, 0 )) == NULL )
1497 {
1498 printf( "Cannot read current directory\n" );
1499 return 0;
1500 }
1501 if ( _chdir(pDirStr) )
1502 {
1503 printf( "Cannot change to directory: %s\n", pDirStr );
1504 return 0;
1505 }
1506 }
1507
1508 sprintf( pNewName, "*.%s", pNameExt );
1509 if( (hFile = _findfirst( pNewName, &c_file )) == -1L )
1510 {
1511 if ( pDirStr )
1512 printf( "No .aig files in the current directory.\n" );
1513 else
1514 printf( "No .aig files in directory: %s\n", pDirStr );
1515 }
1516 else
1517 {
1518 char * pName, * pOldName;
1519 int nDigits, * pOrder;
1520 Vec_Ptr_t * vNames = Vec_PtrAlloc( 1000 );
1521 Vec_Int_t * vNums = Vec_IntAlloc( 1000 );
1522 // collect names
1523 do {
1524 Vec_PtrPush( vNames, Abc_UtilStrsav(c_file.name) );
1525 } while( _findnext( hFile, &c_file ) == 0 );
1526 _findclose( hFile );
1527 // sort files by number
1528 Vec_PtrForEachEntry( char *, vNames, pName, i )
1529 {
1530 Vec_IntPush( vNums, CmfFindNumber(pName) );
1531 if ( Vec_IntEntryLast(vNums) < 0 )
1532 {
1533 printf( "Directory \"%s\" contains file (%s) with extension %s without number\n", pDirStr, pName, pNameExt );
1534 Vec_PtrFreeFree( vNames );
1535 Vec_IntFree( vNums );
1536 return 0;
1537 }
1538 }
1539 // sort by number
1540 pOrder = Abc_QuickSortCost( Vec_IntArray(vNums), Vec_IntSize(vNums), 0 );
1541 // rename files in that order
1542// nDigits = Abc_Base10Log( nBase + Vec_IntSize(vNums) );
1543 nDigits = Abc_Base10Log( nBase + Vec_IntEntry(vNums, pOrder[Vec_IntSize(vNums)-1]) + 1 );
1544 for ( i = 0; i < Vec_IntSize(vNums); i++ )
1545 {
1546 pOldName = (char *)Vec_PtrEntry( vNames, pOrder[i] );
1547 sprintf( pNewName, "%s%0*d.%s", pNameNew ? pNameNew : "", nDigits, nBase+Vec_IntEntry(vNums, pOrder[i]), pNameExt );
1548 rename( pOldName, pNewName );
1549 printf( "%s -> %s\n", pOldName, pNewName );
1550// CnfDupFileUnzip( pOldName );
1551 }
1552 // cleanup
1553 Vec_PtrFreeFree( vNames );
1554 Vec_IntFree( vNums );
1555 ABC_FREE( pOrder );
1556 }
1557 if ( pDirStr )
1558 {
1559 if ( _chdir(pDirCur) )
1560 {
1561 ABC_FREE( pDirCur );
1562 printf( "Cannot change to directory: %s\n", pDirCur );
1563 return 0;
1564 }
1565 ABC_FREE( pDirCur );
1566 }
1567 return 0;
1568
1569usage:
1570 fprintf( pAbc->Err, "usage: renamefiles [-DEN str] [-B num]\n" );
1571 fprintf( pAbc->Err, " performs renaming of files in the given directory\n" );
1572 fprintf( pAbc->Err, "\t-D str : the directory to read files from [default = current]\n" );
1573 fprintf( pAbc->Err, "\t-E str : the extension of files to look for [default = none]\n" );
1574 fprintf( pAbc->Err, "\t-N str : the root of the resulting files [default = none]\n" );
1575 fprintf( pAbc->Err, "\t-B num : the base number for all files [default = %d]\n", nBase );
1576 return 1;
1577}
1578
1579
1591int CmdCommandLs( Abc_Frame_t * pAbc, int argc, char **argv )
1592{
1593 struct _finddata_t c_file;
1594 ABC_PTRINT_T hFile;
1595 int fLong = 0;
1596 int fOnlyBLIF = 0;
1597 char Buffer[25];
1598 int Counter = 0;
1599 int fPrintedNewLine;
1600 char c;
1601
1603 while ( (c = Extra_UtilGetopt(argc, argv, "lb") ) != EOF )
1604 {
1605 switch (c)
1606 {
1607 case 'l':
1608 fLong = 1;
1609 break;
1610 case 'b':
1611 fOnlyBLIF = 1;
1612 break;
1613 default:
1614 goto usage;
1615 }
1616 }
1617
1618 // find first .mv file in current directory
1619 if( (hFile = _findfirst( ((fOnlyBLIF)? "*.mv": "*.*"), &c_file )) == -1L )
1620 {
1621 if ( fOnlyBLIF )
1622 fprintf( pAbc->Out, "No *.mv files in the current directory.\n" );
1623 else
1624 fprintf( pAbc->Out, "No files in the current directory.\n" );
1625 }
1626 else
1627 {
1628 if ( fLong )
1629 {
1630 fprintf( pAbc->Out, " File Date Size | File Date Size \n" );
1631 fprintf( pAbc->Out, " ----------------------------------------------------------------------------- \n" );
1632 do
1633 {
1634 strcpy( Buffer, ctime( &(c_file.time_write) ) );
1635 Buffer[16] = 0;
1636 fprintf( pAbc->Out, " %-17s %.24s%7ld", c_file.name, Buffer+4, c_file.size );
1637 if ( ++Counter % 2 == 0 )
1638 {
1639 fprintf( pAbc->Out, "\n" );
1640 fPrintedNewLine = 1;
1641 }
1642 else
1643 {
1644 fprintf( pAbc->Out, " |" );
1645 fPrintedNewLine = 0;
1646 }
1647 }
1648 while( _findnext( hFile, &c_file ) == 0 );
1649 }
1650 else
1651 {
1652 do
1653 {
1654 fprintf( pAbc->Out, " %-18s", c_file.name );
1655 if ( ++Counter % 4 == 0 )
1656 {
1657 fprintf( pAbc->Out, "\n" );
1658 fPrintedNewLine = 1;
1659 }
1660 else
1661 {
1662 fprintf( pAbc->Out, " " );
1663 fPrintedNewLine = 0;
1664 }
1665 }
1666 while( _findnext( hFile, &c_file ) == 0 );
1667 }
1668 if ( !fPrintedNewLine )
1669 fprintf( pAbc->Out, "\n" );
1670 _findclose( hFile );
1671 }
1672 return 0;
1673
1674usage:
1675 fprintf( pAbc->Err, "usage: ls [-l] [-b]\n" );
1676 fprintf( pAbc->Err, " print the file names in the current directory\n" );
1677 fprintf( pAbc->Err, " -l : print in the long format [default = short]\n" );
1678 fprintf( pAbc->Err, " -b : print only .mv files [default = all]\n" );
1679 return 1;
1680}
1681
1682
1694int CmdCommandScrGen( Abc_Frame_t * pAbc, int argc, char **argv )
1695{
1696 struct _finddata_t c_file;
1697 ABC_PTRINT_T hFile;
1698 FILE * pFile = NULL;
1699 char * pFileStr = "test.s";
1700 char * pDirStr = NULL;
1701 char * pComStr = "ps";
1702 char * pWriteStr = NULL;
1703 char Buffer[1000], Line[2000];
1704 int nFileNameMax, nFileNameCur;
1705 int Counter = 0;
1706 int fUseCurrent;
1707 int c;
1708
1709 fUseCurrent = 0;
1711 while ( (c = Extra_UtilGetopt(argc, argv, "FRCWch") ) != EOF )
1712 {
1713 switch (c)
1714 {
1715 case 'F':
1716 if ( globalUtilOptind >= argc )
1717 {
1718 fprintf( pAbc->Err, "Command line switch \"-F\" should be followed by a string.\n" );
1719 goto usage;
1720 }
1721 pFileStr = argv[globalUtilOptind];
1723 break;
1724 case 'R':
1725 if ( globalUtilOptind >= argc )
1726 {
1727 fprintf( pAbc->Err, "Command line switch \"-D\" should be followed by a string.\n" );
1728 goto usage;
1729 }
1730 pDirStr = argv[globalUtilOptind];
1732 break;
1733 case 'C':
1734 if ( globalUtilOptind >= argc )
1735 {
1736 fprintf( pAbc->Err, "Command line switch \"-C\" should be followed by a string.\n" );
1737 goto usage;
1738 }
1739 pComStr = argv[globalUtilOptind];
1741 break;
1742 case 'W':
1743 if ( globalUtilOptind >= argc )
1744 {
1745 fprintf( pAbc->Err, "Command line switch \"-W\" should be followed by a string.\n" );
1746 goto usage;
1747 }
1748 pWriteStr = argv[globalUtilOptind];
1750 break;
1751 case 'c':
1752 fUseCurrent ^= 1;
1753 break;
1754 default:
1755 goto usage;
1756 }
1757 }
1758
1759// printf( "File = %s.\n", pFileStr );
1760// printf( "Dir = %s.\n", pDirStr );
1761// printf( "Com = %s.\n", pComStr );
1762 if ( pDirStr == NULL )
1763 fUseCurrent = 1;
1764
1765 if ( _getcwd( Buffer, 1000 ) == NULL )
1766 {
1767 printf( "Cannot get the current directory.\n" );
1768 return 0;
1769 }
1770 if ( fUseCurrent )
1771 pFile = fopen( pFileStr, "w" );
1772 if ( pDirStr )
1773 {
1774 if ( _chdir(pDirStr) )
1775 {
1776 printf( "Cannot change to directory: %s\n", pDirStr );
1777 return 0;
1778 }
1779 }
1780 if ( !fUseCurrent )
1781 pFile = fopen( pFileStr, "w" );
1782 if ( pFile == NULL )
1783 {
1784 printf( "Cannot open file %s.\n", pFileStr );
1785 if ( pDirStr && _chdir(Buffer) )
1786 {
1787 printf( "Cannot change to the current directory: %s\n", Buffer );
1788 return 0;
1789 }
1790 return 0;
1791 }
1792
1793 // find the first file in the directory
1794 if( (hFile = _findfirst( "*.*", &c_file )) == -1L )
1795 {
1796 if ( pDirStr )
1797 printf( "No files in the current directory.\n" );
1798 else
1799 printf( "No files in directory: %s\n", pDirStr );
1800 if ( pDirStr && _chdir(Buffer) )
1801 {
1802 printf( "Cannot change to the current directory: %s\n", Buffer );
1803 return 0;
1804 }
1805 }
1806
1807 // get the longest file name
1808 {
1809 nFileNameMax = 0;
1810 do
1811 {
1812 // skip script and txt files
1813 nFileNameCur = strlen(c_file.name);
1814 if ( c_file.name[nFileNameCur-1] == '.' )
1815 continue;
1816 if ( nFileNameCur > 2 &&
1817 c_file.name[nFileNameCur-1] == 's' &&
1818 c_file.name[nFileNameCur-2] == '.' )
1819 continue;
1820 if ( nFileNameCur > 4 &&
1821 c_file.name[nFileNameCur-1] == 't' &&
1822 c_file.name[nFileNameCur-2] == 'x' &&
1823 c_file.name[nFileNameCur-3] == 't' &&
1824 c_file.name[nFileNameCur-4] == '.' )
1825 continue;
1826 if ( nFileNameMax < nFileNameCur )
1827 nFileNameMax = nFileNameCur;
1828 }
1829 while( _findnext( hFile, &c_file ) == 0 );
1830 _findclose( hFile );
1831 }
1832
1833 // print the script file
1834 {
1835 if( (hFile = _findfirst( "*.*", &c_file )) == -1L )
1836 {
1837 if ( pDirStr )
1838 printf( "No files in the current directory.\n" );
1839 else
1840 printf( "No files in directory: %s\n", pDirStr );
1841 }
1842 fprintf( pFile, "# Script file produced by ABC on %s\n", Extra_TimeStamp() );
1843 fprintf( pFile, "# Command line was: scrgen -F %s -D %s -C \"%s\"%s%s\n",
1844 pFileStr, pDirStr, pComStr, pWriteStr?" -W ":"", pWriteStr?pWriteStr:"" );
1845 do
1846 {
1847 // skip script and txt files
1848 nFileNameCur = strlen(c_file.name);
1849 if ( c_file.name[nFileNameCur-1] == '.' )
1850 continue;
1851 if ( nFileNameCur > 2 &&
1852 c_file.name[nFileNameCur-1] == 's' &&
1853 c_file.name[nFileNameCur-2] == '.' )
1854 continue;
1855 if ( nFileNameCur > 4 &&
1856 c_file.name[nFileNameCur-1] == 't' &&
1857 c_file.name[nFileNameCur-2] == 'x' &&
1858 c_file.name[nFileNameCur-3] == 't' &&
1859 c_file.name[nFileNameCur-4] == '.' )
1860 continue;
1861 sprintf( Line, "r %s%s%-*s ; %s", pDirStr?pDirStr:"", pDirStr?"/":"", nFileNameMax, c_file.name, pComStr );
1862 for ( c = (int)strlen(Line)-1; c >= 0; c-- )
1863 if ( Line[c] == '\\' )
1864 Line[c] = '/';
1865 fprintf( pFile, "%s", Line );
1866 if ( pWriteStr )
1867 {
1868 sprintf( Line, " ; w %s/%-*s", pWriteStr, nFileNameMax, c_file.name );
1869 for ( c = (int)strlen(Line)-1; c >= 0; c-- )
1870 if ( Line[c] == '\\' )
1871 Line[c] = '/';
1872 fprintf( pFile, "%s", Line );
1873 }
1874 fprintf( pFile, "\n" );
1875 }
1876 while( _findnext( hFile, &c_file ) == 0 );
1877 _findclose( hFile );
1878 }
1879 fclose( pFile );
1880 if ( pDirStr && _chdir(Buffer) )
1881 {
1882 printf( "Cannot change to the current directory: %s\n", Buffer );
1883 return 0;
1884 }
1885
1886 // report
1887 if ( fUseCurrent )
1888 printf( "Script file \"%s\" was saved in the current directory.\n", pFileStr );
1889 else
1890 printf( "Script file \"%s\" was saved in directory: %s\n", pFileStr, pDirStr );
1891 return 0;
1892
1893usage:
1894 fprintf( pAbc->Err, "usage: scrgen -F <str> -R <str> -C <str> -W <str> -ch\n" );
1895 fprintf( pAbc->Err, "\t generates script for running ABC\n" );
1896 fprintf( pAbc->Err, "\t-F str : the name of the script file [default = \"test.s\"]\n" );
1897 fprintf( pAbc->Err, "\t-R str : the directory to read files from [default = current]\n" );
1898 fprintf( pAbc->Err, "\t-C str : the sequence of commands to run [default = \"ps\"]\n" );
1899 fprintf( pAbc->Err, "\t-W str : the directory to write the resulting files [default = no writing]\n" );
1900 fprintf( pAbc->Err, "\t-c : toggle placing file in current/target dir [default = %s]\n", fUseCurrent? "current": "target" );
1901 fprintf( pAbc->Err, "\t-h : print the command usage\n\n");
1902 fprintf( pAbc->Err, "\tExample : scrgen -F test1.s -R a/in -C \"ps; st; ps\" -W a/out\n" );
1903 return 1;
1904}
1905
1906#else
1907
1908Vec_Ptr_t * CmdReturnFileNames( char * pDirStr )
1909{
1910 Vec_Ptr_t * vRes = Vec_PtrAlloc( 100 );
1911 struct dirent **namelist;
1912 int num_files = scandir(pDirStr, &namelist, NULL, alphasort);
1913 if (num_files == -1) {
1914 printf("Error opening directory.\n");
1915 return NULL;
1916 }
1917 for (int i = 0; i < num_files; i++) {
1918 char * pExt = strstr(namelist[i]->d_name, ".");
1919 if ( !pExt || !strcmp(pExt, ".") || !strcmp(pExt, "..") || !strcmp(pExt, ".s") || !strcmp(pExt, ".txt") )
1920 continue;
1921 Vec_PtrPush( vRes, Abc_UtilStrsav(namelist[i]->d_name) );
1922 free(namelist[i]);
1923 }
1924 free(namelist);
1925 return vRes;
1926}
1927
1928int CmdCommandScrGenLinux( Abc_Frame_t * pAbc, int argc, char **argv )
1929{
1930 Vec_Ptr_t * vNames = NULL;
1931 FILE * pFile = NULL;
1932 char * pFileStr = (char *)"test.s";
1933 char * pDirStr = (char *)".";
1934 char * pComStr = (char *)"ps";
1935 char * pWriteStr = NULL;
1936 char * pWriteExt = NULL;
1937 char Line[2000], * pName;
1938 int nFileNameMax;
1939 int fBatch = 0;
1940 int c, k;
1941
1943 while ( (c = Extra_UtilGetopt(argc, argv, "FRCWEbh") ) != EOF )
1944 {
1945 switch (c)
1946 {
1947 case 'F':
1948 if ( globalUtilOptind >= argc )
1949 {
1950 fprintf( pAbc->Err, "Command line switch \"-F\" should be followed by a string.\n" );
1951 goto usage;
1952 }
1953 pFileStr = argv[globalUtilOptind];
1955 break;
1956 case 'R':
1957 if ( globalUtilOptind >= argc )
1958 {
1959 fprintf( pAbc->Err, "Command line switch \"-D\" should be followed by a string.\n" );
1960 goto usage;
1961 }
1962 pDirStr = argv[globalUtilOptind];
1964 break;
1965 case 'C':
1966 if ( globalUtilOptind >= argc )
1967 {
1968 fprintf( pAbc->Err, "Command line switch \"-C\" should be followed by a string.\n" );
1969 goto usage;
1970 }
1971 pComStr = argv[globalUtilOptind];
1973 break;
1974 case 'W':
1975 if ( globalUtilOptind >= argc )
1976 {
1977 fprintf( pAbc->Err, "Command line switch \"-W\" should be followed by a string.\n" );
1978 goto usage;
1979 }
1980 pWriteStr = argv[globalUtilOptind];
1982 break;
1983 case 'E':
1984 if ( globalUtilOptind >= argc )
1985 {
1986 fprintf( pAbc->Err, "Command line switch \"-E\" should be followed by a string.\n" );
1987 goto usage;
1988 }
1989 pWriteExt = argv[globalUtilOptind];
1991 break;
1992 case 'b':
1993 fBatch ^= 1;
1994 break;
1995 default:
1996 goto usage;
1997 }
1998 }
1999 pFile = fopen( pFileStr, "w" );
2000 if ( pFile == NULL )
2001 {
2002 printf( "Cannot open output file %s.\n", pFileStr );
2003 return 0;
2004 }
2005 vNames = CmdReturnFileNames( pDirStr );
2006 if ( !vNames || !Vec_PtrSize(vNames) )
2007 {
2008 if ( vNames )
2009 printf( "It looks like the directory \"%s\" does not contain any relevant files.\n", pDirStr );
2010 Vec_PtrFreeP(&vNames);
2011 return 0;
2012 }
2013 nFileNameMax = 0;
2014 Vec_PtrForEachEntry( char *, vNames, pName, k )
2015 if ( nFileNameMax < strlen(pName) )
2016 nFileNameMax = strlen(pName);
2017 {
2018 int fAndSpace = pComStr[0] == '&';
2019 fprintf( pFile, "# Script file produced by ABC on %s\n", Extra_TimeStamp() );
2020 fprintf( pFile, "# Command line was: scrgen -F %s -D %s -C \"%s\"%s%s%s%s\n",
2021 pFileStr, pDirStr, pComStr,
2022 pWriteStr?" -W ":"", pWriteStr?pWriteStr:"",
2023 pWriteExt?" -E ":"", pWriteExt?pWriteExt:"" );
2024 Vec_PtrForEachEntry( char *, vNames, pName, k ) {
2025 char * pExt = strstr(pName, ".");
2026 if ( !pExt || !strcmp(pExt, ".") || !strcmp(pExt, "..") || !strcmp(pExt, ".s") || !strcmp(pExt, ".txt") )
2027 continue;
2028 sprintf( Line, "%s%sread %s%s%-*s ; %s", fBatch ? "./abc -q \"":"", fAndSpace ? "&" : "", pDirStr?pDirStr:"", pDirStr?"/":"", nFileNameMax, pName, pComStr );
2029 for ( c = (int)strlen(Line)-1; c >= 0; c-- )
2030 if ( Line[c] == '\\' )
2031 Line[c] = '/';
2032 fprintf( pFile, "%s", Line );
2033 if ( pWriteStr )
2034 {
2035 char * pFNameOut = pWriteExt ? Extra_FileNameGenericAppend(pName, pWriteExt) : pName;
2036 sprintf( Line, " ; %swrite %s/%-*s", fAndSpace ? "&" : "", pWriteStr, nFileNameMax, pFNameOut );
2037 for ( c = (int)strlen(Line)-1; c >= 0; c-- )
2038 if ( Line[c] == '\\' )
2039 Line[c] = '/';
2040 fprintf( pFile, "%s", Line );
2041 }
2042 if ( fBatch )
2043 fprintf( pFile, "\"" );
2044 fprintf( pFile, "\n" );
2045 }
2046 }
2047 fclose( pFile );
2048 printf( "Script file \"%s\" with command lines for %d files.\n", pFileStr, Vec_PtrSize(vNames) );
2049 Vec_PtrFreeFree( vNames );
2050 return 0;
2051
2052usage:
2053 fprintf( pAbc->Err, "usage: scrgen -F <str> -R <str> -C <str> -W <str> -E <str> -bh\n" );
2054 fprintf( pAbc->Err, "\t generates script for running ABC\n" );
2055 fprintf( pAbc->Err, "\t-F str : the name of the script file [default = \"test.s\"]\n" );
2056 fprintf( pAbc->Err, "\t-R str : the directory to read files from [default = current]\n" );
2057 fprintf( pAbc->Err, "\t-C str : the sequence of commands to run [default = \"ps\"]\n" );
2058 fprintf( pAbc->Err, "\t-W str : the directory to write the resulting files [default = no writing]\n" );
2059 fprintf( pAbc->Err, "\t-E str : the output files extension (with \".\") [default = the same as input files]\n" );
2060 fprintf( pAbc->Err, "\t-b : toggles adding batch mode support [default = %s]\n", fBatch? "yes": "no" );
2061 fprintf( pAbc->Err, "\t-h : print the command usage\n\n");
2062 fprintf( pAbc->Err, "\tExample : scrgen -F test1.s -R a/in -C \"ps; st; ps\" -W a/out -E .blif\n" );
2063 return 1;
2064}
2065
2066#endif
2067
2068
2069#ifdef WIN32
2070#define unlink _unlink
2071#endif
2072
2084int CmdCommandSis( Abc_Frame_t * pAbc, int argc, char **argv )
2085{
2086 FILE * pFile;
2087 FILE * pOut, * pErr;
2088 Abc_Ntk_t * pNtk, * pNtkNew, * pNetlist;
2089 char * pNameWin = "sis.exe";
2090 char * pNameUnix = "sis";
2091 char Command[1000], Buffer[100];
2092 char * pSisName;
2093 int i;
2094
2095 pNtk = Abc_FrameReadNtk(pAbc);
2096 pOut = Abc_FrameReadOut(pAbc);
2097 pErr = Abc_FrameReadErr(pAbc);
2098
2099 if ( argc == 1 )
2100 goto usage;
2101 if ( strcmp( argv[1], "-h" ) == 0 )
2102 goto usage;
2103 if ( strcmp( argv[1], "-?" ) == 0 )
2104 goto usage;
2105
2106 if ( pNtk == NULL )
2107 {
2108 fprintf( pErr, "Empty network.\n" );
2109 goto usage;
2110 }
2111
2112 if ( strcmp( argv[0], "sis" ) != 0 )
2113 {
2114 fprintf( pErr, "Wrong command: \"%s\".\n", argv[0] );
2115 goto usage;
2116 }
2117
2118 // get the names from the resource file
2119 if ( Cmd_FlagReadByName(pAbc, "siswin") )
2120 pNameWin = Cmd_FlagReadByName(pAbc, "siswin");
2121 if ( Cmd_FlagReadByName(pAbc, "sisunix") )
2122 pNameUnix = Cmd_FlagReadByName(pAbc, "sisunix");
2123
2124 // check if SIS is available
2125 if ( (pFile = fopen( pNameWin, "r" )) )
2126 pSisName = pNameWin;
2127 else if ( (pFile = fopen( pNameUnix, "r" )) )
2128 pSisName = pNameUnix;
2129 else if ( pFile == NULL )
2130 {
2131 fprintf( pErr, "Cannot find \"%s\" or \"%s\" in the current directory.\n", pNameWin, pNameUnix );
2132 goto usage;
2133 }
2134 fclose( pFile );
2135
2136 if ( Abc_NtkIsMappedLogic(pNtk) )
2137 {
2138 Abc_NtkMapToSop(pNtk);
2139 printf( "The current network is unmapped before calling SIS.\n" );
2140 }
2141
2142 // write out the current network
2143 if ( Abc_NtkIsLogic(pNtk) )
2144 Abc_NtkToSop(pNtk, -1, ABC_INFINITY);
2145 pNetlist = Abc_NtkToNetlist(pNtk);
2146 if ( pNetlist == NULL )
2147 {
2148 fprintf( pErr, "Cannot produce the intermediate network.\n" );
2149 goto usage;
2150 }
2151 Io_WriteBlif( pNetlist, "_sis_in.blif", 1, 0, 0 );
2152 Abc_NtkDelete( pNetlist );
2153
2154 // create the file for sis
2155 sprintf( Command, "%s -x -c ", pSisName );
2156 strcat ( Command, "\"" );
2157 strcat ( Command, "read_blif _sis_in.blif" );
2158 strcat ( Command, "; " );
2159 for ( i = 1; i < argc; i++ )
2160 {
2161 sprintf( Buffer, " %s", argv[i] );
2162 strcat( Command, Buffer );
2163 }
2164 strcat( Command, "; " );
2165 strcat( Command, "write_blif _sis_out.blif" );
2166 strcat( Command, "\"" );
2167
2168 // call SIS
2169 if ( Util_SignalSystem( Command ) )
2170 {
2171 fprintf( pErr, "The following command has returned non-zero exit status:\n" );
2172 fprintf( pErr, "\"%s\"\n", Command );
2173 unlink( "_sis_in.blif" );
2174 goto usage;
2175 }
2176
2177 // read in the SIS output
2178 if ( (pFile = fopen( "_sis_out.blif", "r" )) == NULL )
2179 {
2180 fprintf( pErr, "Cannot open SIS output file \"%s\".\n", "_sis_out.blif" );
2181 unlink( "_sis_in.blif" );
2182 goto usage;
2183 }
2184 fclose( pFile );
2185
2186 // set the new network
2187 pNtkNew = Io_Read( "_sis_out.blif", IO_FILE_BLIF, 1, 0 );
2188 // set the original spec of the new network
2189 if ( pNtk->pSpec )
2190 {
2191 ABC_FREE( pNtkNew->pSpec );
2192 pNtkNew->pSpec = Extra_UtilStrsav( pNtk->pSpec );
2193 }
2194 // replace the current network
2195 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew );
2196
2197 // remove temporary networks
2198 unlink( "_sis_in.blif" );
2199 unlink( "_sis_out.blif" );
2200 return 0;
2201
2202usage:
2203 fprintf( pErr, "Usage: sis [-h] <com>\n");
2204 fprintf( pErr, " invokes SIS command for the current ABC network\n" );
2205 fprintf( pErr, " (the executable of SIS should be in the same directory)\n" );
2206 fprintf( pErr, " -h : print the command usage\n" );
2207 fprintf( pErr, " <com> : a SIS command (or a semicolon-separated list of commands in quotes)\n" );
2208 fprintf( pErr, " Example 1: sis eliminate 0\n" );
2209 fprintf( pErr, " Example 2: sis \"ps; rd; fx; ps\"\n" );
2210 fprintf( pErr, " Example 3: sis source script.rugged\n" );
2211 return 1; // error exit
2212}
2213
2214
2226int CmdCommandMvsis( Abc_Frame_t * pAbc, int argc, char **argv )
2227{
2228 FILE * pFile;
2229 FILE * pOut, * pErr;
2230 Abc_Ntk_t * pNtk, * pNtkNew, * pNetlist;
2231 char Command[1000], Buffer[100];
2232 char * pNameWin = "mvsis.exe";
2233 char * pNameUnix = "mvsis";
2234 char * pMvsisName;
2235 int i;
2236
2237 pNtk = Abc_FrameReadNtk(pAbc);
2238 pOut = Abc_FrameReadOut(pAbc);
2239 pErr = Abc_FrameReadErr(pAbc);
2240
2241 if ( argc == 1 )
2242 goto usage;
2243 if ( strcmp( argv[1], "-h" ) == 0 )
2244 goto usage;
2245 if ( strcmp( argv[1], "-?" ) == 0 )
2246 goto usage;
2247
2248 if ( pNtk == NULL )
2249 {
2250 fprintf( pErr, "Empty network.\n" );
2251 goto usage;
2252 }
2253
2254 if ( strcmp( argv[0], "mvsis" ) != 0 )
2255 {
2256 fprintf( pErr, "Wrong command: \"%s\".\n", argv[0] );
2257 goto usage;
2258 }
2259
2260 // get the names from the resource file
2261 if ( Cmd_FlagReadByName(pAbc, "mvsiswin") )
2262 pNameWin = Cmd_FlagReadByName(pAbc, "mvsiswin");
2263 if ( Cmd_FlagReadByName(pAbc, "mvsisunix") )
2264 pNameUnix = Cmd_FlagReadByName(pAbc, "mvsisunix");
2265
2266 // check if MVSIS is available
2267 if ( (pFile = fopen( pNameWin, "r" )) )
2268 pMvsisName = pNameWin;
2269 else if ( (pFile = fopen( pNameUnix, "r" )) )
2270 pMvsisName = pNameUnix;
2271 else if ( pFile == NULL )
2272 {
2273 fprintf( pErr, "Cannot find \"%s\" or \"%s\" in the current directory.\n", pNameWin, pNameUnix );
2274 goto usage;
2275 }
2276 fclose( pFile );
2277
2278 if ( Abc_NtkIsMappedLogic(pNtk) )
2279 {
2280 Abc_NtkMapToSop(pNtk);
2281 printf( "The current network is unmapped before calling MVSIS.\n" );
2282 }
2283
2284 // write out the current network
2285 if ( Abc_NtkIsLogic(pNtk) )
2286 Abc_NtkToSop(pNtk, -1, ABC_INFINITY);
2287 pNetlist = Abc_NtkToNetlist(pNtk);
2288 if ( pNetlist == NULL )
2289 {
2290 fprintf( pErr, "Cannot produce the intermediate network.\n" );
2291 goto usage;
2292 }
2293 Io_WriteBlif( pNetlist, "_mvsis_in.blif", 1, 0, 0 );
2294 Abc_NtkDelete( pNetlist );
2295
2296 // create the file for MVSIS
2297 sprintf( Command, "%s -x -c ", pMvsisName );
2298 strcat ( Command, "\"" );
2299 strcat ( Command, "read_blif _mvsis_in.blif" );
2300 strcat ( Command, "; " );
2301 for ( i = 1; i < argc; i++ )
2302 {
2303 sprintf( Buffer, " %s", argv[i] );
2304 strcat( Command, Buffer );
2305 }
2306 strcat( Command, "; " );
2307 strcat( Command, "write_blif _mvsis_out.blif" );
2308 strcat( Command, "\"" );
2309
2310 // call MVSIS
2311 if ( Util_SignalSystem( Command ) )
2312 {
2313 fprintf( pErr, "The following command has returned non-zero exit status:\n" );
2314 fprintf( pErr, "\"%s\"\n", Command );
2315 unlink( "_mvsis_in.blif" );
2316 goto usage;
2317 }
2318
2319 // read in the MVSIS output
2320 if ( (pFile = fopen( "_mvsis_out.blif", "r" )) == NULL )
2321 {
2322 fprintf( pErr, "Cannot open MVSIS output file \"%s\".\n", "_mvsis_out.blif" );
2323 unlink( "_mvsis_in.blif" );
2324 goto usage;
2325 }
2326 fclose( pFile );
2327
2328 // set the new network
2329 pNtkNew = Io_Read( "_mvsis_out.blif", IO_FILE_BLIF, 1, 0 );
2330 // set the original spec of the new network
2331 if ( pNtk->pSpec )
2332 {
2333 ABC_FREE( pNtkNew->pSpec );
2334 pNtkNew->pSpec = Extra_UtilStrsav( pNtk->pSpec );
2335 }
2336 // replace the current network
2337 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew );
2338
2339 // remove temporary networks
2340 unlink( "_mvsis_in.blif" );
2341 unlink( "_mvsis_out.blif" );
2342 return 0;
2343
2344usage:
2345 fprintf( pErr, "Usage: mvsis [-h] <com>\n");
2346 fprintf( pErr, " invokes MVSIS command for the current ABC network\n" );
2347 fprintf( pErr, " (the executable of MVSIS should be in the same directory)\n" );
2348 fprintf( pErr, " -h : print the command usage\n" );
2349 fprintf( pErr, " <com> : a MVSIS command (or a semicolon-separated list of commands in quotes)\n" );
2350 fprintf( pErr, " Example 1: mvsis fraig_sweep\n" );
2351 fprintf( pErr, " Example 2: mvsis \"ps; fxu; ps\"\n" );
2352 fprintf( pErr, " Example 3: mvsis source mvsis.rugged\n" );
2353 return 1; // error exit
2354}
2355
2356
2368void Gia_ManGnuplotShow( char * pPlotFileName )
2369{
2370 FILE * pFile;
2371 void * pAbc;
2372 char * pProgNameGnuplotWin = "wgnuplot.exe";
2373 char * pProgNameGnuplotUnix = "gnuplot";
2374 char * pProgNameGnuplot = NULL;
2375
2376 // read in the Capo plotting output
2377 if ( (pFile = fopen( pPlotFileName, "r" )) == NULL )
2378 {
2379 fprintf( stdout, "Cannot open the plot file \"%s\".\n\n", pPlotFileName );
2380 return;
2381 }
2382 fclose( pFile );
2383
2384 pAbc = Abc_FrameGetGlobalFrame();
2385
2386 // get the names from the plotting software
2387 if ( Cmd_FlagReadByName((Abc_Frame_t *)pAbc, "gnuplotwin") )
2388 pProgNameGnuplotWin = Cmd_FlagReadByName((Abc_Frame_t *)pAbc, "gnuplotwin");
2389 if ( Cmd_FlagReadByName((Abc_Frame_t *)pAbc, "gnuplotunix") )
2390 pProgNameGnuplotUnix = Cmd_FlagReadByName((Abc_Frame_t *)pAbc, "gnuplotunix");
2391
2392 // check if Gnuplot is available
2393 if ( (pFile = fopen( pProgNameGnuplotWin, "r" )) )
2394 pProgNameGnuplot = pProgNameGnuplotWin;
2395 else if ( (pFile = fopen( pProgNameGnuplotUnix, "r" )) )
2396 pProgNameGnuplot = pProgNameGnuplotUnix;
2397 else if ( pFile == NULL )
2398 {
2399 fprintf( stdout, "Cannot find \"%s\" or \"%s\" in the current directory.\n", pProgNameGnuplotWin, pProgNameGnuplotUnix );
2400 return;
2401 }
2402 fclose( pFile );
2403
2404 // spawn the viewer
2405#ifdef WIN32
2406 if ( _spawnl( _P_NOWAIT, pProgNameGnuplot, pProgNameGnuplot, pPlotFileName, NULL ) == -1 )
2407 {
2408 fprintf( stdout, "Cannot find \"%s\".\n", pProgNameGnuplot );
2409 return;
2410 }
2411#else
2412 {
2413 char Command[1000];
2414 sprintf( Command, "%s %s ", pProgNameGnuplot, pPlotFileName );
2415#if defined(__wasm)
2416 if ( 1 )
2417#else
2418 if ( system( Command ) == -1 )
2419#endif
2420 {
2421 fprintf( stdout, "Cannot execute \"%s\".\n", Command );
2422 return;
2423 }
2424 }
2425#endif
2426}
2427
2439int CmdCommandCapo( Abc_Frame_t * pAbc, int argc, char **argv )
2440{
2441 FILE * pFile;
2442 FILE * pOut, * pErr;
2443 Abc_Ntk_t * pNtk, * pNetlist;
2444 char Command[1000], Buffer[100];
2445 char * pProgNameCapoWin = "capo.exe";
2446 char * pProgNameCapoUnix = "capo";
2447 char * pProgNameGnuplotWin = "wgnuplot.exe";
2448 char * pProgNameGnuplotUnix = "gnuplot";
2449 char * pProgNameCapo;
2450 char * pProgNameGnuplot;
2451 char * pPlotFileName;
2452 int i;
2453
2454 pNtk = Abc_FrameReadNtk(pAbc);
2455 pOut = Abc_FrameReadOut(pAbc);
2456 pErr = Abc_FrameReadErr(pAbc);
2457
2458 if ( argc > 1 )
2459 {
2460 if ( strcmp( argv[1], "-h" ) == 0 )
2461 goto usage;
2462 if ( strcmp( argv[1], "-?" ) == 0 )
2463 goto usage;
2464 }
2465
2466 if ( pNtk == NULL )
2467 {
2468 fprintf( pErr, "Empty network.\n" );
2469 goto usage;
2470 }
2471
2472 if ( strcmp( argv[0], "capo" ) != 0 )
2473 {
2474 fprintf( pErr, "Wrong command: \"%s\".\n", argv[0] );
2475 goto usage;
2476 }
2477
2478 // get the names from the resource file
2479 if ( Cmd_FlagReadByName(pAbc, "capowin") )
2480 pProgNameCapoWin = Cmd_FlagReadByName(pAbc, "capowin");
2481 if ( Cmd_FlagReadByName(pAbc, "capounix") )
2482 pProgNameCapoUnix = Cmd_FlagReadByName(pAbc, "capounix");
2483
2484 // check if capo is available
2485 if ( (pFile = fopen( pProgNameCapoWin, "r" )) )
2486 pProgNameCapo = pProgNameCapoWin;
2487 else if ( (pFile = fopen( pProgNameCapoUnix, "r" )) )
2488 pProgNameCapo = pProgNameCapoUnix;
2489 else if ( pFile == NULL )
2490 {
2491 fprintf( pErr, "Cannot find \"%s\" or \"%s\" in the current directory.\n", pProgNameCapoWin, pProgNameCapoUnix );
2492 goto usage;
2493 }
2494 fclose( pFile );
2495
2496 if ( Abc_NtkIsMappedLogic(pNtk) )
2497 {
2498 Abc_NtkMapToSop(pNtk);
2499 printf( "The current network is unmapped before calling Capo.\n" );
2500 }
2501
2502 // write out the current network
2503 if ( Abc_NtkIsLogic(pNtk) )
2504 Abc_NtkToSop(pNtk, -1, ABC_INFINITY);
2505 pNetlist = Abc_NtkToNetlist(pNtk);
2506 if ( pNetlist == NULL )
2507 {
2508 fprintf( pErr, "Cannot produce the intermediate network.\n" );
2509 goto usage;
2510 }
2511 Io_WriteBlif( pNetlist, "_capo_in.blif", 1, 0, 0 );
2512 Abc_NtkDelete( pNetlist );
2513
2514 // create the file for Capo
2515 sprintf( Command, "%s -f _capo_in.blif -log out.txt ", pProgNameCapo );
2516 pPlotFileName = NULL;
2517 for ( i = 1; i < argc; i++ )
2518 {
2519 sprintf( Buffer, " %s", argv[i] );
2520 strcat( Command, Buffer );
2521 if ( !strcmp( argv[i], "-plot" ) )
2522 pPlotFileName = argv[i+1];
2523 }
2524
2525 // call Capo
2526 if ( Util_SignalSystem( Command ) )
2527 {
2528 fprintf( pErr, "The following command has returned non-zero exit status:\n" );
2529 fprintf( pErr, "\"%s\"\n", Command );
2530 unlink( "_capo_in.blif" );
2531 goto usage;
2532 }
2533 // remove temporary networks
2534 unlink( "_capo_in.blif" );
2535 if ( pPlotFileName == NULL )
2536 return 0;
2537
2538 // get the file name
2539 sprintf( Buffer, "%s.plt", pPlotFileName );
2540 pPlotFileName = Buffer;
2541
2542 // read in the Capo plotting output
2543 if ( (pFile = fopen( pPlotFileName, "r" )) == NULL )
2544 {
2545 fprintf( pErr, "Cannot open the plot file \"%s\".\n\n", pPlotFileName );
2546 goto usage;
2547 }
2548 fclose( pFile );
2549
2550 // get the names from the plotting software
2551 if ( Cmd_FlagReadByName(pAbc, "gnuplotwin") )
2552 pProgNameGnuplotWin = Cmd_FlagReadByName(pAbc, "gnuplotwin");
2553 if ( Cmd_FlagReadByName(pAbc, "gnuplotunix") )
2554 pProgNameGnuplotUnix = Cmd_FlagReadByName(pAbc, "gnuplotunix");
2555
2556 // check if Gnuplot is available
2557 pProgNameGnuplot = NULL;
2558 if ( (pFile = fopen( pProgNameGnuplotWin, "r" )) )
2559 pProgNameGnuplot = pProgNameGnuplotWin;
2560 else if ( (pFile = fopen( pProgNameGnuplotUnix, "r" )) )
2561 pProgNameGnuplot = pProgNameGnuplotUnix;
2562 else if ( pFile == NULL )
2563 {
2564 fprintf( pErr, "Cannot find \"%s\" or \"%s\" in the current directory.\n", pProgNameGnuplotWin, pProgNameGnuplotUnix );
2565 goto usage;
2566 }
2567 fclose( pFile );
2568
2569 // spawn the viewer
2570#ifdef WIN32
2571 if ( _spawnl( _P_NOWAIT, pProgNameGnuplot, pProgNameGnuplot, pPlotFileName, NULL ) == -1 )
2572 {
2573 fprintf( stdout, "Cannot find \"%s\".\n", pProgNameGnuplot );
2574 goto usage;
2575 }
2576#else
2577 {
2578 sprintf( Command, "%s %s ", pProgNameGnuplot, pPlotFileName );
2579 if ( Util_SignalSystem( Command ) == -1 )
2580 {
2581 fprintf( stdout, "Cannot execute \"%s\".\n", Command );
2582 goto usage;
2583 }
2584 }
2585#endif
2586
2587 // remove temporary networks
2588// unlink( pPlotFileName );
2589 return 0;
2590
2591usage:
2592 fprintf( pErr, "Usage: capo [-h] <com>\n");
2593 fprintf( pErr, " peforms placement of the current network using Capo\n" );
2594 fprintf( pErr, " a Capo binary should be present in the same directory\n" );
2595 fprintf( pErr, " (if plotting, the Gnuplot binary should also be present)\n" );
2596 fprintf( pErr, " -h : print the command usage\n" );
2597 fprintf( pErr, " <com> : a Capo command\n" );
2598 fprintf( pErr, " Example 1: capo\n" );
2599 fprintf( pErr, " (performs placement with default options)\n" );
2600 fprintf( pErr, " Example 2: capo -AR <aspec_ratio> -WS <whitespace_percentage> -save\n" );
2601 fprintf( pErr, " (specifies the aspect ratio [default = 1.0] and\n" );
2602 fprintf( pErr, " the whitespace percentage [0%%; 100%%) [default = 15%%])\n" );
2603 fprintf( pErr, " Example 3: capo -plot <base_fileName>\n" );
2604 fprintf( pErr, " (produces <base_fileName.plt> and visualize it using Gnuplot)\n" );
2605 fprintf( pErr, " Example 4: capo -help\n" );
2606 fprintf( pErr, " (prints the default usage message of the Capo binary)\n" );
2607 fprintf( pErr, " Please refer to the Capo webpage for additional information:\n" );
2608 fprintf( pErr, " http://vlsicad.eecs.umich.edu/BK/PDtools/\n" );
2609 return 1; // error exit
2610}
2611
2623int CmdCommandStarter( Abc_Frame_t * pAbc, int argc, char ** argv )
2624{
2625 extern void Cmd_RunStarter( char * pFileName, char * pBinary, char * pCommand, int nCores, int fVerbose );
2626 FILE * pFile;
2627 char * pFileName;
2628 char * pCommand = NULL;
2629 int c, nCores = 3;
2630 int fVerbose = 0;
2632 while ( ( c = Extra_UtilGetopt( argc, argv, "PCvh" ) ) != EOF )
2633 {
2634 switch ( c )
2635 {
2636 case 'P':
2637 if ( globalUtilOptind >= argc )
2638 {
2639 Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
2640 goto usage;
2641 }
2642 nCores = atoi(argv[globalUtilOptind]);
2644 if ( nCores < 0 )
2645 goto usage;
2646 break;
2647 case 'C':
2648 if ( globalUtilOptind >= argc )
2649 {
2650 Abc_Print( -1, "Command line switch \"-C\" should be followed by a string (possibly in quotes).\n" );
2651 goto usage;
2652 }
2653 pCommand = argv[globalUtilOptind];
2655 break;
2656 case 'v':
2657 fVerbose ^= 1;
2658 break;
2659 case 'h':
2660 goto usage;
2661 default:
2662 goto usage;
2663 }
2664 }
2665 if ( argc != globalUtilOptind + 1 )
2666 {
2667 Abc_Print( -2, "The file name should be given on the command line.\n" );
2668 return 1;
2669 }
2670 // get the input file name
2671 pFileName = argv[globalUtilOptind];
2672 if ( (pFile = Io_FileOpen( pFileName, "open_path", "rb", 0 )) == NULL )
2673// if ( (pFile = fopen( pFileName, "rb" )) == NULL )
2674 {
2675 Abc_Print( -2, "Cannot open input file \"%s\". ", pFileName );
2676 if (( pFileName = Extra_FileGetSimilarName( pFileName, ".c", ".s", ".scr", ".script", NULL ) ))
2677 Abc_Print( -2, "Did you mean \"%s\"?", pFileName );
2678 Abc_Print( -2, "\n" );
2679 return 1;
2680 }
2681 fclose( pFile );
2682 // run commands
2683 Cmd_RunStarter( pFileName, pAbc->sBinary, pCommand, nCores, fVerbose );
2684 return 0;
2685
2686usage:
2687 Abc_Print( -2, "usage: starter [-P num] [-C cmd] [-vh] <file>\n" );
2688 Abc_Print( -2, "\t runs command lines listed in <file> concurrently on <num> CPUs\n" );
2689 Abc_Print( -2, "\t-P num : the number of concurrent jobs including the controller [default = %d]\n", nCores );
2690 Abc_Print( -2, "\t-C cmd : (optional) ABC command line to execute on benchmarks in <file>\n" );
2691 Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
2692 Abc_Print( -2, "\t-h : print the command usage\n");
2693 Abc_Print( -2, "\t<file> : file name with ABC command lines (or benchmark names, if <cmd> is given)\n");
2694 return 1;
2695}
2696
2708int CmdCommandAutoTuner( Abc_Frame_t * pAbc, int argc, char ** argv )
2709{
2710 extern void Cmd_RunAutoTuner( char * pConfig, char * pFileList, int nCores );
2711 FILE * pFile;
2712 char * pFileConf = NULL;
2713 char * pFileList = NULL;
2714 char * pFileName;
2715 int c, nCores = 3;
2716 int fVerbose = 0;
2718 while ( ( c = Extra_UtilGetopt( argc, argv, "NCFvh" ) ) != EOF )
2719 {
2720 switch ( c )
2721 {
2722 case 'N':
2723 if ( globalUtilOptind >= argc )
2724 {
2725 Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
2726 goto usage;
2727 }
2728 nCores = atoi(argv[globalUtilOptind]);
2730 if ( nCores < 0 )
2731 goto usage;
2732 break;
2733 case 'C':
2734 if ( globalUtilOptind >= argc )
2735 {
2736 Abc_Print( -1, "Command line switch \"-C\" should be followed by a string (possibly in quotes).\n" );
2737 goto usage;
2738 }
2739 pFileConf = argv[globalUtilOptind];
2741 break;
2742 case 'F':
2743 if ( globalUtilOptind >= argc )
2744 {
2745 Abc_Print( -1, "Command line switch \"-F\" should be followed by a string (possibly in quotes).\n" );
2746 goto usage;
2747 }
2748 pFileList = argv[globalUtilOptind];
2750 break;
2751 case 'v':
2752 fVerbose ^= 1;
2753 break;
2754 case 'h':
2755 goto usage;
2756 default:
2757 goto usage;
2758 }
2759 }
2760 if ( pFileConf == NULL )
2761 {
2762 Abc_Print( -2, "File containing configuration for autotuning is not given.\n" );
2763 return 1;
2764 }
2765 if ( pFileList == NULL )
2766 {
2767 Abc_Print( -2, "File contining list of files for autotuning is not given.\n" );
2768 return 1;
2769 }
2770 // get the input file name
2771 pFileName = pFileConf;
2772 if ( (pFile = Io_FileOpen( pFileName, "open_path", "rb", 0 )) == NULL )
2773// if ( (pFile = fopen( pFileName, "rb" )) == NULL )
2774 {
2775 Abc_Print( -2, "Cannot open configuration file \"%s\". ", pFileName );
2776 if (( pFileName = Extra_FileGetSimilarName( pFileName, ".c", ".s", ".scr", ".script", NULL ) ))
2777 Abc_Print( -2, "Did you mean \"%s\"?", pFileName );
2778 Abc_Print( -2, "\n" );
2779 return 1;
2780 }
2781 fclose( pFile );
2782 // get the input file name
2783 pFileName = pFileList;
2784 if ( (pFile = Io_FileOpen( pFileName, "open_path", "rb", 0 )) == NULL )
2785// if ( (pFile = fopen( pFileName, "rb" )) == NULL )
2786 {
2787 Abc_Print( -2, "Cannot open the file list \"%s\". ", pFileName );
2788 if (( pFileName = Extra_FileGetSimilarName( pFileName, ".c", ".s", ".scr", ".script", NULL ) ))
2789 Abc_Print( -2, "Did you mean \"%s\"?", pFileName );
2790 Abc_Print( -2, "\n" );
2791 return 1;
2792 }
2793 fclose( pFile );
2794 // run commands
2795 Cmd_RunAutoTuner( pFileConf, pFileList, nCores );
2796 return 0;
2797
2798usage:
2799 Abc_Print( -2, "usage: autotuner [-N num] [-C file] [-F file] [-vh]\n" );
2800 Abc_Print( -2, "\t performs autotuning\n" );
2801 Abc_Print( -2, "\t-N num : the number of concurrent jobs including the controller [default = %d]\n", nCores );
2802 Abc_Print( -2, "\t-C cmd : configuration file with settings for autotuning\n" );
2803 Abc_Print( -2, "\t-F cmd : list of AIGER files to be used for autotuning\n" );
2804 Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
2805 Abc_Print( -2, "\t-h : print the command usage\n");
2806 return 1;
2807}
2808
2820int CmdCommandVersion( Abc_Frame_t * pAbc, int argc, char **argv )
2821{
2822 int c;
2823
2825 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
2826 {
2827 switch ( c )
2828 {
2829 case 'h':
2830 goto usage;
2831 default:
2832 goto usage;
2833 }
2834 }
2835
2836 printf("%s\n", Abc_UtilsGetVersion(pAbc));
2837 return 0;
2838
2839usage:
2840 fprintf( pAbc->Err, "usage: version [-h]\n" );
2841 fprintf( pAbc->Err, " print the version string\n" );
2842 fprintf( pAbc->Err, " -h : print the command usage\n");
2843 return 1;
2844}
2845
2857int CmdCommandSGen( Abc_Frame_t * pAbc, int argc, char ** argv )
2858{
2859 extern void Cmd_CommandSGen( Abc_Frame_t * pAbc, int nParts, int nIters, int fVerbose );
2860 int c, nParts = 10;
2861 int nIters = 10;
2862 int fVerbose = 0;
2864 while ( ( c = Extra_UtilGetopt( argc, argv, "NIvh" ) ) != EOF )
2865 {
2866 switch ( c )
2867 {
2868 case 'N':
2869 if ( globalUtilOptind >= argc )
2870 {
2871 Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
2872 goto usage;
2873 }
2874 nParts = atoi(argv[globalUtilOptind]);
2876 if ( nParts < 0 )
2877 goto usage;
2878 break;
2879 case 'I':
2880 if ( globalUtilOptind >= argc )
2881 {
2882 Abc_Print( -1, "Command line switch \"-I\" should be followed by a string (possibly in quotes).\n" );
2883 goto usage;
2884 }
2885 nIters = atoi(argv[globalUtilOptind]);
2887 break;
2888 case 'v':
2889 fVerbose ^= 1;
2890 break;
2891 case 'h':
2892 goto usage;
2893 default:
2894 goto usage;
2895 }
2896 }
2897 if ( Abc_FrameReadNtk(pAbc) == NULL )
2898 {
2899 Abc_Print( -2, "There is no current network.\n" );
2900 return 1;
2901 }
2902 if ( !Abc_NtkIsStrash(Abc_FrameReadNtk(pAbc)) )
2903 {
2904 Abc_Print( -2, "The current network is not an AIG.\n" );
2905 return 1;
2906 }
2907 Cmd_CommandSGen( pAbc, nParts, nIters, fVerbose );
2908 return 0;
2909
2910usage:
2911 Abc_Print( -2, "usage: sgen [-N num] [-I num] [-vh]\n" );
2912 Abc_Print( -2, "\t experiment with script generation\n" );
2913 Abc_Print( -2, "\t-N num : the number of commands to use [default = %d]\n", nParts );
2914 Abc_Print( -2, "\t-I num : the number of iterations to perform [default = %d]\n", nIters );
2915 Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
2916 Abc_Print( -2, "\t-h : print the command usage\n");
2917 return 1;
2918}
2919
2923
2924
ABC_DLL int Abc_NtkMapToSop(Abc_Ntk_t *pNtk)
Definition abcFunc.c:1228
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
ABC_DLL Abc_Ntk_t * Abc_NtkToNetlist(Abc_Ntk_t *pNtk)
Definition abcNetlist.c:100
ABC_DLL int Abc_NtkToSop(Abc_Ntk_t *pNtk, int fMode, int nCubeLimit)
Definition abcFunc.c:1261
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition abcNtk.c:1421
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition abcNtk.c:472
ABC_INT64_T abctime
Definition abc_global.h:332
int * Abc_QuickSortCost(int *pCosts, int nSize, int fDecrease)
Definition utilSort.c:923
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
Definition abcapis.h:38
ABC_DLL Abc_Frame_t * Abc_FrameGetGlobalFrame()
Definition mainFrame.c:643
ABC_DLL void Abc_FrameDeleteAllNetworks(Abc_Frame_t *p)
Definition mainFrame.c:596
ABC_DLL Abc_Ntk_t * Abc_FrameReadNtk(Abc_Frame_t *p)
Definition mainFrame.c:327
ABC_DLL FILE * Abc_FrameReadErr(Abc_Frame_t *p)
Definition mainFrame.c:375
ABC_DLL void Abc_FrameReplaceCurrentNetwork(Abc_Frame_t *p, Abc_Ntk_t *pNet)
Definition mainFrame.c:538
ABC_DLL FILE * Abc_FrameReadOut(Abc_Frame_t *p)
Definition mainFrame.c:359
ABC_DLL void Abc_FrameRestart(Abc_Frame_t *p)
Definition mainFrame.c:277
ABC_DLL void Abc_FrameSetCurrentNetwork(Abc_Frame_t *p, Abc_Ntk_t *pNet)
Definition mainFrame.c:441
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
ABC_NAMESPACE_IMPL_START typedef signed char value
ABC_NAMESPACE_IMPL_START void CmdCommandAliasAdd(Abc_Frame_t *pAbc, char *sName, int argc, char **argv)
DECLARATIONS ///.
Definition cmdAlias.c:46
void CmdCommandAliasFree(Abc_Alias *pAlias)
Definition cmdAlias.c:113
void CmdCommandAliasPrint(Abc_Frame_t *pAbc, Abc_Alias *pAlias)
Definition cmdAlias.c:72
void Cmd_RunAutoTuner(char *pConfig, char *pFileList, int nCores)
Definition cmdAuto.c:636
FILE * CmdFileOpen(Abc_Frame_t *pAbc, char *sFileName, char *sMode, char **pFileNameReal, int silent)
Definition cmdUtils.c:412
void CmdCommandFree(Abc_Command *pCommand)
Definition cmdUtils.c:539
char * CmdHistorySubstitution(Abc_Frame_t *pAbc, char *line, int *changed)
Definition cmdUtils.c:394
void CmdCommandPrint(Abc_Frame_t *pAbc, int fPrintAll, int fDetails)
Definition cmdUtils.c:558
void CmdPrintTable(st__table *tTable, int fAliases)
Definition cmdUtils.c:726
ABC_NAMESPACE_IMPL_START void Cmd_RunStarter(char *pFileName, char *pBinary, char *pCommand, int nCores, int fVerbose)
DECLARATIONS ///.
Definition cmdStarter.c:47
void Cmd_CommandSGen(Abc_Frame_t *pAbc, int nParts, int nIters, int fVerbose)
Definition cmdUtils.c:861
void Gia_ManGnuplotShow(char *pPlotFileName)
Definition cmd.c:2368
void Cmd_Init(Abc_Frame_t *pAbc)
FUNCTION DEFINITIONS ///.
Definition cmd.c:85
void Cmd_End(Abc_Frame_t *pAbc)
Definition cmd.c:139
int Cmd_CommandAbcLoadPlugIn(Abc_Frame_t *pAbc, int argc, char **argv)
Definition cmdPlugin.c:631
Vec_Ptr_t * CmdReturnFileNames(char *pDirStr)
Definition cmd.c:1908
char * Cmd_FlagReadByName(Abc_Frame_t *pAbc, char *flag)
DECLARATIONS ///.
Definition cmdFlag.c:47
void Cmd_HistoryWrite(Abc_Frame_t *p, int Limit)
Definition cmdHist.c:134
void Cmd_CommandAdd(Abc_Frame_t *pAbc, const char *sGroup, const char *sName, Cmd_CommandFuncType pFunc, int fChanges)
Definition cmdApi.c:63
struct MvAlias Abc_Alias
Definition cmd.h:40
void Cmd_HistoryRead(Abc_Frame_t *p)
Definition cmdHist.c:103
typedefABC_NAMESPACE_HEADER_START struct MvCommand Abc_Command
INCLUDES ///.
Definition cmd.h:39
void Cmd_HistoryAddCommand(Abc_Frame_t *pAbc, const char *command)
FUNCTION DEFINITIONS ///.
Definition cmdHist.c:50
ABC_DLL int Cmd_CommandExecute(Abc_Frame_t *pAbc, const char *sCommand)
Definition cmdApi.c:193
int globalUtilOptind
char * Extra_FileGetSimilarName(char *pFileNameWrong, char *pS1, char *pS2, char *pS3, char *pS4, char *pS5)
char * Extra_UtilStrsav(const char *s)
int Extra_UtilGetopt(int argc, char *argv[], const char *optstring)
char * Extra_TimeStamp()
ABC_DLL void Extra_UtilGetoptReset()
char * Extra_FileNameGenericAppend(char *pBase, char *pSuffix)
char * Extra_FileReadContents(char *pFileName)
@ IO_FILE_BLIF
Definition ioAbc.h:52
void Io_WriteBlif(Abc_Ntk_t *pNtk, char *pFileName, int fWriteLatches, int fBb2Wb, int fSeq)
Definition ioWriteBlif.c:84
FILE * Io_FileOpen(const char *FileName, const char *PathVar, const char *Mode, int fVerbose)
Definition ioUtil.c:828
Abc_Ntk_t * Io_Read(char *pFileName, Io_FileType_t FileType, int fCheck, int fBarBufs)
Definition ioUtil.c:241
char * Io_MvLoadFileBz2(char *pFileName, long *pnFileSize)
#define ABC_MAX_STR
Definition mainInt.h:52
ABC_DLL void Abc_UtilsSource(Abc_Frame_t *pAbc)
Definition mainUtils.c:160
ABC_DLL char * Abc_UtilsGetVersion(Abc_Frame_t *pAbc)
FUNCTION DEFINITIONS ///.
Definition mainUtils.c:52
usage()
Definition main.c:626
enum keys key
Definition main.h:25
int st__delete(st__table *table, const char **keyp, char **value)
Definition st.c:375
int st__strhash(const char *string, int modulus)
Definition st.c:449
int st__lookup(st__table *table, const char *key, char **value)
Definition st.c:114
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition st.c:72
int st__insert(st__table *table, const char *key, char *value)
Definition st.c:171
void st__free_table(st__table *table)
Definition st.c:81
#define st__foreach_item(table, gen, key, value)
Definition st.h:107
char * pSpec
Definition abc.h:159
ABC_NAMESPACE_IMPL_START int Util_SignalSystem(const char *cmd)
DECLARATIONS ///.
Definition utilSignal.c:44
#define assert(ex)
Definition util_old.h:213
VOID_HACK clearerr()
char * strrchr()
int strlen()
int system()
int strcmp()
char * sprintf()
char * strstr()
char * strcpy()
VOID_HACK free()
char * strchr()
char * strcat()
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition vecPtr.h:57
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55