ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
cmdApi.c File Reference
#include "base/abc/abc.h"
#include "base/main/mainInt.h"
#include "cmdInt.h"
Include dependency graph for cmdApi.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START 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)
 
int Cmd_CommandHandleSpecial (Abc_Frame_t *pAbc, const char *sCommand)
 
int Cmd_CommandExecute (Abc_Frame_t *pAbc, const char *sCommand)
 

Function Documentation

◆ Cmd_CommandAdd()

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

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()

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

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_CommandHandleSpecial()

int Cmd_CommandHandleSpecial ( Abc_Frame_t * pAbc,
const char * sCommand )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 99 of file cmdApi.c.

100{
101 Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
102 int piCountNew = (pNtk && Abc_NtkHasMapping(pNtk)) ? Abc_NtkCiNum(pNtk) : 0, piCount = 0;
103 int poCountNew = (pNtk && Abc_NtkHasMapping(pNtk)) ? Abc_NtkCoNum(pNtk) : 0, poCount = 0;
104 int ndCountNew = (pNtk && Abc_NtkHasMapping(pNtk)) ? Abc_NtkNodeNum(pNtk) : 0, ndCount = 0;
105 double AreaNew = (pNtk && Abc_NtkHasMapping(pNtk)) ? Abc_NtkGetMappedArea(pNtk) : 0, Area = 0;
106 int DepthNew = (pNtk && Abc_NtkHasMapping(pNtk)) ? Abc_NtkLevel(pNtk) : 0, Depth = 0;
107 if ( strstr(sCommand, "#PS") )
108 {
109 printf( "pi=%d ", piCountNew );
110 printf( "po=%d ", poCountNew );
111 printf( "fn=%d ", ndCountNew );
112 printf( "ma=%.1f ", AreaNew );
113 printf( "de=%d ", DepthNew );
114 printf( "\n" );
115 return 1;
116 }
117 if ( strstr(sCommand, "#CEC") )
118 {
119 //int proofStatus = Abc_NtkVerifyUsingCec(pNtk);
120 int proofStatus = 1;
121 // -1 (undecided), 0 (different), 1 (equivalent)
122 printf( "proofStatus=%d\n", proofStatus );
123 return 1;
124 }
125 if ( strstr(sCommand, "#ASSERT") )
126 {
127 int Status = 0;
128 char * pNumb = strrchr( (char *)sCommand, '=' );
129 if ( strstr(sCommand, "_PI_") )
130 {
131 piCount = pNumb ? atoi(pNumb+1) : 0;
132 if ( strstr( sCommand, "==" ) )
133 Status = piCountNew == piCount;
134 else if ( strstr( sCommand, "<=" ) )
135 Status = piCountNew <= piCount;
136 else return 0;
137 }
138 else if ( strstr(sCommand, "_PO_") )
139 {
140 poCount = pNumb ? atoi(pNumb+1) : 0;
141 if ( strstr( sCommand, "==" ) )
142 Status = poCountNew == poCount;
143 else if ( strstr( sCommand, "<=" ) )
144 Status = poCountNew <= poCount;
145 else return 0;
146 }
147 else if ( strstr(sCommand, "_NODE_") )
148 {
149 ndCount = pNumb ? atoi(pNumb+1) : 0;
150 if ( strstr( sCommand, "==" ) )
151 Status = ndCountNew == ndCount;
152 else if ( strstr( sCommand, "<=" ) )
153 Status = ndCountNew <= ndCount;
154 else return 0;
155 }
156 else if ( strstr(sCommand, "_AREA_") )
157 {
158 double Eplison = 1.0;
159 Area = pNumb ? atof(pNumb+1) : 0;
160 if ( strstr( sCommand, "==" ) )
161 Status = AreaNew >= Area - Eplison && AreaNew <= Area + Eplison;
162 else if ( strstr( sCommand, "<=" ) )
163 Status = AreaNew <= Area + Eplison;
164 else return 0;
165 }
166 else if ( strstr(sCommand, "_DEPTH_") )
167 {
168 Depth = pNumb ? atoi(pNumb+1) : 0;
169 if ( strstr( sCommand, "==" ) )
170 Status = DepthNew == Depth;
171 else if ( strstr( sCommand, "<=" ) )
172 Status = DepthNew <= Depth;
173 else return 0;
174 }
175 else return 0;
176 printf( "%s\n", Status ? "succeeded" : "failed" );
177 return 1;
178 }
179 return 0;
180}
ABC_DLL double Abc_NtkGetMappedArea(Abc_Ntk_t *pNtk)
Definition abcUtil.c:347
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
Definition abcDfs.c:1449
ABC_DLL Abc_Ntk_t * Abc_FrameReadNtk(Abc_Frame_t *p)
Definition mainFrame.c:327
char * strrchr()
char * strstr()
double atof()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cmd_CommandIsDefined()

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

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