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

Go to the source code of this file.

Functions

char * Abc_UtilsGetVersion (Abc_Frame_t *pAbc)
 FUNCTION DEFINITIONS ///.
 
char * Abc_UtilsGetUsersInput (Abc_Frame_t *pAbc)
 
void Abc_UtilsPrintHello (Abc_Frame_t *pAbc)
 
void Abc_UtilsPrintUsage (Abc_Frame_t *pAbc, char *ProgName)
 
void Abc_UtilsSource (Abc_Frame_t *pAbc)
 
void Abc_FrameStoreStop (Abc_Frame_t *pAbc)
 
void Abc_FrameStoreStart (Abc_Frame_t *pAbc)
 
void Abc_FrameStoreAdd (Abc_Frame_t *pAbc, Gia_Man_t *pGia)
 
void Abc_FrameStorePrint (Abc_Frame_t *pAbc)
 

Function Documentation

◆ Abc_FrameStoreAdd()

void Abc_FrameStoreAdd ( Abc_Frame_t * pAbc,
Gia_Man_t * pGia )

Definition at line 316 of file mainUtils.c.

317{
318 if ( pAbc->pHash == NULL )
319 Abc_FrameStoreStart( pAbc );
320 Gia_Man_t * p = Gia_ManIsoCanonicize( pGia, 0 );
321 Vec_IntClear( pAbc->pHash->vEntry );
322 Vec_IntPush( pAbc->pHash->vEntry, 0 );
323 Vec_IntPush( pAbc->pHash->vEntry, Gia_ManPiNum(p) );
324 Vec_IntPush( pAbc->pHash->vEntry, Gia_ManPoNum(p) );
325 Vec_IntPush( pAbc->pHash->vEntry, Gia_ManRegNum(p) );
326 Gia_Obj_t * pObj; int i;
327 Gia_ManForEachAnd( p, pObj, i )
328 Vec_IntPushTwo( pAbc->pHash->vEntry, Gia_ObjFaninLit0(pObj, i), Gia_ObjFaninLit1(pObj, i) );
329 int iEntry = Hsh_VecManAdd( pAbc->pHash, pAbc->pHash->vEntry );
330 if ( Vec_IntSize(pAbc->pHash->vValue) == iEntry )
331 Vec_IntPush( pAbc->pHash->vValue, 0 );
332 Vec_IntAddToEntry( pAbc->pHash->vValue, iEntry, 1 );
333 assert( Vec_IntSize(pAbc->pHash->vValue) == Hsh_VecSize(pAbc->pHash) );
334 Gia_ManStop( p );
335}
Cube * p
Definition exorList.c:222
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
#define Gia_ManForEachAnd(p, pObj, i)
Definition gia.h:1214
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
Gia_Man_t * Gia_ManIsoCanonicize(Gia_Man_t *p, int fVerbose)
Definition giaIso.c:958
void Abc_FrameStoreStart(Abc_Frame_t *pAbc)
Definition mainUtils.c:309
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:

◆ Abc_FrameStorePrint()

void Abc_FrameStorePrint ( Abc_Frame_t * pAbc)

Definition at line 336 of file mainUtils.c.

337{
338 if ( pAbc->pHash == NULL )
339 Abc_FrameStoreStart( pAbc );
340 int i, Entry, nAll = 0, Max = Vec_IntFindMax( pAbc->pHash->vValue );
341 Vec_Int_t * vCounts = Vec_IntStart( Max+1 );
342 Vec_IntForEachEntry( pAbc->pHash->vValue, Entry, i )
343 Vec_IntAddToEntry( vCounts, Entry, 1 );
344 printf( "Distribution of %d stored items by reference count (<ref_count>=<num_items>): ", Hsh_VecSize(pAbc->pHash) );
345 Vec_IntForEachEntry( vCounts, Entry, i )
346 if ( Entry )
347 printf( "%d=%d ", i, Entry ), nAll += i * Entry;
348 printf( "ALL=%d\n", nAll );
349 Vec_IntFree( vCounts );
350}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the call graph for this function:

◆ Abc_FrameStoreStart()

void Abc_FrameStoreStart ( Abc_Frame_t * pAbc)

Definition at line 309 of file mainUtils.c.

