From e73e5438ca483866096bdc82ab43ac290549b7c9 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 27 Nov 2013 12:17:00 -0800 Subject: Patching ABC for Yosys. --- Makefile | 18 ++++---- src/base/abci/abc.c | 36 ++++++++++------ src/base/cmd/cmd.c | 109 +++++++++++++++++++++++++++++------------------- src/base/cmd/cmdInt.h | 2 +- src/base/cmd/cmdUtils.c | 37 +++++++++++++++- src/map/fpga/fpga.c | 4 +- 6 files changed, 139 insertions(+), 67 deletions(-) diff --git a/Makefile b/Makefile index 4f751b24..b8d3613e 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ + CC := gcc CXX := g++ LD := $(CXX) @@ -40,6 +41,7 @@ arch_flags : arch_flags.c ARCHFLAGS ?= $(shell $(CC) arch_flags.c -o arch_flags && ./arch_flags) OPTFLAGS ?= -g -O #-DABC_NAMESPACE=xxx +MSG_PREFIX ?= CFLAGS += -Wall -Wno-unused-function -Wno-write-strings -Wno-sign-compare $(OPTFLAGS) $(ARCHFLAGS) -Isrc @@ -99,19 +101,19 @@ DEP := $(OBJ:.o=.d) # implicit rules %.o: %.c - @echo "\`\` Compiling:" $(LOCAL_PATH)/$< + @echo "$(MSG_PREFIX)\`\` Compiling:" $(LOCAL_PATH)/$< @$(CC) -c $(CFLAGS) $< -o $@ %.o: %.cc - @echo "\`\` Compiling:" $(LOCAL_PATH)/$< + @echo "$(MSG_PREFIX)\`\` Compiling:" $(LOCAL_PATH)/$< @$(CXX) -c $(CXXFLAGS) $< -o $@ %.d: %.c - @echo "\`\` Dependency:" $(LOCAL_PATH)/$< + @echo "$(MSG_PREFIX)\`\` Dependency:" $(LOCAL_PATH)/$< @./depends.sh $(CC) `dirname $*.c` $(CFLAGS) $*.c > $@ %.d: %.cc - @echo "\`\` Generating dependency:" $(LOCAL_PATH)/$< + @echo "$(MSG_PREFIX)\`\` Generating dependency:" $(LOCAL_PATH)/$< @./depends.sh $(CXX) `dirname $*.cc` $(CXXFLAGS) $*.cc > $@ -include $(DEP) @@ -121,21 +123,21 @@ DEP := $(OBJ:.o=.d) depend: $(DEP) clean: - @echo "\`\` Cleaning up..." + @echo "$(MSG_PREFIX)\`\` Cleaning up..." @rm -rvf $(PROG) lib$(PROG).a $(OBJ) $(GARBAGE) $(OBJ:.o=.d) tags: etags `find . -type f -regex '.*\.\(c\|h\)'` $(PROG): $(OBJ) - @echo "\`\` Building binary:" $(notdir $@) + @echo "$(MSG_PREFIX)\`\` Building binary:" $(notdir $@) @$(LD) -o $@ $^ $(LIBS) lib$(PROG).a: $(OBJ) - @echo "\`\` Linking:" $(notdir $@) + @echo "$(MSG_PREFIX)\`\` Linking:" $(notdir $@) @ar rv $@ $? @ranlib $@ docs: - @echo "\`\` Building documentation." $(notdir $@) + @echo "$(MSG_PREFIX)\`\` Building documentation." $(notdir $@) @doxygen doxygen.conf diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 7683d313..ed42e7ef 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -6162,7 +6162,6 @@ usage: Abc_Print( -2, " Professor Tsutomu Sasao (sasao@cse.kyutech.ac.jp) at Kyushu Institute\n"); Abc_Print( -2, " of Technology. This work received Takeda Techno-Entrepreneurship Award:\n"); Abc_Print( -2, " http://www.lsi-cad.com/sasao/photo/takeda.html\n"); - Abc_Print( -2, "\t \n"); return 1; } @@ -6244,7 +6243,6 @@ usage: Abc_Print( -2, "\t-a : toggle multi-input XOR vs multi-input AND [default = %s]\n", fAnd? "AND": "XOR" ); Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); - Abc_Print( -2, "\t \n"); return 1; } @@ -9390,6 +9388,12 @@ int Abc_CommandEspresso( Abc_Frame_t * pAbc, int argc, char ** argv ) int fVerbose; extern void Abc_NtkEspresso( Abc_Ntk_t * pNtk, int fVerbose ); + if ( argc == 2 && !strcmp(argv[1], "-h") ) + { + Abc_Print( -2, "The espresso command is currently disabled.\n" ); + return 1; + } + Abc_Print( -1, "This command is currently disabled.\n" ); return 0; @@ -12525,7 +12529,7 @@ int Abc_CommandNpnLoad( Abc_Frame_t * pAbc, int argc, char ** argv ) char * pFileName; int c; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { @@ -12565,7 +12569,7 @@ int Abc_CommandNpnSave( Abc_Frame_t * pAbc, int argc, char ** argv ) char * pFileName; int c; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { @@ -12607,7 +12611,7 @@ int Abc_CommandSendAig( Abc_Frame_t * pAbc, int argc, char ** argv ) int c, fAndSpace = 1, fAbsNetlist = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "a" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "ah" ) ) != EOF ) { switch ( c ) { @@ -12617,6 +12621,8 @@ int Abc_CommandSendAig( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'b': fAbsNetlist ^= 1; break; + case 'h': + goto usage; default: goto usage; } @@ -12682,7 +12688,7 @@ int Abc_CommandSendStatus( Abc_Frame_t * pAbc, int argc, char ** argv ) extern int Gia_ManToBridgeResult( FILE * pFile, int Result, Abc_Cex_t * pCex, int iPoProved ); int c; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) { @@ -13947,12 +13953,6 @@ int Abc_CommandRecDump2( Abc_Frame_t * pAbc, int argc, char ** argv ) //pNtk = Abc_FrameReadNtk(pAbc); // set defaults Extra_UtilGetoptReset(); - - if ( !Abc_NtkRecIsRunning2() ) - { - Abc_Print( -1, "The AIG subgraph recording is not started.\n" ); - return 1; - } while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { switch ( c ) @@ -13963,6 +13963,12 @@ int Abc_CommandRecDump2( Abc_Frame_t * pAbc, int argc, char ** argv ) goto usage; } } + + if ( !Abc_NtkRecIsRunning2() ) + { + Abc_Print( -1, "The AIG subgraph recording is not started.\n" ); + return 1; + } pGia = Abc_NtkRecGetGia(); pArgvNew = argv + globalUtilOptind; nArgcNew = argc - globalUtilOptind; @@ -16991,6 +16997,12 @@ int Abc_CommandFlowRetime( Abc_Frame_t * pAbc, int argc, char ** argv ) int fFastButConservative; int maxDelay; + if ( argc == 2 && !strcmp(argv[1], "-h") ) + { + Abc_Print( -2, "The fretime command is temporarily disabled.\n" ); + return 1; + } + Abc_Print( -1, "This command is temporarily disabled.\n" ); return 0; // extern Abc_Ntk_t* Abc_FlowRetime_MinReg( Abc_Ntk_t * pNtk, int fVerbose, diff --git a/src/base/cmd/cmd.c b/src/base/cmd/cmd.c index e69bbc0e..9f087585 100644 --- a/src/base/cmd/cmd.c +++ b/src/base/cmd/cmd.c @@ -498,12 +498,13 @@ int CmdCommandUnalias( Abc_Frame_t * pAbc, int argc, char **argv ) ******************************************************************************/ int CmdCommandHelp( Abc_Frame_t * pAbc, int argc, char **argv ) { - int fPrintAll; + int fPrintAll, fDetails; int c; fPrintAll = 0; + fDetails = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "ah" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "adh" ) ) != EOF ) { switch ( c ) { @@ -512,6 +513,9 @@ int CmdCommandHelp( Abc_Frame_t * pAbc, int argc, char **argv ) fPrintAll ^= 1; break; break; + case 'd': + fDetails ^= 1; + break; case 'h': goto usage; break; @@ -523,13 +527,14 @@ int CmdCommandHelp( Abc_Frame_t * pAbc, int argc, char **argv ) if ( argc != globalUtilOptind ) goto usage; - CmdCommandPrint( pAbc, fPrintAll ); + CmdCommandPrint( pAbc, fPrintAll, fDetails ); return 0; usage: - fprintf( pAbc->Err, "usage: help [-a] [-h]\n" ); + fprintf( pAbc->Err, "usage: help [-a] [-d] [-h]\n" ); fprintf( pAbc->Err, " prints the list of available commands by group\n" ); fprintf( pAbc->Err, " -a toggle printing hidden commands [default = %s]\n", fPrintAll? "yes": "no" ); + fprintf( pAbc->Err, " -d print usage details to all commands [default = %s]\n", fDetails? "yes": "no" ); fprintf( pAbc->Err, " -h print the command usage\n" ); return 1; } @@ -885,6 +890,9 @@ int CmdCommandUnsetVariable( Abc_Frame_t * pAbc, int argc, char **argv ) ******************************************************************************/ int CmdCommandUndo( Abc_Frame_t * pAbc, int argc, char **argv ) { + if ( argc == 2 && !strcmp(argv[1], "-h") ) + goto usage; + if ( pAbc->pNtkCur == NULL ) { fprintf( pAbc->Out, "Empty network.\n" ); @@ -896,6 +904,7 @@ int CmdCommandUndo( Abc_Frame_t * pAbc, int argc, char **argv ) if ( argc == 1 ) return CmdCommandRecall( pAbc, argc, argv ); +usage: fprintf( pAbc->Err, "usage: undo\n" ); fprintf( pAbc->Err, " sets the current network to be the previously saved network\n" ); return 1; @@ -921,13 +930,6 @@ int CmdCommandRecall( Abc_Frame_t * pAbc, int argc, char **argv ) char * pValue; int iStepStart, iStepStop; - if ( pAbc->pNtkCur == NULL ) - { - fprintf( pAbc->Out, "Empty network.\n" ); - return 0; - } - - Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { @@ -940,6 +942,12 @@ int CmdCommandRecall( Abc_Frame_t * pAbc, int argc, char **argv ) } } + if ( pAbc->pNtkCur == NULL ) + { + fprintf( pAbc->Out, "Empty network.\n" ); + return 0; + } + // get the number of networks to save pValue = Cmd_FlagReadByName( pAbc, "savesteps" ); // if the value of steps to save is not set, assume 1-level undo @@ -1034,12 +1042,6 @@ int CmdCommandEmpty( Abc_Frame_t * pAbc, int argc, char **argv ) { int c; - if ( pAbc->pNtkCur == NULL ) - { - fprintf( pAbc->Out, "Empty network.\n" ); - return 0; - } - Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) { @@ -1052,6 +1054,12 @@ int CmdCommandEmpty( Abc_Frame_t * pAbc, int argc, char **argv ) } } + if ( pAbc->pNtkCur == NULL ) + { + fprintf( pAbc->Out, "Empty network.\n" ); + return 0; + } + Abc_FrameDeleteAllNetworks( pAbc ); Abc_FrameRestart( pAbc ); return 0; @@ -1635,6 +1643,13 @@ int CmdCommandSis( Abc_Frame_t * pAbc, int argc, char **argv ) pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); + if ( argc == 1 ) + goto usage; + if ( strcmp( argv[1], "-h" ) == 0 ) + goto usage; + if ( strcmp( argv[1], "-?" ) == 0 ) + goto usage; + if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); @@ -1647,13 +1662,6 @@ int CmdCommandSis( Abc_Frame_t * pAbc, int argc, char **argv ) goto usage; } - if ( argc == 1 ) - goto usage; - if ( strcmp( argv[1], "-h" ) == 0 ) - goto usage; - if ( strcmp( argv[1], "-?" ) == 0 ) - goto usage; - // get the names from the resource file if ( Cmd_FlagReadByName(pAbc, "siswin") ) pNameWin = Cmd_FlagReadByName(pAbc, "siswin"); @@ -1739,7 +1747,6 @@ int CmdCommandSis( Abc_Frame_t * pAbc, int argc, char **argv ) return 0; usage: - fprintf( pErr, "\n" ); fprintf( pErr, "Usage: sis [-h] \n"); fprintf( pErr, " invokes SIS command for the current ABC network\n" ); fprintf( pErr, " (the executable of SIS should be in the same directory)\n" ); @@ -1778,6 +1785,13 @@ int CmdCommandMvsis( Abc_Frame_t * pAbc, int argc, char **argv ) pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); + if ( argc == 1 ) + goto usage; + if ( strcmp( argv[1], "-h" ) == 0 ) + goto usage; + if ( strcmp( argv[1], "-?" ) == 0 ) + goto usage; + if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); @@ -1790,13 +1804,6 @@ int CmdCommandMvsis( Abc_Frame_t * pAbc, int argc, char **argv ) goto usage; } - if ( argc == 1 ) - goto usage; - if ( strcmp( argv[1], "-h" ) == 0 ) - goto usage; - if ( strcmp( argv[1], "-?" ) == 0 ) - goto usage; - // get the names from the resource file if ( Cmd_FlagReadByName(pAbc, "mvsiswin") ) pNameWin = Cmd_FlagReadByName(pAbc, "mvsiswin"); @@ -1882,7 +1889,6 @@ int CmdCommandMvsis( Abc_Frame_t * pAbc, int argc, char **argv ) return 0; usage: - fprintf( pErr, "\n" ); fprintf( pErr, "Usage: mvsis [-h] \n"); fprintf( pErr, " invokes MVSIS command for the current ABC network\n" ); fprintf( pErr, " (the executable of MVSIS should be in the same directory)\n" ); @@ -1992,6 +1998,14 @@ int CmdCommandCapo( Abc_Frame_t * pAbc, int argc, char **argv ) pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); + if ( argc > 1 ) + { + if ( strcmp( argv[1], "-h" ) == 0 ) + goto usage; + if ( strcmp( argv[1], "-?" ) == 0 ) + goto usage; + } + if ( pNtk == NULL ) { fprintf( pErr, "Empty network.\n" ); @@ -2004,14 +2018,6 @@ int CmdCommandCapo( Abc_Frame_t * pAbc, int argc, char **argv ) goto usage; } - if ( argc > 1 ) - { - if ( strcmp( argv[1], "-h" ) == 0 ) - goto usage; - if ( strcmp( argv[1], "-?" ) == 0 ) - goto usage; - } - // get the names from the resource file if ( Cmd_FlagReadByName(pAbc, "capowin") ) pProgNameCapoWin = Cmd_FlagReadByName(pAbc, "capowin"); @@ -2125,7 +2131,6 @@ int CmdCommandCapo( Abc_Frame_t * pAbc, int argc, char **argv ) return 0; usage: - fprintf( pErr, "\n" ); fprintf( pErr, "Usage: capo [-h] \n"); fprintf( pErr, " peforms placement of the current network using Capo\n" ); fprintf( pErr, " a Capo binary should be present in the same directory\n" ); @@ -2244,8 +2249,28 @@ usage: ******************************************************************************/ int CmdCommandVersion( Abc_Frame_t * pAbc, int argc, char **argv ) { + int c; + + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + { + switch ( c ) + { + case 'h': + goto usage; + default: + goto usage; + } + } + printf("%s\n", Abc_UtilsGetVersion(pAbc)); return 0; + +usage: + fprintf( pAbc->Err, "usage: version [-h]\n" ); + fprintf( pAbc->Err, " print the version string\n" ); + fprintf( pAbc->Err, " -h : print the command usage\n"); + return 1; } diff --git a/src/base/cmd/cmdInt.h b/src/base/cmd/cmdInt.h index 2827e47b..dc6a46f6 100644 --- a/src/base/cmd/cmdInt.h +++ b/src/base/cmd/cmdInt.h @@ -77,7 +77,7 @@ extern FILE * CmdFileOpen( Abc_Frame_t * pAbc, char * sFileName, char * sMod extern void CmdFreeArgv( int argc, char ** argv ); extern char ** CmdAddToArgv( int argc, char ** argv ); extern void CmdCommandFree( Abc_Command * pCommand ); -extern void CmdCommandPrint( Abc_Frame_t * pAbc, int fPrintAll ); +extern void CmdCommandPrint( Abc_Frame_t * pAbc, int fPrintAll, int fDetails ); extern void CmdPrintTable( st__table * tTable, int fAliases ); //////////////////////////////////////////////////////////////////////// diff --git a/src/base/cmd/cmdUtils.c b/src/base/cmd/cmdUtils.c index 7f2e9b08..d86ecf7e 100644 --- a/src/base/cmd/cmdUtils.c +++ b/src/base/cmd/cmdUtils.c @@ -543,16 +543,17 @@ void CmdCommandFree( Abc_Command * pCommand ) SeeAlso [] ***********************************************************************/ -void CmdCommandPrint( Abc_Frame_t * pAbc, int fPrintAll ) +void CmdCommandPrint( Abc_Frame_t * pAbc, int fPrintAll, int fDetails ) { const char *key; char *value; st__generator * gen; Abc_Command ** ppCommands; Abc_Command * pCommands; - int nCommands, i; + int nCommands, iGroupStart, i, j; char * sGroupCur; int LenghtMax, nColumns, iCom = 0; + FILE *backupErr = pAbc->Err; // put all commands into one array nCommands = st__count( pAbc->tCommands ); @@ -584,6 +585,8 @@ void CmdCommandPrint( Abc_Frame_t * pAbc, int fPrintAll ) // print the command by group sGroupCur = NULL; + iGroupStart = 0; + pAbc->Err = pAbc->Out; for ( i = 0; i < nCommands; i++ ) if ( sGroupCur && strcmp( sGroupCur, ppCommands[i]->sGroup ) == 0 ) { // this command belongs to the same group as the previous one @@ -595,6 +598,22 @@ void CmdCommandPrint( Abc_Frame_t * pAbc, int fPrintAll ) else { // this command starts the new group of commands // start the new group + if ( fDetails && i != iGroupStart ) + { // print help messages for all commands in the previous groups + fprintf( pAbc->Out, "\n" ); + for ( j = iGroupStart; j < i; j++ ) + { + fprintf( pAbc->Out, "\n" ); + // fprintf( pAbc->Out, "--- %s ---\n", ppCommands[j]->sName ); + char *tmp_cmd = ABC_ALLOC(char, strlen(ppCommands[j]->sName)+4); + (void) sprintf(tmp_cmd, "%s -h", ppCommands[j]->sName); + (void) Cmd_CommandExecute( pAbc, tmp_cmd ); + ABC_FREE(tmp_cmd); + } + fprintf( pAbc->Out, "\n" ); + fprintf( pAbc->Out, " ----------------------------------------------------------------------" ); + iGroupStart = i; + } fprintf( pAbc->Out, "\n" ); fprintf( pAbc->Out, "\n" ); fprintf( pAbc->Out, "%s commands:\n", ppCommands[i]->sGroup ); @@ -605,6 +624,20 @@ void CmdCommandPrint( Abc_Frame_t * pAbc, int fPrintAll ) // reset the command counter iCom = 1; } + if ( fDetails && i != iGroupStart ) + { // print help messages for all commands in the previous groups + fprintf( pAbc->Out, "\n" ); + for ( j = iGroupStart; j < i; j++ ) + { + fprintf( pAbc->Out, "\n" ); + // fprintf( pAbc->Out, "--- %s ---\n", ppCommands[j]->sName ); + char *tmp_cmd = ABC_ALLOC(char, strlen(ppCommands[j]->sName)+4); + (void) sprintf(tmp_cmd, "%s -h", ppCommands[j]->sName); + (void) Cmd_CommandExecute( pAbc, tmp_cmd ); + ABC_FREE(tmp_cmd); + } + } + pAbc->Err = backupErr; fprintf( pAbc->Out, "\n" ); ABC_FREE( ppCommands ); } diff --git a/src/map/fpga/fpga.c b/src/map/fpga/fpga.c index cf88e90b..5cf04f85 100644 --- a/src/map/fpga/fpga.c +++ b/src/map/fpga/fpga.c @@ -161,7 +161,7 @@ int Fpga_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv ) return 0; usage: - fprintf( pErr, "\nusage: read_lut [-vh]\n"); + fprintf( pErr, "usage: read_lut [-vh]\n"); fprintf( pErr, "\t read the LUT library from the file\n" ); fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") ); fprintf( pErr, "\t-h : print the command usage\n"); @@ -231,7 +231,7 @@ int Fpga_CommandPrintLibrary( Abc_Frame_t * pAbc, int argc, char **argv ) return 0; usage: - fprintf( pErr, "\nusage: print_lut [-vh]\n"); + fprintf( pErr, "usage: print_lut [-vh]\n"); fprintf( pErr, "\t print the current LUT library\n" ); fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") ); fprintf( pErr, "\t-h : print the command usage\n"); -- cgit v1.2.3