24#ifdef ABC_USE_READLINE
25#include <readline/readline.h>
26#include <readline/history.h>
35static char * DateReadFromDateString(
char * datestr );
54 static char Version[1000];
56 #pragma GCC diagnostic push
57 #pragma GCC diagnostic ignored "-Wdate-time"
61 #pragma GCC diagnostic pop
79 static char Prompt[5000];
80 sprintf( Prompt,
"abc %02d> ", pAbc->nSteps );
81#ifdef ABC_USE_READLINE
83 static char * line = NULL;
85 line = readline(Prompt);
86 if (line == NULL){ printf(
"***EOF***\n");
exit(0); }
93 fprintf( pAbc->Out,
"%s", Prompt );
94 pRetValue = fgets( Prompt, 5000, stdin );
113 fprintf( pAbc->Out,
"%s\n", pAbc->sVersion );
129 fprintf( pAbc->Err,
"\n" );
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",
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" );
166 printf(
"Loaded \"abc.rc\" from the parent directory.\n" );
168 printf(
"Loaded \"abc.rc\" from the grandparent directory.\n" );
174 char * sPath1, * sPath2;
181 if ( sPath1 && sPath2 ) {
202 char * sPath1, * sPath2;
210 (void)
sprintf(sPath3,
"%s/", home);
218 if ( sPath1 && sPath2 ) {
221 (void)
sprintf(tmp_cmd,
"source -s %s", sPath1);
229 (void)
sprintf(tmp_cmd,
"source -s %s", sPath1);
236 (void)
sprintf(tmp_cmd,
"source -s %s", sPath2);
262char * DateReadFromDateString(
char * datestr )
264 static char result[100];
275 if (sscanf(datestr,
"%s %s %2d %2d:%2d:%2d %s %4d",
276 day, month, &date, &hour, &minute, &second, zone, &year) == 8) {
278 if (hour >= 13) hour -= 12;
282 if (hour == 0) hour = 12;
285 (void)
sprintf(result,
"%d-%3s-%02d at %d:%02d %s",
286 date, month, year % 100, hour, minute, at);
306 Hsh_VecManStop( pAbc->pHash );
312 pAbc->pHash = Hsh_VecManStart( 1000 );
313 pAbc->pHash->vEntry = Vec_IntAlloc( 1000 );
314 pAbc->pHash->vValue = Vec_IntAlloc( 1000 );
318 if ( pAbc->pHash == NULL )
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) );
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) );
338 if ( pAbc->pHash == NULL )
340 int i, Entry, nAll = 0, Max = Vec_IntFindMax( pAbc->pHash->vValue );
341 Vec_Int_t * vCounts = Vec_IntStart( Max+1 );
343 Vec_IntAddToEntry( vCounts, Entry, 1 );
344 printf(
"Distribution of %d stored items by reference count (<ref_count>=<num_items>): ", Hsh_VecSize(pAbc->pHash) );
347 printf(
"%d=%d ", i, Entry ), nAll += i * Entry;
348 printf(
"ALL=%d\n", nAll );
349 Vec_IntFree( vCounts );
#define ABC_ALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
ABC_DLL int Cmd_CommandExecute(Abc_Frame_t *pAbc, const char *sCommand)
void Gia_ManStop(Gia_Man_t *p)
#define Gia_ManForEachAnd(p, pObj, i)
struct Gia_Obj_t_ Gia_Obj_t
struct Gia_Man_t_ Gia_Man_t
Gia_Man_t * Gia_ManIsoCanonicize(Gia_Man_t *p, int fVerbose)
#define ABC_VERSION
INCLUDES ///.
char * Abc_UtilsGetUsersInput(Abc_Frame_t *pAbc)
void Abc_FrameStoreAdd(Abc_Frame_t *pAbc, Gia_Man_t *pGia)
void Abc_UtilsPrintHello(Abc_Frame_t *pAbc)
void Abc_FrameStorePrint(Abc_Frame_t *pAbc)
void Abc_UtilsSource(Abc_Frame_t *pAbc)
void Abc_FrameStoreStart(Abc_Frame_t *pAbc)
char * Abc_UtilsGetVersion(Abc_Frame_t *pAbc)
FUNCTION DEFINITIONS ///.
void Abc_UtilsPrintUsage(Abc_Frame_t *pAbc, char *ProgName)
void Abc_FrameStoreStop(Abc_Frame_t *pAbc)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.