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

Go to the source code of this file.

Macros

#define Abc_NamManForEachObj(p, pStr, i)
 MACRO DEFINITIONS ///.
 

Typedefs

typedef typedefABC_NAMESPACE_HEADER_START struct Abc_Nam_t_ Abc_Nam_t
 INCLUDES ///.
 

Functions

Abc_Nam_tAbc_NamStart (int nObjs, int nAveSize)
 FUNCTION DECLARATIONS ///.
 
void Abc_NamStop (Abc_Nam_t *p)
 
void Abc_NamPrint (Abc_Nam_t *p, char *pFileName)
 
void Abc_NamSave (Abc_Nam_t *p, char *pFileName)
 
Abc_Nam_tAbc_NamLoad (char *pFileName)
 
Abc_Nam_tAbc_NamRef (Abc_Nam_t *p)
 
void Abc_NamDeref (Abc_Nam_t *p)
 
int Abc_NamObjNumMax (Abc_Nam_t *p)
 
int Abc_NamMemUsed (Abc_Nam_t *p)
 
int Abc_NamMemAlloc (Abc_Nam_t *p)
 
int Abc_NamStrFind (Abc_Nam_t *p, char *pStr)
 
int Abc_NamStrFindLim (Abc_Nam_t *p, char *pStr, char *pLim)
 
int Abc_NamStrFindOrAdd (Abc_Nam_t *p, char *pStr, int *pfFound)
 
int Abc_NamStrFindOrAddLim (Abc_Nam_t *p, char *pStr, char *pLim, int *pfFound)
 
int Abc_NamStrFindOrAddF (Abc_Nam_t *p, const char *format,...)
 
char * Abc_NamStr (Abc_Nam_t *p, int id)
 
Vec_Str_tAbc_NamBuffer (Abc_Nam_t *p)
 
Vec_Int_tAbc_NamComputeIdMap (Abc_Nam_t *p1, Abc_Nam_t *p2)
 
int Abc_NamReportCommon (Vec_Int_t *vNameIds1, Abc_Nam_t *p1, Abc_Nam_t *p2)
 
char * Abc_NamReportUnique (Vec_Int_t *vNameIds1, Abc_Nam_t *p1, Abc_Nam_t *p2)
 

Macro Definition Documentation

◆ Abc_NamManForEachObj

#define Abc_NamManForEachObj ( p,
pStr,
i )
Value:
for ( i = 1; (i < Abc_NamObjNumMax(p)) && ((pStr) = Abc_NamStr(p, i)); i++ )
Cube * p
Definition exorList.c:222
int Abc_NamObjNumMax(Abc_Nam_t *p)
Definition utilNam.c:231
char * Abc_NamStr(Abc_Nam_t *p, int NameId)
Definition utilNam.c:555

MACRO DEFINITIONS ///.

Definition at line 45 of file utilNam.h.

45#define Abc_NamManForEachObj( p, pStr, i ) \
46 for ( i = 1; (i < Abc_NamObjNumMax(p)) && ((pStr) = Abc_NamStr(p, i)); i++ )

Typedef Documentation

◆ Abc_Nam_t

typedef typedefABC_NAMESPACE_HEADER_START struct Abc_Nam_t_ Abc_Nam_t

INCLUDES ///.

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

FileName [utilNam.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Memory recycling utilities.]

Synopsis [Internal declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

] PARAMETERS /// BASIC TYPES ///

Definition at line 39 of file utilNam.h.

Function Documentation

◆ Abc_NamBuffer()

Vec_Str_t * Abc_NamBuffer ( Abc_Nam_t * p)
extern

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

Synopsis [Returns internal buffer.]

Description []

SideEffects []

SeeAlso []

Definition at line 571 of file utilNam.c.

572{
573 Vec_StrClear(&p->vBuffer);
574 return &p->vBuffer;
575}
Here is the caller graph for this function:

◆ Abc_NamComputeIdMap()

