src/misc/nm/nmApi.c File Reference

#include "nmInt.h"
Include dependency graph for nmApi.c:

Go to the source code of this file.

Functions

Nm_Man_tNm_ManCreate (int nSize)
void Nm_ManFree (Nm_Man_t *p)
int Nm_ManNumEntries (Nm_Man_t *p)
char * Nm_ManStoreIdName (Nm_Man_t *p, int ObjId, int Type, char *pName, char *pSuffix)
void Nm_ManDeleteIdName (Nm_Man_t *p, int ObjId)
char * Nm_ManCreateUniqueName (Nm_Man_t *p, int ObjId)
char * Nm_ManFindNameById (Nm_Man_t *p, int ObjId)
int Nm_ManFindIdByName (Nm_Man_t *p, char *pName, int Type)
int Nm_ManFindIdByNameTwoTypes (Nm_Man_t *p, char *pName, int Type1, int Type2)
Vec_Int_tNm_ManReturnNameIds (Nm_Man_t *p)

Function Documentation

Nm_Man_t* Nm_ManCreate ( int  nSize  ) 

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

FileName [nmApi.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Name manager.]

Synopsis [APIs of the name manager.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Allocates the name manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 42 of file nmApi.c.

00043 {
00044     Nm_Man_t * p;
00045     // allocate the table
00046     p = ALLOC( Nm_Man_t, 1 );
00047     memset( p, 0, sizeof(Nm_Man_t) );
00048     // set the parameters
00049     p->nSizeFactor   = 2; // determined the limit on the grow of data before the table resizes
00050     p->nGrowthFactor = 3; // determined how much the table grows after resizing
00051     // allocate and clean the bins
00052     p->nBins = Cudd_PrimeNm(nSize);
00053     p->pBinsI2N = ALLOC( Nm_Entry_t *, p->nBins );
00054     p->pBinsN2I = ALLOC( Nm_Entry_t *, p->nBins );
00055     memset( p->pBinsI2N, 0, sizeof(Nm_Entry_t *) * p->nBins );
00056     memset( p->pBinsN2I, 0, sizeof(Nm_Entry_t *) * p->nBins );
00057     // start the memory manager
00058     p->pMem = Extra_MmFlexStart();
00059     return p;
00060 }

char* Nm_ManCreateUniqueName ( Nm_Man_t p,
int  ObjId 
)

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

Synopsis [Finds a unique name for the node.]

Description [If the name exists, tries appending numbers to it until it becomes unique. The name is not added to the table.]

SideEffects []

SeeAlso []

Definition at line 171 of file nmApi.c.

00172 {
00173     static char NameStr[1000];
00174     Nm_Entry_t * pEntry;
00175     int i;
00176     if ( pEntry = Nm_ManTableLookupId(p, ObjId) )
00177         return pEntry->Name;
00178     sprintf( NameStr, "n%d", ObjId );
00179     for ( i = 1; Nm_ManTableLookupName(p, NameStr, -1); i++ )
00180         sprintf( NameStr, "n%d_%d", ObjId, i );
00181     return NameStr;
00182 }

void Nm_ManDeleteIdName ( Nm_Man_t p,
int  ObjId 
)

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

Synopsis [Creates a new entry in the name manager.]

Description [Returns 1 if the entry with the given object ID already exists in the name manager.]

SideEffects []

SeeAlso []

Definition at line 145 of file nmApi.c.

00146 {
00147     Nm_Entry_t * pEntry;
00148     pEntry = Nm_ManTableLookupId(p, ObjId);
00149     if ( pEntry == NULL )
00150     {
00151         printf( "Nm_ManDeleteIdName(): This entry is not in the table.\n" );
00152         return;
00153     }
00154     // remove entry from the table
00155     Nm_ManTableDelete( p, ObjId );
00156 }

int Nm_ManFindIdByName ( Nm_Man_t p,
char *  pName,
int  Type 
)

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

Synopsis [Returns ID of the object if its name is known.]

Description [This procedure may return two IDs because POs and latches may have the same name (the only allowed case of name duplication).]

SideEffects []

SeeAlso []

Definition at line 215 of file nmApi.c.

00216 {
00217     Nm_Entry_t * pEntry;
00218     if ( pEntry = Nm_ManTableLookupName(p, pName, Type) )
00219         return pEntry->ObjId;
00220     return -1;
00221 }

int Nm_ManFindIdByNameTwoTypes ( Nm_Man_t p,
char *  pName,
int  Type1,
int  Type2 
)

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

Synopsis [Returns ID of the object if its name is known.]

Description [This procedure may return two IDs because POs and latches may have the same name (the only allowed case of name duplication).]

SideEffects []

SeeAlso []

Definition at line 235 of file nmApi.c.

00236 {
00237     int iNodeId;
00238     iNodeId = Nm_ManFindIdByName( p, pName, Type1 );
00239     if ( iNodeId == -1 )
00240         iNodeId = Nm_ManFindIdByName( p, pName, Type2 );
00241     if ( iNodeId == -1 )
00242         return -1;
00243     return iNodeId;
00244 }

char* Nm_ManFindNameById ( Nm_Man_t p,
int  ObjId 
)

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

Synopsis [Returns name of the object if the ID is known.]

Description []

SideEffects []

SeeAlso []

Definition at line 195 of file nmApi.c.

00196 {
00197     Nm_Entry_t * pEntry;
00198     if ( pEntry = Nm_ManTableLookupId(p, ObjId) )
00199         return pEntry->Name;
00200     return NULL;
00201 }

void Nm_ManFree ( Nm_Man_t p  ) 

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

Synopsis [Deallocates the name manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 73 of file nmApi.c.

00074 {
00075     Extra_MmFlexStop( p->pMem );
00076     FREE( p->pBinsI2N );
00077     FREE( p->pBinsN2I );
00078     FREE( p );
00079 }

int Nm_ManNumEntries ( Nm_Man_t p  ) 

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

Synopsis [Returns the number of objects with names.]

Description []

SideEffects []

SeeAlso []

Definition at line 92 of file nmApi.c.

00093 {
00094     return p->nEntries;
00095 }

Vec_Int_t* Nm_ManReturnNameIds ( Nm_Man_t p  ) 

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

Synopsis [Return the IDs of objects with names.]

Description []

SideEffects []

SeeAlso []

Definition at line 257 of file nmApi.c.

00258 {
00259     Vec_Int_t * vNameIds;
00260     int i;
00261     vNameIds = Vec_IntAlloc( p->nEntries );
00262     for ( i = 0; i < p->nBins; i++ )
00263         if ( p->pBinsI2N[i] )
00264             Vec_IntPush( vNameIds, p->pBinsI2N[i]->ObjId );
00265     return vNameIds;
00266 }

char* Nm_ManStoreIdName ( Nm_Man_t p,
int  ObjId,
int  Type,
char *  pName,
char *  pSuffix 
)

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

Synopsis [Creates a new entry in the name manager.]

Description [Returns 1 if the entry with the given object ID already exists in the name manager.]

SideEffects []

SeeAlso []

Definition at line 109 of file nmApi.c.

00110 {
00111     Nm_Entry_t * pEntry;
00112     int RetValue, nEntrySize;
00113     // check if the object with this ID is already stored
00114     if ( pEntry = Nm_ManTableLookupId(p, ObjId) )
00115     {
00116         printf( "Nm_ManStoreIdName(): Entry with the same ID already exists.\n" );
00117         return NULL;
00118     }
00119     // create a new entry
00120     nEntrySize = sizeof(Nm_Entry_t) + strlen(pName) + (pSuffix?strlen(pSuffix):0) + 1;
00121     nEntrySize = (nEntrySize / 4 + ((nEntrySize % 4) > 0)) * 4;
00122     pEntry = (Nm_Entry_t *)Extra_MmFlexEntryFetch( p->pMem, nEntrySize );
00123     pEntry->pNextI2N = pEntry->pNextN2I = pEntry->pNameSake = NULL;
00124     pEntry->ObjId = ObjId;
00125     pEntry->Type = Type;
00126     sprintf( pEntry->Name, "%s%s", pName, pSuffix? pSuffix : "" );
00127     // add the entry to the hash table
00128     RetValue = Nm_ManTableAdd( p, pEntry );
00129     assert( RetValue == 1 );
00130     return pEntry->Name;
00131 }


Generated on Tue Jan 5 12:19:18 2010 for abc70930 by  doxygen 1.6.1