ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
cmd.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef typedefABC_NAMESPACE_HEADER_START struct MvCommand Abc_Command
 INCLUDES ///.
 
typedef struct MvAlias Abc_Alias
 
typedef int(* Cmd_CommandFuncType) (Abc_Frame_t *, int, char **)
 

Functions

void Cmd_Init (Abc_Frame_t *pAbc)
 MACRO DEFINITIONS ///.
 
void Cmd_End (Abc_Frame_t *pAbc)
 
int Cmd_CommandIsDefined (Abc_Frame_t *pAbc, const char *sName)
 DECLARATIONS ///.
 
void Cmd_CommandAdd (Abc_Frame_t *pAbc, const char *sGroup, const char *sName, Cmd_CommandFuncType pFunc, int fChanges)
 
ABC_DLL int Cmd_CommandExecute (Abc_Frame_t *pAbc, const char *sCommand)
 
char * Cmd_FlagReadByName (Abc_Frame_t *pAbc, char *flag)
 DECLARATIONS ///.
 
void Cmd_FlagDeleteByName (Abc_Frame_t *pAbc, const char *key)
 
void Cmd_FlagUpdateValue (Abc_Frame_t *pAbc, const char *key, char *value)
 
void Cmd_HistoryAddCommand (Abc_Frame_t *pAbc, const char *command)
 FUNCTION DEFINITIONS ///.
 
void Cmd_HistoryRead (Abc_Frame_t *p)
 
void Cmd_HistoryWrite (Abc_Frame_t *p, int Limit)
 
void Cmd_HistoryPrint (Abc_Frame_t *p, int Limit)
 
int CmdCommandLoad (Abc_Frame_t *pAbc, int argc, char **argv)
 DECLARATIONS ///.
 

Typedef Documentation

◆ Abc_Alias

typedef struct MvAlias Abc_Alias

Definition at line 40 of file cmd.h.

◆ Abc_Command

typedef typedefABC_NAMESPACE_HEADER_START struct MvCommand Abc_Command

INCLUDES ///.

CFile****************************************************************