Vec_Int_t * Abc_NamComputeIdMap ( Abc_Nam_t * p1,
Abc_Nam_t * p2 )
extern

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

Synopsis [For each ID of the first manager, gives ID of the second one.]

Description []

SideEffects []

SeeAlso []

Definition at line 588 of file utilNam.c.

589{
590 Vec_Int_t * vMap;
591 char * pThis;
592 int * piPlace, iHandle1, i;
593 if ( p1 == p2 )
594 return Vec_IntStartNatural( Abc_NamObjNumMax(p1) );
595 vMap = Vec_IntStart( Abc_NamObjNumMax(p1) );
596 Vec_IntForEachEntryStart( &p1->vInt2Handle, iHandle1, i, 1 )
597 {
598 pThis = Abc_NamHandleToStr( p1, iHandle1 );
599 piPlace = Abc_NamStrHashFind( p2, pThis, NULL );
600 Vec_IntWriteEntry( vMap, i, *piPlace );
601// Abc_Print( 1, "%d->%d ", i, *piPlace );
602 }
603 return vMap;
604}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition vecInt.h:56
Here is the call graph for this function:

◆ Abc_NamDeref()

void Abc_NamDeref ( Abc_Nam_t * p)
extern

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

Synopsis [Dereferences the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 212 of file utilNam.c.

213{
214 if ( p == NULL )
215 return;
216 if ( --p->nRefs == 0 )
217 Abc_NamStop( p );
218}
void Abc_NamStop(Abc_Nam_t *p)
Definition utilNam.c:112
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NamLoad()

Abc_Nam_t * Abc_NamLoad ( char * pFileName)
extern

Definition at line 164 of file utilNam.c.

165{
166 Abc_Nam_t * p;
167 int fFound, NameId = -1, nLineSize = 1 << 20;
168 char * pBuffer = ABC_ALLOC( char, nLineSize+1 );
169 FILE * pFile = fopen( pFileName, "rb" );
170 if ( pFile == NULL ) { printf( "Count node open output file %s\n", pFileName ); return NULL; }
171 p = Abc_NamStart( 1000, 20 );
172 while ( fgets( pBuffer, nLineSize, pFile ) != NULL )
173 {
174 pBuffer[strlen(pBuffer)-1] = 0;
175 NameId = Abc_NamStrFindOrAdd( p, pBuffer, &fFound );
176 assert( !fFound );
177 }
178 assert( NameId+1 == Abc_NamObjNumMax(p) );
179 fclose( pFile );
180 ABC_FREE( pBuffer );
181 return p;
182}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
int Abc_NamStrFindOrAdd(Abc_Nam_t *p, char *pStr, int *pfFound)
Definition utilNam.c:453
Abc_Nam_t * Abc_NamStart(int nObjs, int nAveSize)
FUNCTION DEFINITIONS ///.
Definition utilNam.c:80
typedefABC_NAMESPACE_HEADER_START struct Abc_Nam_t_ Abc_Nam_t
INCLUDES ///.
Definition utilNam.h:39
#define assert(ex)
Definition util_old.h:213
int strlen()
Here is the call graph for this function:

◆ Abc_NamMemAlloc()

int Abc_NamMemAlloc ( Abc_Nam_t * p)
extern

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

Synopsis [Reports memory usage of the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 266 of file utilNam.c.

267{
268 if ( p == NULL )
269 return 0;
270 return sizeof(Abc_Nam_t) + p->nStore + sizeof(int) * p->nBins +
271 sizeof(int) * (p->vInt2Handle.nCap + p->vInt2Next.nCap);
272}

◆ Abc_NamMemUsed()

int Abc_NamMemUsed ( Abc_Nam_t * p)
extern

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

Synopsis [Reports memory usage of the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 247 of file utilNam.c.

248{
249 if ( p == NULL )
250 return 0;
251 return sizeof(Abc_Nam_t) + p->iHandle + sizeof(int) * p->nBins +
252 sizeof(int) * (p->vInt2Handle.nSize + p->vInt2Next.nSize);
253}
Here is the caller graph for this function:

◆ Abc_NamObjNumMax()

int Abc_NamObjNumMax ( Abc_Nam_t * p)
extern

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

Synopsis [Returns the number of used entries.]

Description []

SideEffects []

SeeAlso []

Definition at line 231 of file utilNam.c.

232{
233 return Vec_IntSize(&p->vInt2Handle);
234}
Here is the caller graph for this function:

◆ Abc_NamPrint()

void Abc_NamPrint ( Abc_Nam_t * p,
char * pFileName )
extern

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

Synopsis [Prints manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 134 of file utilNam.c.

135{
136 FILE * pFile = pFileName ? fopen( pFileName, "wb" ) : stdout;
137 int h, i;
138 if ( pFile == NULL ) { printf( "Count node open file %s\n", pFileName ); return; }
139 Vec_IntForEachEntryStart( &p->vInt2Handle, h, i, 1 )
140 fprintf( pFile, "%8d = %s\n", i, Abc_NamHandleToStr(p, h) );
141 if ( pFile != stdout )
142 fclose(pFile);
143}
if(last==0)
Definition sparse_int.h:34

◆ Abc_NamRef()

Abc_Nam_t * Abc_NamRef ( Abc_Nam_t * p)
extern

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

Synopsis [References the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 195 of file utilNam.c.

196{
197 p->nRefs++;
198 return p;
199}
Here is the caller graph for this function:

◆ Abc_NamReportCommon()

int Abc_NamReportCommon ( Vec_Int_t * vNameIds1,
Abc_Nam_t * p1,
Abc_Nam_t * p2 )
extern

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

Synopsis [Returns the number of common names in the array.]

Description [The array contains name IDs in the first manager. The procedure returns the number of entries that correspond to names in the first manager that appear in the second manager.]

SideEffects []

SeeAlso []

Definition at line 619 of file utilNam.c.

620{
621 int i, Entry, Counter = 0;
622 Vec_IntForEachEntry( vNameIds1, Entry, i )
623 {
624 assert( Entry > 0 && Entry < Abc_NamObjNumMax(p1) );
625 Counter += (Abc_NamStrFind(p2, Abc_NamStr(p1, Entry)) > 0);
626// if ( Abc_NamStrFind(p2, Abc_NamStr(p1, Entry)) == 0 )
627// Abc_Print( 1, "unique name <%s>\n", Abc_NamStr(p1, Entry) );
628 }
629 return Counter;
630}
int Abc_NamStrFind(Abc_Nam_t *p, char *pStr)
Definition utilNam.c:433
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the call graph for this function:

◆ Abc_NamReportUnique()

char * Abc_NamReportUnique ( Vec_Int_t * vNameIds1,
Abc_Nam_t * p1,
Abc_Nam_t * p2 )
extern

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

Synopsis [Returns the name that appears in p1 does not appear in p2.]

Description []

SideEffects []

SeeAlso []

Definition at line 643 of file utilNam.c.

644{
645 int i, Entry;
646 Vec_IntForEachEntry( vNameIds1, Entry, i )
647 {
648 assert( Entry > 0 && Entry < Abc_NamObjNumMax(p1) );
649 if ( Abc_NamStrFind(p2, Abc_NamStr(p1, Entry)) == 0 )
650 return Abc_NamStr(p1, Entry);
651 }
652 return NULL;
653}
Here is the call graph for this function:

◆ Abc_NamSave()

void Abc_NamSave ( Abc_Nam_t * p,
char * pFileName )
extern

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

Synopsis [Writes into a file and reads from a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 156 of file utilNam.c.

157{
158 FILE * pFile = fopen( pFileName, "wb" ); int h, i;
159 if ( pFile == NULL ) { printf( "Count node open input file %s\n", pFileName ); return; }
160 Vec_IntForEachEntryStart( &p->vInt2Handle, h, i, 1 )
161 fprintf( pFile, "%s\n", Abc_NamHandleToStr(p, h) );
162 fclose(pFile);
163}

◆ Abc_NamStart()

Abc_Nam_t * Abc_NamStart ( int nObjs,
int nAveSize )
extern

FUNCTION DECLARATIONS ///.

FUNCTION DECLARATIONS ///.

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

Synopsis [Creates manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 80 of file utilNam.c.

81{
82 Abc_Nam_t * p;
83 if ( nObjs == 0 )
84 nObjs = 16;
85 p = ABC_CALLOC( Abc_Nam_t, 1 );
86 p->nStore = ((nObjs * (nAveSize + 1) + 16) / 4) * 4;
87 p->pStore = ABC_ALLOC( char, p->nStore );
88 p->nBins = Abc_PrimeCudd( nObjs );
89 p->pBins = ABC_CALLOC( int, p->nBins );
90 // 0th object is unused
91 Vec_IntGrow( &p->vInt2Handle, nObjs ); Vec_IntPush( &p->vInt2Handle, -1 );
92 Vec_IntGrow( &p->vInt2Next, nObjs ); Vec_IntPush( &p->vInt2Next, -1 );
93 p->iHandle = 4;
94 memset( p->pStore, 0, 4 );
95//Abc_Print( 1, "Starting nam with %d bins.\n", p->nBins );
96 // start reference counting
97 p->nRefs = 1;
98 return p;
99}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NamStop()

void Abc_NamStop ( Abc_Nam_t * p)
extern

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

Synopsis [Deletes manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 112 of file utilNam.c.

113{
114//Abc_Print( 1, "Starting nam with %d bins.\n", p->nBins );
115 Vec_StrErase( &p->vBuffer );
116 Vec_IntErase( &p->vInt2Handle );
117 Vec_IntErase( &p->vInt2Next );
118 ABC_FREE( p->pStore );
119 ABC_FREE( p->pBins );
120 ABC_FREE( p );
121}
Here is the caller graph for this function:

◆ Abc_NamStr()

char * Abc_NamStr ( Abc_Nam_t * p,
int NameId )
extern

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

Synopsis [Returns name from name ID.]

Description []

SideEffects []

SeeAlso []

Definition at line 555 of file utilNam.c.

556{
557 return NameId > 0 ? Abc_NamIntToStr(p, NameId) : NULL;
558}
Here is the caller graph for this function:

◆ Abc_NamStrFind()

int Abc_NamStrFind ( Abc_Nam_t * p,
char * pStr )
extern

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

Synopsis [Returns the index of the string in the table.]

Description []

SideEffects []

SeeAlso []

Definition at line 433 of file utilNam.c.

434{
435 return *Abc_NamStrHashFind( p, pStr, NULL );
436}
Here is the caller graph for this function:

◆ Abc_NamStrFindLim()

int Abc_NamStrFindLim ( Abc_Nam_t * p,
char * pStr,
char * pLim )
extern

Definition at line 437 of file utilNam.c.

438{
439 return *Abc_NamStrHashFind( p, pStr, pLim );
440}

◆ Abc_NamStrFindOrAdd()

int Abc_NamStrFindOrAdd ( Abc_Nam_t * p,
char * pStr,
int * pfFound )
extern

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

Synopsis [Finds or adds the given name to storage.]

Description []

SideEffects []

SeeAlso []

Definition at line 453 of file utilNam.c.

454{
455 int i, iHandleNew;
456 int *piPlace;
457 if ( !(pStr[0] != '\\' || pStr[strlen(pStr)-1] == ' ') )
458 {
459 for ( i = strlen(pStr) - 1; i >= 0; i-- )
460 if ( *pStr == ' ' )
461 break;
462 assert( i < (int)strlen(pStr) );
463 }
464 piPlace = Abc_NamStrHashFind( p, pStr, NULL );
465 if ( *piPlace )
466 {
467 if ( pfFound )
468 *pfFound = 1;
469 return *piPlace;
470 }
471 if ( pfFound )
472 *pfFound = 0;
473 iHandleNew = p->iHandle + strlen(pStr) + 1;
474 while ( p->nStore < iHandleNew )
475 {
476 p->nStore *= 3;
477 p->nStore /= 2;
478 p->pStore = ABC_REALLOC( char, p->pStore, p->nStore );
479 }
480 assert( p->nStore >= iHandleNew );
481 // create new handle
482 *piPlace = Vec_IntSize( &p->vInt2Handle );
483 strcpy( Abc_NamHandleToStr( p, p->iHandle ), pStr );
484 Vec_IntPush( &p->vInt2Handle, p->iHandle );
485 Vec_IntPush( &p->vInt2Next, 0 );
486 p->iHandle = iHandleNew;
487 // extend the hash table
488 if ( Vec_IntSize(&p->vInt2Handle) > 2 * p->nBins )
490 return Vec_IntSize(&p->vInt2Handle) - 1;
491}
#define ABC_REALLOC(type, obj, num)
Definition abc_global.h:268
void Abc_NamStrHashResize(Abc_Nam_t *p)
Definition utilNam.c:390
char * strcpy()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NamStrFindOrAddF()

int Abc_NamStrFindOrAddF ( Abc_Nam_t * p,
const char * format,
... )
extern

Definition at line 528 of file utilNam.c.

529{
530 int nAdded, nSize = 1000;
531 va_list args; va_start( args, format );
532 Vec_StrGrow( &p->vBuffer, Vec_StrSize(&p->vBuffer) + nSize );
533 nAdded = vsnprintf( Vec_StrLimit(&p->vBuffer), nSize, format, args );
534 if ( nAdded > nSize )
535 {
536 Vec_StrGrow( &p->vBuffer, Vec_StrSize(&p->vBuffer) + nAdded + nSize );
537 nSize = vsnprintf( Vec_StrLimit(&p->vBuffer), nAdded, format, args );
538 assert( nSize == nAdded );
539 }
540 va_end( args );
541 return Abc_NamStrFindOrAddLim( p, Vec_StrLimit(&p->vBuffer), Vec_StrLimit(&p->vBuffer) + nAdded, NULL );
542}
int Abc_NamStrFindOrAddLim(Abc_Nam_t *p, char *pStr, char *pLim, int *pfFound)
Definition utilNam.c:492
Here is the call graph for this function:

◆ Abc_NamStrFindOrAddLim()

int Abc_NamStrFindOrAddLim ( Abc_Nam_t * p,
char * pStr,
char * pLim,
int * pfFound )
extern

Definition at line 492 of file utilNam.c.

493{
494 int iHandleNew;
495 int *piPlace;
496 char * pStore;
497 assert( pStr < pLim );
498 piPlace = Abc_NamStrHashFind( p, pStr, pLim );
499 if ( *piPlace )
500 {
501 if ( pfFound )
502 *pfFound = 1;
503 return *piPlace;
504 }
505 if ( pfFound )
506 *pfFound = 0;
507 iHandleNew = p->iHandle + (pLim - pStr) + 1;
508 while ( p->nStore < iHandleNew )
509 {
510 p->nStore *= 3;
511 p->nStore /= 2;
512 p->pStore = ABC_REALLOC( char, p->pStore, p->nStore );
513 }
514 assert( p->nStore >= iHandleNew );
515 // create new handle
516 *piPlace = Vec_IntSize( &p->vInt2Handle );
517 pStore = Abc_NamHandleToStr( p, p->iHandle );
518 strncpy( pStore, pStr, pLim - pStr );
519 pStore[pLim - pStr] = 0;
520 Vec_IntPush( &p->vInt2Handle, p->iHandle );
521 Vec_IntPush( &p->vInt2Next, 0 );
522 p->iHandle = iHandleNew;
523 // extend the hash table
524 if ( Vec_IntSize(&p->vInt2Handle) > 2 * p->nBins )
526 return Vec_IntSize(&p->vInt2Handle) - 1;
527}
char * strncpy()
Here is the call graph for this function:
Here is the caller graph for this function: