abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcNames.c File Reference
#include "abc.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START char * Abc_ObjName (Abc_Obj_t *pObj)
 DECLARATIONS ///. More...
 
char * Abc_ObjAssignName (Abc_Obj_t *pObj, char *pName, char *pSuffix)
 
char * Abc_ObjNamePrefix (Abc_Obj_t *pObj, char *pPrefix)
 
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_NtkAddDummyBoxNames (Abc_Ntk_t *pNtk)
 
void Abc_NtkShortNames (Abc_Ntk_t *pNtk)
 
void Abc_NtkMoveNames (Abc_Ntk_t *pNtk, Abc_Ntk_t *pOld)
 
void Abc_NtkStartNameIds (Abc_Ntk_t *p)
 
void Abc_NtkTransferNameIds (Abc_Ntk_t *p, Abc_Ntk_t *pNew)
 
void Abc_NtkUpdateNameIds (Abc_Ntk_t *p)
 

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 309 of file abcNames.c.

310 {
311  int Diff = strcmp( (char *)(*pp1)->pCopy, (char *)(*pp2)->pCopy );
312  if ( Diff < 0 )
313  return -1;
314  if ( Diff > 0 )
315  return 1;
316  Diff = (*pp1)->Id - (*pp2)->Id;
317  if ( Diff < 0 )
318  return -1;
319  if ( Diff > 0 )
320  return 1;
321  return 0;
322 }
int strcmp()
void Abc_NodeFreeNames ( Vec_Ptr_t vNames)

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

Synopsis [Gets fanin node names.]

Description []

SideEffects []

SeeAlso []

Definition at line 257 of file abcNames.c.

258 {
259  int i;
260  if ( vNames == NULL )
261  return;
262  for ( i = 0; i < vNames->nSize; i++ )
263  ABC_FREE( vNames->pArray[i] );
264  Vec_PtrFree( vNames );
265 }
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Vec_Ptr_t* Abc_NodeGetFakeNames ( int  nNames)

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

Synopsis [Gets fanin node names.]

Description []

SideEffects []

SeeAlso []

Definition at line 221 of file abcNames.c.

