47 assert( !Hop_IsComplement(pObj) );
48 if ( !Hop_ObjIsNode(pObj) || Hop_ObjIsMarkA(pObj) )
53 assert( !Hop_ObjIsMarkA(pObj) );
54 Hop_ObjSetMarkA( pObj );
61 assert( Abc_ObjIsNode(pNode) );
62 assert( Abc_NtkHasAig(pNode->
pNtk) && !Abc_NtkIsStrash(pNode->
pNtk) );
64 if (
Abc_NodeIsConst(pNode) || Hop_Regular(pRoot) == Hop_ManConst1(pMan) )
65 return Abc_LitNotCond( 1, Hop_IsComplement(pRoot) );
74 return Abc_LitNotCond( Hop_Regular(pRoot)->iData, Hop_IsComplement(pRoot) );
93 int i, k; (*pCounter)++;
97 if ( Abc_ObjIsNode(pObj) )
101 int iBufStart = Gia_ManBufNum(pNew);
103 assert( !Abc_ObjIsLatch(pObj) );
104 assert( Abc_NtkPiNum(pModel) == Abc_ObjFaninNum(pObj) );
105 assert( Abc_NtkPoNum(pModel) == Abc_ObjFanoutNum(pObj) );
109 assert( Abc_ObjIsNet(Abc_ObjFanin0(pTerm)) );
110 Abc_ObjFanout0(Abc_NtkPi(pModel, k))->iTemp = Abc_ObjFanin0(pTerm)->iTemp;
114 Abc_ObjFanout0(Abc_NtkPi(pModel, k))->iTemp = Gia_ManAppendBuf( pNew, Abc_ObjFanout0(Abc_NtkPi(pModel, k))->iTemp );
118 Abc_ObjFanin0(Abc_NtkPo(pModel, k))->iTemp = Gia_ManAppendBuf( pNew, Abc_ObjFanin0(Abc_NtkPo(pModel, k))->iTemp );
121 assert( Abc_ObjIsNet(Abc_ObjFanout0(pTerm)) );
122 Abc_ObjFanout0(pTerm)->iTemp = Abc_ObjFanin0(Abc_NtkPo(pModel, k))->iTemp;
127 Vec_IntPush( vBufs, iBufStart );
128 Vec_IntPush( vBufs, Abc_NtkPiNum(pModel) );
129 Vec_IntPush( vBufs, Gia_ManBufNum(pNew) - Abc_NtkPoNum(pModel) );
130 Vec_IntPush( vBufs, Abc_NtkPoNum(pModel) );
142 assert( Abc_NtkIsNetlist(pNtk) );
151 pNew->
vBarBufs = Vec_IntAlloc( 1000 );
155 pTerm->
iTemp = Gia_ManAppendCi( pNew );
157 Abc_ObjFanout0(pTerm)->iTemp = fUseInter ? Gia_ManAppendBuf(pNew, pTerm->
iTemp) : pTerm->
iTemp;
170 printf(
"Hierarchy reader flattened %d instances of logic boxes.\n", Counter );
181 pTerm->
iTemp = fUseInter ? Gia_ManAppendBuf(pNew, Abc_ObjFanin0(pTerm)->iTemp) : Abc_ObjFanin0(pTerm)->iTemp;
183 Gia_ManAppendCo( pNew, pTerm->
iTemp );
189 Vec_IntPush( pNew->
vBarBufs, Abc_NtkPiNum(pNtk) );
190 Vec_IntPush( pNew->
vBarBufs, Gia_ManBufNum(pNew) - Abc_NtkPoNum(pNtk) );
191 Vec_IntPush( pNew->
vBarBufs, Abc_NtkPoNum(pNtk) );
217 int i, iFanin, CountCrit[2] = {0}, CountFans[2] = {0};
219 vMap = Vec_IntStart( Gia_ManObjNum(
p) );
220 vFan = Vec_IntStart( Gia_ManObjNum(
p) );
221 vCrits = Vec_IntAlloc( 100 );
225 if ( Gia_ObjIsBuf(pObj) || Gia_ObjIsCo(pObj) )
226 Vec_IntAddToEntry( vFan, Gia_ObjFaninId0(pObj, i), 1 );
227 else if ( Gia_ObjIsAnd(pObj) )
229 Vec_IntAddToEntry( vFan, Gia_ObjFaninId0(pObj, i), 1 );
230 Vec_IntAddToEntry( vFan, Gia_ObjFaninId1(pObj, i), 1 );
233 if ( Gia_ObjIsBuf(pObj) )
235 iFanin = Gia_ObjFaninId0( pObj, i );
236 if ( iFanin == 0 || Vec_IntEntry(vMap, iFanin) != 0 )
238 CountCrit[(int)(iFanin != 0)]++;
239 Vec_IntPush( vCrits, i );
242 Vec_IntWriteEntry( vMap, iFanin, Abc_Var2Lit(i, Gia_ObjFaninC0(pObj)) );
248 assert( Gia_ObjIsBuf(pObj) );
249 if ( Vec_IntEntry(vFan, i) == 0 )
251 iFanin = Gia_ObjFaninId0p(
p, pObj );
252 CountFans[(int)(iFanin != 0)]++;
254 printf(
"Detected %d const (out of %d) and %d shared (out of %d) barbufs with fanout.\n",
255 CountFans[0], CountCrit[0], CountFans[1], CountCrit[1] );
258 Vec_IntFree( vCrits );
272static inline void Gia_ManPatchBufDriver(
Gia_Man_t *
p,
int iBuf,
int iLit0 )
275 assert( Gia_ObjIsBuf(pObjBuf) );
276 assert( Gia_ObjId(
p, pObjBuf) > Abc_Lit2Var(iLit0) );
277 pObjBuf->
iDiff1 = pObjBuf->
iDiff0 = Gia_ObjId(
p, pObjBuf) - Abc_Lit2Var(iLit0);
294 Vec_Int_t * vMap = Vec_IntStart( Gia_ManObjNum(
p) );
297 int i, iFanin, CountReals[2] = {0};
301 pNew->
pName = Abc_UtilStrsav(
p->pName );
302 pNew->
pSpec = Abc_UtilStrsav(
p->pSpec );
303 Gia_ManConst0(
p)->Value = 0;
307 if ( Gia_ObjIsBuf(pObj) )
309 pObj->
Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
310 pObjNew = Gia_ManObj( pNew, Abc_Lit2Var(pObj->
Value) );
311 iFanin = Gia_ObjFaninId0p( pNew, pObjNew );
314 pObj->
Value = Gia_ObjFaninC0(pObjNew);
316 Gia_ManPatchBufDriver( pNew, Gia_ObjId(pNew, pObjNew), 0 );
318 else if ( Vec_IntEntry(vMap, iFanin) )
320 pObjNewR = Gia_ManObj( pNew, Vec_IntEntry(vMap, iFanin) );
321 pObj->
Value = Abc_Var2Lit( Vec_IntEntry(vMap, iFanin), Gia_ObjFaninC0(pObjNewR) ^ Gia_ObjFaninC0(pObjNew) );
323 Gia_ManPatchBufDriver( pNew, Gia_ObjId(pNew, pObjNew), 0 );
326 Vec_IntWriteEntry( vMap, iFanin, Gia_ObjId(pNew, pObjNew) );
328 else if ( Gia_ObjIsAnd(pObj) )
330 else if ( Gia_ObjIsCi(pObj) )
331 pObj->
Value = Gia_ManAppendCi( pNew );
332 else if ( Gia_ObjIsCo(pObj) )
333 pObj->
Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
366 assert( !Abc_ObjIsLatch(pBox) );
372 return Abc_NtkPiNum(pNtk) + Abc_NtkPoNum(pNtk);
379 if ( pObj->
iTemp != -1 )
381 if ( Abc_ObjIsNet(pObj) || Abc_ObjIsPo(pObj) || Abc_ObjIsBi(pObj) )
383 if ( Abc_ObjIsPi(pObj) )
385 pBox = (
Abc_Obj_t *)Vec_PtrPop( vSupers );
386 pModel = Abc_ObjModel(pBox);
388 assert( Abc_ObjFaninNum(pBox) == Abc_NtkPiNum(pModel) );
390 pFanin = Abc_ObjFanin( pBox, pObj->
iData );
392 Vec_PtrPush( vSupers, pBox );
394 if ( vBuffers ) Vec_PtrPush( vBuffers, pObj );
395 return (pObj->
iTemp = (vBuffers ? Gia_ManAppendBuf(pNew, iLit) : iLit));
397 if ( Abc_ObjIsBo(pObj) )
399 pBox = Abc_ObjFanin0(pObj);
400 assert( Abc_ObjIsBox(pBox) );
401 Vec_PtrPush( vSupers, pBox );
402 pModel = Abc_ObjModel(pBox);
404 assert( Abc_ObjFanoutNum(pBox) == Abc_NtkPoNum(pModel) );
406 pFanin = Abc_NtkPo( pModel, pObj->
iData );
408 Vec_PtrPop( vSupers );
410 if ( vBuffers ) Vec_PtrPush( vBuffers, pFanin );
411 return (pObj->
iTemp = (vBuffers ? Gia_ManAppendBuf(pNew, iLit) : iLit));
413 assert( Abc_ObjIsNode(pObj) );
425 Vec_Ptr_t * vBuffers = fUseBufs ? Vec_PtrAlloc(1000) : NULL;
427 assert( Abc_NtkIsNetlist(pNtk) );
431 Counter -= Abc_NtkPiNum(pNtk) + Abc_NtkPoNum(pNtk);
445 pTerm->
iTemp = Gia_ManAppendCi( pNew );
448 vSupers = Vec_PtrAlloc( 100 );
453 Vec_PtrFree( vSupers );
454 printf(
"Hierarchy reader flattened %d instances of boxes and added %d barbufs (out of %d).\n",
459 Gia_ManAppendCo( pNew, pTerm->
iTemp );
462 *pvBuffers = vBuffers;
464 Vec_PtrFreeP( &vBuffers );
493 assert( Abc_ObjNtk(pObj) == pNew );
506 assert( !Abc_NtkHasMapping(pNtk) );
507 assert( Abc_NtkHasMapping(pNew) );
515 pObj->
pCopy = Abc_NtkPo(Abc_ObjModel(pBox), k)->
pCopy;
524 if ( Abc_ObjFaninNum(pObj) == 0 )
528 if ( Abc_ObjFaninNum(pObj) == 0 )
533 assert( Abc_NtkHasMapping(pNtk) );
543 assert( Gia_ManPiNum(pGia) == Abc_NtkPiNum(pNtk) );
544 assert( Gia_ManPiNum(pGia) == Abc_NtkPiNum(pNew) );
545 assert( Gia_ManPoNum(pGia) == Abc_NtkPoNum(pNtk) );
546 assert( Gia_ManPoNum(pGia) == Abc_NtkPoNum(pNew) );
547 assert( Gia_ManBufNum(pGia) == Vec_PtrSize(vBuffers) );
560 Abc_NtkPi(pNtk, i)->pCopy = pObj;
562 Abc_NtkPo(pNtk, i)->
pCopy = pObj;
565 Vec_PtrFree( vBuffers );
572 if ( pModel != pNtk )
void Abc_NtkFlattenHierarchyGia2_rec(Gia_Man_t *pNew, Abc_Ntk_t *pNtk, int *pCounter, Vec_Int_t *vBufs)
void Abc_NtkInsertHierarchyGia(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNew, int fVerbose)
ABC_NAMESPACE_IMPL_START void Abc_NodeStrashToGia_rec(Gia_Man_t *pNew, Hop_Obj_t *pObj)
DECLARATIONS ///.
Gia_Man_t * Abc_NtkFlattenHierarchyGia(Abc_Ntk_t *pNtk, Vec_Ptr_t **pvBuffers, int fVerbose)
Gia_Man_t * Gia_ManSweepHierarchy(Gia_Man_t *p)
Abc_Obj_t * Gia_ManInsertOne_rec(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNew, Abc_Obj_t *pObj)
Gia_Man_t * Abc_NtkFlattenHierarchyGia2(Abc_Ntk_t *pNtk)
int Abc_NodeStrashToGia(Gia_Man_t *pNew, Abc_Obj_t *pNode)
int Abc_NtkFlattenHierarchyGia_rec(Gia_Man_t *pNew, Vec_Ptr_t *vSupers, Abc_Obj_t *pObj, Vec_Ptr_t *vBuffers)
void Gia_ManPrintBarBufDrivers(Gia_Man_t *p)
int Gia_ManFlattenLogicPrepare(Abc_Ntk_t *pNtk)
void Gia_ManInsertOne(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNew)
#define Abc_NtkForEachBarBuf(pNtk, pNode, i)
struct Abc_Obj_t_ Abc_Obj_t
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
ABC_DLL void Abc_NtkDeleteObj(Abc_Obj_t *pObj)
ABC_DLL Vec_Ptr_t * Abc_NtkDfsWithBoxes(Abc_Ntk_t *pNtk)
#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_NtkCreateNodeConst0(Abc_Ntk_t *pNtk)
#define Abc_ObjForEachFanin(pObj, pFanin, i)
#define Abc_ObjForEachFanout(pObj, pFanout, i)
struct Abc_Ntk_t_ Abc_Ntk_t
ABC_DLL int Abc_NodeIsConst(Abc_Obj_t *pNode)
#define Abc_NtkForEachPi(pNtk, pPi, i)
ABC_DLL void Abc_NtkFillTemp(Abc_Ntk_t *pNtk)
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
#define Abc_NtkForEachBox(pNtk, pObj, i)
#define Abc_NtkForEachNode(pNtk, pNode, i)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
void Gia_ManStop(Gia_Man_t *p)
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
void Gia_ManHashAlloc(Gia_Man_t *p)
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
struct Gia_Obj_t_ Gia_Obj_t
struct Gia_Man_t_ Gia_Man_t
#define Gia_ManForEachObj1(p, pObj, i)
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
void Gia_ManHashStop(Gia_Man_t *p)
void Hop_ConeUnmark_rec(Hop_Obj_t *pObj)
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 ///.
struct Hop_Obj_t_ Hop_Obj_t
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.