52 #if defined(WIN32) && !defined(__cplusplus)
53 static int CmdCommandScanDir (
Abc_Frame_t * pAbc,
int argc,
char ** argv );
54 static int CmdCommandRenameFiles (
Abc_Frame_t * pAbc,
int argc,
char ** argv );
55 static int CmdCommandLs (
Abc_Frame_t * pAbc,
int argc,
char ** argv );
56 static int CmdCommandScrGen (
Abc_Frame_t * pAbc,
int argc,
char ** argv );
100 #if defined(WIN32) && !defined(__cplusplus)
102 Cmd_CommandAdd( pAbc,
"Basic",
"renamefiles", CmdCommandRenameFiles, 0 );
130 char * pKey, * pValue;
137 st__foreach_item( pAbc->tCommands, gen, (
const char **)&pKey, (
char **)&pValue )
141 st__foreach_item( pAbc->tAliases, gen, (
const char **)&pKey, (
char **)&pValue )
145 st__foreach_item( pAbc->tFlags, gen, (
const char **)&pKey, (
char **)&pValue )
188 pAbc->TimeTotal += pAbc->TimeCommand;
189 pAbc->TimeCommand = 0.0;
199 pAbc->TimeTotal += pAbc->TimeCommand;
200 fprintf( pAbc->Out,
"elapse: %3.2f seconds, total: %3.2f seconds\n",
201 pAbc->TimeCommand, pAbc->TimeTotal );
210 pAbc->TimeCommand = 0.0;
214 fprintf( pAbc->Err,
"usage: time [-ch]\n" );
215 fprintf( pAbc->Err,
" \t\tprint the runtime since the last call\n" );
216 fprintf( pAbc->Err,
" -c \t\tclears the elapsed time without printing it\n" );
217 fprintf( pAbc->Err,
" -h \t\tprint the command usage\n" );
254 if (pAbc->Out == stdout){
262 fprintf( pAbc->Out,
"%s ", argv[i] );
264 fprintf( pAbc->Out,
"\n" );
266 fflush ( pAbc->Out );
271 fprintf( pAbc->Err,
"usage: echo [-h] string \n" );
272 fprintf( pAbc->Err,
" -n \t\tsuppress newline at the end\n" );
273 fprintf( pAbc->Err,
" -h \t\tprint the command usage\n" );
313 fprintf( pAbc->Err,
"usage: quit [-h] [-s]\n" );
314 fprintf( pAbc->Err,
" -h print the command usage\n" );
316 " -s frees all the memory before quitting\n" );
370 fprintf( pAbc->Out,
"%2d : %s\n",
Vec_PtrSize(pAbc->aHistory)-i, pName );
374 fprintf( pAbc->Err,
"usage: history [-h] <num>\n" );
375 fprintf( pAbc->Err,
"\t lists the last commands entered on the command line\n" );
376 fprintf( pAbc->Err,
"\t-h : print the command usage\n" );
377 fprintf( pAbc->Err,
"\t<num> : the maximum number of entries to show [default = %d]\n", nPrints );
418 else if ( argc == 2 )
420 if (
st__lookup( pAbc->tAliases, argv[1], &value ) )
427 if (
st__delete( pAbc->tAliases, &key, &value ) )
433 fprintf( pAbc->Err,
"usage: alias [-h] [command [string]]\n" );
434 fprintf( pAbc->Err,
" -h \t\tprint the command usage\n" );
474 for ( i = 1; i < argc; i++ )
477 if (
st__delete( pAbc->tAliases, &key, &value ) )
485 fprintf( pAbc->Err,
"usage: unalias [-h] alias_names\n" );
486 fprintf( pAbc->Err,
" -h \t\tprint the command usage\n" );
503 int fPrintAll, fDetails;
536 fprintf( pAbc->Err,
"usage: help [-a] [-d] [-h]\n" );
537 fprintf( pAbc->Err,
" prints the list of available commands by group\n" );
538 fprintf( pAbc->Err,
" -a toggle printing hidden commands [default = %s]\n", fPrintAll?
"yes":
"no" );
539 fprintf( pAbc->Err,
" -d print usage details to all commands [default = %s]\n", fDetails?
"yes":
"no" );
540 fprintf( pAbc->Err,
" -h print the command usage\n" );
557 int c, echo, prompt, silent, interactive, quit_count, lp_count;
559 int lp_file_index, did_subst;
560 char *prompt_string, *real_filename, line[
ABC_MAX_STR], *command;
563 interactive = silent = prompt = echo = 0;
608 char * pFileName, * pTemp;
611 pFileName = argv[lp_file_index];
613 for ( pTemp = pFileName; *pTemp; pTemp++ )
619 fp =
CmdFileOpen( pAbc, pFileName,
"r", &real_filename, silent );
633 if ( prompt_string == NULL )
634 prompt_string =
"abc> ";
639 prompt_string = NULL;
650 if ( quit_count++ < 5 )
652 fprintf( pAbc->Err,
"\nUse \"quit\" to leave ABC.\n" );
667 fprintf( pAbc->Out,
"abc - > %s", line );
670 if ( command == NULL )
679 fprintf( pAbc->Out,
"%s\n", command );
682 if ( command != line )
686 if ( interactive && *line !=
'\0' )
689 if ( pAbc->Hst != NULL )
691 fprintf( pAbc->Hst,
"%s\n", line );
699 while ( status == 0 );
706 "** cmd error: aborting 'source %s'\n",
714 while ( ( status == 0 ) && ( lp_count <= 0 ) );
719 fprintf( pAbc->Err,
"usage: source [-psxh] <file_name>\n" );
720 fprintf( pAbc->Err,
"\t-p supply prompt before reading each line [default = %s]\n", prompt?
"yes":
"no" );
721 fprintf( pAbc->Err,
"\t-s silently ignore nonexistant file [default = %s]\n", silent?
"yes":
"no" );
722 fprintf( pAbc->Err,
"\t-x echo each line as it is executed [default = %s]\n", echo?
"yes":
"no" );
723 fprintf( pAbc->Err,
"\t-h print the command usage\n" );
740 char *flag_value, *
value;
755 if ( argc == 0 || argc > 3 )
759 else if ( argc == 1 )
767 if (
st__delete( pAbc->tFlags, &key, &value ) )
777 if (
strcmp( argv[1],
"abcout" ) == 0 )
779 if ( pAbc->Out != stdout )
781 if (
strcmp( flag_value,
"" ) == 0 )
783 pAbc->Out =
CmdFileOpen( pAbc, flag_value,
"w", NULL, 0 );
784 if ( pAbc->Out == NULL )
787 setvbuf( pAbc->Out, (
char * ) NULL, _IOLBF, 0 );
790 if (
strcmp( argv[1],
"abcerr" ) == 0 )
792 if ( pAbc->Err != stderr )
794 if (
strcmp( flag_value,
"" ) == 0 )
796 pAbc->Err =
CmdFileOpen( pAbc, flag_value,
"w", NULL, 0 );
797 if ( pAbc->Err == NULL )
800 setvbuf( pAbc->Err, (
char * ) NULL, _IOLBF, 0 );
803 if (
strcmp( argv[1],
"history" ) == 0 )
805 if ( pAbc->Hst != NULL )
807 if (
strcmp( flag_value,
"" ) == 0 )
811 pAbc->Hst =
CmdFileOpen( pAbc, flag_value,
"w", NULL, 0 );
812 if ( pAbc->Hst == NULL )
820 fprintf( pAbc->Err,
"usage: set [-h] <name> <value>\n" );
821 fprintf( pAbc->Err,
"\t sets the value of parameter <name>\n" );
822 fprintf( pAbc->Err,
"\t-h : print the command usage\n" );
863 for ( i = 1; i < argc; i++ )
866 if (
st__delete( pAbc->tFlags, &key, &value ) )
876 fprintf( pAbc->Err,
"usage: unset [-h] <name> \n" );
877 fprintf( pAbc->Err,
"\t removes the value of parameter <name>\n" );
878 fprintf( pAbc->Err,
"\t-h : print the command usage\n" );
895 if ( argc == 2 && !
strcmp(argv[1],
"-h") )
898 if ( pAbc->pNtkCur == NULL )
900 fprintf( pAbc->Out,
"Empty network.\n" );
910 fprintf( pAbc->Err,
"usage: undo\n" );
911 fprintf( pAbc->Err,
" sets the current network to be the previously saved network\n" );
930 int iStep, iStepFound;
933 int iStepStart, iStepStop;
947 if ( pAbc->pNtkCur == NULL )
949 fprintf( pAbc->Out,
"Empty network.\n" );
956 if ( pValue == NULL )
959 nNetsToSave = atoi(pValue);
968 fprintf( pAbc->Out,
"There is no previously saved network.\n" );
976 iStep = atoi(argv[1]);
978 if ( iStep >= pAbc->nSteps )
980 iStepStart = pAbc->nSteps - nNetsToSave;
981 if ( iStepStart <= 0 )
983 iStepStop = pAbc->nSteps;
984 if ( iStepStop <= 0 )
986 if ( iStepStart == iStepStop )
987 fprintf( pAbc->Out,
"Can only recall step %d.\n", iStepStop );
989 fprintf( pAbc->Out,
"Can only recall steps %d-%d.\n", iStepStart, iStepStop );
991 else if ( iStep < 0 )
992 fprintf( pAbc->Out,
"Cannot recall step %d.\n", iStep );
993 else if ( iStep == 0 )
1000 for ( pNtk = pAbc->pNtkCur; pNtk; pNtk =
Abc_NtkBackup(pNtk) )
1005 iStepStart = iStepFound;
1006 if ( iStepStart <= 0 )
1008 iStepStop = pAbc->nSteps;
1009 if ( iStepStop <= 0 )
1011 if ( iStepStart == iStepStop )
1012 fprintf( pAbc->Out,
"Can only recall step %d.\n", iStepStop );
1014 fprintf( pAbc->Out,
"Can only recall steps %d-%d.\n", iStepStart, iStepStop );
1024 fprintf( pAbc->Err,
"usage: recall -h <num>\n" );
1025 fprintf( pAbc->Err,
" set the current network to be one of the previous networks\n" );
1026 fprintf( pAbc->Err,
"<num> : level to return to [default = previous]\n" );
1027 fprintf( pAbc->Err,
" -h : print the command usage\n");
1059 if ( pAbc->pNtkCur == NULL )
1061 fprintf( pAbc->Out,
"Empty network.\n" );
1070 fprintf( pAbc->Err,
"usage: empty [-h]\n" );
1071 fprintf( pAbc->Err,
" removes all the currently stored networks\n" );
1072 fprintf( pAbc->Err,
" -h : print the command usage\n");
1107 pNtkTemp = pAbc->pNtk;
1108 pAbc->pNtk = pAbc->pNtkSaved;
1109 pAbc->pNtkSaved = pNtkTemp;
1112 pNtkTemp = Cmd_HistoryGetSnapshot(pAbc,
id);
1114 fprintf( pAbc->Err,
"Snapshot %d does not exist\n",
id);
1116 pAbc->pNtk =
Abc_NtkDup(pNtkTemp, Abc_NtkMan(pNtkTemp));
1120 fprintf( pAbc->Err,
"usage: undo\n" );
1121 fprintf( pAbc->Err,
" swaps the current network and the backup network\n" );
1128 #if defined(WIN32) && !defined(__cplusplus)
1132 typedef unsigned long _fsize_t;
1134 struct _finddata_t {
1143 extern long _findfirst(
char *filespec,
struct _finddata_t *fileinfo );
1144 extern int _findnext(
long handle,
struct _finddata_t *fileinfo );
1145 extern int _findclose(
long handle );
1162 int CmdCommandScanDir(
Abc_Frame_t * pAbc,
int argc,
char **argv )
1164 struct _finddata_t c_file;
1165 char * pDirStr = NULL;
1166 char* pDirCur = NULL;
1178 fprintf( pAbc->Err,
"Command line switch \"-D\" should be followed by a string.\n" );
1192 if( (pDirCur = _getcwd( NULL, 0 )) == NULL )
1194 printf(
"Cannot read current directory\n" );
1197 if ( _chdir(pDirStr) )
1199 printf(
"Cannot change to directory: %s\n", pDirStr );
1204 if( (hFile = _findfirst(
"*.txt", &c_file )) == -1L )
1207 printf(
"No .txt files in the current directory.\n" );
1209 printf(
"No .txt files in directory: %s\n", pDirStr );
1215 FILE * pFile = fopen( c_file.name,
"rb" );
1216 char * pStr1 =
"Property UNDECIDED. Time =";
1217 char * pStr2 =
"Property proved. Time =";
1218 char * pStr3 =
"Time =";
1219 char * pBuffer, * pPlace, * pThis, * pThat;
1223 sprintf( FileName,
"%s", c_file.name );
1224 pThis =
strrchr( FileName,
'_' );
1225 pThat =
strchr( FileName,
'.' );
1226 if ( pThis == NULL || pThat == NULL || pThis >= pThat )
1234 if ( pFile == NULL )
1236 printf(
"Cannot open file %s\n", c_file.name );
1241 pPlace =
strstr( pBuffer, pStr1 );
1242 if ( pPlace == NULL )
1244 pPlace =
strstr( pBuffer, pStr2 );
1245 if ( pPlace == NULL )
1247 pPlace =
strstr( pBuffer, pStr3 );
1248 if ( pPlace == NULL )
1255 pPlace +=
strlen( pStr3 );
1258 pPlace +=
strlen( pStr2 );
1261 pPlace +=
strlen( pStr1 );
1262 sscanf( pPlace,
"%f", &Time );
1263 printf(
"%s %.2f\n", pThis, Time );
1266 while( _findnext( hFile, &c_file ) == 0 );
1267 _findclose( hFile );
1271 if ( _chdir(pDirCur) )
1274 printf(
"Cannot change to directory: %s\n", pDirCur );
1282 fprintf( pAbc->Err,
"usage: scandir [-D string]\n" );
1283 fprintf( pAbc->Err,
" performs custom scanning of the files in the given directory\n" );
1284 fprintf( pAbc->Err,
"\t-D str : the directory to read files from [default = current]\n" );
1301 int CmfFindNumber(
char * pName )
1304 for ( pTemp = pName; *pTemp; pTemp++ )
1305 if ( *pTemp ==
'.' )
1309 for ( --pTemp; pTemp > pName; pTemp-- )
1310 if ( *pTemp < '0' || *pTemp >
'9' )
1315 if ( *pTemp ==
'.' )
1317 return atoi( pTemp );
1331 void CnfDupFileUnzip(
char * pOldName )
1334 char pNewName[1000];
1339 sprintf( pNewName,
"%s.v", pOldName );
1340 pFile = fopen( pNewName,
"wb" );
1341 fwrite( pBuffer, nFileSize, 1, pFile );
1357 int CmdCommandRenameFiles(
Abc_Frame_t * pAbc,
int argc,
char **argv )
1359 struct _finddata_t c_file;
1361 char pNewName[1000];
1362 char * pDirStr = NULL;
1363 char * pDirCur = NULL;
1364 char * pNameNew = NULL;
1365 char * pNameExt = NULL;
1366 int c, i, nBase = 0;
1375 fprintf( pAbc->Err,
"Command line switch \"-D\" should be followed by a string.\n" );
1384 fprintf( pAbc->Err,
"Command line switch \"-E\" should be followed by a string.\n" );
1393 fprintf( pAbc->Err,
"Command line switch \"-N\" should be followed by a string.\n" );
1402 fprintf( pAbc->Err,
"Command line switch \"-B\" should be followed by a positive integer.\n" );
1415 if ( pNameExt == NULL )
1417 printf(
"Extension of the files should be given on the command line.\n" );
1423 if( (pDirCur = _getcwd( NULL, 0 )) == NULL )
1425 printf(
"Cannot read current directory\n" );
1428 if ( _chdir(pDirStr) )
1430 printf(
"Cannot change to directory: %s\n", pDirStr );
1435 sprintf( pNewName,
"*.%s", pNameExt );
1436 if( (hFile = _findfirst( pNewName, &c_file )) == -1L )
1439 printf(
"No .aig files in the current directory.\n" );
1441 printf(
"No .aig files in directory: %s\n", pDirStr );
1445 char * pName, * pOldName;
1446 int nDigits, * pOrder;
1452 }
while( _findnext( hFile, &c_file ) == 0 );
1453 _findclose( hFile );
1460 printf(
"Directory \"%s\" contains file (%s) with extension %s without number\n", pDirStr, pName, pNameExt );
1474 sprintf( pNewName,
"%s%0*d.%s", pNameNew ? pNameNew :
"", nDigits, nBase+
Vec_IntEntry(vNums, pOrder[i]), pNameExt );
1475 rename( pOldName, pNewName );
1476 printf(
"%s -> %s\n", pOldName, pNewName );
1486 if ( _chdir(pDirCur) )
1489 printf(
"Cannot change to directory: %s\n", pDirCur );
1497 fprintf( pAbc->Err,
"usage: renamefiles [-DEN str] [-B num]\n" );
1498 fprintf( pAbc->Err,
" performs renaming of files in the given directory\n" );
1499 fprintf( pAbc->Err,
"\t-D str : the directory to read files from [default = current]\n" );
1500 fprintf( pAbc->Err,
"\t-E str : the extension of files to look for [default = none]\n" );
1501 fprintf( pAbc->Err,
"\t-N str : the root of the resulting files [default = none]\n" );
1502 fprintf( pAbc->Err,
"\t-B num : the base number for all files [default = %d]\n", nBase );
1518 int CmdCommandLs(
Abc_Frame_t * pAbc,
int argc,
char **argv )
1520 struct _finddata_t c_file;
1526 int fPrintedNewLine;
1546 if( (hFile = _findfirst( ((fOnlyBLIF)?
"*.mv":
"*.*"), &c_file )) == -1L )
1549 fprintf( pAbc->Out,
"No *.mv files in the current directory.\n" );
1551 fprintf( pAbc->Out,
"No files in the current directory.\n" );
1557 fprintf( pAbc->Out,
" File Date Size | File Date Size \n" );
1558 fprintf( pAbc->Out,
" ----------------------------------------------------------------------------- \n" );
1561 strcpy( Buffer, ctime( &(c_file.time_write) ) );
1563 fprintf( pAbc->Out,
" %-17s %.24s%7ld", c_file.name, Buffer+4, c_file.size );
1564 if ( ++Counter % 2 == 0 )
1566 fprintf( pAbc->Out,
"\n" );
1567 fPrintedNewLine = 1;
1571 fprintf( pAbc->Out,
" |" );
1572 fPrintedNewLine = 0;
1575 while( _findnext( hFile, &c_file ) == 0 );
1581 fprintf( pAbc->Out,
" %-18s", c_file.name );
1582 if ( ++Counter % 4 == 0 )
1584 fprintf( pAbc->Out,
"\n" );
1585 fPrintedNewLine = 1;
1589 fprintf( pAbc->Out,
" " );
1590 fPrintedNewLine = 0;
1593 while( _findnext( hFile, &c_file ) == 0 );
1595 if ( !fPrintedNewLine )
1596 fprintf( pAbc->Out,
"\n" );
1597 _findclose( hFile );
1602 fprintf( pAbc->Err,
"usage: ls [-l] [-b]\n" );
1603 fprintf( pAbc->Err,
" print the file names in the current directory\n" );
1604 fprintf( pAbc->Err,
" -l : print in the long format [default = short]\n" );
1605 fprintf( pAbc->Err,
" -b : print only .mv files [default = all]\n" );
1621 int CmdCommandScrGen(
Abc_Frame_t * pAbc,
int argc,
char **argv )
1623 struct _finddata_t c_file;
1625 FILE * pFile = NULL;
1626 char * pFileStr =
"test.s";
1627 char * pDirStr = NULL;
1628 char * pComStr =
"ps";
1629 char * pWriteStr = NULL;
1630 char Buffer[1000], Line[2000];
1631 int nFileNameMax, nFileNameCur;
1645 fprintf( pAbc->Err,
"Command line switch \"-F\" should be followed by a string.\n" );
1654 fprintf( pAbc->Err,
"Command line switch \"-D\" should be followed by a string.\n" );
1663 fprintf( pAbc->Err,
"Command line switch \"-C\" should be followed by a string.\n" );
1672 fprintf( pAbc->Err,
"Command line switch \"-W\" should be followed by a string.\n" );
1689 if ( pDirStr == NULL )
1692 if ( _getcwd( Buffer, 1000 ) == NULL )
1694 printf(
"Cannot get the current directory.\n" );
1698 pFile = fopen( pFileStr,
"w" );
1701 if ( _chdir(pDirStr) )
1703 printf(
"Cannot change to directory: %s\n", pDirStr );
1708 pFile = fopen( pFileStr,
"w" );
1709 if ( pFile == NULL )
1711 printf(
"Cannot open file %s.\n", pFileStr );
1712 if ( pDirStr && _chdir(Buffer) )
1714 printf(
"Cannot change to the current directory: %s\n", Buffer );
1721 if( (hFile = _findfirst(
"*.*", &c_file )) == -1L )
1724 printf(
"No files in the current directory.\n" );
1726 printf(
"No files in directory: %s\n", pDirStr );
1727 if ( pDirStr && _chdir(Buffer) )
1729 printf(
"Cannot change to the current directory: %s\n", Buffer );
1740 nFileNameCur =
strlen(c_file.name);
1741 if ( c_file.name[nFileNameCur-1] ==
'.' )
1743 if ( nFileNameCur > 2 &&
1744 c_file.name[nFileNameCur-1] ==
's' &&
1745 c_file.name[nFileNameCur-2] ==
'.' )
1747 if ( nFileNameCur > 4 &&
1748 c_file.name[nFileNameCur-1] ==
't' &&
1749 c_file.name[nFileNameCur-2] ==
'x' &&
1750 c_file.name[nFileNameCur-3] ==
't' &&
1751 c_file.name[nFileNameCur-4] ==
'.' )
1753 if ( nFileNameMax < nFileNameCur )
1754 nFileNameMax = nFileNameCur;
1756 while( _findnext( hFile, &c_file ) == 0 );
1757 _findclose( hFile );
1762 if( (hFile = _findfirst(
"*.*", &c_file )) == -1L )
1765 printf(
"No files in the current directory.\n" );
1767 printf(
"No files in directory: %s\n", pDirStr );
1769 fprintf( pFile,
"# Script file produced by ABC on %s\n",
Extra_TimeStamp() );
1770 fprintf( pFile,
"# Command line was: scrgen -F %s -D %s -C \"%s\"%s%s\n",
1771 pFileStr, pDirStr, pComStr, pWriteStr?
" -W ":
"", pWriteStr?pWriteStr:
"" );
1775 nFileNameCur =
strlen(c_file.name);
1776 if ( c_file.name[nFileNameCur-1] ==
'.' )
1778 if ( nFileNameCur > 2 &&
1779 c_file.name[nFileNameCur-1] ==
's' &&
1780 c_file.name[nFileNameCur-2] ==
'.' )
1782 if ( nFileNameCur > 4 &&
1783 c_file.name[nFileNameCur-1] ==
't' &&
1784 c_file.name[nFileNameCur-2] ==
'x' &&
1785 c_file.name[nFileNameCur-3] ==
't' &&
1786 c_file.name[nFileNameCur-4] ==
'.' )
1788 sprintf( Line,
"r %s%s%-*s ; %s", pDirStr?pDirStr:
"", pDirStr?
"/":
"", nFileNameMax, c_file.name, pComStr );
1789 for ( c = (
int)
strlen(Line)-1; c >= 0; c-- )
1790 if ( Line[c] ==
'\\' )
1792 fprintf( pFile,
"%s", Line );
1795 sprintf( Line,
" ; w %s/%-*s", pWriteStr, nFileNameMax, c_file.name );
1796 for ( c = (
int)
strlen(Line)-1; c >= 0; c-- )
1797 if ( Line[c] ==
'\\' )
1799 fprintf( pFile,
"%s", Line );
1801 fprintf( pFile,
"\n", Line );
1803 while( _findnext( hFile, &c_file ) == 0 );
1804 _findclose( hFile );
1807 if ( pDirStr && _chdir(Buffer) )
1809 printf(
"Cannot change to the current directory: %s\n", Buffer );
1815 printf(
"Script file \"%s\" was saved in the current directory.\n", pFileStr );
1817 printf(
"Script file \"%s\" was saved in directory: %s\n", pFileStr, pDirStr );
1821 fprintf( pAbc->Err,
"usage: scrgen -F <str> -D <str> -C <str> -W <str> -ch\n" );
1822 fprintf( pAbc->Err,
"\t generates script for running ABC\n" );
1823 fprintf( pAbc->Err,
"\t-F str : the name of the script file [default = \"test.s\"]\n" );
1824 fprintf( pAbc->Err,
"\t-D str : the directory to read files from [default = current]\n" );
1825 fprintf( pAbc->Err,
"\t-C str : the sequence of commands to run [default = \"ps\"]\n" );
1826 fprintf( pAbc->Err,
"\t-W str : the directory to write the resulting files [default = no writing]\n" );
1827 fprintf( pAbc->Err,
"\t-c : toggle placing file in current/target dir [default = %s]\n", fUseCurrent?
"current":
"target" );
1828 fprintf( pAbc->Err,
"\t-h : print the command usage\n\n");
1829 fprintf( pAbc->Err,
"\tExample : scrgen -F test1.s -D a/in -C \"ps; st; ps\" -W a/out\n" );
1836 #define unlink _unlink
1853 FILE * pOut, * pErr;
1854 Abc_Ntk_t * pNtk, * pNtkNew, * pNetlist;
1855 char * pNameWin =
"sis.exe";
1856 char * pNameUnix =
"sis";
1857 char Command[1000], Buffer[100];
1867 if (
strcmp( argv[1],
"-h" ) == 0 )
1869 if (
strcmp( argv[1],
"-?" ) == 0 )
1874 fprintf( pErr,
"Empty network.\n" );
1878 if (
strcmp( argv[0],
"sis" ) != 0 )
1880 fprintf( pErr,
"Wrong command: \"%s\".\n", argv[0] );
1891 if ( (pFile = fopen( pNameWin,
"r" )) )
1892 pSisName = pNameWin;
1893 else if ( (pFile = fopen( pNameUnix,
"r" )) )
1894 pSisName = pNameUnix;
1895 else if ( pFile == NULL )
1897 fprintf( pErr,
"Cannot find \"%s\" or \"%s\" in the current directory.\n", pNameWin, pNameUnix );
1905 printf(
"The current network is unmapped before calling SIS.\n" );
1912 if ( pNetlist == NULL )
1914 fprintf( pErr,
"Cannot produce the intermediate network.\n" );
1921 sprintf( Command,
"%s -x -c ", pSisName );
1922 strcat ( Command,
"\"" );
1923 strcat ( Command,
"read_blif _sis_in.blif" );
1924 strcat ( Command,
"; " );
1925 for ( i = 1; i < argc; i++ )
1927 sprintf( Buffer,
" %s", argv[i] );
1928 strcat( Command, Buffer );
1931 strcat( Command,
"write_blif _sis_out.blif" );
1937 fprintf( pErr,
"The following command has returned non-zero exit status:\n" );
1938 fprintf( pErr,
"\"%s\"\n", Command );
1939 unlink(
"_sis_in.blif" );
1944 if ( (pFile = fopen(
"_sis_out.blif",
"r" )) == NULL )
1946 fprintf( pErr,
"Cannot open SIS output file \"%s\".\n",
"_sis_out.blif" );
1947 unlink(
"_sis_in.blif" );
1964 unlink(
"_sis_in.blif" );
1965 unlink(
"_sis_out.blif" );
1969 fprintf( pErr,
"Usage: sis [-h] <com>\n");
1970 fprintf( pErr,
" invokes SIS command for the current ABC network\n" );
1971 fprintf( pErr,
" (the executable of SIS should be in the same directory)\n" );
1972 fprintf( pErr,
" -h : print the command usage\n" );
1973 fprintf( pErr,
" <com> : a SIS command (or a semicolon-separated list of commands in quotes)\n" );
1974 fprintf( pErr,
" Example 1: sis eliminate 0\n" );
1975 fprintf( pErr,
" Example 2: sis \"ps; rd; fx; ps\"\n" );
1976 fprintf( pErr,
" Example 3: sis source script.rugged\n" );
1995 FILE * pOut, * pErr;
1996 Abc_Ntk_t * pNtk, * pNtkNew, * pNetlist;
1997 char Command[1000], Buffer[100];
1998 char * pNameWin =
"mvsis.exe";
1999 char * pNameUnix =
"mvsis";
2009 if (
strcmp( argv[1],
"-h" ) == 0 )
2011 if (
strcmp( argv[1],
"-?" ) == 0 )
2016 fprintf( pErr,
"Empty network.\n" );
2020 if (
strcmp( argv[0],
"mvsis" ) != 0 )
2022 fprintf( pErr,
"Wrong command: \"%s\".\n", argv[0] );
2033 if ( (pFile = fopen( pNameWin,
"r" )) )
2034 pMvsisName = pNameWin;
2035 else if ( (pFile = fopen( pNameUnix,
"r" )) )
2036 pMvsisName = pNameUnix;
2037 else if ( pFile == NULL )
2039 fprintf( pErr,
"Cannot find \"%s\" or \"%s\" in the current directory.\n", pNameWin, pNameUnix );
2047 printf(
"The current network is unmapped before calling MVSIS.\n" );
2054 if ( pNetlist == NULL )
2056 fprintf( pErr,
"Cannot produce the intermediate network.\n" );
2063 sprintf( Command,
"%s -x -c ", pMvsisName );
2064 strcat ( Command,
"\"" );
2065 strcat ( Command,
"read_blif _mvsis_in.blif" );
2066 strcat ( Command,
"; " );
2067 for ( i = 1; i < argc; i++ )
2069 sprintf( Buffer,
" %s", argv[i] );
2070 strcat( Command, Buffer );
2073 strcat( Command,
"write_blif _mvsis_out.blif" );
2079 fprintf( pErr,
"The following command has returned non-zero exit status:\n" );
2080 fprintf( pErr,
"\"%s\"\n", Command );
2081 unlink(
"_mvsis_in.blif" );
2086 if ( (pFile = fopen(
"_mvsis_out.blif",
"r" )) == NULL )
2088 fprintf( pErr,
"Cannot open MVSIS output file \"%s\".\n",
"_mvsis_out.blif" );
2089 unlink(
"_mvsis_in.blif" );
2106 unlink(
"_mvsis_in.blif" );
2107 unlink(
"_mvsis_out.blif" );
2111 fprintf( pErr,
"Usage: mvsis [-h] <com>\n");
2112 fprintf( pErr,
" invokes MVSIS command for the current ABC network\n" );
2113 fprintf( pErr,
" (the executable of MVSIS should be in the same directory)\n" );
2114 fprintf( pErr,
" -h : print the command usage\n" );
2115 fprintf( pErr,
" <com> : a MVSIS command (or a semicolon-separated list of commands in quotes)\n" );
2116 fprintf( pErr,
" Example 1: mvsis fraig_sweep\n" );
2117 fprintf( pErr,
" Example 2: mvsis \"ps; fxu; ps\"\n" );
2118 fprintf( pErr,
" Example 3: mvsis source mvsis.rugged\n" );
2138 char * pProgNameGnuplotWin =
"wgnuplot.exe";
2139 char * pProgNameGnuplotUnix =
"gnuplot";
2140 char * pProgNameGnuplot = NULL;
2143 if ( (pFile = fopen( pPlotFileName,
"r" )) == NULL )
2145 fprintf( stdout,
"Cannot open the plot file \"%s\".\n\n", pPlotFileName );
2159 if ( (pFile = fopen( pProgNameGnuplotWin,
"r" )) )
2160 pProgNameGnuplot = pProgNameGnuplotWin;
2161 else if ( (pFile = fopen( pProgNameGnuplotUnix,
"r" )) )
2162 pProgNameGnuplot = pProgNameGnuplotUnix;
2163 else if ( pFile == NULL )
2165 fprintf( stdout,
"Cannot find \"%s\" or \"%s\" in the current directory.\n", pProgNameGnuplotWin, pProgNameGnuplotUnix );
2172 if ( _spawnl( _P_NOWAIT, pProgNameGnuplot, pProgNameGnuplot, pPlotFileName, NULL ) == -1 )
2174 fprintf( stdout,
"Cannot find \"%s\".\n", pProgNameGnuplot );
2180 sprintf( Command,
"%s %s ", pProgNameGnuplot, pPlotFileName );
2181 if (
system( Command ) == -1 )
2183 fprintf( stdout,
"Cannot execute \"%s\".\n", Command );
2204 FILE * pOut, * pErr;
2206 char Command[1000], Buffer[100];
2207 char * pProgNameCapoWin =
"capo.exe";
2208 char * pProgNameCapoUnix =
"capo";
2209 char * pProgNameGnuplotWin =
"wgnuplot.exe";
2210 char * pProgNameGnuplotUnix =
"gnuplot";
2211 char * pProgNameCapo;
2212 char * pProgNameGnuplot;
2213 char * pPlotFileName;
2222 if (
strcmp( argv[1],
"-h" ) == 0 )
2224 if (
strcmp( argv[1],
"-?" ) == 0 )
2230 fprintf( pErr,
"Empty network.\n" );
2234 if (
strcmp( argv[0],
"capo" ) != 0 )
2236 fprintf( pErr,
"Wrong command: \"%s\".\n", argv[0] );
2247 if ( (pFile = fopen( pProgNameCapoWin,
"r" )) )
2248 pProgNameCapo = pProgNameCapoWin;
2249 else if ( (pFile = fopen( pProgNameCapoUnix,
"r" )) )
2250 pProgNameCapo = pProgNameCapoUnix;
2251 else if ( pFile == NULL )
2253 fprintf( pErr,
"Cannot find \"%s\" or \"%s\" in the current directory.\n", pProgNameCapoWin, pProgNameCapoUnix );
2261 printf(
"The current network is unmapped before calling Capo.\n" );
2268 if ( pNetlist == NULL )
2270 fprintf( pErr,
"Cannot produce the intermediate network.\n" );
2277 sprintf( Command,
"%s -f _capo_in.blif -log out.txt ", pProgNameCapo );
2278 pPlotFileName = NULL;
2279 for ( i = 1; i < argc; i++ )
2281 sprintf( Buffer,
" %s", argv[i] );
2282 strcat( Command, Buffer );
2283 if ( !
strcmp( argv[i],
"-plot" ) )
2284 pPlotFileName = argv[i+1];
2290 fprintf( pErr,
"The following command has returned non-zero exit status:\n" );
2291 fprintf( pErr,
"\"%s\"\n", Command );
2292 unlink(
"_capo_in.blif" );
2296 unlink(
"_capo_in.blif" );
2297 if ( pPlotFileName == NULL )
2301 sprintf( Buffer,
"%s.plt", pPlotFileName );
2302 pPlotFileName = Buffer;
2305 if ( (pFile = fopen( pPlotFileName,
"r" )) == NULL )
2307 fprintf( pErr,
"Cannot open the plot file \"%s\".\n\n", pPlotFileName );
2319 if ( (pFile = fopen( pProgNameGnuplotWin,
"r" )) )
2320 pProgNameGnuplot = pProgNameGnuplotWin;
2321 else if ( (pFile = fopen( pProgNameGnuplotUnix,
"r" )) )
2322 pProgNameGnuplot = pProgNameGnuplotUnix;
2323 else if ( pFile == NULL )
2325 fprintf( pErr,
"Cannot find \"%s\" or \"%s\" in the current directory.\n", pProgNameGnuplotWin, pProgNameGnuplotUnix );
2332 if ( _spawnl( _P_NOWAIT, pProgNameGnuplot, pProgNameGnuplot, pPlotFileName, NULL ) == -1 )
2334 fprintf( stdout,
"Cannot find \"%s\".\n", pProgNameGnuplot );
2339 sprintf( Command,
"%s %s ", pProgNameGnuplot, pPlotFileName );
2342 fprintf( stdout,
"Cannot execute \"%s\".\n", Command );
2353 fprintf( pErr,
"Usage: capo [-h] <com>\n");
2354 fprintf( pErr,
" peforms placement of the current network using Capo\n" );
2355 fprintf( pErr,
" a Capo binary should be present in the same directory\n" );
2356 fprintf( pErr,
" (if plotting, the Gnuplot binary should also be present)\n" );
2357 fprintf( pErr,
" -h : print the command usage\n" );
2358 fprintf( pErr,
" <com> : a Capo command\n" );
2359 fprintf( pErr,
" Example 1: capo\n" );
2360 fprintf( pErr,
" (performs placement with default options)\n" );
2361 fprintf( pErr,
" Example 2: capo -AR <aspec_ratio> -WS <whitespace_percentage> -save\n" );
2362 fprintf( pErr,
" (specifies the aspect ratio [default = 1.0] and\n" );
2363 fprintf( pErr,
" the whitespace percentage [0%%; 100%%) [default = 15%%])\n" );
2364 fprintf( pErr,
" Example 3: capo -plot <base_fileName>\n" );
2365 fprintf( pErr,
" (produces <base_fileName.plt> and visualize it using Gnuplot)\n" );
2366 fprintf( pErr,
" Example 4: capo -help\n" );
2367 fprintf( pErr,
" (prints the default usage message of the Capo binary)\n" );
2368 fprintf( pErr,
" Please refer to the Capo webpage for additional information:\n" );
2369 fprintf( pErr,
" http://vlsicad.eecs.umich.edu/BK/PDtools/\n" );
2386 extern void Cmd_RunStarter(
char * pFileName,
char * pBinary,
char * pCommand,
int nCores );
2389 char * pCommand = NULL;
2400 Abc_Print( -1,
"Command line switch \"-N\" should be followed by an integer.\n" );
2409 if ( globalUtilOptind >= argc )
2411 Abc_Print( -1,
"Command line switch \"-C\" should be followed by a string (possibly in quotes).\n" );
2428 Abc_Print( -2,
"The file name should be given on the command line.\n" );
2433 if ( (pFile =
Io_FileOpen( pFileName,
"open_path",
"rb", 0 )) == NULL )
2436 Abc_Print( -2,
"Cannot open input file \"%s\". ", pFileName );
2438 Abc_Print( -2,
"Did you mean \"%s\"?", pFileName );
2448 Abc_Print( -2,
"usage: starter [-N num] [-C cmd] [-vh] <file>\n" );
2449 Abc_Print( -2,
"\t runs command lines listed in <file> concurrently on <num> CPUs\n" );
2450 Abc_Print( -2,
"\t-N num : the number of concurrent jobs including the controler [default = %d]\n", nCores );
2451 Abc_Print( -2,
"\t-C cmd : (optional) ABC command line to execute on benchmarks in <file>\n" );
2452 Abc_Print( -2,
"\t-v : toggle printing verbose information [default = %s]\n", fVerbose?
"yes":
"no" );
2453 Abc_Print( -2,
"\t-h : print the command usage\n");
2454 Abc_Print( -2,
"\t<file> : file name with ABC command lines (or benchmark names, if <cmd> is given)\n");
2489 fprintf( pAbc->Err,
"usage: version [-h]\n" );
2490 fprintf( pAbc->Err,
" print the version string\n" );
2491 fprintf( pAbc->Err,
" -h : print the command usage\n");
static int * Vec_IntArray(Vec_Int_t *p)
void st__free_table(st__table *table)
void Cmd_Init(Abc_Frame_t *pAbc)
FUNCTION DEFINITIONS ///.
ABC_DLL void Abc_FrameReplaceCurrentNetwork(Abc_Frame_t *p, Abc_Ntk_t *pNet)
static ABC_NAMESPACE_IMPL_START int CmdCommandTime(Abc_Frame_t *pAbc, int argc, char **argv)
DECLARATIONS ///.
int * Abc_QuickSortCost(int *pCosts, int nSize, int fDecrease)
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
typedefABC_NAMESPACE_HEADER_START struct MvCommand Abc_Command
INCLUDES ///.
FILE * Io_FileOpen(const char *FileName, const char *PathVar, const char *Mode, int fVerbose)
static int CmdCommandSource(Abc_Frame_t *pAbc, int argc, char **argv)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
static int CmdCommandRecall(Abc_Frame_t *pAbc, int argc, char **argv)
ABC_DLL void Abc_FrameDeleteAllNetworks(Abc_Frame_t *p)
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
int Cmd_CommandExecute(void *pAbc, char *pCommandLine)
int st__delete(st__table *table, const char **keyp, char **value)
int st__insert(st__table *table, const char *key, char *value)
char * CmdHistorySubstitution(Abc_Frame_t *pAbc, char *line, int *changed)
ABC_DLL void Abc_FrameSetCurrentNetwork(Abc_Frame_t *p, Abc_Ntk_t *pNet)
void Gia_ManGnuplotShow(char *pPlotFileName)
void CmdCommandAliasFree(Abc_Alias *pAlias)
static void Vec_PtrFreeFree(Vec_Ptr_t *p)
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
void Cmd_CommandAdd(Abc_Frame_t *pAbc, const char *sGroup, const char *sName, Cmd_CommandFuncType pFunc, int fChanges)
static int CmdCommandWhich(Abc_Frame_t *pAbc, int argc, char **argv)
ABC_DLL Abc_Ntk_t * Abc_NtkToNetlist(Abc_Ntk_t *pNtk)
void Io_WriteBlif(Abc_Ntk_t *pNtk, char *pFileName, int fWriteLatches, int fBb2Wb, int fSeq)
static int CmdCommandSetVariable(Abc_Frame_t *pAbc, int argc, char **argv)
static int Abc_MaxInt(int a, int b)
static int Vec_PtrSize(Vec_Ptr_t *p)
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
int Cmd_CommandAbcLoadPlugIn(Abc_Frame_t *pAbc, int argc, char **argv)
Abc_Ntk_t * Io_Read(char *pFileName, Io_FileType_t FileType, int fCheck, int fBarBufs)
ABC_NAMESPACE_IMPL_START void Cmd_RunStarter(char *pFileName, char *pBinary, char *pCommand, int nCores)
DECLARATIONS ///.
void Cmd_HistoryAddCommand(Abc_Frame_t *pAbc, const char *command)
DECLARATIONS ///.
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
static int CmdCommandVersion(Abc_Frame_t *pAbc, int argc, char **argv)
int st__strhash(const char *string, int modulus)
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
ABC_DLL int Abc_NtkMapToSop(Abc_Ntk_t *pNtk)
static int CmdCommandHelp(Abc_Frame_t *pAbc, int argc, char **argv)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
ABC_DLL int Abc_NtkToSop(Abc_Ntk_t *pNtk, int fDirect)
static int Vec_IntEntry(Vec_Int_t *p, int i)
static int Abc_Base10Log(unsigned n)
#define ABC_NAMESPACE_IMPL_END
void * Abc_FrameGetGlobalFrame()
static void Vec_IntPush(Vec_Int_t *p, int Entry)
static int CmdCommandCapo(Abc_Frame_t *pAbc, int argc, char **argv)
void CmdPrintTable(st__table *tTable, int fAliases)
void CmdCommandPrint(Abc_Frame_t *pAbc, int fPrintAll, int fDetails)
void Cmd_End(Abc_Frame_t *pAbc)
static int CmdCommandQuit(Abc_Frame_t *pAbc, int argc, char **argv)
ABC_DLL char * Abc_UtilsGetVersion(Abc_Frame_t *pAbc)
FUNCTION DEFINITIONS ///.
static int CmdCommandMvsis(Abc_Frame_t *pAbc, int argc, char **argv)
static void Abc_Print(int level, const char *format,...)
static int CmdCommandEmpty(Abc_Frame_t *pAbc, int argc, char **argv)
void Cmd_HistoryRead(Abc_Frame_t *p)
#define ABC_NAMESPACE_IMPL_START
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
ABC_DLL Abc_Ntk_t * Abc_FrameReadNtk(Abc_Frame_t *p)
void CmdCommandAliasPrint(Abc_Frame_t *pAbc, Abc_Alias *pAlias)
static int Vec_IntEntryLast(Vec_Int_t *p)
FILE * CmdFileOpen(Abc_Frame_t *pAbc, char *sFileName, char *sMode, char **pFileNameReal, int silent)
int st__lookup(st__table *table, const char *key, char **value)
static int CmdCommandUnalias(Abc_Frame_t *pAbc, int argc, char **argv)
static int Abc_NtkIsMappedLogic(Abc_Ntk_t *pNtk)
static int Vec_IntSize(Vec_Int_t *p)
void CmdCommandFree(Abc_Command *pCommand)
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static int CmdCommandEcho(Abc_Frame_t *pAbc, int argc, char **argv)
static int CmdCommandAlias(Abc_Frame_t *pAbc, int argc, char **argv)
static int Abc_NtkStep(Abc_Ntk_t *pNtk)
static int CmdCommandSis(Abc_Frame_t *pAbc, int argc, char **argv)
static int CmdCommandUnsetVariable(Abc_Frame_t *pAbc, int argc, char **argv)
#define ABC_INFINITY
MACRO DEFINITIONS ///.
#define st__foreach_item(table, gen, key, value)
ABC_DLL FILE * Abc_FrameReadErr(Abc_Frame_t *p)
ABC_DLL FILE * Abc_FrameReadOut(Abc_Frame_t *p)
char * Io_MvLoadFileBz2(char *pFileName, int *pnFileSize)
ABC_NAMESPACE_IMPL_START int Util_SignalSystem(const char *cmd)
DECLARATIONS ///.
static void Vec_IntFree(Vec_Int_t *p)
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
void Cmd_HistoryWrite(Abc_Frame_t *p, int Limit)
ABC_NAMESPACE_IMPL_START void CmdCommandAliasAdd(Abc_Frame_t *pAbc, char *sName, int argc, char **argv)
DECLARATIONS ///.
char * Abc_UtilStrsav(char *s)
ABC_DLL void Abc_FrameRestart(Abc_Frame_t *p)
static int CmdCommandHistory(Abc_Frame_t *pAbc, int argc, char **argv)
static int CmdCommandStarter(Abc_Frame_t *pAbc, int argc, char **argv)
static int CmdCommandUndo(Abc_Frame_t *pAbc, int argc, char **argv)
char * Cmd_FlagReadByName(Abc_Frame_t *pAbc, char *flag)
DECLARATIONS ///.
static Abc_Ntk_t * Abc_NtkBackup(Abc_Ntk_t *pNtk)