310{
311 Abc_FrameStoreStop( pAbc );
312 pAbc->pHash = Hsh_VecManStart( 1000 );
313 pAbc->pHash->vEntry = Vec_IntAlloc( 1000 );
314 pAbc->pHash->vValue = Vec_IntAlloc( 1000 );
315}
void Abc_FrameStoreStop(Abc_Frame_t *pAbc)
Definition mainUtils.c:303
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_FrameStoreStop()

void Abc_FrameStoreStop ( Abc_Frame_t * pAbc)

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

Synopsis []

Description []

SideEffects []

Definition at line 303 of file mainUtils.c.

304{
305 if ( pAbc->pHash )
306 Hsh_VecManStop( pAbc->pHash );
307 pAbc->pHash = NULL;
308}
Here is the caller graph for this function:

◆ Abc_UtilsGetUsersInput()

char * Abc_UtilsGetUsersInput ( Abc_Frame_t * pAbc)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 77 of file mainUtils.c.

78{
79 static char Prompt[5000];
80 sprintf( Prompt, "abc %02d> ", pAbc->nSteps );
81#ifdef ABC_USE_READLINE
82 {
83 static char * line = NULL;
84 if (line != NULL) ABC_FREE(line);
85 line = readline(Prompt);
86 if (line == NULL){ printf("***EOF***\n"); exit(0); }
87 add_history(line);
88 return line;
89 }
90#else
91 {
92 char * pRetValue;
93 fprintf( pAbc->Out, "%s", Prompt );
94 pRetValue = fgets( Prompt, 5000, stdin );
95 return Prompt;
96 }
97#endif
98}
#define ABC_FREE(obj)
Definition abc_global.h:267
char * sprintf()
VOID_HACK exit()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_UtilsGetVersion()

char * Abc_UtilsGetVersion ( Abc_Frame_t * pAbc)

FUNCTION DEFINITIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 52 of file mainUtils.c.

53{
54 static char Version[1000];
55#if __GNUC__
56 #pragma GCC diagnostic push
57 #pragma GCC diagnostic ignored "-Wdate-time"
58#endif
59 sprintf(Version, "%s (compiled %s %s)", ABC_VERSION, __DATE__, __TIME__);
60#if __GNUC__
61 #pragma GCC diagnostic pop
62#endif
63 return Version;
64}
#define ABC_VERSION
INCLUDES ///.
Definition mainInt.h:49
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_UtilsPrintHello()

void Abc_UtilsPrintHello ( Abc_Frame_t * pAbc)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 111 of file mainUtils.c.

112{
113 fprintf( pAbc->Out, "%s\n", pAbc->sVersion );
114}
Here is the caller graph for this function:

◆ Abc_UtilsPrintUsage()

void Abc_UtilsPrintUsage ( Abc_Frame_t * pAbc,
char * ProgName )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 127 of file mainUtils.c.

128{
129 fprintf( pAbc->Err, "\n" );
130 fprintf( pAbc->Err,
131 "usage: %s [-c cmd] [-q cmd] [-C cmd] [-Q cmd] [-f script] [-h] [-o file] [-s] [-t type] [-T type] [-x] [-b] [file]\n",
132 ProgName);
133 fprintf( pAbc->Err, " -c cmd\texecute commands `cmd'\n");
134 fprintf( pAbc->Err, " -q cmd\texecute commands `cmd' quietly\n");
135 fprintf( pAbc->Err, " -C cmd\texecute commands `cmd', then continue in interactive mode\n");
136 fprintf( pAbc->Err, " -Q cmd\texecute commands `cmd' quietly, then continue in interactive mode\n");
137 fprintf( pAbc->Err, " -F script\texecute commands from a script file and echo commands\n");
138 fprintf( pAbc->Err, " -f script\texecute commands from a script file\n");
139 fprintf( pAbc->Err, " -h\t\tprint the command usage\n");
140 fprintf( pAbc->Err, " -o file\tspecify output filename to store the result\n");
141 fprintf( pAbc->Err, " -s\t\tdo not read any initialization file\n");
142 fprintf( pAbc->Err, " -t type\tspecify input type (blif_mv (default), blif_mvs, blif, or none)\n");
143 fprintf( pAbc->Err, " -T type\tspecify output type (blif_mv (default), blif_mvs, blif, or none)\n");
144 fprintf( pAbc->Err, " -x\t\tequivalent to '-t none -T none'\n");
145 fprintf( pAbc->Err, " -b\t\trunning in bridge mode\n");
146 fprintf( pAbc->Err, "\n" );
147}
Here is the caller graph for this function:

◆ Abc_UtilsSource()

void Abc_UtilsSource ( Abc_Frame_t * pAbc)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 160 of file mainUtils.c.

161{
162#ifdef WIN32
163 if ( Cmd_CommandExecute(pAbc, "source abc.rc") )
164 {
165 if ( Cmd_CommandExecute(pAbc, "source ..\\abc.rc") == 0 )
166 printf( "Loaded \"abc.rc\" from the parent directory.\n" );
167 else if ( Cmd_CommandExecute(pAbc, "source ..\\..\\abc.rc") == 0 )
168 printf( "Loaded \"abc.rc\" from the grandparent directory.\n" );
169 }
170#else
171
172#if 0
173 {
174 char * sPath1, * sPath2;
175
176 // If .rc is present in both the home and current directories, then read
177 // it from the home directory. Otherwise, read it from wherever it's located.
178 sPath1 = Extra_UtilFileSearch(".rc", "~/", "r");
179 sPath2 = Extra_UtilFileSearch(".rc", ".", "r");
180
181 if ( sPath1 && sPath2 ) {
182 /* ~/.rc == .rc : Source the file only once */
183 (void) Cmd_CommandExecute(pAbc, "source -s ~/.rc");
184 }
185 else {
186 if (sPath1) {
187 (void) Cmd_CommandExecute(pAbc, "source -s ~/.rc");
188 }
189 if (sPath2) {
190 (void) Cmd_CommandExecute(pAbc, "source -s .rc");
191 }
192 }
193 if ( sPath1 ) ABC_FREE(sPath1);
194 if ( sPath2 ) ABC_FREE(sPath2);
195
196 /* execute the abc script which can be open with the "open_path" */
197 Cmd_CommandExecute( pAbc, "source -s abc.rc" );
198 }
199#endif
200
201 {
202 char * sPath1, * sPath2;
203 char * home;
204
205 // If .rc is present in both the home and current directories, then read
206 // it from the home directory. Otherwise, read it from wherever it's located.
207 home = getenv("HOME");
208 if (home){
209 char * sPath3 = ABC_ALLOC(char, strlen(home) + 2);
210 (void) sprintf(sPath3, "%s/", home);
211 sPath1 = Extra_UtilFileSearch(".abc.rc", sPath3, "r");
212 ABC_FREE(sPath3);
213 }else
214 sPath1 = NULL;
215
216 sPath2 = Extra_UtilFileSearch(".abc.rc", ".", "r");
217
218 if ( sPath1 && sPath2 ) {
219 /* ~/.rc == .rc : Source the file only once */
220 char *tmp_cmd = ABC_ALLOC(char, strlen(sPath1)+12);
221 (void) sprintf(tmp_cmd, "source -s %s", sPath1);
222 // (void) Cmd_CommandExecute(pAbc, "source -s ~/.abc.rc");
223 (void) Cmd_CommandExecute(pAbc, tmp_cmd);
224 ABC_FREE(tmp_cmd);
225 }
226 else {
227 if (sPath1) {
228 char *tmp_cmd = ABC_ALLOC(char, strlen(sPath1)+12);
229 (void) sprintf(tmp_cmd, "source -s %s", sPath1);
230 // (void) Cmd_CommandExecute(pAbc, "source -s ~/.abc.rc");
231 (void) Cmd_CommandExecute(pAbc, tmp_cmd);
232 ABC_FREE(tmp_cmd);
233 }
234 if (sPath2) {
235 char *tmp_cmd = ABC_ALLOC(char, strlen(sPath2)+12);
236 (void) sprintf(tmp_cmd, "source -s %s", sPath2);
237 // (void) Cmd_CommandExecute(pAbc, "source -s .abc.rc");
238 (void) Cmd_CommandExecute(pAbc, tmp_cmd);
239 ABC_FREE(tmp_cmd);
240 }
241 }
242 if ( sPath1 ) ABC_FREE(sPath1);
243 if ( sPath2 ) ABC_FREE(sPath2);
244
245 /* execute the abc script which can be open with the "open_path" */
246 Cmd_CommandExecute( pAbc, "source -s abc.rc" );
247 }
248
249#endif //WIN32
250}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
ABC_DLL int Cmd_CommandExecute(Abc_Frame_t *pAbc, const char *sCommand)
Definition cmdApi.c:193
char * Extra_UtilFileSearch(char *file, char *path, char *mode)
int strlen()
char * getenv()
Here is the call graph for this function:
Here is the caller graph for this function: