src/base/abc/abcNames.c File Reference

#include "abc.h"
Include dependency graph for abcNames.c:

Go to the source code of this file.

Functions

char * Abc_ObjName (Abc_Obj_t *pObj)
char * Abc_ObjAssignName (Abc_Obj_t *pObj, char *pName, char *pSuffix)
char * Abc_ObjNameSuffix (Abc_Obj_t *pObj, char *pSuffix)
char * Abc_ObjNameDummy (char *pPrefix, int Num, int nDigits)
void Abc_NtkTrasferNames (Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew)
void Abc_NtkTrasferNamesNoLatches (Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew)
Vec_Ptr_tAbc_NodeGetFaninNames (Abc_Obj_t *pNode)
Vec_Ptr_tAbc_NodeGetFakeNames (int nNames)
void Abc_NodeFreeNames (Vec_Ptr_t *vNames)
char ** Abc_NtkCollectCioNames (Abc_Ntk_t *pNtk, int fCollectCos)
int Abc_NodeCompareNames (Abc_Obj_t **pp1, Abc_Obj_t **pp2)
void Abc_NtkOrderObjsByName (Abc_Ntk_t *pNtk, int fComb)
void Abc_NtkAddDummyPiNames (Abc_Ntk_t *pNtk)
void Abc_NtkAddDummyPoNames (Abc_Ntk_t *pNtk)
void Abc_NtkAddDummyAssertNames (Abc_Ntk_t *pNtk)
void Abc_NtkAddDummyBoxNames (Abc_Ntk_t *pNtk)
void Abc_NtkShortNames (Abc_Ntk_t *pNtk)

Function Documentation

int Abc_NodeCompareNames ( Abc_Obj_t **  pp1,
Abc_Obj_t **  pp2 
)

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

Synopsis [Procedure used for sorting the nodes in decreasing order of levels.]

Description []

SideEffects []

SeeAlso []

Definition at line 290 of file abcNames.c.

00291 {
00292     int Diff = strcmp( (char *)(*pp1)->pCopy, (char *)(*pp2)->pCopy );
00293     if ( Diff < 0 )
00294         return -1;
00295     if ( Diff > 0 ) 
00296         return 1;
00297     return 0; 
00298 }

void Abc_NodeFreeNames ( Vec_Ptr_t vNames  ) 

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

Synopsis [Gets fanin node names.]

Description []

SideEffects []

SeeAlso []

Definition at line 238 of file abcNames.c.

00239 {
00240     int i;
00241     if ( vNames == NULL )
00242         return;
00243     for ( i = 0; i < vNames->nSize; i++ )
00244         free( vNames->pArray[i] );
00245     Vec_PtrFree( vNames );
00246 }

Vec_Ptr_t* Abc_NodeGetFakeNames ( int  nNames  ) 

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

Synopsis [Gets fanin node names.]

Description []

SideEffects []

SeeAlso []

Definition at line 202 of file abcNames.c.

00203 {
00204     Vec_Ptr_t * vNames;
00205     char Buffer[5];
00206     int i;
00207 
00208     vNames = Vec_PtrAlloc( nNames );
00209     for ( i = 0; i < nNames; i++ )
00210     {
00211         if ( nNames < 26 )
00212         {
00213             Buffer[0] = 'a' + i;
00214             Buffer[1] = 0;
00215         }
00216         else
00217         {
00218             Buffer[0] = 'a' + i%26;
00219             Buffer[1] = '0' + i/26;
00220             Buffer[2] = 0;
00221         }
00222         Vec_PtrPush( vNames, Extra_UtilStrsav(Buffer) );
00223     }
00224     return vNames;
00225 }

Vec_Ptr_t* Abc_NodeGetFaninNames ( Abc_Obj_t pNode  ) 

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

Synopsis [Gets fanin node names.]

Description []

SideEffects []

SeeAlso []

Definition at line 180 of file abcNames.c.

00181 {
00182     Vec_Ptr_t * vNodes;
00183     Abc_Obj_t * pFanin;
00184     int i;
00185     vNodes = Vec_PtrAlloc( 100 );
00186     Abc_ObjForEachFanin( pNode, pFanin, i )
00187         Vec_PtrPush( vNodes, Extra_UtilStrsav(Abc_ObjName(pFanin)) );
00188     return vNodes;
00189 }

void Abc_NtkAddDummyAssertNames ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Adds dummy names.]

