ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcNames.c
Go to the documentation of this file.
1
20
21#include "abc.h"
22#include "misc/util/utilNam.h"
23
25
26
30
34
49char * Abc_ObjName( Abc_Obj_t * pObj )
50{
51 return Nm_ManCreateUniqueName( pObj->pNtk->pManName, pObj->Id );
52}
53
69char * Abc_ObjAssignName( Abc_Obj_t * pObj, char * pName, char * pSuffix )
70{
71 assert( pName != NULL );
72 return Nm_ManStoreIdName( pObj->pNtk->pManName, pObj->Id, pObj->Type, pName, pSuffix );
73}
74
86char * Abc_ObjNamePrefix( Abc_Obj_t * pObj, char * pPrefix )
87{
88 static char Buffer[2000];
89 sprintf( Buffer, "%s%s", pPrefix, Abc_ObjName(pObj) );
90 return Buffer;
91}
92
104char * Abc_ObjNameSuffix( Abc_Obj_t * pObj, char * pSuffix )
105{
106 static char Buffer[2000];
107 sprintf( Buffer, "%s%s", Abc_ObjName(pObj), pSuffix );
108 return Buffer;
109}
110
122char * Abc_ObjNameDummy( char * pPrefix, int Num, int nDigits )
123{
124 static char Buffer[2000];
125 sprintf( Buffer, "%s%0*d", pPrefix, nDigits, Num );
126 return Buffer;
127}
128char * Abc_ObjNameChar( int Num, int fCap )
129{
130 static char Buffer[2000];
131 sprintf( Buffer, "%c", (fCap ? 'A':'a') + Num );
132 return Buffer;
133}
134
146void Abc_NtkTrasferNames( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew )
147{
148 Abc_Obj_t * pObj;
149 int i;
150 assert( Abc_NtkPiNum(pNtk) == Abc_NtkPiNum(pNtkNew) );
151 assert( Abc_NtkPoNum(pNtk) == Abc_NtkPoNum(pNtkNew) );
152 assert( Abc_NtkBoxNum(pNtk) == Abc_NtkBoxNum(pNtkNew) );
153 assert( Nm_ManNumEntries(pNtk->pManName) > 0 );
154 assert( Nm_ManNumEntries(pNtkNew->pManName) == 0 );
155 // copy the CI/CO/box names
156 Abc_NtkForEachCi( pNtk, pObj, i )
157 Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(Abc_ObjFanout0Ntk(pObj)), NULL );
158 Abc_NtkForEachCo( pNtk, pObj, i )
159 Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(Abc_ObjFanin0Ntk(pObj)), NULL );
160 Abc_NtkForEachBox( pNtk, pObj, i )
161 Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
162}
163
176{
177 Abc_Obj_t * pObj;
178 int i;
179 assert( Abc_NtkPiNum(pNtk) == Abc_NtkPiNum(pNtkNew) );
180 assert( Abc_NtkPoNum(pNtk) == Abc_NtkPoNum(pNtkNew) );
181 assert( Nm_ManNumEntries(pNtk->pManName) > 0 );
182 assert( Nm_ManNumEntries(pNtkNew->pManName) == 0 );
183 // copy the CI/CO/box name and skip latches and theirs inputs/outputs
184 Abc_NtkForEachCi( pNtk, pObj, i )
185 if ( Abc_ObjFaninNum(pObj) == 0 || !Abc_ObjIsLatch(Abc_ObjFanin0(pObj)) )
186 Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(Abc_ObjFanout0Ntk(pObj)), NULL );
187 Abc_NtkForEachCo( pNtk, pObj, i )
188 if ( Abc_ObjFanoutNum(pObj) == 0 || !Abc_ObjIsLatch(Abc_ObjFanout0(pObj)) )
189 Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(Abc_ObjFanin0Ntk(pObj)), NULL );
190 Abc_NtkForEachBox( pNtk, pObj, i )
191 if ( !Abc_ObjIsLatch(pObj) )
192 Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
193}
194
207{
208 Vec_Ptr_t * vNodes;
209 Abc_Obj_t * pFanin;
210 int i;
211 vNodes = Vec_PtrAlloc( 100 );
212 Abc_ObjForEachFanin( pNode, pFanin, i )
213 Vec_PtrPush( vNodes, Abc_UtilStrsav(Abc_ObjName(pFanin)) );
214 return vNodes;
215}
216
229{
230 Vec_Ptr_t * vNames;
231 char Buffer[5];
232 int i;
233
234 vNames = Vec_PtrAlloc( nNames );
235 for ( i = 0; i < nNames; i++ )
236 {
237 if ( nNames < 26 )
238 {
239 Buffer[0] = 'a' + i;
240 Buffer[1] = 0;
241 }
242 else
243 {
244 Buffer[0] = 'a' + i%26;
245 Buffer[1] = '0' + i/26;
246 Buffer[2] = 0;
247 }
248 Vec_PtrPush( vNames, Extra_UtilStrsav(Buffer) );
249 }
250 return vNames;
251}
252
265{
266 int i;
267 if ( vNames == NULL )
268 return;
269 for ( i = 0; i < vNames->nSize; i++ )
270 ABC_FREE( vNames->pArray[i] );
271 Vec_PtrFree( vNames );
272}
273
285char ** Abc_NtkCollectCioNames( Abc_Ntk_t * pNtk, int fCollectCos )
286{
287 Abc_Obj_t * pObj;
288 char ** ppNames;
289 int i;
290 if ( fCollectCos )
291 {
292 ppNames = ABC_ALLOC( char *, Abc_NtkCoNum(pNtk) );
293 Abc_NtkForEachCo( pNtk, pObj, i )
294 ppNames[i] = Abc_ObjName(pObj);
295 }
296 else
297 {
298 ppNames = ABC_ALLOC( char *, Abc_NtkCiNum(pNtk) );
299 Abc_NtkForEachCi( pNtk, pObj, i )
300 ppNames[i] = Abc_ObjName(pObj);
301 }
302 return ppNames;
303}
304
317{
318 int Diff = strcmp( (char *)(*pp1)->pCopy, (char *)(*pp2)->pCopy );
319 if ( Diff < 0 )
320 return -1;
321 if ( Diff > 0 )
322 return 1;
323 Diff = (*pp1)->Id - (*pp2)->Id;
324 if ( Diff < 0 )
325 return -1;
326 if ( Diff > 0 )
327 return 1;
328 return 0;
329}
330void Abc_NtkOrderObjsByName( Abc_Ntk_t * pNtk, int fComb )
331{
332 Abc_Obj_t * pObj;
333 int i;
334 assert( Abc_NtkHasOnlyLatchBoxes(pNtk) );
335 // temporarily store the names in the copy field
336 Abc_NtkForEachPi( pNtk, pObj, i )
337 pObj->pCopy = (Abc_Obj_t *)Abc_ObjName(pObj);
338 Abc_NtkForEachPo( pNtk, pObj, i )
339 pObj->pCopy = (Abc_Obj_t *)Abc_ObjName(pObj);
340 Abc_NtkForEachBox( pNtk, pObj, i )
341 pObj->pCopy = (Abc_Obj_t *)Abc_ObjName(Abc_ObjFanout0(pObj));
342 // order objects alphabetically
343 qsort( (void *)Vec_PtrArray(pNtk->vPis), (size_t)Vec_PtrSize(pNtk->vPis), sizeof(Abc_Obj_t *),
344 (int (*)(const void *, const void *)) Abc_NodeCompareNames );
345 qsort( (void *)Vec_PtrArray(pNtk->vPos), (size_t)Vec_PtrSize(pNtk->vPos), sizeof(Abc_Obj_t *),
346 (int (*)(const void *, const void *)) Abc_NodeCompareNames );
347 // if the comparison if combinational (latches as PIs/POs), order them too
348 if ( fComb )
349 qsort( (void *)Vec_PtrArray(pNtk->vBoxes), (size_t)Vec_PtrSize(pNtk->vBoxes), sizeof(Abc_Obj_t *),
350 (int (*)(const void *, const void *)) Abc_NodeCompareNames );
351 // order CIs/COs first PIs/POs(Asserts) then latches
352 Abc_NtkOrderCisCos( pNtk );
353 // clean the copy fields
354 Abc_NtkForEachPi( pNtk, pObj, i )
355 pObj->pCopy = NULL;
356 Abc_NtkForEachPo( pNtk, pObj, i )
357 pObj->pCopy = NULL;
358 Abc_NtkForEachBox( pNtk, pObj, i )
359 pObj->pCopy = NULL;
360}
361
374{
375 if ( fOuts )
376 {
377 Abc_Obj_t * pObj; int i;
378 Abc_Nam_t * pStrsCo = Abc_NamStart( Abc_NtkCoNum(p), 24 );
379 Abc_NtkForEachCo( p, pObj, i )
380 Abc_NamStrFindOrAdd( pStrsCo, Abc_ObjName(pObj), NULL );
381 assert( Abc_NamObjNumMax(pStrsCo) == i + 1 );
382 return pStrsCo;
383 }
384 else
385 {
386 Abc_Obj_t * pObj; int i;
387 Abc_Nam_t * pStrsCi = Abc_NamStart( Abc_NtkCiNum(p), 24 );
388 Abc_NtkForEachCi( p, pObj, i )
389 Abc_NamStrFindOrAdd( pStrsCi, Abc_ObjName(pObj), NULL );
390 assert( Abc_NamObjNumMax(pStrsCi) == i + 1 );
391 return pStrsCi;
392 }
393}
394
407{
408 int Diff = (*pp1)->iTemp - (*pp2)->iTemp;
409 if ( Diff < 0 )
410 return -1;
411 if ( Diff > 0 )
412 return 1;
413 return 0;
414}
415void Abc_NtkTransferOrder( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew )
416{
417 Abc_Obj_t * pObj; int i;
418 Abc_Nam_t * pStrsCi = Abc_NtkNameMan( pNtkOld, 0 );
419 Abc_Nam_t * pStrsCo = Abc_NtkNameMan( pNtkOld, 1 );
420 assert( Abc_NtkPiNum(pNtkOld) == Abc_NtkPiNum(pNtkNew) );
421 assert( Abc_NtkPoNum(pNtkOld) == Abc_NtkPoNum(pNtkNew) );
422 assert( Abc_NtkLatchNum(pNtkOld) == Abc_NtkLatchNum(pNtkNew) );
423 // transfer to the new network
424 Abc_NtkForEachCi( pNtkNew, pObj, i )
425 {
426 pObj->iTemp = Abc_NamStrFind(pStrsCi, Abc_ObjName(pObj));
427 assert( pObj->iTemp > 0 && pObj->iTemp <= Abc_NtkCiNum(pNtkNew) );
428 }
429 Abc_NtkForEachCo( pNtkNew, pObj, i )
430 {
431 pObj->iTemp = Abc_NamStrFind(pStrsCo, Abc_ObjName(pObj));
432 assert( pObj->iTemp > 0 && pObj->iTemp <= Abc_NtkCoNum(pNtkNew) );
433 }
434 Abc_NamDeref( pStrsCi );
435 Abc_NamDeref( pStrsCo );
436 // order PI/PO
437 qsort( (void *)Vec_PtrArray(pNtkNew->vPis), (size_t)Vec_PtrSize(pNtkNew->vPis), sizeof(Abc_Obj_t *),
438 (int (*)(const void *, const void *)) Abc_NodeCompareIndexes );
439 qsort( (void *)Vec_PtrArray(pNtkNew->vPos), (size_t)Vec_PtrSize(pNtkNew->vPos), sizeof(Abc_Obj_t *),
440 (int (*)(const void *, const void *)) Abc_NodeCompareIndexes );
441 // order CI/CO
442 qsort( (void *)Vec_PtrArray(pNtkNew->vCis), (size_t)Vec_PtrSize(pNtkNew->vCis), sizeof(Abc_Obj_t *),
443 (int (*)(const void *, const void *)) Abc_NodeCompareIndexes );
444 qsort( (void *)Vec_PtrArray(pNtkNew->vCos), (size_t)Vec_PtrSize(pNtkNew->vCos), sizeof(Abc_Obj_t *),
445 (int (*)(const void *, const void *)) Abc_NodeCompareIndexes );
446 // order CIs/COs first PIs/POs(Asserts) then latches
447 //Abc_NtkOrderCisCos( pNtk );
448 // clean the copy fields
449 Abc_NtkForEachCi( pNtkNew, pObj, i )
450 pObj->iTemp = 0;
451 Abc_NtkForEachCo( pNtkNew, pObj, i )
452 pObj->iTemp = 0;
453}
454
466int Abc_NodeCompareCiCo( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew )
467{
468 int i;
469 if ( Abc_NtkPiNum(pNtkOld) != Abc_NtkPiNum(pNtkNew) )
470 return 0;
471 if ( Abc_NtkPoNum(pNtkOld) != Abc_NtkPoNum(pNtkNew) )
472 return 0;
473 if ( Abc_NtkLatchNum(pNtkOld) != Abc_NtkLatchNum(pNtkNew) )
474 return 0;
475 for ( i = 0; i < Abc_NtkCiNum(pNtkOld); i++ )
476 if ( strcmp(Abc_ObjName(Abc_NtkCi(pNtkOld, i)), Abc_ObjName(Abc_NtkCi(pNtkNew, i))) )
477 return 0;
478 for ( i = 0; i < Abc_NtkCoNum(pNtkOld); i++ )
479 if ( strcmp(Abc_ObjName(Abc_NtkCo(pNtkOld, i)), Abc_ObjName(Abc_NtkCo(pNtkNew, i))) )
480 return 0;
481 return 1;
482}
483
496{
497 Abc_Obj_t * pObj;
498 int nDigits, i;
499 nDigits = Abc_Base10Log( Abc_NtkPiNum(pNtk) );
500 Abc_NtkForEachPi( pNtk, pObj, i )
501 Abc_ObjAssignName( pObj, Abc_ObjNameDummy("pi", i, nDigits), NULL );
502}
504{
505 Abc_Obj_t * pObj; int i;
506 Abc_NtkForEachPi( pNtk, pObj, i )
507 Abc_ObjAssignName( pObj, Abc_ObjNameChar(i, 0), NULL );
508}
509
522{
523 Abc_Obj_t * pObj;
524 int nDigits, i;
525 nDigits = Abc_Base10Log( Abc_NtkPoNum(pNtk) );
526 Abc_NtkForEachPo( pNtk, pObj, i )
527 Abc_ObjAssignName( pObj, Abc_ObjNameDummy("po", i, nDigits), NULL );
528}
530{
531 Abc_Obj_t * pObj; int i;
532 Abc_NtkForEachPo( pNtk, pObj, i )
533 Abc_ObjAssignName( pObj, Abc_ObjNameChar(i, 1), NULL );
534}
535
548{
549 char * pName, PrefLi[100], PrefLo[100];
550 Abc_Obj_t * pObj;
551 int nDigits, i, k, CountCur, CountMax = 0;
552 // if PIs/POs already have nodes with what looks like latch names
553 // we need to add different prefix for the new latches
554 Abc_NtkForEachPi( pNtk, pObj, i )
555 {
556 CountCur = 0;
557 pName = Abc_ObjName(pObj);
558 for ( k = 0; pName[k]; k++ )
559 if ( pName[k] == 'l' )
560 CountCur++;
561 else
562 break;
563 CountMax = Abc_MaxInt( CountMax, CountCur );
564 }
565 Abc_NtkForEachPo( pNtk, pObj, i )
566 {
567 CountCur = 0;
568 pName = Abc_ObjName(pObj);
569 for ( k = 0; pName[k]; k++ )
570 if ( pName[k] == 'l' )
571 CountCur++;
572 else
573 break;
574 CountMax = Abc_MaxInt( CountMax, CountCur );
575 }
576//printf( "CountMax = %d\n", CountMax );
577 assert( CountMax < 100-2 );
578 for ( i = 0; i <= CountMax; i++ )
579 PrefLi[i] = PrefLo[i] = 'l';
580 PrefLi[i] = 'i';
581 PrefLo[i] = 'o';
582 PrefLi[i+1] = 0;
583 PrefLo[i+1] = 0;
584 // create latch names
585 assert( !Abc_NtkIsNetlist(pNtk) );
586 nDigits = Abc_Base10Log( Abc_NtkLatchNum(pNtk) );
587 Abc_NtkForEachLatch( pNtk, pObj, i )
588 {
589 Abc_ObjAssignName( pObj, Abc_ObjNameDummy("l", i, nDigits), NULL );
590 Abc_ObjAssignName( Abc_ObjFanin0(pObj), Abc_ObjNameDummy(PrefLi, i, nDigits), NULL );
591 Abc_ObjAssignName( Abc_ObjFanout0(pObj), Abc_ObjNameDummy(PrefLo, i, nDigits), NULL );
592 }
593/*
594 nDigits = Abc_Base10Log( Abc_NtkBlackboxNum(pNtk) );
595 Abc_NtkForEachBlackbox( pNtk, pObj, i )
596 {
597 pName = Abc_ObjAssignName( pObj, Abc_ObjNameDummy("B", i, nDigits), NULL );
598 nDigitsF = Abc_Base10Log( Abc_ObjFaninNum(pObj) );
599 Abc_ObjForEachFanin( pObj, pTerm, k )
600 Abc_ObjAssignName( Abc_ObjFanin0(pObj), pName, Abc_ObjNameDummy("i", k, nDigitsF) );
601 nDigitsF = Abc_Base10Log( Abc_ObjFanoutNum(pObj) );
602 Abc_ObjForEachFanout( pObj, pTerm, k )
603 Abc_ObjAssignName( Abc_ObjFanin0(pObj), pName, Abc_ObjNameDummy("o", k, nDigitsF) );
604 }
605*/
606}
607
620{
621 Nm_ManFree( pNtk->pManName );
622 pNtk->pManName = Nm_ManCreate( Abc_NtkCiNum(pNtk) + Abc_NtkCoNum(pNtk) + Abc_NtkBoxNum(pNtk) );
626}
628{
629 Nm_ManFree( pNtk->pManName );
630 pNtk->pManName = Nm_ManCreate( Abc_NtkCiNum(pNtk) + Abc_NtkCoNum(pNtk) + Abc_NtkBoxNum(pNtk) );
631 Abc_NtkAddCharPiNames( pNtk );
632 Abc_NtkAddCharPoNames( pNtk );
634}
636{
637 Abc_Obj_t * pObj; int i;
638 Nm_Man_t * pManName = Nm_ManCreate( Abc_NtkCiNum(pNtk) + Abc_NtkCoNum(pNtk) + Abc_NtkBoxNum(pNtk) );
639 Abc_NtkForEachCi( pNtk, pObj, i )
640 Nm_ManStoreIdName( pManName, pObj->Id, pObj->Type, Abc_ObjName(pObj), NULL );
641 Abc_NtkForEachCo( pNtk, pObj, i )
642 Nm_ManStoreIdName( pManName, pObj->Id, pObj->Type, Abc_ObjName(pObj), NULL );
643 Nm_ManFree( pNtk->pManName );
644 pNtk->pManName = pManName;
645}
646
659{
660 Abc_Obj_t * pObj, * pObjCi, * pFanin;
661 int i, Count = 0;
662 // if CO points to CI with the same name, remove buffer between them
663 Abc_NtkForEachCo( pNtk, pObj, i )
664 {
666 if ( nCiId == -1 )
667 continue;
668 pObjCi = Abc_NtkObj( pNtk, nCiId );
669 assert( !strcmp( Abc_ObjName(pObj), Abc_ObjName(pObjCi) ) );
670 pFanin = Abc_ObjFanin0(pObj);
671 if ( pFanin == pObjCi )
672 continue;
673 assert( Abc_NodeIsBuf(pFanin) );
674 Abc_ObjPatchFanin( pObj, pFanin, pObjCi );
675 if ( Abc_ObjFanoutNum(pFanin) == 0 )
676 Abc_NtkDeleteObj( pFanin );
677 Count++;
678 }
679 if ( Count )
680 printf( "Redirected %d POs from buffers to PIs with the same name.\n", Count );
681}
683{
684 Abc_Obj_t * pObj; int i;
685 Nm_ManFree( pNtk->pManName );
686 pNtk->pManName = Nm_ManCreate( Abc_NtkCiNum(pNtk) + Abc_NtkCoNum(pNtk) + Abc_NtkBoxNum(pNtk) );
687 Abc_NtkForEachPi( pNtk, pObj, i )
688 Abc_ObjAssignName( pObj, Abc_ObjName(Abc_NtkPi(pOld, i)), NULL );
689 Abc_NtkForEachPo( pNtk, pObj, i )
690 Abc_ObjAssignName( pObj, Abc_ObjName(Abc_NtkPo(pOld, i)), NULL );
691 Abc_NtkForEachLatch( pNtk, pObj, i )
692 {
693 Abc_ObjAssignName( Abc_ObjFanin0(pObj), Abc_ObjName(Abc_ObjFanin0(Abc_NtkBox(pOld, i))), NULL );
694 Abc_ObjAssignName( Abc_ObjFanout0(pObj), Abc_ObjName(Abc_ObjFanout0(Abc_NtkBox(pOld, i))), NULL );
695 }
696 Abc_NtkRedirectCiCo( pNtk );
697}
698
699
712{
713 char pFileName[1000];
714 FILE * pFile;
715 Abc_Obj_t * pObj, * pFanin;
716 Vec_Ptr_t * vNodes;
717 int i, Counter = 1;
718 assert( Abc_NtkIsNetlist(p) );
719 assert( p->vNameIds == NULL );
720 assert( strlen(p->pSpec) < 1000 );
721 sprintf( pFileName, "%s_%s_names.txt", Extra_FileNameGenericAppend(p->pSpec,""), Extra_FileNameExtension(p->pSpec) );
722 pFile = fopen( pFileName, "wb" );
723 p->vNameIds = Vec_IntStart( Abc_NtkObjNumMax(p) );
724 // add inputs
725 Abc_NtkForEachCi( p, pObj, i )
726 fprintf( pFile, "%s \n", Abc_ObjName(Abc_ObjFanout0(pObj)) ), Vec_IntWriteEntry(p->vNameIds, Abc_ObjId(pObj), 2*Counter++);
727 // add outputs
728 Abc_NtkForEachCo( p, pObj, i )
729 {
730 pFanin = Abc_ObjFanin0(Abc_ObjFanin0(pObj));
731 if ( !Vec_IntEntry(p->vNameIds, Abc_ObjId(pFanin)) )
732 fprintf( pFile, "%s \n", Abc_ObjName(Abc_ObjFanout0(pFanin)) ), Vec_IntWriteEntry(p->vNameIds, Abc_ObjId(pFanin), 2*Counter++);
733 }
734 // add nodes in a topo order
735 vNodes = Abc_NtkDfs( p, 1 );
736 Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
737 if ( !Vec_IntEntry(p->vNameIds, Abc_ObjId(pObj)) )
738 fprintf( pFile, "%s \n", Abc_ObjName(Abc_ObjFanout0(pObj)) ), Vec_IntWriteEntry(p->vNameIds, Abc_ObjId(pObj), 2*Counter++);
739 Vec_PtrFree( vNodes );
740 fclose( pFile );
741 // transfer driver node names to COs
742 Abc_NtkForEachCo( p, pObj, i )
743 {
744 pFanin = Abc_ObjFanin0(Abc_ObjFanin0(pObj));
745 Vec_IntWriteEntry( p->vNameIds, Abc_ObjId(pObj), Vec_IntEntry(p->vNameIds, Abc_ObjId(pFanin)) );
746 Vec_IntWriteEntry( p->vNameIds, Abc_ObjId(pFanin), 0 );
747 }
748}
749
762{
763 Abc_Obj_t * pObj, * pObjNew;
764 int i;
765 assert( p->vNameIds != NULL );
766 assert( pNew->vNameIds == NULL );
767 pNew->vNameIds = Vec_IntStart( Abc_NtkObjNumMax(pNew) );
768// Abc_NtkForEachCi( p, pObj, i )
769// printf( "%d ", Vec_IntEntry(p->vNameIds, Abc_ObjId(pObj)) );
770// printf( "\n" );
771 Abc_NtkForEachObj( p, pObj, i )
772 if ( pObj->pCopy && i < Vec_IntSize(p->vNameIds) && Vec_IntEntry(p->vNameIds, i) )
773 {
774 pObjNew = Abc_ObjRegular(pObj->pCopy);
775 assert( Abc_ObjNtk(pObjNew) == pNew );
776 if ( Abc_ObjIsCi(pObjNew) && !Abc_ObjIsCi(pObj) ) // do not overwrite CI name by internal node name
777 continue;
778 Vec_IntWriteEntry( pNew->vNameIds, Abc_ObjId(pObjNew), Vec_IntEntry(p->vNameIds, i) ^ Abc_ObjIsComplement(pObj->pCopy) );
779 }
780}
781
794{
795 char pFileName[1000];
796 Vec_Int_t * vStarts;
797 Abc_Obj_t * pObj;
798 FILE * pFile;
799 int i, c, iVar, fCompl, fSeenSpace, Counter = 0;
800 assert( !Abc_NtkIsNetlist(p) );
801 assert( strlen(p->pSpec) < 1000 );
802 assert( p->vNameIds != NULL );
803 sprintf( pFileName, "%s_%s_names.txt", Extra_FileNameGenericAppend(p->pSpec,""), Extra_FileNameExtension(p->pSpec) );
804 pFile = fopen( pFileName, "r+" );
805 // collect info about lines
806 fSeenSpace = 0;
807 vStarts = Vec_IntAlloc( 1000 );
808 Vec_IntPush( vStarts, -1 );
809 while ( (c = fgetc(pFile)) != EOF && ++Counter )
810 if ( c == ' ' && !fSeenSpace )
811 Vec_IntPush(vStarts, Counter), fSeenSpace = 1;
812 else if ( c == '\n' )
813 fSeenSpace = 0;
814 // add info about names
815 Abc_NtkForEachObj( p, pObj, i )
816 {
817 if ( i == 0 || i >= Vec_IntSize(p->vNameIds) || !Vec_IntEntry(p->vNameIds, i) )
818 continue;
819 iVar = Abc_Lit2Var( Vec_IntEntry(p->vNameIds, i) );
820 fCompl = Abc_LitIsCompl( Vec_IntEntry(p->vNameIds, i) );
821 assert( iVar < Vec_IntSize(vStarts) );
822 fseek( pFile, Vec_IntEntry(vStarts, iVar), SEEK_SET );
823 fprintf( pFile, "%s%d", fCompl? "-":"", i );
824 }
825 printf( "Saved %d names into file \"%s\".\n", Vec_IntSize(vStarts)-1, pFileName );
826 fclose( pFile );
827 Vec_IntFree( vStarts );
828 Vec_IntFreeP( &p->vNameIds );
829// Abc_NtkForEachObj( p, pObj, i )
830// Abc_ObjPrint( stdout, pObj );
831}
832
836
837
839
Abc_Nam_t * Abc_NtkNameMan(Abc_Ntk_t *p, int fOuts)
Definition abcNames.c:373
char * Abc_ObjNameDummy(char *pPrefix, int Num, int nDigits)
Definition abcNames.c:122
char ** Abc_NtkCollectCioNames(Abc_Ntk_t *pNtk, int fCollectCos)
Definition abcNames.c:285
void Abc_NtkTransferNameIds(Abc_Ntk_t *p, Abc_Ntk_t *pNew)
Definition abcNames.c:761
void Abc_NtkTrasferNamesNoLatches(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew)
Definition abcNames.c:175
int Abc_NodeCompareNames(Abc_Obj_t **pp1, Abc_Obj_t **pp2)
Definition abcNames.c:316
void Abc_NtkAddDummyPoNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:521
void Abc_NtkAddCharPiNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:503
void Abc_NtkAddCharPoNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:529
Vec_Ptr_t * Abc_NodeGetFaninNames(Abc_Obj_t *pNode)
Definition abcNames.c:206
char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition abcNames.c:69
void Abc_NtkOrderObjsByName(Abc_Ntk_t *pNtk, int fComb)
Definition abcNames.c:330
void Abc_NtkAddDummyPiNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:495
void Abc_NtkMoveNames(Abc_Ntk_t *pNtk, Abc_Ntk_t *pOld)
Definition abcNames.c:682
void Abc_NtkCharNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:627
char * Abc_ObjNameSuffix(Abc_Obj_t *pObj, char *pSuffix)
Definition abcNames.c:104
int Abc_NodeCompareCiCo(Abc_Ntk_t *pNtkOld, Abc_Ntk_t *pNtkNew)
Definition abcNames.c:466
int Abc_NodeCompareIndexes(Abc_Obj_t **pp1, Abc_Obj_t **pp2)
Definition abcNames.c:406
void Abc_NtkRedirectCiCo(Abc_Ntk_t *pNtk)
Definition abcNames.c:658
ABC_NAMESPACE_IMPL_START char * Abc_ObjName(Abc_Obj_t *pObj)
DECLARATIONS ///.
Definition abcNames.c:49
void Abc_NtkUpdateNameIds(Abc_Ntk_t *p)
Definition abcNames.c:793
void Abc_NodeFreeNames(Vec_Ptr_t *vNames)
Definition abcNames.c:264
char * Abc_ObjNameChar(int Num, int fCap)
Definition abcNames.c:128
void Abc_NtkAddDummyBoxNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:547
void Abc_NtkCleanNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:635
char * Abc_ObjNamePrefix(Abc_Obj_t *pObj, char *pPrefix)
Definition abcNames.c:86
void Abc_NtkTrasferNames(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew)
Definition abcNames.c:146
void Abc_NtkTransferOrder(Abc_Ntk_t *pNtkOld, Abc_Ntk_t *pNtkNew)
Definition abcNames.c:415
Vec_Ptr_t * Abc_NodeGetFakeNames(int nNames)
Definition abcNames.c:228
void Abc_NtkStartNameIds(Abc_Ntk_t *p)
Definition abcNames.c:711
void Abc_NtkShortNames(Abc_Ntk_t *pNtk)
Definition abcNames.c:619
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition abc.h:522
ABC_DLL void Abc_NtkDeleteObj(Abc_Obj_t *pObj)
Definition abcObj.c:170
ABC_DLL int Abc_NodeIsBuf(Abc_Obj_t *pNode)
Definition abcObj.c:948
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition abc.h:520
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition abc.h:500
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition abcDfs.c:82
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition abc.h:449
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
@ ABC_OBJ_BO
Definition abc.h:92
@ ABC_OBJ_PI
Definition abc.h:89
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition abcNames.c:49
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition abc.h:516
ABC_DLL int Abc_NodeCompareNames(Abc_Obj_t **pp1, Abc_Obj_t **pp2)
Definition abcNames.c:316
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition abc.h:518
ABC_DLL void Abc_ObjPatchFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFaninOld, Abc_Obj_t *pFaninNew)
Definition abcFanio.c:172
#define Abc_NtkForEachBox(pNtk, pObj, i)
Definition abc.h:498
ABC_DLL void Abc_NtkOrderCisCos(Abc_Ntk_t *pNtk)
Definition abcUtil.c:76
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Cube * p
Definition exorList.c:222
char * Extra_UtilStrsav(const char *s)
char * Extra_FileNameGenericAppend(char *pBase, char *pSuffix)
char * Extra_FileNameExtension(char *FileName)
int Nm_ManNumEntries(Nm_Man_t *p)
Definition nmApi.c:95
void Nm_ManFree(Nm_Man_t *p)
Definition nmApi.c:76
int Nm_ManFindIdByNameTwoTypes(Nm_Man_t *p, char *pName, int Type1, int Type2)
Definition nmApi.c:239
char * Nm_ManCreateUniqueName(Nm_Man_t *p, int ObjId)
Definition nmApi.c:175
Nm_Man_t * Nm_ManCreate(int nSize)
MACRO DEFINITIONS ///.
Definition nmApi.c:45
typedefABC_NAMESPACE_HEADER_START struct Nm_Man_t_ Nm_Man_t
INCLUDES ///.
Definition nm.h:63
char * Nm_ManStoreIdName(Nm_Man_t *p, int ObjId, int Type, char *pName, char *pSuffix)
Definition nmApi.c:112
Vec_Ptr_t * vCis
Definition abc.h:165
Vec_Ptr_t * vCos
Definition abc.h:166
Vec_Ptr_t * vPos
Definition abc.h:164
Vec_Ptr_t * vBoxes
Definition abc.h:168
Vec_Int_t * vNameIds
Definition abc.h:215
Nm_Man_t * pManName
Definition abc.h:160
Vec_Ptr_t * vPis
Definition abc.h:163
Abc_Ntk_t * pNtk
Definition abc.h:130
int Id
Definition abc.h:132
int iTemp
Definition abc.h:149
Abc_Obj_t * pCopy
Definition abc.h:148
unsigned Type
Definition abc.h:133
int Abc_NamStrFind(Abc_Nam_t *p, char *pStr)
Definition utilNam.c:433
int Abc_NamStrFindOrAdd(Abc_Nam_t *p, char *pStr, int *pfFound)
Definition utilNam.c:453
int Abc_NamObjNumMax(Abc_Nam_t *p)
Definition utilNam.c:231
Abc_Nam_t * Abc_NamStart(int nObjs, int nAveSize)
FUNCTION DEFINITIONS ///.
Definition utilNam.c:80
void Abc_NamDeref(Abc_Nam_t *p)
Definition utilNam.c:212
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()
int strcmp()
char * sprintf()
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
#define SEEK_SET
Definition zconf.h:390