48 char Suffix[2000] = {0};
50 Abc_Obj_t * pObj, * pTerm, * pNet, * pFanin;
54 if ( Abc_NtkHasBlackbox(pNtk) )
57 assert( Abc_NtkBoxNum(pNtk) == 1 );
58 pObj = Abc_NtkBox( pNtk, 0 );
63 assert( Abc_ObjFaninNum(pObj->
pCopy) == Abc_NtkPiNum(pNtk) );
68 assert( Abc_ObjFanoutNum(pObj->
pCopy) == Abc_NtkPoNum(pNtk) );
78 sprintf( Suffix,
"_%s_%d", Abc_NtkName(pNtk), *pCounter );
85 pNet = Abc_ObjFanin0(pTerm);
92 pNet = Abc_ObjFanout0(pTerm);
100 Abc_NtkIncrementTravId( pNtk );
102 Abc_NodeSetTravIdCurrent( pTerm );
105 Abc_NodeSetTravIdCurrent( pTerm );
108 pNet = Abc_ObjFanin0(pTerm);
118 if ( Abc_ObjIsLatch(pObj) )
120 Abc_NodeSetTravIdCurrent( pObj );
122 Abc_NodeSetTravIdCurrent( pTerm );
124 Abc_NodeSetTravIdCurrent( pTerm );
130 if ( Abc_NodeIsTravIdCurrent(pObj) )
139 if ( !Abc_NodeIsTravIdCurrent(pObj) )
141 if ( !Abc_NodeIsTravIdCurrent(pFanin) )
147 if ( Abc_ObjIsLatch(pObj) )
151 assert( Abc_ObjFaninNum(pObj) == Abc_NtkPiNum(pNtkModel) );
152 assert( Abc_ObjFanoutNum(pObj) == Abc_NtkPoNum(pNtkModel) );
157 Abc_ObjFanout0( Abc_NtkPi(pNtkModel, k) )->pCopy = Abc_ObjFanin0(pTerm)->pCopy;
159 Abc_ObjFanin0( Abc_NtkPo(pNtkModel, k) )->pCopy = Abc_ObjFanout0(pTerm)->pCopy;
165 if ( Abc_NtkHasBlifMv(pNtk) && Abc_NtkMvVar(pNtk) )
167 if ( Abc_NtkMvVar( pNtkNew ) == NULL )
192 assert( Abc_NtkIsNetlist(pNtk) );
206 pNet = Abc_ObjFanout0( pTerm );
213 pNet = Abc_ObjFanin0( pTerm );
221 printf(
"Hierarchy reader flattened %d instances of logic boxes and left %d black boxes.\n",
222 Counter, Abc_NtkBlackboxNum(pNtkNew) );
241 printf(
"EXDC is not transformed.\n" );
244 fprintf( stdout,
"Abc_NtkFlattenLogicHierarchy2(): Network check has failed.\n" );
268 Abc_Obj_t * pObj, * pTerm, * pNet, * pFanin;
272 if ( Abc_NtkHasBlackbox(pNtk) )
276 assert( Abc_NtkBoxNum(pNtk) == 1 );
277 pObj = Abc_NtkBox( pNtk, 0 );
282 assert( Abc_ObjFaninNum(pObj->
pCopy) == Abc_NtkPiNum(pNtk) );
287 assert( Abc_ObjFanoutNum(pObj->
pCopy) == Abc_NtkPoNum(pNtk) );
299 sprintf( Buffer,
"(%d)", *pCounter );
300 Vec_StrPrintStr( vPref, Buffer );
302 Vec_StrPush( vPref,
'|' );
303 Vec_StrPush( vPref, 0 );
310 pNet = Abc_ObjFanin0(pTerm);
317 pNet = Abc_ObjFanout0(pTerm);
325 Abc_NtkIncrementTravId( pNtk );
327 Abc_NodeSetTravIdCurrent( pTerm );
330 Abc_NodeSetTravIdCurrent( pTerm );
333 pNet = Abc_ObjFanin0(pTerm);
343 if ( Abc_ObjIsLatch(pObj) )
345 Abc_NodeSetTravIdCurrent( pObj );
347 Abc_NodeSetTravIdCurrent( pTerm );
349 Abc_NodeSetTravIdCurrent( pTerm );
355 if ( Abc_NodeIsTravIdCurrent(pObj) )
364 if ( !Abc_NodeIsTravIdCurrent(pObj) )
366 if ( !Abc_NodeIsTravIdCurrent(pFanin) )
371 Length = Vec_StrSize( vPref );
374 if ( Abc_ObjIsLatch(pObj) )
378 assert( Abc_ObjFaninNum(pObj) == Abc_NtkPiNum(pNtkModel) );
379 assert( Abc_ObjFanoutNum(pObj) == Abc_NtkPoNum(pNtkModel) );
384 Abc_ObjFanout0( Abc_NtkPi(pNtkModel, k) )->pCopy = Abc_ObjFanin0(pTerm)->pCopy;
386 Abc_ObjFanin0( Abc_NtkPo(pNtkModel, k) )->pCopy = Abc_ObjFanout0(pTerm)->pCopy;
388 Vec_StrShrink( vPref, Length );
389 Vec_StrPrintStr( vPref, Abc_NtkName(pNtkModel) );
395 if ( Abc_NtkHasBlifMv(pNtk) && Abc_NtkMvVar(pNtk) )
397 if ( Abc_NtkMvVar( pNtkNew ) == NULL )
417 return strcmp( Abc_NtkName(*p1), Abc_NtkName(*p2) );
450 Num = Vec_PtrFind( vMods, pNtk );
451 assert( Num >= 0 && Num < Vec_PtrSize(vMods) );
452 pBoxModel = (
Abc_Ntk_t *)Vec_PtrEntry(vMods, 0);
453 Vec_PtrWriteEntry(vMods, 0, (
Abc_Ntk_t *)Vec_PtrEntry(vMods, Num) );
454 Vec_PtrWriteEntry(vMods, Num, pBoxModel );
457 vCounts = Vec_IntStart( Vec_PtrSize(vMods) );
460 if ( Abc_NtkBoxNum(pModel) == 0 )
462 Vec_IntFill( vCounts, Vec_IntSize(vCounts), 0 );
466 if ( pBoxModel == NULL )
468 Num = Vec_PtrFind( vMods, pBoxModel );
469 assert( Num >= 0 && Num < Vec_PtrSize(vMods) );
470 Vec_IntAddToEntry( vCounts, Num, 1 );
475 printf(
"%-30s : ", Abc_NtkName(pModel) );
476 printf(
"PI=%6d ", Abc_NtkPiNum(pModel) );
477 printf(
"PO=%6d ", Abc_NtkPoNum(pModel) );
478 printf(
"BB=%6d ", Abc_NtkBoxNum(pModel) );
479 printf(
"ND=%6d ", Abc_NtkNodeNum(pModel) );
485 printf(
"%15d : %s\n", Num, Abc_NtkName((
Abc_Ntk_t *)Vec_PtrEntry(vMods, k)) );
487 Vec_IntFree( vCounts );
490 if ( Abc_NtkBoxNum(pModel) != 0 )
493 printf(
"%-30s : ", Abc_NtkName(pModel) );
494 printf(
"PI=%6d ", Abc_NtkPiNum(pModel) );
495 printf(
"PO=%6d ", Abc_NtkPoNum(pModel) );
496 printf(
"BB=%6d ", Abc_NtkBoxNum(pModel) );
497 printf(
"ND=%6d ", Abc_NtkNodeNum(pModel) );
522 assert( Abc_NtkIsNetlist(pNtk) );
538 pNet = Abc_ObjFanout0( pTerm );
545 pNet = Abc_ObjFanin0( pTerm );
551 vPref = Vec_StrAlloc( 1000 );
552 Vec_StrPrintStr( vPref, Abc_NtkName(pNtk) );
554 printf(
"Hierarchy reader flattened %d instances of logic boxes and left %d black boxes.\n",
555 Counter, Abc_NtkBlackboxNum(pNtkNew) );
556 Vec_StrFree( vPref );
575 printf(
"EXDC is not transformed.\n" );
578 fprintf( stdout,
"Abc_NtkFlattenLogicHierarchy(): Network check has failed.\n" );
601 Abc_Obj_t * pObj, * pNet, * pFanin, * pTerm;
604 assert( Abc_NtkIsNetlist(pNtk) );
605 assert( Abc_NtkWhiteboxNum(pNtk) == 0 );
617 Abc_NtkIncrementTravId( pNtk );
619 Abc_NodeSetTravIdCurrent( pObj );
621 Abc_NodeSetTravIdCurrent( pTerm );
623 Abc_NodeSetTravIdCurrent( pTerm );
626 Abc_NodeSetTravIdPrevious( pTerm );
628 Abc_NodeSetTravIdPrevious( pTerm );
630 Abc_NodeSetTravIdPrevious( pTerm );
634 pTerm->
pCopy = Abc_NtkCreatePi( pNtkNew );
638 if ( !Abc_NodeIsTravIdCurrent(pObj) )
643 if ( !Abc_NodeIsTravIdCurrent(pObj) )
648 Abc_NtkIncrementTravId( pNtk );
652 assert( Abc_ObjFanoutNum(pTerm) <= 1 );
653 if ( Abc_ObjFanoutNum(pTerm) > 0 && Abc_ObjIsLatch(Abc_ObjFanout0(pTerm)) )
656 pNet = Abc_ObjFanin0(pTerm);
657 if ( Abc_NodeIsTravIdCurrent(pNet) )
660 Abc_NodeSetTravIdCurrent( pNet );
667 fprintf( stdout,
"Abc_NtkConvertBlackboxes(): Network check has failed.\n" );
695 Abc_Obj_t * pObjH, * pObjL, * pNetH, * pNetL, * pTermH;
698 assert( Abc_NtkIsNetlist(pNtkH) );
699 assert( Abc_NtkWhiteboxNum(pNtkH) == 0 );
700 assert( Abc_NtkBlackboxNum(pNtkH) > 0 );
702 assert( Abc_NtkIsNetlist(pNtkL) );
703 assert( Abc_NtkWhiteboxNum(pNtkL) == 0 );
704 assert( Abc_NtkBlackboxNum(pNtkL) == 0 );
718 pNetH = Abc_ObjFanout0(pObjH);
720 if ( pNetL == NULL || !Abc_ObjIsPi( Abc_ObjFanin0(pNetL) ) )
722 printf(
"Error in Abc_NtkInsertNewLogic(): There is no PI corresponding to the PI %s.\n",
Abc_ObjName(pNetH) );
728 printf(
"Error in Abc_NtkInsertNewLogic(): Primary input %s is repeated twice.\n",
Abc_ObjName(pNetH) );
746 pNetH = Abc_ObjFanout0( pTermH );
748 if ( pNetL == NULL || !Abc_ObjIsPi( Abc_ObjFanin0(pNetL) ) )
750 printf(
"Error in Abc_NtkInsertNewLogic(): There is no PI corresponding to the inpout %s of blackbox %s.\n",
Abc_ObjName(pNetH),
Abc_ObjName(pObjH) );
756 printf(
"Error in Abc_NtkInsertNewLogic(): Box output %s is repeated twice.\n",
Abc_ObjName(pNetH) );
762 Abc_ObjFanin0(pNetL)->pCopy = pTermH->
pCopy;
768 pNetH = Abc_ObjFanin0(pObjH);
770 if ( pNetL == NULL || !Abc_ObjIsPo( Abc_ObjFanout0(pNetL) ) )
772 printf(
"Error in Abc_NtkInsertNewLogic(): There is no PO corresponding to the PO %s.\n",
Abc_ObjName(pNetH) );
787 pNetH = Abc_ObjFanin0( pTermH );
790 if ( pNetL == NULL || !Abc_ObjIsPo( Abc_ObjFanout0(pNetL) ) )
792 printf(
"There is no PO corresponding to the input %s of blackbox %s.\n",
Abc_ObjName(pNetH),
Abc_ObjName(pObjH) );
799 if ( Abc_ObjFanout0(pNetL)->pCopy == NULL )
800 Abc_ObjFanout0(pNetL)->pCopy = pTermH->
pCopy;
806 Abc_ObjFanout0(pNetL)->pCopy = pTermH->
pCopy;
812 if ( pObjL->
pCopy == NULL && !Abc_ObjIsPo(pObjL) )
824 Vec_PtrWriteEntry( pDesign->
vModules, 0, pNtkNew );
830 fprintf( stdout,
"Abc_NtkInsertNewLogic(): Network check has failed.\n" );
int Abc_NtkCompareNames(Abc_Ntk_t **p1, Abc_Ntk_t **p2)
Abc_Ntk_t * Abc_NtkConvertBlackboxes(Abc_Ntk_t *pNtk)
void Abc_NtkFlattenLogicHierarchy_rec(Abc_Ntk_t *pNtkNew, Abc_Ntk_t *pNtk, int *pCounter, Vec_Str_t *vPref)
Abc_Ntk_t * Abc_NtkFlattenLogicHierarchy2(Abc_Ntk_t *pNtk)
Abc_Ntk_t * Abc_NtkInsertNewLogic(Abc_Ntk_t *pNtkH, Abc_Ntk_t *pNtkL)
Abc_Ntk_t * Abc_NtkFlattenLogicHierarchy(Abc_Ntk_t *pNtk)
ABC_NAMESPACE_IMPL_START void Abc_NtkFlattenLogicHierarchy2_rec(Abc_Ntk_t *pNtkNew, Abc_Ntk_t *pNtk, int *pCounter)
DECLARATIONS ///.
void Abc_NtkPrintBoxInfo(Abc_Ntk_t *pNtk)
Abc_Des_t * Abc_DesDupBlackboxes(Abc_Des_t *p, Abc_Ntk_t *pNtkSave)
struct Abc_Obj_t_ Abc_Obj_t
ABC_DLL Abc_Obj_t * Abc_NtkFindOrCreateNet(Abc_Ntk_t *pNtk, char *pName)
#define Abc_NtkForEachCo(pNtk, pCo, i)
#define Abc_NtkForEachNet(pNtk, pNet, i)
ABC_DLL Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
#define Abc_NtkForEachPo(pNtk, pPo, i)
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
ABC_DLL void Abc_NtkSetMvVarValues(Abc_Obj_t *pObj, int nValues)
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
#define Abc_ObjForEachFanin(pObj, pFanin, i)
#define Abc_ObjForEachFanout(pObj, pFanout, i)
#define Abc_NtkForEachBlackbox(pNtk, pObj, i)
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
struct Abc_Ntk_t_ Abc_Ntk_t
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
struct Abc_Des_t_ Abc_Des_t
BASIC TYPES ///.
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
#define Abc_NtkForEachLatchOutput(pNtk, pObj, i)
ABC_DLL char * Abc_ObjNameSuffix(Abc_Obj_t *pObj, char *pSuffix)
#define Abc_NtkForEachLatchInput(pNtk, pObj, i)
ABC_DLL char * Abc_ObjNamePrefix(Abc_Obj_t *pObj, char *pPrefix)
#define Abc_NtkForEachPi(pNtk, pPi, i)
ABC_DLL void Abc_NtkStartMvVars(Abc_Ntk_t *pNtk)
DECLARATIONS ///.
#define Abc_NtkForEachCi(pNtk, pCi, i)
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
#define Abc_NtkForEachBox(pNtk, pObj, i)
ABC_DLL void Abc_NtkOrderCisCos(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Obj_t * Abc_NtkFindNet(Abc_Ntk_t *pNtk, char *pName)
ABC_DLL Abc_Obj_t * Abc_NtkDupBox(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pBox, int fCopyName)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
struct Vec_Str_t_ Vec_Str_t
char * Nm_ManFindNameById(Nm_Man_t *p, int ObjId)
void Nm_ManDeleteIdName(Nm_Man_t *p, int ObjId)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.