51 assert( Abc_ObjIsLatch(pLatch) );
52 if ( pLatch == pLatchRoot )
54 pFanin = Abc_ObjFanin0(Abc_ObjFanin0(pLatch));
55 if ( !Abc_ObjIsBo(pFanin) || !Abc_ObjIsLatch(Abc_ObjFanin0(pFanin)) )
74 assert( Abc_ObjIsLatch(pLatch) );
75 pFanin = Abc_ObjFanin0(Abc_ObjFanin0(pLatch));
76 if ( !Abc_ObjIsBo(pFanin) || !Abc_ObjIsLatch(Abc_ObjFanin0(pFanin)) )
126 if ( Abc_NtkIsStrash(pNtk) )
130 Abc_ObjPatchFanin( Abc_ObjFanin0(pLatch), Abc_ObjFanin0(Abc_ObjFanin0(pLatch)), pConst1 );
152 int i, k,
nTotal, nDigits;
155 nTotal = nLatches * Abc_NtkPiNum(pNtk);
156 nDigits = Abc_Base10Log(
nTotal );
157 vNodes = Vec_PtrAlloc( 100 );
161 for ( pFanin = pObj, k = 0; k < nLatches; k++ )
166 Vec_PtrFree( vNodes );
186 vValues = Vec_IntAlloc( Abc_NtkLatchNum(pNtk) );
188 Vec_IntPush( vValues, Abc_LatchIsInit1(pLatch) );
208 pInits =
ABC_ALLOC(
char, Abc_NtkLatchNum(pNtk) + 1 );
211 if ( Abc_LatchIsInit0(pLatch) )
213 else if ( Abc_LatchIsInit1(pLatch) )
215 else if ( Abc_LatchIsInitDc(pLatch) )
256 Abc_Obj_t * pLatchOut, * pLatch, * pLatchIn;
257 pLatchOut = Abc_NtkCreateBo(pNtk);
258 pLatch = Abc_NtkCreateLatch(pNtk);
259 pLatchIn = Abc_NtkCreateBi(pNtk);
266 pLatch->
pData = (
void *)Init;
283 assert( Abc_NtkIsLogic(pNtk) );
287 if ( Abc_NtkHasSop(pNtk) )
290 else if ( Abc_NtkHasBdd(pNtk) )
291 pMux->
pData = Cudd_bddIte((DdManager *)pNtk->
pManFunc,Cudd_bddIthVar((DdManager *)pNtk->
pManFunc,0),Cudd_bddIthVar((DdManager *)pNtk->
pManFunc,1),Cudd_bddIthVar((DdManager *)pNtk->
pManFunc,2)), Cudd_Ref( (DdNode *)pMux->
pData );
293 else if ( Abc_NtkHasAig(pNtk) )
312 Abc_Obj_t * pCtrl, * pLatch, * pMux, * pPi;
314 int i, fFound = 0, Counter;
317 if ( Abc_LatchIsInitDc(pLatch) )
330 if ( !Abc_LatchIsInitDc(pLatch) )
333 pLatch->
pData = (
void *)Init;
341 pPi = Abc_NtkCreatePi( pNtk );
344 pMux = Abc_NtkCreateNode( pNtk );
350 printf(
"The number of converted latches with DC values = %d.\n", Counter );
377 vResult = Vec_PtrAlloc( Vec_PtrSize(pNtk->
vOnehots) );
380 vNumbers = Vec_IntAlloc( Vec_PtrSize(vNames) );
386 pObj = Abc_NtkObj( pNtk, Num );
387 if ( Abc_ObjFaninNum(pObj) != 1 || !Abc_ObjIsLatch(Abc_ObjFanin0(pObj)) )
389 Vec_IntPush( vNumbers, (
int)(ABC_PTRINT_T)pObj->
pNext );
391 if ( Vec_IntSize( vNumbers ) > 1 )
393 Vec_PtrPush( vResult, vNumbers );
394printf(
"Converted %d one-hot registers.\n", Vec_IntSize(vNumbers) );
397 Vec_IntFree( vNumbers );
421 Abc_Obj_t * pObj, * pFanin, * pObjNew, * pObjLiNew, * pObjLoNew;
422 int i, k, nFlops, nStates, iState, pfCompl[32];
423 assert( Abc_NtkIsLogic(pNtk) );
424 nFlops = Abc_NtkLatchNum(pNtk);
429 printf(
"Cannot re-encode %d flops because it will lead to 2^%d states.\n", nFlops, nFlops );
436 if ( Abc_LatchIsInitDc(pObj) )
438 printf(
"Cannot process logic network with don't-care init values. Run \"zero\".\n" );
441 if ( Abc_LatchIsInit1(pObj) )
448 nStates = (1 << nFlops);
449 for ( i = 0; i < nStates; i++ )
451 pObjNew = Abc_NtkCreateLatch( pNtkNew );
452 pObjLiNew = Abc_NtkCreateBi( pNtkNew );
453 pObjLoNew = Abc_NtkCreateBo( pNtkNew );
457 Abc_LatchSetInit1( pObjNew );
459 Abc_LatchSetInit0( pObjNew );
462 assert( Abc_NtkLatchNum(pNtkNew) == nStates );
463 assert( Abc_NtkPiNum(pNtkNew) == Abc_NtkPiNum(pNtk) );
464 assert( Abc_NtkPoNum(pNtkNew) == Abc_NtkPoNum(pNtk) );
465 assert( Abc_NtkCiNum(pNtkNew) == Abc_NtkPiNum(pNtkNew) + nStates );
466 assert( Abc_NtkCoNum(pNtkNew) == Abc_NtkPoNum(pNtkNew) + nStates );
467 assert( Abc_NtkCiNum(pNtk) == Abc_NtkPiNum(pNtk) + nFlops );
468 assert( Abc_NtkCoNum(pNtk) == Abc_NtkPoNum(pNtk) + nFlops );
470 for ( i = 0; i < nFlops; i++ )
472 pObjNew = Abc_NtkCreateNode( pNtkNew );
473 for ( k = 0; k < nStates; k++ )
475 Abc_ObjAddFanin( pObjNew, Abc_NtkCi(pNtkNew, Abc_NtkPiNum(pNtkNew)+k) );
476 assert( Abc_ObjFaninNum(pObjNew) == nStates/2 );
479 pObj = Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i );
480 pObj->
pCopy = pObjNew;
490 Vec_PtrFree( vNodes );
493 Abc_ObjAddFanin( pObj->
pCopy, Abc_ObjNotCond(Abc_ObjFanin0(pObj)->pCopy, Abc_ObjFaninC0(pObj)) );
496 pObj->
pCopy = Abc_ObjNotCond(Abc_ObjFanin0(pObj)->pCopy, Abc_ObjFaninC0(pObj));
498 for ( k = 0; k < nStates; k++ )
500 pObjNew = Abc_NtkCreateNode( pNtkNew );
501 for ( i = 0; i < nFlops; i++ )
503 pObj = Abc_NtkCo( pNtk, Abc_NtkPoNum(pNtk) + i );
505 pfCompl[i] = Abc_ObjIsComplement(pObj->
pCopy) ^ !((k >> i) & 1);
509 Abc_ObjAddFanin( Abc_NtkCo(pNtkNew, Abc_NtkPoNum(pNtkNew)+k), pObjNew );
512 fprintf( stdout,
"Abc_NtkConvertOnehot(): Network check has failed.\n" );
539 assert( Gia_ManRegNum(pGia) == Vec_IntSize(vClasses) );
565 Abc_Ntk_t * pNtkAig, * pNtkAigRet, * pNtkRes;
592 Abc_Obj_t * pObj, * pNodeNew, * pCtrl, * pDriver;
594 assert( Abc_NtkPoNum(pNtkOld) == Abc_NtkPoNum(pNtkNew) );
597 pObj->
pCopy = Abc_NtkPo( pNtkNew, i );
601 assert( Abc_ObjIsPo(pObj) && pObj->
pNtk == pNtkOld );
602 Vec_PtrWriteEntry( vControls, i, pObj->
pCopy );
605 assert( Abc_NtkLatchNum(pNtkNew) == Vec_IntSize(vClasses) );
608 Class = Vec_IntEntry( vClasses, i );
611 pDriver = Abc_ObjFanin0(Abc_ObjFanin0(pObj));
612 pCtrl = (
Abc_Obj_t *)Vec_PtrEntry( vControls, Class );
613 pCtrl = Abc_ObjFanin0( pCtrl );
614 pNodeNew = Abc_NtkCreateNode( pNtkNew );
641 Vec_Int_t * vFlopClasses, * vFlopClassesNew;
642 Abc_Obj_t * pObj, * pDriver, * pFlopOut, * pObjPo;
643 int i, iFlop, CountN = 0, Count2 = 0, Count1 = 0, Count0 = 0;
649 vControls = Vec_PtrAlloc( 100 );
650 vFlopClasses = Vec_IntAlloc( 100 );
653 pFlopOut = Abc_ObjFanout0(pObj);
654 pDriver = Abc_ObjFanin0( Abc_ObjFanin0(pObj) );
655 if ( Abc_ObjFaninNum(pDriver) != 3 )
657 Vec_IntPush( vFlopClasses, -1 );
661 if ( Abc_ObjFanin(pDriver, 1) != pFlopOut && Abc_ObjFanin(pDriver, 2) != pFlopOut )
663 Vec_IntPush( vFlopClasses, -1 );
667 if ( Abc_ObjFanin(pDriver, 1) == pFlopOut )
669 Vec_IntPush( vFlopClasses, -1 );
673 assert( Abc_ObjFanin(pDriver, 2) == pFlopOut );
675 Vec_PtrPushUnique( vControls, Abc_ObjFanin0(pDriver) );
677 iFlop = Vec_PtrFind( vControls, Abc_ObjFanin0(pDriver) );
678 Vec_IntPush( vFlopClasses, iFlop );
683 printf(
"Opposite phase enable is present in %d flops (out of %d).\n", Count1, Abc_NtkLatchNum(pNtk) );
685 printf(
"CountN = %4d. Count2 = %4d. Count1 = %4d. Count0 = %4d. Ctrls = %d.\n",
686 CountN, Count2, Count1, Count0, Vec_PtrSize(vControls) );
691 pObjPo = Abc_NtkCreatePo( pNtk );
694 Vec_PtrWriteEntry( vControls, i, pObjPo );
705 Vec_PtrFree( vControls );
707 Vec_IntFree( vFlopClassesNew );
725 int RetValue, i, k, iBit = 0;
726 assert( Abc_NtkIsStrash(pNtk) );
727 assert(
p->nPis == Abc_NtkPiNum(pNtk) );
733 Abc_ObjFanout0(pObj)->fMarkC = Abc_InfoHasBit(
p->pData, iBit++);
736 for ( i = 0; i <=
p->iFrame; i++ )
739 pObj->
fMarkC = Abc_InfoHasBit(
p->pData, iBit++);
741 pObj->
fMarkC = (Abc_ObjFanin0(pObj)->fMarkC ^ Abc_ObjFaninC0(pObj)) &
742 (Abc_ObjFanin1(pObj)->fMarkC ^ Abc_ObjFaninC1(pObj));
744 pObj->
fMarkC = Abc_ObjFanin0(pObj)->fMarkC ^ Abc_ObjFaninC0(pObj);
746 Abc_ObjFanout0(pObj)->fMarkC = Abc_ObjFanin0(pObj)->fMarkC;
Abc_Ntk_t * Abc_NtkFromDarSeqSweep(Abc_Ntk_t *pNtkOld, Aig_Man_t *pMan)
Abc_Obj_t * Abc_NtkAddLatch(Abc_Ntk_t *pNtk, Abc_Obj_t *pDriver, Abc_InitType_t Init)
Vec_Int_t * Abc_NtkCollectLatchValues(Abc_Ntk_t *pNtk)
int Abc_NtkVerifyCex(Abc_Ntk_t *pNtk, Abc_Cex_t *p)
int Abc_NtkLatchIsSelfFeed(Abc_Obj_t *pLatch)
void Abc_NtkLatchPipe(Abc_Ntk_t *pNtk, int nLatches)
Abc_Ntk_t * Abc_NtkConvertOnehot(Abc_Ntk_t *pNtk)
ABC_NAMESPACE_IMPL_START int Abc_NtkLatchIsSelfFeed_rec(Abc_Obj_t *pLatch, Abc_Obj_t *pLatchRoot)
DECLARATIONS ///.
Vec_Ptr_t * Abc_NtkConverLatchNamesIntoNumbers(Abc_Ntk_t *pNtk)
int Abc_NtkRemoveSelfFeedLatches(Abc_Ntk_t *pNtk)
ABC_NAMESPACE_IMPL_END ABC_NAMESPACE_IMPL_START Aig_Man_t * Abc_NtkRetimeWithClassesAig(Aig_Man_t *pMan, Vec_Int_t *vClasses, Vec_Int_t **pvClasses, int fVerbose)
Abc_Ntk_t * Abc_NtkRetimeWithClassesNtk(Abc_Ntk_t *pNtk, Vec_Int_t *vClasses, Vec_Int_t **pvClasses, int fVerbose)
char * Abc_NtkCollectLatchValuesStr(Abc_Ntk_t *pNtk)
void Abc_NtkConvertDcLatches(Abc_Ntk_t *pNtk)
void Abc_NtkTransformBack(Abc_Ntk_t *pNtkOld, Abc_Ntk_t *pNtkNew, Vec_Ptr_t *vControls, Vec_Int_t *vClasses)
void Abc_NtkNodeConvertToMux(Abc_Ntk_t *pNtk, Abc_Obj_t *pNodeC, Abc_Obj_t *pNode1, Abc_Obj_t *pNode0, Abc_Obj_t *pMux)
void Abc_NtkInsertLatchValues(Abc_Ntk_t *pNtk, Vec_Int_t *vValues)
int Abc_NtkCountSelfFeedLatches(Abc_Ntk_t *pNtk)
Abc_Ntk_t * Abc_NtkCRetime(Abc_Ntk_t *pNtk, int fVerbose)
struct Abc_Obj_t_ Abc_Obj_t
#define Abc_NtkForEachCo(pNtk, pCo, i)
ABC_DLL void Abc_NtkCleanMarkC(Abc_Ntk_t *pNtk)
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
ABC_DLL void Abc_NtkDeleteObj(Abc_Obj_t *pObj)
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Ntk_t * Abc_NtkToLogic(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
#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_NtkAddDummyBoxNames(Abc_Ntk_t *pNtk)
ABC_DLL int Abc_NtkCleanup(Abc_Ntk_t *pNtk, int fVerbose)
#define Abc_NtkForEachLatch(pNtk, pObj, i)
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
#define Abc_ObjForEachFanin(pObj, pFanin, i)
ABC_DLL Abc_Ntk_t * Abc_NtkStartFromNoLatches(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
ABC_DLL char * Abc_SopCreateOr(Mem_Flex_t *pMan, int nVars, int *pfCompl)
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 char * Abc_SopCreateAnd(Mem_Flex_t *pMan, int nVars, int *pfCompl)
ABC_DLL int Abc_NtkLogicMakeSimpleCos(Abc_Ntk_t *pNtk, int fDuplicate)
ABC_DLL int Abc_NtkToSop(Abc_Ntk_t *pNtk, int fMode, int nCubeLimit)
#define Abc_NtkForEachPi(pNtk, pPi, i)
ABC_DLL Abc_Ntk_t * Abc_NtkStrash(Abc_Ntk_t *pNtk, int fAllNodes, int fCleanup, int fRecord)
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Obj_t * Abc_NodeFindCoFanout(Abc_Obj_t *pNode)
ABC_DLL void Abc_ObjPatchFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFaninOld, Abc_Obj_t *pFaninNew)
ABC_DLL char * Abc_SopRegister(Mem_Flex_t *pMan, const char *pName)
DECLARATIONS ///.
ABC_DLL void Abc_NtkOrderCisCos(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
#define Abc_NtkForEachNode(pNtk, pNode, i)
#define ABC_ALLOC(type, num)
#define ABC_INFINITY
MACRO DEFINITIONS ///.
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
void Aig_ManStop(Aig_Man_t *p)
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
int nTotal
DECLARATIONS ///.
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Aig_Man_t * Gia_ManToAig(Gia_Man_t *p, int fChoices)
Gia_Man_t * Gia_ManFromAigSimple(Aig_Man_t *p)
Aig_Man_t * Abc_NtkToDar(Abc_Ntk_t *pNtk, int fExors, int fRegisters)
void Gia_ManStop(Gia_Man_t *p)
struct Gia_Man_t_ Gia_Man_t
Gia_Man_t * Gia_ManRetimeForward(Gia_Man_t *p, int nMaxIters, int fVerbose)
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Hop_Obj_t * Hop_IthVar(Hop_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Hop_Obj_t * Hop_Mux(Hop_Man_t *p, Hop_Obj_t *pC, Hop_Obj_t *p1, Hop_Obj_t *p0)
struct Mem_Flex_t_ Mem_Flex_t
void Nm_ManDeleteIdName(Nm_Man_t *p, int ObjId)
int Nm_ManFindIdByName(Nm_Man_t *p, char *pName, int Type)
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.