Description []

SideEffects []

SeeAlso []

Definition at line 395 of file abcNames.c.

00396 {
00397     Abc_Obj_t * pObj;
00398     int nDigits, i;
00399     nDigits = Extra_Base10Log( Abc_NtkAssertNum(pNtk) );
00400     Abc_NtkForEachAssert( pNtk, pObj, i )
00401         Abc_ObjAssignName( pObj, Abc_ObjNameDummy("a", i, nDigits), NULL );
00402 }

void Abc_NtkAddDummyBoxNames ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Adds dummy names.]

Description []

SideEffects []

SeeAlso []

Definition at line 415 of file abcNames.c.

00416 {
00417     Abc_Obj_t * pObj;
00418     int nDigits, i;
00419     assert( !Abc_NtkIsNetlist(pNtk) );
00420     nDigits = Extra_Base10Log( Abc_NtkLatchNum(pNtk) );
00421     Abc_NtkForEachLatch( pNtk, pObj, i )
00422     {
00423         Abc_ObjAssignName( pObj, Abc_ObjNameDummy("l", i, nDigits), NULL );
00424         Abc_ObjAssignName( Abc_ObjFanin0(pObj),  Abc_ObjNameDummy("li", i, nDigits), NULL );
00425         Abc_ObjAssignName( Abc_ObjFanout0(pObj), Abc_ObjNameDummy("lo", i, nDigits), NULL );
00426     }
00427 /*
00428     nDigits = Extra_Base10Log( Abc_NtkBlackboxNum(pNtk) );
00429     Abc_NtkForEachBlackbox( pNtk, pObj, i )
00430     {
00431         pName = Abc_ObjAssignName( pObj, Abc_ObjNameDummy("B", i, nDigits), NULL );
00432         nDigitsF = Extra_Base10Log( Abc_ObjFaninNum(pObj) );
00433         Abc_ObjForEachFanin( pObj, pTerm, k )
00434             Abc_ObjAssignName( Abc_ObjFanin0(pObj), pName, Abc_ObjNameDummy("i", k, nDigitsF) );
00435         nDigitsF = Extra_Base10Log( Abc_ObjFanoutNum(pObj) );
00436         Abc_ObjForEachFanout( pObj, pTerm, k )
00437             Abc_ObjAssignName( Abc_ObjFanin0(pObj), pName, Abc_ObjNameDummy("o", k, nDigitsF) );
00438     }
00439 */
00440 }

void Abc_NtkAddDummyPiNames ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Adds dummy names.]

Description []

SideEffects []

SeeAlso []

Definition at line 355 of file abcNames.c.

00356 {
00357     Abc_Obj_t * pObj;
00358     int nDigits, i;
00359     nDigits = Extra_Base10Log( Abc_NtkPiNum(pNtk) );
00360     Abc_NtkForEachPi( pNtk, pObj, i )
00361         Abc_ObjAssignName( pObj, Abc_ObjNameDummy("pi", i, nDigits), NULL );
00362 }

void Abc_NtkAddDummyPoNames ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Adds dummy names.]

Description []

SideEffects []

SeeAlso []

Definition at line 375 of file abcNames.c.

00376 {
00377     Abc_Obj_t * pObj;
00378     int nDigits, i;
00379     nDigits = Extra_Base10Log( Abc_NtkPoNum(pNtk) );
00380     Abc_NtkForEachPo( pNtk, pObj, i )
00381         Abc_ObjAssignName( pObj, Abc_ObjNameDummy("po", i, nDigits), NULL );
00382 }

char** Abc_NtkCollectCioNames ( Abc_Ntk_t pNtk,
int  fCollectCos 
)

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

Synopsis [Collects the CI or CO names.]

Description []

SideEffects []

SeeAlso []

Definition at line 259 of file abcNames.c.

00260 {
00261     Abc_Obj_t * pObj;
00262     char ** ppNames;
00263     int i;
00264     if ( fCollectCos )
00265     {
00266         ppNames = ALLOC( char *, Abc_NtkCoNum(pNtk) );
00267         Abc_NtkForEachCo( pNtk, pObj, i )
00268             ppNames[i] = Abc_ObjName(pObj);
00269     }
00270     else
00271     {
00272         ppNames = ALLOC( char *, Abc_NtkCiNum(pNtk) );
00273         Abc_NtkForEachCi( pNtk, pObj, i )
00274             ppNames[i] = Abc_ObjName(pObj);
00275     }
00276     return ppNames;
00277 }

