36static inline int Gia_FanoutCreate(
int FanId,
int Num ) {
assert( Num < 2 );
return (FanId << 1) | Num; }
37static inline int * Gia_FanoutObj(
int * pData,
int ObjId ) {
return pData + 5*ObjId; }
38static inline int * Gia_FanoutPrev(
int * pData,
int iFan ) {
return pData + 5*(iFan >> 1) + 1 + (iFan & 1); }
39static inline int * Gia_FanoutNext(
int * pData,
int iFan ) {
return pData + 5*(iFan >> 1) + 3 + (iFan & 1); }
42static inline int Gia_ObjFanout0Int(
Gia_Man_t *
p,
int ObjId ) {
assert(ObjId < p->nFansAlloc);
return p->pFanData[5*ObjId]; }
43static inline int Gia_ObjFanoutNext(
Gia_Man_t *
p,
int iFan ) {
assert(iFan/2 <
p->nFansAlloc);
return p->pFanData[5*(iFan >> 1) + 3 + (iFan & 1)]; }
46#define Gia_ObjForEachFanout( p, pObj, pFanout, iFan, i ) \
47 for ( assert(p->pFanData), i = 0; (i < (int)(pObj)->nRefs) && \
48 (((iFan) = i? Gia_ObjFanoutNext(p, iFan) : Gia_ObjFanout0Int(p, Gia_ObjId(p, pObj))), 1) && \
49 (((pFanout) = Gia_ManObj(p, iFan>>1)), 1); i++ )
72 p->nFansAlloc = 2 * Gia_ManObjNum(
p);
73 if (
p->nFansAlloc < (1<<12) )
74 p->nFansAlloc = (1<<12);
76 memset(
p->pFanData, 0,
sizeof(
int) * 5 *
p->nFansAlloc );
80 if ( Gia_ObjChild0(pObj) )
82 if ( Gia_ObjChild1(pObj) )
118 int iFan, * pFirst, * pPrevC, * pNextC, * pPrev, * pNext;
120 assert( !Gia_IsComplement(pObj) && !Gia_IsComplement(pFanout) );
121 assert( Gia_ObjId(
p, pFanout) > 0 );
122 if ( Gia_ObjId(
p, pObj) >=
p->nFansAlloc || Gia_ObjId(
p, pFanout) >=
p->nFansAlloc )
124 int nFansAlloc = 2 * Abc_MaxInt( Gia_ObjId(
p, pObj), Gia_ObjId(
p, pFanout) );
125 p->pFanData =
ABC_REALLOC(
int,
p->pFanData, 5 * nFansAlloc );
126 memset(
p->pFanData + 5 *
p->nFansAlloc, 0,
sizeof(
int) * 5 * (nFansAlloc -
p->nFansAlloc) );
127 p->nFansAlloc = nFansAlloc;
129 assert( Gia_ObjId(
p, pObj) <
p->nFansAlloc && Gia_ObjId(
p, pFanout) <
p->nFansAlloc );
130 iFan = Gia_FanoutCreate( Gia_ObjId(
p, pFanout), Gia_ObjWhatFanin(
p, pFanout, pObj) );
131 pPrevC = Gia_FanoutPrev(
p->pFanData, iFan );
132 pNextC = Gia_FanoutNext(
p->pFanData, iFan );
133 pFirst = Gia_FanoutObj(
p->pFanData, Gia_ObjId(
p, pObj) );
142 pPrev = Gia_FanoutPrev(
p->pFanData, *pFirst );
143 pNext = Gia_FanoutNext(
p->pFanData, *pPrev );
144 assert( *pNext == *pFirst );
165 int iFan, * pFirst, * pPrevC, * pNextC, * pPrev, * pNext;
166 assert(
p->pFanData && Gia_ObjId(
p, pObj) <
p->nFansAlloc && Gia_ObjId(
p, pFanout) <
p->nFansAlloc );
167 assert( !Gia_IsComplement(pObj) && !Gia_IsComplement(pFanout) );
168 assert( Gia_ObjId(
p, pFanout) > 0 );
169 iFan = Gia_FanoutCreate( Gia_ObjId(
p, pFanout), Gia_ObjWhatFanin(
p, pFanout, pObj) );
170 pPrevC = Gia_FanoutPrev(
p->pFanData, iFan );
171 pNextC = Gia_FanoutNext(
p->pFanData, iFan );
172 pPrev = Gia_FanoutPrev(
p->pFanData, *pNextC );
173 pNext = Gia_FanoutNext(
p->pFanData, *pPrevC );
176 pFirst = Gia_FanoutObj(
p->pFanData, Gia_ObjId(
p, pObj) );
178 if ( *pFirst == iFan )
180 if ( *pNextC == iFan )
216 iOffset = Gia_ManObjNum(
p);
217 vEdgeMap = Vec_IntStart( iOffset + Gia_ManMuxNum(
p) + 2 * Gia_ManAndNum(
p) + Gia_ManCoNum(
p) - Gia_ManBufNum(
p) );
220 Vec_IntWriteEntry( vEdgeMap, i, iOffset );
221 iOffset += Vec_IntEntry( vFanoutNums, Gia_ObjId(
p, pObj) );
223 assert( iOffset <= Vec_IntSize(vEdgeMap) );
244 assert(
p->vFanoutNums == NULL );
247 pRefsOld =
p->pRefs;
p->pRefs = NULL;
249 p->vFanoutNums = Vec_IntAllocArray(
p->pRefs, Gia_ManObjNum(
p) );
254 vCounts = Vec_IntStart( Gia_ManObjNum(
p) );
257 if ( Gia_ObjIsAnd(pObj) || Gia_ObjIsCo(pObj) )
259 pFanin = Gia_ObjFanin0(pObj);
260 iFanout = Vec_IntEntry( vCounts, Gia_ObjId(
p, pFanin) );
261 Gia_ObjSetFanout(
p, pFanin, iFanout, pObj );
262 Vec_IntAddToEntry( vCounts, Gia_ObjId(
p, pFanin), 1 );
264 if ( Gia_ObjIsAnd(pObj) && !Gia_ObjIsBuf(pObj) )
266 pFanin = Gia_ObjFanin1(pObj);
267 iFanout = Vec_IntEntry( vCounts, Gia_ObjId(
p, pFanin) );
268 Gia_ObjSetFanout(
p, pFanin, iFanout, pObj );
269 Vec_IntAddToEntry( vCounts, Gia_ObjId(
p, pFanin), 1 );
271 if ( Gia_ObjIsMux(
p, pObj) )
274 pFanin = Gia_ObjFanin2(
p, pObj);
275 iFanout = Vec_IntEntry( vCounts, Gia_ObjId(
p, pFanin) );
276 Gia_ObjSetFanout(
p, pFanin, iFanout, pObj );
277 Vec_IntAddToEntry( vCounts, Gia_ObjId(
p, pFanin), 1 );
282 assert( Vec_IntEntry(vCounts, i) == Gia_ObjFanoutNum(
p, pObj) );
283 Vec_IntFree( vCounts );
301 int i, iOffset = Gia_ManObjNum(
p);
302 Vec_Int_t * vEdgeMap = Vec_IntAlloc( 2 * iOffset );
303 Vec_IntFill( vEdgeMap, iOffset, 0 );
306 if ( Vec_IntEntry(vFanoutNums, i) == 0 )
308 Vec_IntWriteEntry( vEdgeMap, i, iOffset );
309 iOffset += Vec_IntEntry( vFanoutNums, i );
310 Vec_IntFillExtra( vEdgeMap, iOffset, 0 );
329 int * pFanins = Gia_ObjLutFanins(
p, iObj );
330 int i, k, nFanins = Gia_ObjLutSize(
p, iObj );
331 for ( i = 0; i < nFanins; i++ )
332 for ( k = i + 1; k < nFanins; k++ )
333 assert( pFanins[i] != pFanins[k] );
340 int i, k, iFan, iFanout, Index;
341 assert(
p->vFanoutNums == NULL );
344 pRefsOld =
p->pLutRefs;
p->pLutRefs = NULL;
346 p->vFanoutNums = Vec_IntAllocArray(
p->pLutRefs, Gia_ManObjNum(
p) );
347 p->pLutRefs = pRefsOld;
351 *pvIndex = Vec_IntStart( Vec_IntSize(
p->vFanout) );
353 vCounts = Vec_IntStart( Gia_ManObjNum(
p) );
357 pObj = Gia_ManObj(
p, i );
360 pFanin = Gia_ManObj(
p, iFan );
361 iFanout = Vec_IntEntry( vCounts, iFan );
362 Gia_ObjSetFanout(
p, pFanin, iFanout, pObj );
363 Vec_IntAddToEntry( vCounts, iFan, 1 );
365 Vec_IntWriteEntry( *pvIndex, Vec_IntEntry(
p->vFanout, iFan) + iFanout, Index );
370 iFan = Gia_ObjFaninId0p(
p, pObj);
371 pFanin = Gia_ManObj(
p, iFan );
372 iFanout = Vec_IntEntry( vCounts, iFan );
373 Gia_ObjSetFanout(
p, pFanin, iFanout, pObj );
374 Vec_IntAddToEntry( vCounts, iFan, 1 );
378 assert( Vec_IntEntry(vCounts, i) == Gia_ObjFanoutNum(
p, pObj) );
379 Vec_IntFree( vCounts );
395 Vec_IntFreeP( &
p->vFanoutNums );
396 Vec_IntFreeP( &
p->vFanout );
419 printf(
" Fanouts : " );
421 printf(
"%5d ", Gia_ObjId(
p, pFanout) );
#define ABC_ALLOC(type, num)
#define ABC_REALLOC(type, obj, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
void Gia_ManFanoutStart(Gia_Man_t *p)
FUNCTION DEFINITIONS ///.
void Gia_ManStaticFanoutStart(Gia_Man_t *p)
void Gia_ManStaticFanoutStop(Gia_Man_t *p)
void Gia_ManStaticFanoutTest(Gia_Man_t *p)
void Gia_ManStaticMappingFanoutStart(Gia_Man_t *p, Vec_Int_t **pvIndex)
Vec_Int_t * Gia_ManStartMappingFanoutMap(Gia_Man_t *p, Vec_Int_t *vFanoutNums)
Vec_Int_t * Gia_ManStartFanoutMap(Gia_Man_t *p, Vec_Int_t *vFanoutNums)
void Gia_ObjCheckDupMappingFanins(Gia_Man_t *p, int iObj)
void Gia_ObjRemoveFanout(Gia_Man_t *p, Gia_Obj_t *pObj, Gia_Obj_t *pFanout)
void Gia_ManFanoutStop(Gia_Man_t *p)
void Gia_ObjAddFanout(Gia_Man_t *p, Gia_Obj_t *pObj, Gia_Obj_t *pFanout)
#define Gia_ObjForEachFanoutStatic(p, pObj, pFanout, i)
#define Gia_ManForEachLut(p, i)
struct Gia_Obj_t_ Gia_Obj_t
void Gia_ObjPrint(Gia_Man_t *p, Gia_Obj_t *pObj)
struct Gia_Man_t_ Gia_Man_t
void Gia_ManCreateRefs(Gia_Man_t *p)
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
#define Gia_ManForEachCo(p, pObj, i)
void Gia_ManSetLutRefs(Gia_Man_t *p)
#define Gia_LutForEachFaninIndex(p, i, iFan, k, Index)