ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
giaFanout.c File Reference
#include "gia.h"
Include dependency graph for giaFanout.c:

Go to the source code of this file.

Macros

#define Gia_ObjForEachFanout(p, pObj, pFanout, iFan, i)
 

Functions

void Gia_ManFanoutStart (Gia_Man_t *p)
 FUNCTION DEFINITIONS ///.
 
void Gia_ManFanoutStop (Gia_Man_t *p)
 
void Gia_ObjAddFanout (Gia_Man_t *p, Gia_Obj_t *pObj, Gia_Obj_t *pFanout)
 
void Gia_ObjRemoveFanout (Gia_Man_t *p, Gia_Obj_t *pObj, Gia_Obj_t *pFanout)
 
Vec_Int_tGia_ManStartFanoutMap (Gia_Man_t *p, Vec_Int_t *vFanoutNums)
 
void Gia_ManStaticFanoutStart (Gia_Man_t *p)
 
Vec_Int_tGia_ManStartMappingFanoutMap (Gia_Man_t *p, Vec_Int_t *vFanoutNums)
 
void Gia_ObjCheckDupMappingFanins (Gia_Man_t *p, int iObj)
 
void Gia_ManStaticMappingFanoutStart (Gia_Man_t *p, Vec_Int_t **pvIndex)
 
void Gia_ManStaticFanoutStop (Gia_Man_t *p)
 
void Gia_ManStaticFanoutTest (Gia_Man_t *p)
 

Macro Definition Documentation

◆ Gia_ObjForEachFanout

#define Gia_ObjForEachFanout ( p,
pObj,
pFanout,
iFan,
i )
Value:
for ( assert(p->pFanData), i = 0; (i < (int)(pObj)->nRefs) && \
(((iFan) = i? Gia_ObjFanoutNext(p, iFan) : Gia_ObjFanout0Int(p, Gia_ObjId(p, pObj))), 1) && \
(((pFanout) = Gia_ManObj(p, iFan>>1)), 1); i++ )
Cube * p
Definition exorList.c:222
#define assert(ex)
Definition util_old.h:213

Definition at line 46 of file giaFanout.c.

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++ )

Function Documentation

◆ Gia_ManFanoutStart()

void Gia_ManFanoutStart ( Gia_Man_t * p)

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Create fanout for all objects in the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 66 of file giaFanout.c.

67{
68 Gia_Obj_t * pObj;
69 int i;
70 // allocate fanout datastructure
71 assert( p->pFanData == NULL );
72 p->nFansAlloc = 2 * Gia_ManObjNum(p);
73 if ( p->nFansAlloc < (1<<12) )
74 p->nFansAlloc = (1<<12);
75 p->pFanData = ABC_ALLOC( int, 5 * p->nFansAlloc );
76 memset( p->pFanData, 0, sizeof(int) * 5 * p->nFansAlloc );
77 // add fanouts for all objects
78 Gia_ManForEachObj( p, pObj, i )
79 {
80 if ( Gia_ObjChild0(pObj) )
81 Gia_ObjAddFanout( p, Gia_ObjFanin0(pObj), pObj );
82 if ( Gia_ObjChild1(pObj) )
83 Gia_ObjAddFanout( p, Gia_ObjFanin1(pObj), pObj );
84 }
85}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
void Gia_ObjAddFanout(Gia_Man_t *p, Gia_Obj_t *pObj, Gia_Obj_t *pFanout)
Definition giaFanout.c:116
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition gia.h:1190
char * memset()
Here is the call graph for this function:

◆ Gia_ManFanoutStop()

void Gia_ManFanoutStop ( Gia_Man_t * p)

Function*************************************************************