void Abc_NtkOrderObjsByName ( Abc_Ntk_t pNtk,
int  fComb 
)

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

Synopsis [Orders PIs/POs/latches alphabetically.]

Description []

SideEffects []

SeeAlso []

Definition at line 311 of file abcNames.c.

00312 {
00313     Abc_Obj_t * pObj;
00314     int i;
00315     assert( Abc_NtkAssertNum(pNtk) == 0 );
00316     assert( Abc_NtkHasOnlyLatchBoxes(pNtk) );
00317     // temporarily store the names in the copy field
00318     Abc_NtkForEachPi( pNtk, pObj, i )
00319         pObj->pCopy = (Abc_Obj_t *)Abc_ObjName(pObj);
00320     Abc_NtkForEachPo( pNtk, pObj, i )
00321         pObj->pCopy = (Abc_Obj_t *)Abc_ObjName(pObj);
00322     Abc_NtkForEachBox( pNtk, pObj, i )
00323         pObj->pCopy = (Abc_Obj_t *)Abc_ObjName(Abc_ObjFanout0(pObj));
00324     // order objects alphabetically
00325     qsort( (void *)Vec_PtrArray(pNtk->vPis), Vec_PtrSize(pNtk->vPis), sizeof(Abc_Obj_t *), 
00326         (int (*)(const void *, const void *)) Abc_NodeCompareNames );
00327     qsort( (void *)Vec_PtrArray(pNtk->vPos), Vec_PtrSize(pNtk->vPos), sizeof(Abc_Obj_t *), 
00328         (int (*)(const void *, const void *)) Abc_NodeCompareNames );
00329     // if the comparison if combinational (latches as PIs/POs), order them too
00330     if ( fComb )
00331         qsort( (void *)Vec_PtrArray(pNtk->vBoxes), Vec_PtrSize(pNtk->vBoxes), sizeof(Abc_Obj_t *), 
00332             (int (*)(const void *, const void *)) Abc_NodeCompareNames );
00333     // order CIs/COs first PIs/POs(Asserts) then latches
00334     Abc_NtkOrderCisCos( pNtk );
00335     // clean the copy fields
00336     Abc_NtkForEachPi( pNtk, pObj, i )
00337         pObj->pCopy = NULL;
00338     Abc_NtkForEachPo( pNtk, pObj, i )
00339         pObj->pCopy = NULL;
00340     Abc_NtkForEachBox( pNtk, pObj, i )
00341         pObj->pCopy = NULL;
00342 }

void Abc_NtkShortNames ( Abc_Ntk_t pNtk  ) 

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

Synopsis [Replaces names by short names.]

Description []

SideEffects []

SeeAlso []

Definition at line 453 of file abcNames.c.

00454 {
00455     Nm_ManFree( pNtk->pManName );
00456     pNtk->pManName = Nm_ManCreate( Abc_NtkCiNum(pNtk) + Abc_NtkCoNum(pNtk) + Abc_NtkBoxNum(pNtk) );
00457     Abc_NtkAddDummyPiNames( pNtk );
00458     Abc_NtkAddDummyPoNames( pNtk );
00459     Abc_NtkAddDummyAssertNames( pNtk );
00460     Abc_NtkAddDummyBoxNames( pNtk );
00461 }

void Abc_NtkTrasferNames ( Abc_Ntk_t pNtk,
Abc_Ntk_t pNtkNew 
)

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

Synopsis [Tranfers names to the old network.]

Description [Assumes that the new nodes are attached using pObj->pCopy.]

SideEffects []

SeeAlso []

Definition at line 118 of file abcNames.c.

00119 {
00120     Abc_Obj_t * pObj;
00121     int i;
00122     assert( Abc_NtkPiNum(pNtk) == Abc_NtkPiNum(pNtkNew) );
00123     assert( Abc_NtkPoNum(pNtk) == Abc_NtkPoNum(pNtkNew) );
00124     assert( Abc_NtkBoxNum(pNtk) == Abc_NtkBoxNum(pNtkNew) );
00125     assert( Abc_NtkAssertNum(pNtk) == Abc_NtkAssertNum(pNtkNew) );
00126     assert( Nm_ManNumEntries(pNtk->pManName) > 0 );
00127     assert( Nm_ManNumEntries(pNtkNew->pManName) == 0 );
00128     // copy the CI/CO/box names
00129     Abc_NtkForEachCi( pNtk, pObj, i )
00130         Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(Abc_ObjFanout0Ntk(pObj)), NULL );
00131     Abc_NtkForEachCo( pNtk, pObj, i ) 
00132         Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(Abc_ObjFanin0Ntk(pObj)), NULL );
00133     Abc_NtkForEachBox( pNtk, pObj, i ) 
00134         Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
00135 }