222 {
223  Vec_Ptr_t * vNames;
224  char Buffer[5];
225  int i;
226 
227  vNames = Vec_PtrAlloc( nNames );
228  for ( i = 0; i < nNames; i++ )
229  {
230  if ( nNames < 26 )
231  {
232  Buffer[0] = 'a' + i;
233  Buffer[1] = 0;
234  }
235  else
236  {
237  Buffer[0] = 'a' + i%26;
238  Buffer[1] = '0' + i/26;
239  Buffer[2] = 0;
240  }
241  Vec_PtrPush( vNames, Extra_UtilStrsav(Buffer) );
242  }
243  return vNames;
244 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
char * Extra_UtilStrsav(const char *s)
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
Vec_Ptr_t* Abc_NodeGetFaninNames ( Abc_Obj_t pNode)

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

Synopsis [Gets fanin node names.]

Description []

SideEffects []

SeeAlso []

Definition at line 199 of file abcNames.c.

200 {
201  Vec_Ptr_t * vNodes;
202  Abc_Obj_t * pFanin;
203  int i;
204  vNodes = Vec_PtrAlloc( 100 );
205  Abc_ObjForEachFanin( pNode, pFanin, i )
206  Vec_PtrPush( vNodes, Abc_UtilStrsav(Abc_ObjName(pFanin)) );
207  return vNodes;
208 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
ABC_NAMESPACE_IMPL_START char * Abc_ObjName(Abc_Obj_t *pObj)
DECLARATIONS ///.
Definition: abcNames.c:48
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
void Abc_NtkAddDummyBoxNames ( Abc_Ntk_t pNtk)

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

Synopsis [Adds dummy names.]

Description []

SideEffects []

SeeAlso []

Definition at line 418 of file abcNames.c.

419 {
420  char * pName, PrefLi[100], PrefLo[100];
421  Abc_Obj_t * pObj;
422  int nDigits, i, k, CountCur, CountMax = 0;
423  // if PIs/POs already have nodes with what looks like latch names
424  // we need to add different prefix for the new latches
425  Abc_NtkForEachPi( pNtk, pObj, i )
426  {
427  CountCur = 0;
428  pName = Abc_ObjName(pObj);
429  for ( k = 0; pName[k]; k++ )
430  if ( pName[k] == 'l' )
431  CountCur++;
432  else
433  break;
434  CountMax = Abc_MaxInt( CountMax, CountCur );
435  }
436  Abc_NtkForEachPo( pNtk, pObj, i )
437  {
438  CountCur = 0;
439  pName = Abc_ObjName(pObj);
440  for ( k = 0; pName[k]; k++ )
441  if ( pName[k] == 'l' )
442  CountCur++;
443  else
444  break;
445  CountMax = Abc_MaxInt( CountMax, CountCur );
446  }
447 //printf( "CountMax = %d\n", CountMax );
448  assert( CountMax < 100-2 );
449  for ( i = 0; i <= CountMax; i++ )
450  PrefLi[i] = PrefLo[i] = 'l';
451  PrefLi[i] = 'i';
452  PrefLo[i] = 'o';
453  PrefLi[i+1] = 0;
454  PrefLo[i+1] = 0;
455  // create latch names
456  assert( !Abc_NtkIsNetlist(pNtk) );
457  nDigits = Abc_Base10Log( Abc_NtkLatchNum(pNtk) );
458  Abc_NtkForEachLatch( pNtk, pObj, i )
459  {
460  Abc_ObjAssignName( pObj, Abc_ObjNameDummy("l", i, nDigits), NULL );
461  Abc_ObjAssignName( Abc_ObjFanin0(pObj), Abc_ObjNameDummy(PrefLi, i, nDigits), NULL );
462  Abc_ObjAssignName( Abc_ObjFanout0(pObj), Abc_ObjNameDummy(PrefLo, i, nDigits), NULL );
463  }
464 /*
465  nDigits = Abc_Base10Log( Abc_NtkBlackboxNum(pNtk) );
466  Abc_NtkForEachBlackbox( pNtk, pObj, i )
467  {
468  pName = Abc_ObjAssignName( pObj, Abc_ObjNameDummy("B", i, nDigits), NULL );
469  nDigitsF = Abc_Base10Log( Abc_ObjFaninNum(pObj) );
470  Abc_ObjForEachFanin( pObj, pTerm, k )
471  Abc_ObjAssignName( Abc_ObjFanin0(pObj), pName, Abc_ObjNameDummy("i", k, nDigitsF) );
472  nDigitsF = Abc_Base10Log( Abc_ObjFanoutNum(pObj) );
473  Abc_ObjForEachFanout( pObj, pTerm, k )
474  Abc_ObjAssignName( Abc_ObjFanin0(pObj), pName, Abc_ObjNameDummy("o", k, nDigitsF) );
475  }
476 */
477 }
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition: abcNames.c:68
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_Base10Log(unsigned n)
Definition: abc_global.h:252
ABC_NAMESPACE_IMPL_START char * Abc_ObjName(Abc_Obj_t *pObj)
DECLARATIONS ///.
Definition: abcNames.c:48
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
char * Abc_ObjNameDummy(char *pPrefix, int Num, int nDigits)
Definition: abcNames.c:121
#define assert(ex)
Definition: util_old.h:213
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
void Abc_NtkAddDummyPiNames ( Abc_Ntk_t pNtk)

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

Synopsis [Adds dummy names.]

Description []

SideEffects []

SeeAlso []

Definition at line 378 of file abcNames.c.

379 {
380  Abc_Obj_t * pObj;
381  int nDigits, i;
382  nDigits = Abc_Base10Log( Abc_NtkPiNum(pNtk) );
383  Abc_NtkForEachPi( pNtk, pObj, i )
384  Abc_ObjAssignName( pObj, Abc_ObjNameDummy("pi", i, nDigits), NULL );
385 }
char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition: abcNames.c:68
static int Abc_Base10Log(unsigned n)
Definition: abc_global.h:252
char * Abc_ObjNameDummy(char *pPrefix, int Num, int nDigits)
Definition: abcNames.c:121
static int Abc_NtkPiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:285
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
void Abc_NtkAddDummyPoNames ( Abc_Ntk_t pNtk)

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

Synopsis [Adds dummy names.]

Description []

SideEffects []

SeeAlso []

Definition at line 398 of file abcNames.c.

399 {
400  Abc_Obj_t * pObj;
401  int nDigits, i;
402  nDigits = Abc_Base10Log( Abc_NtkPoNum(pNtk) );
403  Abc_NtkForEachPo( pNtk, pObj, i )
404  Abc_ObjAssignName( pObj, Abc_ObjNameDummy("po", i, nDigits), NULL );
405 }
char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition: abcNames.c:68
static int Abc_Base10Log(unsigned n)
Definition: abc_global.h:252
static int Abc_NtkPoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:286
char * Abc_ObjNameDummy(char *pPrefix, int Num, int nDigits)
Definition: abcNames.c:121
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
char** Abc_NtkCollectCioNames ( Abc_Ntk_t pNtk,
int  fCollectCos 
)

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

Synopsis [Collects the CI or CO names.]

Description []

SideEffects []

SeeAlso []

Definition at line 278 of file abcNames.c.

279 {
280  Abc_Obj_t * pObj;
281  char ** ppNames;
282  int i;
283  if ( fCollectCos )
284  {
285  ppNames = ABC_ALLOC( char *, Abc_NtkCoNum(pNtk) );
286  Abc_NtkForEachCo( pNtk, pObj, i )
287  ppNames[i] = Abc_ObjName(pObj);
288  }
289  else
290  {
291  ppNames = ABC_ALLOC( char *, Abc_NtkCiNum(pNtk) );
292  Abc_NtkForEachCi( pNtk, pObj, i )
293  ppNames[i] = Abc_ObjName(pObj);
294  }
295  return ppNames;
296 }
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
else
Definition: sparse_int.h:55
ABC_NAMESPACE_IMPL_START char * Abc_ObjName(Abc_Obj_t *pObj)
DECLARATIONS ///.
Definition: abcNames.c:48
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
void Abc_NtkMoveNames ( Abc_Ntk_t pNtk,
Abc_Ntk_t pOld 
)

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

Synopsis [Moves names from the other network.]

Description []

SideEffects []

SeeAlso []

Definition at line 510 of file abcNames.c.

511 {
512  Abc_Obj_t * pObj; int i;
513  Nm_ManFree( pNtk->pManName );
514  pNtk->pManName = Nm_ManCreate( Abc_NtkCiNum(pNtk) + Abc_NtkCoNum(pNtk) + Abc_NtkBoxNum(pNtk) );
515  Abc_NtkForEachPi( pNtk, pObj, i )
516  Abc_ObjAssignName( pObj, Abc_ObjName(Abc_NtkPi(pOld, i)), NULL );
517  Abc_NtkForEachPo( pNtk, pObj, i )
518  Abc_ObjAssignName( pObj, Abc_ObjName(Abc_NtkPo(pOld, i)), NULL );
519  Abc_NtkForEachLatch( pNtk, pObj, i )
520  {
523  }
524 }
Nm_Man_t * pManName
Definition: abc.h:160
static int Abc_NtkBoxNum(Abc_Ntk_t *pNtk)
Definition: abc.h:289
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition: abcNames.c:68
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
ABC_NAMESPACE_IMPL_START char * Abc_ObjName(Abc_Obj_t *pObj)
DECLARATIONS ///.
Definition: abcNames.c:48
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
static Abc_Obj_t * Abc_NtkBox(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:319
static Abc_Obj_t * Abc_NtkPo(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:316
Nm_Man_t * Nm_ManCreate(int nSize)
MACRO DEFINITIONS ///.
Definition: nmApi.c:45
void Nm_ManFree(Nm_Man_t *p)
Definition: nmApi.c:76
static Abc_Obj_t * Abc_NtkPi(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:315
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
void Abc_NtkOrderObjsByName ( Abc_Ntk_t pNtk,
int  fComb 
)

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

Synopsis [Orders PIs/POs/latches alphabetically.]

Description []

SideEffects []

SeeAlso []

Definition at line 335 of file abcNames.c.

336 {
337  Abc_Obj_t * pObj;
338  int i;
340  // temporarily store the names in the copy field
341  Abc_NtkForEachPi( pNtk, pObj, i )
342  pObj->pCopy = (Abc_Obj_t *)Abc_ObjName(pObj);
343  Abc_NtkForEachPo( pNtk, pObj, i )
344  pObj->pCopy = (Abc_Obj_t *)Abc_ObjName(pObj);
345  Abc_NtkForEachBox( pNtk, pObj, i )
346  pObj->pCopy = (Abc_Obj_t *)Abc_ObjName(Abc_ObjFanout0(pObj));
347  // order objects alphabetically
348  qsort( (void *)Vec_PtrArray(pNtk->vPis), Vec_PtrSize(pNtk->vPis), sizeof(Abc_Obj_t *),
349  (int (*)(const void *, const void *)) Abc_NodeCompareNames );
350  qsort( (void *)Vec_PtrArray(pNtk->vPos), Vec_PtrSize(pNtk->vPos), sizeof(Abc_Obj_t *),
351  (int (*)(const void *, const void *)) Abc_NodeCompareNames );
352  // if the comparison if combinational (latches as PIs/POs), order them too
353  if ( fComb )
354  qsort( (void *)Vec_PtrArray(pNtk->vBoxes), Vec_PtrSize(pNtk->vBoxes), sizeof(Abc_Obj_t *),
355  (int (*)(const void *, const void *)) Abc_NodeCompareNames );
356  // order CIs/COs first PIs/POs(Asserts) then latches
357  Abc_NtkOrderCisCos( pNtk );
358  // clean the copy fields
359  Abc_NtkForEachPi( pNtk, pObj, i )
360  pObj->pCopy = NULL;
361  Abc_NtkForEachPo( pNtk, pObj, i )
362  pObj->pCopy = NULL;
363  Abc_NtkForEachBox( pNtk, pObj, i )
364  pObj->pCopy = NULL;
365 }
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
int Abc_NodeCompareNames(Abc_Obj_t **pp1, Abc_Obj_t **pp2)
Definition: abcNames.c:309
if(last==0)
Definition: sparse_int.h:34
ABC_NAMESPACE_IMPL_START char * Abc_ObjName(Abc_Obj_t *pObj)
DECLARATIONS ///.
Definition: abcNames.c:48
#define Abc_NtkForEachBox(pNtk, pObj, i)
Definition: abc.h:495
static int Abc_NtkHasOnlyLatchBoxes(Abc_Ntk_t *pNtk)
Definition: abc.h:298
#define assert(ex)
Definition: util_old.h:213
#define const
Definition: zconf.h:196
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
ABC_DLL void Abc_NtkOrderCisCos(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:71
static void ** Vec_PtrArray(Vec_Ptr_t *p)
Definition: vecPtr.h:279
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
void Abc_NtkShortNames ( Abc_Ntk_t pNtk)

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

Synopsis [Replaces names by short names.]

Description []

SideEffects []

SeeAlso []

Definition at line 490 of file abcNames.c.

491 {
492  Nm_ManFree( pNtk->pManName );
493  pNtk->pManName = Nm_ManCreate( Abc_NtkCiNum(pNtk) + Abc_NtkCoNum(pNtk) + Abc_NtkBoxNum(pNtk) );
494  Abc_NtkAddDummyPiNames( pNtk );
495  Abc_NtkAddDummyPoNames( pNtk );
496  Abc_NtkAddDummyBoxNames( pNtk );
497 }
Nm_Man_t * pManName
Definition: abc.h:160
static int Abc_NtkBoxNum(Abc_Ntk_t *pNtk)
Definition: abc.h:289
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
void Abc_NtkAddDummyPoNames(Abc_Ntk_t *pNtk)
Definition: abcNames.c:398
void Abc_NtkAddDummyPiNames(Abc_Ntk_t *pNtk)
Definition: abcNames.c:378
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
void Abc_NtkAddDummyBoxNames(Abc_Ntk_t *pNtk)
Definition: abcNames.c:418
Nm_Man_t * Nm_ManCreate(int nSize)
MACRO DEFINITIONS ///.
Definition: nmApi.c:45
void Nm_ManFree(Nm_Man_t *p)
Definition: nmApi.c:76
void Abc_NtkStartNameIds ( Abc_Ntk_t p)

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

Synopsis [Saves name IDs into a file.]

Description []

SideEffects []

SeeAlso []

Definition at line 538 of file abcNames.c.

539 {
540  char pFileName[1000];
541  FILE * pFile;
542  Abc_Obj_t * pObj, * pFanin;
543  Vec_Ptr_t * vNodes;
544  int i, Counter = 1;
545  assert( Abc_NtkIsNetlist(p) );
546  assert( p->vNameIds == NULL );
547  assert( strlen(p->pSpec) < 1000 );
548  sprintf( pFileName, "%s_%s_names.txt", Extra_FileNameGenericAppend(p->pSpec,""), Extra_FileNameExtension(p->pSpec) );
549  pFile = fopen( pFileName, "wb" );
551  // add inputs
552  Abc_NtkForEachCi( p, pObj, i )
553  fprintf( pFile, "%s \n", Abc_ObjName(Abc_ObjFanout0(pObj)) ), Vec_IntWriteEntry(p->vNameIds, Abc_ObjId(pObj), 2*Counter++);
554  // add outputs
555  Abc_NtkForEachCo( p, pObj, i )
556  {
557  pFanin = Abc_ObjFanin0(Abc_ObjFanin0(pObj));
558  if ( !Vec_IntEntry(p->vNameIds, Abc_ObjId(pFanin)) )
559  fprintf( pFile, "%s \n", Abc_ObjName(Abc_ObjFanout0(pFanin)) ), Vec_IntWriteEntry(p->vNameIds, Abc_ObjId(pFanin), 2*Counter++);
560  }
561  // add nodes in a topo order
562  vNodes = Abc_NtkDfs( p, 1 );
563  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
564  if ( !Vec_IntEntry(p->vNameIds, Abc_ObjId(pObj)) )
565  fprintf( pFile, "%s \n", Abc_ObjName(Abc_ObjFanout0(pObj)) ), Vec_IntWriteEntry(p->vNameIds, Abc_ObjId(pObj), 2*Counter++);
566  Vec_PtrFree( vNodes );
567  fclose( pFile );
568  // transfer driver node names to COs
569  Abc_NtkForEachCo( p, pObj, i )
570  {
571  pFanin = Abc_ObjFanin0(Abc_ObjFanin0(pObj));
572  Vec_IntWriteEntry( p->vNameIds, Abc_ObjId(pObj), Vec_IntEntry(p->vNameIds, Abc_ObjId(pFanin)) );
573  Vec_IntWriteEntry( p->vNameIds, Abc_ObjId(pFanin), 0 );
574  }
575 }
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Vec_Int_t * vNameIds
Definition: abc.h:215
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition: abcDfs.c:81
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
if(last==0)
Definition: sparse_int.h:34
char * sprintf()
static int Counter
ABC_NAMESPACE_IMPL_START char * Abc_ObjName(Abc_Obj_t *pObj)
DECLARATIONS ///.
Definition: abcNames.c:48
char * pSpec
Definition: abc.h:159
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
#define assert(ex)
Definition: util_old.h:213
char * Extra_FileNameGenericAppend(char *pBase, char *pSuffix)
int strlen()
char * Extra_FileNameExtension(char *FileName)
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Abc_NtkTransferNameIds ( Abc_Ntk_t p,
Abc_Ntk_t pNew 
)

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

Synopsis [Remaps the AIG from the old manager into the new manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 588 of file abcNames.c.

589 {
590  Abc_Obj_t * pObj, * pObjNew;
591  int i;
592  assert( p->vNameIds != NULL );
593  assert( pNew->vNameIds == NULL );
594  pNew->vNameIds = Vec_IntStart( Abc_NtkObjNumMax(pNew) );
595 // Abc_NtkForEachCi( p, pObj, i )
596 // printf( "%d ", Vec_IntEntry(p->vNameIds, Abc_ObjId(pObj)) );
597 // printf( "\n" );
598  Abc_NtkForEachObj( p, pObj, i )
599  if ( pObj->pCopy && i < Vec_IntSize(p->vNameIds) && Vec_IntEntry(p->vNameIds, i) )
600  {
601  pObjNew = Abc_ObjRegular(pObj->pCopy);
602  assert( Abc_ObjNtk(pObjNew) == pNew );
603  if ( Abc_ObjIsCi(pObjNew) && !Abc_ObjIsCi(pObj) ) // do not overwrite CI name by internal node name
604  continue;
606  }
607 }
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
Vec_Int_t * vNameIds
Definition: abc.h:215
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
Abc_Obj_t * pCopy
Definition: abc.h:148
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
if(last==0)
Definition: sparse_int.h:34
static Abc_Obj_t * Abc_ObjRegular(Abc_Obj_t *p)
Definition: abc.h:323
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
static Abc_Ntk_t * Abc_ObjNtk(Abc_Obj_t *pObj)
Definition: abc.h:334
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
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 139 of file abcNames.c.

140 {
141  Abc_Obj_t * pObj;
142  int i;
143  assert( Abc_NtkPiNum(pNtk) == Abc_NtkPiNum(pNtkNew) );
144  assert( Abc_NtkPoNum(pNtk) == Abc_NtkPoNum(pNtkNew) );
145  assert( Abc_NtkBoxNum(pNtk) == Abc_NtkBoxNum(pNtkNew) );
146  assert( Nm_ManNumEntries(pNtk->pManName) > 0 );
147  assert( Nm_ManNumEntries(pNtkNew->pManName) == 0 );
148  // copy the CI/CO/box names
149  Abc_NtkForEachCi( pNtk, pObj, i )
150  Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(Abc_ObjFanout0Ntk(pObj)), NULL );
151  Abc_NtkForEachCo( pNtk, pObj, i )
152  Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(Abc_ObjFanin0Ntk(pObj)), NULL );
153  Abc_NtkForEachBox( pNtk, pObj, i )
154  Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
155 }
Nm_Man_t * pManName
Definition: abc.h:160
int Nm_ManNumEntries(Nm_Man_t *p)
Definition: nmApi.c:95
static int Abc_NtkBoxNum(Abc_Ntk_t *pNtk)
Definition: abc.h:289
static Abc_Obj_t * Abc_ObjFanin0Ntk(Abc_Obj_t *pObj)
Definition: abc.h:375
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition: abcNames.c:68
ABC_NAMESPACE_IMPL_START char * Abc_ObjName(Abc_Obj_t *pObj)
DECLARATIONS ///.
Definition: abcNames.c:48
static Abc_Obj_t * Abc_ObjFanout0Ntk(Abc_Obj_t *pObj)
Definition: abc.h:376
#define Abc_NtkForEachBox(pNtk, pObj, i)
Definition: abc.h:495
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
static int Abc_NtkPoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:286
static int Abc_NtkPiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:285
#define assert(ex)
Definition: util_old.h:213
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 168 of file abcNames.c.

169 {
170  Abc_Obj_t * pObj;
171  int i;
172  assert( Abc_NtkPiNum(pNtk) == Abc_NtkPiNum(pNtkNew) );
173  assert( Abc_NtkPoNum(pNtk) == Abc_NtkPoNum(pNtkNew) );
174  assert( Nm_ManNumEntries(pNtk->pManName) > 0 );
175  assert( Nm_ManNumEntries(pNtkNew->pManName) == 0 );
176  // copy the CI/CO/box name and skip latches and theirs inputs/outputs
177  Abc_NtkForEachCi( pNtk, pObj, i )
178  if ( Abc_ObjFaninNum(pObj) == 0 || !Abc_ObjIsLatch(Abc_ObjFanin0(pObj)) )
179  Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(Abc_ObjFanout0Ntk(pObj)), NULL );
180  Abc_NtkForEachCo( pNtk, pObj, i )
181  if ( Abc_ObjFanoutNum(pObj) == 0 || !Abc_ObjIsLatch(Abc_ObjFanout0(pObj)) )
182  Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(Abc_ObjFanin0Ntk(pObj)), NULL );
183  Abc_NtkForEachBox( pNtk, pObj, i )
184  if ( !Abc_ObjIsLatch(pObj) )
185  Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
186 }
Nm_Man_t * pManName
Definition: abc.h:160
int Nm_ManNumEntries(Nm_Man_t *p)
Definition: nmApi.c:95
static int Abc_ObjIsLatch(Abc_Obj_t *pObj)
Definition: abc.h:356
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
static Abc_Obj_t * Abc_ObjFanin0Ntk(Abc_Obj_t *pObj)
Definition: abc.h:375
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition: abcNames.c:68
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
if(last==0)
Definition: sparse_int.h:34
ABC_NAMESPACE_IMPL_START char * Abc_ObjName(Abc_Obj_t *pObj)
DECLARATIONS ///.
Definition: abcNames.c:48
static Abc_Obj_t * Abc_ObjFanout0Ntk(Abc_Obj_t *pObj)
Definition: abc.h:376
#define Abc_NtkForEachBox(pNtk, pObj, i)
Definition: abc.h:495
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
static int Abc_NtkPoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:286
static int Abc_NtkPiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:285
#define assert(ex)
Definition: util_old.h:213
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
void Abc_NtkUpdateNameIds ( Abc_Ntk_t p)

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

Synopsis [Updates file with name IDs.]

Description []

SideEffects []

SeeAlso []

Definition at line 620 of file abcNames.c.

621 {
622  char pFileName[1000];
623  Vec_Int_t * vStarts;
624  Abc_Obj_t * pObj;
625  FILE * pFile;
626  int i, c, iVar, fCompl, fSeenSpace, Counter = 0;
627  assert( !Abc_NtkIsNetlist(p) );
628  assert( strlen(p->pSpec) < 1000 );
629  assert( p->vNameIds != NULL );
630  sprintf( pFileName, "%s_%s_names.txt", Extra_FileNameGenericAppend(p->pSpec,""), Extra_FileNameExtension(p->pSpec) );
631  pFile = fopen( pFileName, "r+" );
632  // collect info about lines
633  fSeenSpace = 0;
634  vStarts = Vec_IntAlloc( 1000 );
635  Vec_IntPush( vStarts, -1 );
636  while ( (c = fgetc(pFile)) != EOF && ++Counter )
637  if ( c == ' ' && !fSeenSpace )
638  Vec_IntPush(vStarts, Counter), fSeenSpace = 1;
639  else if ( c == '\n' )
640  fSeenSpace = 0;
641  // add info about names
642  Abc_NtkForEachObj( p, pObj, i )
643  {
644  if ( i == 0 || i >= Vec_IntSize(p->vNameIds) || !Vec_IntEntry(p->vNameIds, i) )
645  continue;
646  iVar = Abc_Lit2Var( Vec_IntEntry(p->vNameIds, i) );
647  fCompl = Abc_LitIsCompl( Vec_IntEntry(p->vNameIds, i) );
648  assert( iVar < Vec_IntSize(vStarts) );
649  fseek( pFile, Vec_IntEntry(vStarts, iVar), SEEK_SET );
650  fprintf( pFile, "%s%d", fCompl? "-":"", i );
651  }
652  printf( "Saved %d names into file \"%s\".\n", Vec_IntSize(vStarts)-1, pFileName );
653  fclose( pFile );
654  Vec_IntFree( vStarts );
655  Vec_IntFreeP( &p->vNameIds );
656 // Abc_NtkForEachObj( p, pObj, i )
657 // Abc_ObjPrint( stdout, pObj );
658 }
Vec_Int_t * vNameIds
Definition: abc.h:215
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Abc_NtkIsNetlist(Abc_Ntk_t *pNtk)
Definition: abc.h:249
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
char * sprintf()
static int Counter
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
#define SEEK_SET
Definition: zconf.h:390
char * pSpec
Definition: abc.h:159
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
char * Extra_FileNameGenericAppend(char *pBase, char *pSuffix)
int strlen()
char * Extra_FileNameExtension(char *FileName)
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
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 68 of file abcNames.c.

69 {
70  assert( pName != NULL );
71  return Nm_ManStoreIdName( pObj->pNtk->pManName, pObj->Id, pObj->Type, pName, pSuffix );
72 }
Nm_Man_t * pManName
Definition: abc.h:160
unsigned Type
Definition: abc.h:133
char * Nm_ManStoreIdName(Nm_Man_t *p, int ObjId, int Type, char *pName, char *pSuffix)
Definition: nmApi.c:112
Abc_Ntk_t * pNtk
Definition: abc.h:130
int Id
Definition: abc.h:132
#define assert(ex)
Definition: util_old.h:213
ABC_NAMESPACE_IMPL_START char* Abc_ObjName ( Abc_Obj_t pObj)

DECLARATIONS ///.

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

]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 48 of file abcNames.c.

49 {
50  return Nm_ManCreateUniqueName( pObj->pNtk->pManName, pObj->Id );
51 }
Nm_Man_t * pManName
Definition: abc.h:160
Abc_Ntk_t * pNtk
Definition: abc.h:130
int Id
Definition: abc.h:132
char * Nm_ManCreateUniqueName(Nm_Man_t *p, int ObjId)
Definition: nmApi.c:175
char* Abc_ObjNameDummy ( char *  pPrefix,
int  Num,
int  nDigits 
)

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

Synopsis [Returns the dummy PI name.]

Description []

SideEffects []

SeeAlso []

Definition at line 121 of file abcNames.c.

122 {
123  static char Buffer[2000];
124  sprintf( Buffer, "%s%0*d", pPrefix, nDigits, Num );
125  return Buffer;
126 }
char * sprintf()
char* Abc_ObjNamePrefix ( Abc_Obj_t pObj,
char *  pPrefix 
)

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

Synopsis [Appends name to the prefix]

Description []

SideEffects []

SeeAlso []

Definition at line 85 of file abcNames.c.

86 {
87  static char Buffer[2000];
88  sprintf( Buffer, "%s%s", pPrefix, Abc_ObjName(pObj) );
89  return Buffer;
90 }
char * sprintf()
ABC_NAMESPACE_IMPL_START char * Abc_ObjName(Abc_Obj_t *pObj)
DECLARATIONS ///.
Definition: abcNames.c:48
char* Abc_ObjNameSuffix ( Abc_Obj_t pObj,
char *  pSuffix 
)

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

Synopsis [Appends suffic to the name.]

Description []

SideEffects []

SeeAlso []

Definition at line 103 of file abcNames.c.

104 {
105  static char Buffer[2000];
106  sprintf( Buffer, "%s%s", Abc_ObjName(pObj), pSuffix );
107  return Buffer;
108 }
char * sprintf()
ABC_NAMESPACE_IMPL_START char * Abc_ObjName(Abc_Obj_t *pObj)
DECLARATIONS ///.
Definition: abcNames.c:48