Synopsis [Deletes fanout for all objects in the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 98 of file giaFanout.c.

99{
100 assert( p->pFanData != NULL );
101 ABC_FREE( p->pFanData );
102 p->nFansAlloc = 0;
103}
#define ABC_FREE(obj)
Definition abc_global.h:267

◆ Gia_ManStartFanoutMap()

Vec_Int_t * Gia_ManStartFanoutMap ( Gia_Man_t * p,
Vec_Int_t * vFanoutNums )

Function*************************************************************

Synopsis [Compute the map of all edges.]

Description []

SideEffects []

SeeAlso []

Definition at line 211 of file giaFanout.c.

212{
213 Vec_Int_t * vEdgeMap;
214 Gia_Obj_t * pObj;
215 int i, iOffset;
216 iOffset = Gia_ManObjNum(p);
217 vEdgeMap = Vec_IntStart( iOffset + Gia_ManMuxNum(p) + 2 * Gia_ManAndNum(p) + Gia_ManCoNum(p) - Gia_ManBufNum(p) );
218 Gia_ManForEachObj( p, pObj, i )
219 {
220 Vec_IntWriteEntry( vEdgeMap, i, iOffset );
221 iOffset += Vec_IntEntry( vFanoutNums, Gia_ObjId(p, pObj) );
222 }
223 assert( iOffset <= Vec_IntSize(vEdgeMap) );
224 return vEdgeMap;
225}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Here is the caller graph for this function:

◆ Gia_ManStartMappingFanoutMap()

Vec_Int_t * Gia_ManStartMappingFanoutMap ( Gia_Man_t * p,
Vec_Int_t * vFanoutNums )

Function*************************************************************

Synopsis [Compute the map of all edges.]

Description []

SideEffects []

SeeAlso []

Definition at line 298 of file giaFanout.c.

299{
300 Gia_Obj_t * pObj;
301 int i, iOffset = Gia_ManObjNum(p);
302 Vec_Int_t * vEdgeMap = Vec_IntAlloc( 2 * iOffset );
303 Vec_IntFill( vEdgeMap, iOffset, 0 );
304 Gia_ManForEachObj( p, pObj, i )
305 {
306 if ( Vec_IntEntry(vFanoutNums, i) == 0 )
307 continue;
308 Vec_IntWriteEntry( vEdgeMap, i, iOffset );
309 iOffset += Vec_IntEntry( vFanoutNums, i );
310 Vec_IntFillExtra( vEdgeMap, iOffset, 0 );
311 }
312 //printf( "Fanout map is %.2fx larger than AIG manager.\n", 1.0*Vec_IntSize(vEdgeMap)/Gia_ManObjNum(p) );
313 return vEdgeMap;
314}
Here is the caller graph for this function:

◆ Gia_ManStaticFanoutStart()

void Gia_ManStaticFanoutStart ( Gia_Man_t * p)

Function*************************************************************

Synopsis [Allocates static fanout.]

Description []

SideEffects []

SeeAlso []

Definition at line 238 of file giaFanout.c.

239{
240 Vec_Int_t * vCounts;
241 int * pRefsOld;
242 Gia_Obj_t * pObj, * pFanin;
243 int i, iFanout;
244 assert( p->vFanoutNums == NULL );
245 assert( p->vFanout == NULL );
246 // recompute reference counters
247 pRefsOld = p->pRefs; p->pRefs = NULL;
249 p->vFanoutNums = Vec_IntAllocArray( p->pRefs, Gia_ManObjNum(p) );
250 p->pRefs = pRefsOld;
251 // start the fanout maps
252 p->vFanout = Gia_ManStartFanoutMap( p, p->vFanoutNums );
253 // incrementally add fanouts
254 vCounts = Vec_IntStart( Gia_ManObjNum(p) );
255 Gia_ManForEachObj( p, pObj, i )
256 {
257 if ( Gia_ObjIsAnd(pObj) || Gia_ObjIsCo(pObj) )
258 {
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 );
263 }
264 if ( Gia_ObjIsAnd(pObj) && !Gia_ObjIsBuf(pObj) )
265 {
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 );
270 }
271 if ( Gia_ObjIsMux(p, pObj) )
272 {
273
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 );
278 }
279 }
280 // double-check the current number of fanouts added
281 Gia_ManForEachObj( p, pObj, i )
282 assert( Vec_IntEntry(vCounts, i) == Gia_ObjFanoutNum(p, pObj) );
283 Vec_IntFree( vCounts );
284}
Vec_Int_t * Gia_ManStartFanoutMap(Gia_Man_t *p, Vec_Int_t *vFanoutNums)
Definition giaFanout.c:211
void Gia_ManCreateRefs(Gia_Man_t *p)
Definition giaUtil.c:779
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManStaticFanoutStop()

void Gia_ManStaticFanoutStop ( Gia_Man_t * p)

Function*************************************************************

Synopsis [Deallocates static fanout.]

Description []

SideEffects []

SeeAlso []

Definition at line 393 of file giaFanout.c.

394{
395 Vec_IntFreeP( &p->vFanoutNums );
396 Vec_IntFreeP( &p->vFanout );
397}
Here is the caller graph for this function:

◆ Gia_ManStaticFanoutTest()

void Gia_ManStaticFanoutTest ( Gia_Man_t * p)

Function*************************************************************

Synopsis [Tests static fanout.]

Description []

SideEffects []

SeeAlso []

Definition at line 411 of file giaFanout.c.

412{
413 Gia_Obj_t * pObj, * pFanout;
414 int i, k;
416 Gia_ManForEachObj( p, pObj, i )
417 {
418 Gia_ObjPrint( p, pObj );
419 printf( " Fanouts : " );
420 Gia_ObjForEachFanoutStatic( p, pObj, pFanout, k )
421 printf( "%5d ", Gia_ObjId(p, pFanout) );
422 printf( "\n" );
423 }
425}
void Gia_ManStaticFanoutStart(Gia_Man_t *p)
Definition giaFanout.c:238
void Gia_ManStaticFanoutStop(Gia_Man_t *p)
Definition giaFanout.c:393
#define Gia_ObjForEachFanoutStatic(p, pObj, pFanout, i)
Definition gia.h:1125
void Gia_ObjPrint(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition giaUtil.c:1456
Here is the call graph for this function:

◆ Gia_ManStaticMappingFanoutStart()

void Gia_ManStaticMappingFanoutStart ( Gia_Man_t * p,
Vec_Int_t ** pvIndex )

Definition at line 335 of file giaFanout.c.

336{
337 Vec_Int_t * vCounts;
338 int * pRefsOld;
339 Gia_Obj_t * pObj, * pFanin;
340 int i, k, iFan, iFanout, Index;
341 assert( p->vFanoutNums == NULL );
342 assert( p->vFanout == NULL );
343 // recompute reference counters
344 pRefsOld = p->pLutRefs; p->pLutRefs = NULL;
346 p->vFanoutNums = Vec_IntAllocArray( p->pLutRefs, Gia_ManObjNum(p) );
347 p->pLutRefs = pRefsOld;
348 // start the fanout maps
349 p->vFanout = Gia_ManStartMappingFanoutMap( p, p->vFanoutNums );
350 if ( pvIndex )
351 *pvIndex = Vec_IntStart( Vec_IntSize(p->vFanout) );
352 // incrementally add fanouts
353 vCounts = Vec_IntStart( Gia_ManObjNum(p) );
354 Gia_ManForEachLut( p, i )
355 {
357 pObj = Gia_ManObj( p, i );
358 Gia_LutForEachFaninIndex( p, i, iFan, k, Index )
359 {
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 );
364 if ( pvIndex )
365 Vec_IntWriteEntry( *pvIndex, Vec_IntEntry(p->vFanout, iFan) + iFanout, Index );
366 }
367 }
368 Gia_ManForEachCo( p, pObj, i )
369 {
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 );
375 }
376 // double-check the current number of fanouts added
377 Gia_ManForEachObj( p, pObj, i )
378 assert( Vec_IntEntry(vCounts, i) == Gia_ObjFanoutNum(p, pObj) );
379 Vec_IntFree( vCounts );
380}
Vec_Int_t * Gia_ManStartMappingFanoutMap(Gia_Man_t *p, Vec_Int_t *vFanoutNums)
Definition giaFanout.c:298
void Gia_ObjCheckDupMappingFanins(Gia_Man_t *p, int iObj)
Definition giaFanout.c:327
#define Gia_ManForEachLut(p, i)
Definition gia.h:1157
#define Gia_ManForEachCo(p, pObj, i)
Definition gia.h:1236
void Gia_ManSetLutRefs(Gia_Man_t *p)
Definition giaIf.c:295
#define Gia_LutForEachFaninIndex(p, i, iFan, k, Index)
Definition gia.h:1163
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ObjAddFanout()

void Gia_ObjAddFanout ( Gia_Man_t * p,
Gia_Obj_t * pObj,
Gia_Obj_t * pFanout )

Function*************************************************************

Synopsis [Adds fanout (pFanout) of node (pObj).]

Description []

SideEffects []

SeeAlso []

Definition at line 116 of file giaFanout.c.

117{
118 int iFan, * pFirst, * pPrevC, * pNextC, * pPrev, * pNext;
119 assert( p->pFanData );
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 )
123 {
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;
128 }
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) );
134 if ( *pFirst == 0 )
135 {
136 *pFirst = iFan;
137 *pPrevC = iFan;
138 *pNextC = iFan;
139 }
140 else
141 {
142 pPrev = Gia_FanoutPrev( p->pFanData, *pFirst );
143 pNext = Gia_FanoutNext( p->pFanData, *pPrev );
144 assert( *pNext == *pFirst );
145 *pPrevC = *pPrev;
146 *pNextC = *pFirst;
147 *pPrev = iFan;
148 *pNext = iFan;
149 }
150}
#define ABC_REALLOC(type, obj, num)
Definition abc_global.h:268
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ObjCheckDupMappingFanins()

void Gia_ObjCheckDupMappingFanins ( Gia_Man_t * p,
int iObj )

Function*************************************************************

Synopsis [Allocates static fanout.]

Description []

SideEffects []

SeeAlso []

Definition at line 327 of file giaFanout.c.

328{
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] );
334}
Here is the caller graph for this function:

◆ Gia_ObjRemoveFanout()

void Gia_ObjRemoveFanout ( Gia_Man_t * p,
Gia_Obj_t * pObj,
Gia_Obj_t * pFanout )

Function*************************************************************

Synopsis [Removes fanout (pFanout) of node (pObj).]

Description []

SideEffects []

SeeAlso []

Definition at line 163 of file giaFanout.c.

164{
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 );
174 assert( *pPrev == iFan );
175 assert( *pNext == iFan );
176 pFirst = Gia_FanoutObj( p->pFanData, Gia_ObjId(p, pObj) );
177 assert( *pFirst > 0 );
178 if ( *pFirst == iFan )
179 {
180 if ( *pNextC == iFan )
181 {
182 *pFirst = 0;
183 *pPrev = 0;
184 *pNext = 0;
185 *pPrevC = 0;
186 *pNextC = 0;
187 return;
188 }
189 *pFirst = *pNextC;
190 }
191 *pPrev = *pPrevC;
192 *pNext = *pNextC;
193 *pPrevC = 0;
194 *pNextC = 0;
195}