void Abc_NtkTrasferNamesNoLatches ( Abc_Ntk_t pNtk,
Abc_Ntk_t pNtkNew 
)

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

Synopsis [Tranfers names to the old network.]

Description [Assumes that the new nodes are attached using pObj->pCopy.]

SideEffects []

SeeAlso []

Definition at line 148 of file abcNames.c.

00149 {
00150     Abc_Obj_t * pObj;
00151     int i;
00152     assert( Abc_NtkPiNum(pNtk) == Abc_NtkPiNum(pNtkNew) );
00153     assert( Abc_NtkPoNum(pNtk) == Abc_NtkPoNum(pNtkNew) );
00154     assert( Abc_NtkAssertNum(pNtk) == Abc_NtkAssertNum(pNtkNew) );
00155     assert( Nm_ManNumEntries(pNtk->pManName) > 0 );
00156     assert( Nm_ManNumEntries(pNtkNew->pManName) == 0 );
00157     // copy the CI/CO/box name and skip latches and theirs inputs/outputs
00158     Abc_NtkForEachCi( pNtk, pObj, i )
00159         if ( Abc_ObjFaninNum(pObj) == 0 || !Abc_ObjIsLatch(Abc_ObjFanin0(pObj)) )
00160             Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(Abc_ObjFanout0Ntk(pObj)), NULL );
00161     Abc_NtkForEachCo( pNtk, pObj, i ) 
00162         if ( Abc_ObjFanoutNum(pObj) == 0 || !Abc_ObjIsLatch(Abc_ObjFanout0(pObj)) )
00163             Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(Abc_ObjFanin0Ntk(pObj)), NULL );
00164     Abc_NtkForEachBox( pNtk, pObj, i ) 
00165         if ( !Abc_ObjIsLatch(pObj) )
00166             Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
00167 }

char* Abc_ObjAssignName ( Abc_Obj_t pObj,
char *  pName,
char *  pSuffix 
)

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

Synopsis [Assigns the given name to the object.]

Description [The object should not have a name assigned. The same name may be used for several objects, which they share the same net in the original netlist. (For example, latch output and primary output may have the same name.) This procedure returns the pointer to the internally stored representation of the given name.]

SideEffects []

SeeAlso []

Definition at line 65 of file abcNames.c.

00066 {
00067     assert( pName != NULL );
00068     return Nm_ManStoreIdName( pObj->pNtk->pManName, pObj->Id, pObj->Type, pName, pSuffix );
00069 }

char* Abc_ObjName ( Abc_Obj_t pObj  ) 

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

FileName [abcNames.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Procedures working with net and node names.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Returns the unique name for the object.]

Description [If the name previously did not exist, creates a new unique name but does not assign this name to the object. The temporary unique name is stored in a static buffer inside this procedure. It is important that the name is used before the function is called again!]

SideEffects []

SeeAlso []

Definition at line 45 of file abcNames.c.

00046 {
00047     return Nm_ManCreateUniqueName( pObj->pNtk->pManName, pObj->Id );
00048 }

char* Abc_ObjNameDummy ( char *  pPrefix,
int  Num,
int  nDigits 
)

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

Synopsis [Returns the dummy PI name.]

Description []

SideEffects []

SeeAlso []

Definition at line 100 of file abcNames.c.

00101 {
00102     static char Buffer[100];
00103     sprintf( Buffer, "%s%0*d", pPrefix, nDigits, Num );
00104     return Buffer;
00105 }

char* Abc_ObjNameSuffix ( Abc_Obj_t pObj,
char *  pSuffix 
)

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

Synopsis [Gets the long name of the node.]

Description [This name is the output net's name.]

SideEffects []

SeeAlso []

Definition at line 82 of file abcNames.c.

00083 {
00084     static char Buffer[500];
00085     sprintf( Buffer, "%s%s", Abc_ObjName(pObj), pSuffix );
00086     return Buffer;
00087 }


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