30static Abc_Ntk_t * Abc_NtkRetimeMinAreaOne(
Abc_Ntk_t * pNtk,
int fForward,
int fUseOldNames,
int fVerbose );
31static void Abc_NtkRetimeMinAreaPrepare(
Abc_Ntk_t * pNtk,
int fForward );
34static void Abc_NtkRetimeMinAreaUpdateLatches(
Abc_Ntk_t * pNtk,
Vec_Ptr_t * vMinCut,
int fForward,
int fUseOldNames );
55 Abc_Ntk_t * pNtkTotal = NULL, * pNtkBottom;
57 int nLatches = Abc_NtkLatchNum(pNtk);
59 assert( !fForwardOnly || !fBackwardOnly );
61 assert( Abc_NtkIsSopLogic(pNtk) );
62 assert( Abc_NtkLatchNum(pNtk) == Vec_PtrSize(pNtk->
vBoxes) );
69 Abc_NtkRetimeMinAreaOne( pNtk, 1, fUseOldNames, fVerbose );
71 while ( Abc_NtkRetimeMinAreaOne( pNtk, 1, fUseOldNames, fVerbose ) );
79 pNtkTotal = Abc_NtkRetimeMinAreaOne( pNtk, 0, fUseOldNames, fVerbose );
81 while ( (pNtkBottom = Abc_NtkRetimeMinAreaOne( pNtk, 0, fUseOldNames, fVerbose )) )
89 if ( vValuesNew ) Vec_IntFree( vValuesNew );
90 if ( vValues ) Vec_IntFree( vValues );
95 fprintf( stdout,
"Abc_NtkRetimeMinArea(): Network check has failed.\n" );
97 return nLatches - Abc_NtkLatchNum(pNtk);
111Abc_Ntk_t * Abc_NtkRetimeMinAreaOne(
Abc_Ntk_t * pNtk,
int fForward,
int fUseOldNames,
int fVerbose )
116 Abc_NtkRetimeMinAreaPrepare( pNtk, fForward );
121 if ( Vec_PtrSize(vMinCut) < Abc_NtkLatchNum(pNtk) )
125 Abc_NtkRetimeMinAreaInitValues( pNtk, vMinCut );
127 pNtkNew = Abc_NtkRetimeMinAreaConstructNtk( pNtk, vMinCut );
128 Abc_NtkRetimeMinAreaUpdateLatches( pNtk, vMinCut, fForward, fUseOldNames );
131 Vec_PtrFree( vMinCut );
181 if ( !pObj->
fMarkA || Abc_ObjIsLatch(pObj) )
207void Abc_NtkRetimeMinAreaPrepare(
Abc_Ntk_t * pNtk,
int fForward )
220 Abc_ObjFanin0(pObj)->fMarkA = 1;
226 vNodes = Vec_PtrAlloc( 100 );
231 Vec_PtrPush( vNodes, pFanin );
235 Vec_PtrFree( vNodes );
245 Abc_ObjFanout0(pObj)->fMarkA = 1;
269 if ( Abc_NodeIsTravIdCurrent(pObj) )
270 return (
int)(ABC_PTRUINT_T)pObj->
pCopy;
271 Abc_NodeSetTravIdCurrent(pObj);
273 if ( Abc_ObjIsBo(pObj) )
275 assert( Abc_ObjIsLatch(Abc_ObjFanin0(pObj)) );
277 return (
int)(ABC_PTRUINT_T)pObj->
pCopy;
279 assert( Abc_ObjIsNode(pObj) );
285 return (
int)(ABC_PTRUINT_T)pObj->
pCopy;
304 Abc_NtkIncrementTravId(pNtk);
308 Abc_NodeSetTravIdCurrent( pObj );
315 Abc_NodeSetTravIdPrevious( pObj );
334 if ( Abc_NodeIsTravIdCurrent(pObj) )
336 Abc_NodeSetTravIdCurrent(pObj);
338 if ( Abc_ObjIsBi(pObj) )
343 assert( Abc_ObjIsNode(pObj) );
373 Abc_NtkIncrementTravId(pNtk);
376 pObj->
pCopy = Abc_NtkCreatePi(pNtkNew);
377 Abc_NodeSetTravIdCurrent( pObj );
387 Abc_NodeSetTravIdPrevious( pObj );
390 Abc_NodeSetTravIdPrevious( pObj );
395 fprintf( stdout,
"Abc_NtkRetimeMinAreaConstructNtk(): Network check has failed.\n" );
411void Abc_NtkRetimeMinAreaUpdateLatches(
Abc_Ntk_t * pNtk,
Vec_Ptr_t * vMinCut,
int fForward,
int fUseOldNames )
413 Vec_Ptr_t * vCis, * vCos, * vBoxes, * vBoxesNew, * vNodes, * vBuffers;
414 Abc_Obj_t * pObj, * pLatch, * pLatchIn, * pLatchOut, * pNext, * pBuffer;
417 Vec_PtrShrink( pNtk->
vCis, Abc_NtkCiNum(pNtk) - Abc_NtkLatchNum(pNtk) );
418 Vec_PtrShrink( pNtk->
vCos, Abc_NtkCoNum(pNtk) - Abc_NtkLatchNum(pNtk) );
419 vCis = pNtk->
vCis; pNtk->
vCis = NULL;
420 vCos = pNtk->
vCos; pNtk->
vCos = NULL;
423 vBoxesNew = Vec_PtrAlloc(100);
425 if ( !Abc_ObjIsLatch(pObj) )
426 Vec_PtrPush( vBoxesNew, pObj );
428 vNodes = Vec_PtrAlloc( 100 );
429 vBuffers = Vec_PtrAlloc( 100 );
432 if ( Abc_ObjIsCi(pObj) && fForward )
435 pLatch = Abc_ObjFanin0(pLatchOut);
436 pLatchIn = Abc_ObjFanin0(pLatch);
437 assert( Abc_ObjIsBo(pLatchOut) && Abc_ObjIsLatch(pLatch) && Abc_ObjIsBi(pLatchIn) );
439 Abc_NodeSetTravIdCurrent( pLatch );
446 if ( k < Abc_ObjFanoutNum(pObj) )
452 Vec_PtrPush( vBuffers, pBuffer );
459 assert( Abc_ObjFanoutNum(pObj) > 0 );
463 else if ( Abc_ObjIsCo(pObj) && !fForward )
466 pLatch = Abc_ObjFanout0(pLatchIn);
467 pLatchOut = Abc_ObjFanout0(pLatch);
468 assert( Abc_ObjIsBo(pLatchOut) && Abc_ObjIsLatch(pLatch) && Abc_ObjIsBi(pLatchIn) );
470 Abc_NodeSetTravIdCurrent( pLatch );
471 assert( !Abc_ObjFanin0(pLatchIn)->fMarkA );
475 pLatchOut = Abc_NtkCreateBo(pNtk);
476 pLatch = Abc_NtkCreateLatch(pNtk);
477 pLatchIn = Abc_NtkCreateBi(pNtk);
512 Vec_PtrPush( vCis, pLatchOut );
513 Vec_PtrPush( vBoxesNew, pLatch );
514 Vec_PtrPush( vCos, pLatchIn );
516 Vec_PtrFree( vNodes );
523 Vec_PtrFree( vBuffers );
527 if ( !Abc_ObjIsLatch(pObj) )
529 if ( Abc_NodeIsTravIdCurrent(pObj) )
531 pLatchOut = Abc_ObjFanout0(pObj);
533 pLatchIn = Abc_ObjFanin0(pObj);
534 if ( Abc_ObjFanoutNum(pLatchOut) > 0 )
544 Vec_PtrFree( vBoxes );
struct Abc_Obj_t_ Abc_Obj_t
ABC_DLL void Abc_NtkCleanMarkA(Abc_Ntk_t *pNtk)
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)
ABC_DLL void Abc_NtkDeleteObj(Abc_Obj_t *pObj)
#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 Abc_Obj_t * Abc_NtkCreateNodeBuf(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
#define Abc_NtkForEachLatch(pNtk, pObj, i)
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)
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
ABC_DLL void Abc_NodeCollectFanouts(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
struct Abc_Ntk_t_ Abc_Ntk_t
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
ABC_DLL void Abc_ObjTransferFanout(Abc_Obj_t *pObjOld, Abc_Obj_t *pObjNew)
ABC_DLL void Abc_NtkAddDummyPoNames(Abc_Ntk_t *pNtk)
ABC_DLL void Abc_NtkInsertLatchValues(Abc_Ntk_t *pNtk, Vec_Int_t *vValues)
#define Abc_NtkForEachPi(pNtk, pPi, i)
ABC_DLL Vec_Int_t * Abc_NtkCollectLatchValues(Abc_Ntk_t *pNtk)
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
ABC_DLL void Abc_ObjPatchFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFaninOld, Abc_Obj_t *pFaninNew)
ABC_DLL void Abc_NtkOrderCisCos(Abc_Ntk_t *pNtk)
ABC_DLL void Abc_NtkAddDummyPiNames(Abc_Ntk_t *pNtk)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Abc_Obj_t * Abc_NtkRetimeMinAreaConstructNtk_rec(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj)
int Abc_NtkRetimeMinArea(Abc_Ntk_t *pNtk, int fForwardOnly, int fBackwardOnly, int fUseOldNames, int fVerbose)
FUNCTION DEFINITIONS ///.
int Abc_NtkRetimeMinAreaInitValues_rec(Abc_Obj_t *pObj)
void Abc_NtkUnmarkCone_rec(Abc_Obj_t *pObj, int fForward)
void Abc_NtkMarkCone_rec(Abc_Obj_t *pObj, int fForward)
Abc_Ntk_t * Abc_NtkAttachBottom(Abc_Ntk_t *pNtkTop, Abc_Ntk_t *pNtkBottom)
Vec_Ptr_t * Abc_NtkMaxFlow(Abc_Ntk_t *pNtk, int fForward, int fVerbose)
Vec_Int_t * Abc_NtkRetimeInitialValues(Abc_Ntk_t *pNtkCone, Vec_Int_t *vValues, int fVerbose)
FUNCTION DEFINITIONS ///.
int Abc_ObjSopSimulate(Abc_Obj_t *pObj)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.