FileName [cmd.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [External declarations of the command package.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
cmd.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

] PARAMETERS /// STRUCTURE DEFINITIONS ///

Definition at line 39 of file cmd.h.

◆ Cmd_CommandFuncType

typedef int(* Cmd_CommandFuncType) (Abc_Frame_t *, int, char **)

Definition at line 54 of file cmd.h.

Function Documentation

◆ Cmd_CommandAdd()

void Cmd_CommandAdd ( Abc_Frame_t * pAbc,
const char * sGroup,
const char * sName,
Cmd_CommandFuncType pFunc,
int fChanges )
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 63 of file cmdApi.c.

64{
65 const char * key;
66 char * value;
67 Abc_Command * pCommand;
68 int fStatus;
69
70 key = sName;
71 if ( st__delete( pAbc->tCommands, &key, &value ) )
72 {
73 // delete existing definition for this command
74 fprintf( pAbc->Err, "Cmd warning: redefining '%s'\n", sName );
76 }
77
78 // create the new command
79 pCommand = ABC_ALLOC( Abc_Command, 1 );
80 pCommand->sName = Extra_UtilStrsav( sName );
81 pCommand->sGroup = Extra_UtilStrsav( sGroup );
82 pCommand->pFunc = pFunc;
83 pCommand->fChange = fChanges;
84 fStatus = st__insert( pAbc->tCommands, pCommand->sName, (char *)pCommand );
85 assert( !fStatus ); // the command should not be in the table
86}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
ABC_NAMESPACE_IMPL_START typedef signed char value
void CmdCommandFree(Abc_Command *pCommand)
Definition cmdUtils.c:539
typedefABC_NAMESPACE_HEADER_START struct MvCommand Abc_Command
INCLUDES ///.
Definition cmd.h:39
char * Extra_UtilStrsav(const char *s)
enum keys key
Definition main.h:25
int st__delete(st__table *table, const char **keyp, char **value)
Definition st.c:375
int st__insert(st__table *table, const char *key, char *value)
Definition st.c:171
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cmd_CommandExecute()

ABC_DLL int Cmd_CommandExecute ( Abc_Frame_t * pAbc,
const char * sCommand )
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 193 of file cmdApi.c.

194{
195 int fStatus = 0, argc, loop;
196 const char * sCommandNext;
197 char **argv;
198
199 if ( !pAbc->fAutoexac && !pAbc->fSource )
200 Cmd_HistoryAddCommand(pAbc, sCommand);
201 sCommandNext = sCommand;
202 do
203 {
204 if ( sCommandNext[0] == '#' && Cmd_CommandHandleSpecial( pAbc, sCommandNext ) )
205 break;
206 sCommandNext = CmdSplitLine( pAbc, sCommandNext, &argc, &argv );
207 loop = 0;
208 fStatus = CmdApplyAlias( pAbc, &argc, &argv, &loop );
209 if ( fStatus == 0 )
210 fStatus = CmdCommandDispatch( pAbc, &argc, &argv );
211 CmdFreeArgv( argc, argv );
212 }
213 while ( fStatus == 0 && *sCommandNext != '\0' );
214 return fStatus;
215}
int Cmd_CommandHandleSpecial(Abc_Frame_t *pAbc, const char *sCommand)
Definition cmdApi.c:99
int CmdCommandDispatch(Abc_Frame_t *pAbc, int *argc, char ***argv)
Definition cmdUtils.c:97
const char * CmdSplitLine(Abc_Frame_t *pAbc, const char *sCommand, int *argc, char ***argv)
Definition cmdUtils.c:185
int CmdApplyAlias(Abc_Frame_t *pAbc, int *argc, char ***argv, int *loop)
Definition cmdUtils.c:271
void CmdFreeArgv(int argc, char **argv)
Definition cmdUtils.c:489
void Cmd_HistoryAddCommand(Abc_Frame_t *pAbc, const char *command)
FUNCTION DEFINITIONS ///.
Definition cmdHist.c:50
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cmd_CommandIsDefined()

int Cmd_CommandIsDefined ( Abc_Frame_t * pAbc,
const char * sName )
extern

DECLARATIONS ///.

CFile****************************************************************

FileName [cmdApi.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [External procedures of the command package.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
cmdApi.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

] FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file cmdApi.c.

48{
49 return st__is_member( pAbc->tCommands, sName );
50}
#define st__is_member(table, key)
Definition st.h:70

◆ Cmd_End()

void Cmd_End ( Abc_Frame_t * pAbc)
extern

Function********************************************************************

Synopsis [Ends the command package.]

Description [Ends the command package. Tables are freed.]

SideEffects []

SeeAlso []

Definition at line 139 of file cmd.c.

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}
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition abc_global.h:250
#define ABC_FREE(obj)
Definition abc_global.h:267
void CmdCommandAliasFree(Abc_Alias *pAlias)
Definition cmdAlias.c:113
void Cmd_HistoryWrite(Abc_Frame_t *p, int Limit)
Definition cmdHist.c:134
struct MvAlias Abc_Alias
Definition cmd.h:40
void st__free_table(st__table *table)
Definition st.c:81
#define st__foreach_item(table, gen, key, value)
Definition st.h:107

◆ Cmd_FlagDeleteByName()

void Cmd_FlagDeleteByName ( Abc_Frame_t * pAbc,
const char * key )
extern

Function********************************************************************

Synopsis [Deletes a set value by calling instead of unset command.]

Description [Deletes a set value by calling instead of unset command.]

SideEffects []

Definition at line 90 of file cmdFlag.c.

91{
92 char *value;
93 if ( !key )
94 return;
95 if ( st__delete( pAbc->tFlags, &key, &value ) )
96 {
99 }
100}
Here is the call graph for this function:

◆ Cmd_FlagReadByName()

char * Cmd_FlagReadByName ( Abc_Frame_t * pAbc,
char * flag )
extern

DECLARATIONS ///.

CFile****************************************************************

FileName [cmdFlag.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [Procedures working with flags.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
cmdFlag.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

] FUNCTION DEFINITIONS /// Function********************************************************************

Synopsis [Looks up value of flag in table of named values.]

Description [The command parser maintains a table of named values. These are manipulated using the 'set' and 'unset' commands. The value of the named flag is returned, or NULL is returned if the flag has not been set.]

SideEffects []

Definition at line 47 of file cmdFlag.c.

48{
49 char * value;
50 if ( st__lookup(pAbc->tFlags, flag, &value) )
51 return value;
52 return NULL;
53}
int st__lookup(st__table *table, const char *key, char **value)
Definition st.c:114
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cmd_FlagUpdateValue()

void Cmd_FlagUpdateValue ( Abc_Frame_t * pAbc,
const char * key,
char * value )
extern

Function********************************************************************

Synopsis [Updates a set value by calling instead of set command.]

Description [Updates a set value by calling instead of set command.]

SideEffects []

Definition at line 65 of file cmdFlag.c.

66{
67 char * oldValue, * newValue;
68 if ( !key )
69 return;
70 if ( value )
71 newValue = Extra_UtilStrsav(value);
72 else
73 newValue = Extra_UtilStrsav("");
74// newValue = NULL;
75 if ( st__delete(pAbc->tFlags, &key, &oldValue) )
76 ABC_FREE(oldValue);
77 st__insert( pAbc->tFlags, key, newValue );
78}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cmd_HistoryAddCommand()

void Cmd_HistoryAddCommand ( Abc_Frame_t * p,
const char * command )
extern

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 50 of file cmdHist.c.

51{
52 int nLastLooked = 10; // do not add history if the same entry appears among the last entries
53 int nLastSaved = 10000; // when saving a file, save no more than this number of last entries
54 char Buffer[ABC_MAX_STR];
55 int Len;
56 if ( p->fBatchMode )
57 return;
58 Len = strlen(command);
59 strcpy( Buffer, command );
60 if ( Len > 0 && Buffer[Len-1] == '\n' )
61 Buffer[Len-1] = 0;
62 if ( strlen(Buffer) > 3 &&
63 strncmp(Buffer,"set",3) &&
64 strncmp(Buffer,"unset",5) &&
65 strncmp(Buffer,"time",4) &&
66 strncmp(Buffer,"quit",4) &&
67 strncmp(Buffer,"alias",5) &&
68 strncmp(Buffer,"source abc.rc",13) &&
69 strncmp(Buffer,"source ..\\abc.rc",16) &&
70 strncmp(Buffer,"history",7) && strncmp(Buffer,"hi ", 3) && strcmp(Buffer,"hi") &&
71 Buffer[strlen(Buffer)-1] != '?' )
72 {
73 char * pStr = NULL;
74 int i, Start = Abc_MaxInt( 0, Vec_PtrSize(p->aHistory) - nLastLooked );
75 // do not enter if the same command appears among nLastLooked commands
76 Vec_PtrForEachEntryStart( char *, p->aHistory, pStr, i, Start )
77 if ( !strcmp(pStr, Buffer) )
78 break;
79 if ( i == Vec_PtrSize(p->aHistory) )
80 { // add new entry
81 Vec_PtrPush( p->aHistory, Extra_UtilStrsav(Buffer) );
82 Cmd_HistoryWrite( p, nLastSaved );
83 }
84 else
85 { // put at the end
86 Vec_PtrRemove( p->aHistory, pStr );
87 Vec_PtrPush( p->aHistory, pStr );
88 }
89 }
90}
void Cmd_HistoryWrite(Abc_Frame_t *p, int Limit)
Definition cmdHist.c:134
#define Len
Definition deflate.h:78
Cube * p
Definition exorList.c:222
#define ABC_MAX_STR
Definition mainInt.h:52
int strncmp()
int strlen()
int strcmp()
char * strcpy()
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition vecPtr.h:57
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cmd_HistoryPrint()

void Cmd_HistoryPrint ( Abc_Frame_t * p,
int Limit )
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 164 of file cmdHist.c.

165{
166#if defined(ABC_USE_HISTORY)
167 char * pStr;
168 int i;
169 Limit = Abc_MaxInt( 0, Vec_PtrSize(p->aHistory)-Limit );
170 printf( "================== Command history ==================\n" );
171 Vec_PtrForEachEntryStart( char *, p->aHistory, pStr, i, Limit )
172 printf( "%s\n", pStr );
173 printf( "=====================================================\n" );
174#endif
175}
Here is the caller graph for this function:

◆ Cmd_HistoryRead()

void Cmd_HistoryRead ( Abc_Frame_t * p)
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 103 of file cmdHist.c.

104{
105#if defined(ABC_USE_HISTORY)
106 char Buffer[ABC_MAX_STR];
107 FILE * pFile;
108 assert( Vec_PtrSize(p->aHistory) == 0 );
109 pFile = fopen( "abc.history", "rb" );
110 if ( pFile == NULL )
111 return;
112 while ( fgets( Buffer, ABC_MAX_STR, pFile ) != NULL )
113 {
114 int Len = strlen(Buffer);
115 if ( Buffer[Len-1] == '\n' )
116 Buffer[Len-1] = 0;
117 Vec_PtrPush( p->aHistory, Extra_UtilStrsav(Buffer) );
118 }
119 fclose( pFile );
120#endif
121}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cmd_HistoryWrite()

void Cmd_HistoryWrite ( Abc_Frame_t * p,
int Limit )
extern

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 134 of file cmdHist.c.

135{
136#if defined(ABC_USE_HISTORY)
137 FILE * pFile;
138 char * pStr;
139 int i;
140 pFile = fopen( "abc.history", "wb" );
141 if ( pFile == NULL )
142 {
143 Abc_Print( 0, "Cannot open file \"abc.history\" for writing.\n" );
144 return;
145 }
146 Limit = Abc_MaxInt( 0, Vec_PtrSize(p->aHistory)-Limit );
147 Vec_PtrForEachEntryStart( char *, p->aHistory, pStr, i, Limit )
148 fprintf( pFile, "%s\n", pStr );
149 fclose( pFile );
150#endif
151}
Here is the caller graph for this function:

◆ Cmd_Init()

void Cmd_Init ( Abc_Frame_t * pAbc)
extern

MACRO DEFINITIONS ///.

FUNCTION DEFINITIONS ///

MACRO DEFINITIONS ///.

Function********************************************************************

Synopsis [Initializes the command package.]

SideEffects [Commands are added to the command table.]

SeeAlso [Cmd_End]

Definition at line 85 of file cmd.c.

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}
int Cmd_CommandAbcLoadPlugIn(Abc_Frame_t *pAbc, int argc, char **argv)
Definition cmdPlugin.c:631
void Cmd_CommandAdd(Abc_Frame_t *pAbc, const char *sGroup, const char *sName, Cmd_CommandFuncType pFunc, int fChanges)
Definition cmdApi.c:63
void Cmd_HistoryRead(Abc_Frame_t *p)
Definition cmdHist.c:103
int st__strhash(const char *string, int modulus)
Definition st.c:449
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition st.c:72

◆ CmdCommandLoad()

int CmdCommandLoad ( Abc_Frame_t * pAbc,
int argc,
char ** argv )
extern

DECLARATIONS ///.

CFile****************************************************************

FileName [cmdApi.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [External procedures of the command package.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id
cmdApi.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

] FUNCTION DEFINITIONS /// Function********************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file cmdLoad.c.

49{
50 Vec_Str_t * vCommand;
51 FILE * pFile;
52 int i;
53 vCommand = Vec_StrAlloc( 100 );
54 Vec_StrAppend( vCommand, "abccmd_" );
55 Vec_StrAppend( vCommand, argv[0] );
56 Vec_StrAppend( vCommand, ".exe" );
57 Vec_StrPush( vCommand, 0 );
58 // check if there is the binary
59 if ( (pFile = fopen( Vec_StrArray(vCommand), "r" )) == NULL )
60 {
61 Abc_Print( -1, "Cannot run the binary \"%s\".\n\n", Vec_StrArray(vCommand) );
62 Vec_StrFree( vCommand );
63 return 1;
64 }
65 fclose( pFile );
66 Vec_StrPop( vCommand );
67 // add other arguments
68 for ( i = 1; i < argc; i++ )
69 {
70 Vec_StrAppend( vCommand, " " );
71 Vec_StrAppend( vCommand, argv[i] );
72 }
73 Vec_StrPush( vCommand, 0 );
74 // run the command line
75 if ( Util_SignalSystem( Vec_StrArray(vCommand) ) )
76 {
77 Abc_Print( -1, "The following command has returned non-zero exit status:\n" );
78 Abc_Print( -1, "\"%s\"\n", Vec_StrArray(vCommand) );
79 Vec_StrFree( vCommand );
80 return 1;
81 }
82 Vec_StrFree( vCommand );
83 return 0;
84}
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
ABC_NAMESPACE_IMPL_START int Util_SignalSystem(const char *cmd)
DECLARATIONS ///.
Definition utilSignal.c:44
Here is the call graph for this function:
Here is the caller graph for this function: