abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
giaFanout.c File Reference
#include "gia.h"

Go to the source code of this file.

Macros

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

Functions

static ABC_NAMESPACE_IMPL_START int Gia_FanoutCreate (int FanId, int Num)
 DECLARATIONS ///. More...
 
static int * Gia_FanoutObj (int *pData, int ObjId)
 
static int * Gia_FanoutPrev (int *pData, int iFan)
 
static int * Gia_FanoutNext (int *pData, int iFan)
 
static int Gia_ObjFanout0Int (Gia_Man_t *p, int ObjId)
 
static int Gia_ObjFanoutNext (Gia_Man_t *p, int iFan)
 
void Gia_ManFanoutStart (Gia_Man_t *p)
 FUNCTION DEFINITIONS ///. More...
 
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)
 
void Gia_ManStaticFanoutStop (Gia_Man_t *p)
 
void Gia_ManStaticFanoutTest (Gia_Man_t *p)
 

Macro Definition Documentation

#define Gia_ObjForEachFanout (   p,
  pObj,
  pFanout,
  iFan,
 
)
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++ )
static int Gia_ObjFanoutNext(Gia_Man_t *p, int iFan)
Definition: giaFanout.c:43
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static int Gia_ObjFanout0Int(Gia_Man_t *p, int ObjId)
Definition: giaFanout.c:42
#define assert(ex)
Definition: util_old.h:213

Definition at line 46 of file giaFanout.c.

Function Documentation

static ABC_NAMESPACE_IMPL_START int Gia_FanoutCreate ( int  FanId,
int  Num 
)
inlinestatic

DECLARATIONS ///.

CFile****************************************************************

FileName [giaFanout.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis []

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
giaFanout.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 36 of file giaFanout.c.

36 { assert( Num < 2 ); return (FanId << 1) | Num; }
#define assert(ex)
Definition: util_old.h:213
static int* Gia_FanoutNext ( int *  pData,
int  iFan 
)
inlinestatic

Definition at line 39 of file giaFanout.c.

39 { return pData + 5*(iFan >> 1) + 3 + (iFan & 1); }
static int* Gia_FanoutObj ( int *  pData,
int  ObjId 
)
inlinestatic

Definition at line 37 of file giaFanout.c.

37 { return pData + 5*ObjId; }
static int* Gia_FanoutPrev ( int *  pData,
int  iFan 
)
inlinestatic

Definition at line 38 of file giaFanout.c.

38 { return pData + 5*(iFan >> 1) + 1 + (iFan & 1); }
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 }
char * memset()
static Gia_Obj_t * Gia_ObjChild0(Gia_Obj_t *pObj)
Definition: gia.h:457
int nFansAlloc
Definition: gia.h:128
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Definition: gia.h:75
static Gia_Obj_t * Gia_ObjChild1(Gia_Obj_t *pObj)
Definition: gia.h:458
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
int * pFanData
Definition: gia.h:127
void Gia_ObjAddFanout(Gia_Man_t *p, Gia_Obj_t *pObj, Gia_Obj_t *pFanout)
Definition: giaFanout.c:116
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition: gia.h:984
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
#define assert(ex)
Definition: util_old.h:213
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
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 }
int nFansAlloc
Definition: gia.h:128
int * pFanData
Definition: gia.h:127
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define assert(ex)
Definition: util_old.h:213
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 + 2 * Gia_ManAndNum(p) + Gia_ManCoNum(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
Definition: gia.h:75
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Gia_ManAndNum(Gia_Man_t *p)
Definition: gia.h:389
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition: gia.h:984
#define assert(ex)
Definition: util_old.h:213
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
static int Gia_ManCoNum(Gia_Man_t *p)
Definition: gia.h:384
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;
250  p->pRefs = pRefsOld;
251  // start the fanout maps
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) )
265  {
266 
267  pFanin = Gia_ObjFanin1(pObj);
268  iFanout = Vec_IntEntry( vCounts, Gia_ObjId(p, pFanin) );
269  Gia_ObjSetFanout( p, pFanin, iFanout, pObj );
270  Vec_IntAddToEntry( vCounts, Gia_ObjId(p, pFanin), 1 );
271  }
272  }
273  // double-check the current number of fanouts added
274  Gia_ManForEachObj( p, pObj, i )
275  assert( Vec_IntEntry(vCounts, i) == Gia_ObjFanoutNum(p, pObj) );
276  Vec_IntFree( vCounts );
277 }
void Gia_ManCreateRefs(Gia_Man_t *p)
Definition: giaUtil.c:715
Vec_Int_t * vFanoutNums
Definition: gia.h:129
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static Vec_Int_t * Vec_IntAllocArray(int *pArray, int nSize)
Definition: bblif.c:214
int * pRefs
Definition: gia.h:114
Definition: gia.h:75
Vec_Int_t * Gia_ManStartFanoutMap(Gia_Man_t *p, Vec_Int_t *vFanoutNums)
Definition: giaFanout.c:211
Vec_Int_t * vFanout
Definition: gia.h:130
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
Definition: bblif.c:302
static void Gia_ObjSetFanout(Gia_Man_t *p, Gia_Obj_t *pObj, int i, Gia_Obj_t *pFan)
Definition: gia.h:944
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Gia_ObjFanoutNum(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:940
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static int Gia_ObjIsCo(Gia_Obj_t *pObj)
Definition: gia.h:421
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition: gia.h:984
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
void Gia_ManStaticFanoutStop ( Gia_Man_t p)

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

Synopsis [Deallocates static fanout.]

Description []

SideEffects []

SeeAlso []

Definition at line 290 of file giaFanout.c.

291 {
292  Vec_IntFreeP( &p->vFanoutNums );
293  Vec_IntFreeP( &p->vFanout );
294 }
Vec_Int_t * vFanoutNums
Definition: gia.h:129
Vec_Int_t * vFanout
Definition: gia.h:130
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
void Gia_ManStaticFanoutTest ( Gia_Man_t p)

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

Synopsis [Tests static fanout.]

Description []

SideEffects []

SeeAlso []

Definition at line 308 of file giaFanout.c.

309 {
310  Gia_Obj_t * pObj, * pFanout;
311  int i, k;
313  Gia_ManForEachObj( p, pObj, i )
314  {
315  Gia_ObjPrint( p, pObj );
316  printf( " Fanouts : " );
317  Gia_ObjForEachFanoutStatic( p, pObj, pFanout, k )
318  printf( "%5d ", Gia_ObjId(p, pFanout) );
319  printf( "\n" );
320  }
322 }
Definition: gia.h:75
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
void Gia_ObjPrint(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: giaUtil.c:1258
#define Gia_ObjForEachFanoutStatic(p, pObj, pFanout, i)
Definition: gia.h:946
void Gia_ManStaticFanoutStop(Gia_Man_t *p)
Definition: giaFanout.c:290
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition: gia.h:984
void Gia_ManStaticFanoutStart(Gia_Man_t *p)
Definition: giaFanout.c:238
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(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 }
char * memset()
static int * Gia_FanoutNext(int *pData, int iFan)
Definition: giaFanout.c:39
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
static int * Gia_FanoutPrev(int *pData, int iFan)
Definition: giaFanout.c:38
int nFansAlloc
Definition: gia.h:128
static int * Gia_FanoutObj(int *pData, int ObjId)
Definition: giaFanout.c:37
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Gia_ObjWhatFanin(Gia_Obj_t *pObj, Gia_Obj_t *pFanin)
Definition: gia.h:473
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
int * pFanData
Definition: gia.h:127
static int Gia_IsComplement(Gia_Obj_t *p)
Definition: gia.h:380
#define assert(ex)
Definition: util_old.h:213
static ABC_NAMESPACE_IMPL_START int Gia_FanoutCreate(int FanId, int Num)
DECLARATIONS ///.
Definition: giaFanout.c:36
static int Gia_ObjFanout0Int ( Gia_Man_t p,
int  ObjId 
)
inlinestatic

Definition at line 42 of file giaFanout.c.

42 { assert(ObjId < p->nFansAlloc); return p->pFanData[5*ObjId]; }
int * pFanData
Definition: gia.h:127
#define assert(ex)
Definition: util_old.h:213
static int Gia_ObjFanoutNext ( Gia_Man_t p,
int  iFan 
)
inlinestatic

Definition at line 43 of file giaFanout.c.

43 { assert(iFan/2 < p->nFansAlloc); return p->pFanData[5*(iFan >> 1) + 3 + (iFan & 1)]; }
int nFansAlloc
Definition: gia.h:128
int * pFanData
Definition: gia.h:127
#define assert(ex)
Definition: util_old.h:213
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(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 }
static int * Gia_FanoutNext(int *pData, int iFan)
Definition: giaFanout.c:39
static int * Gia_FanoutPrev(int *pData, int iFan)
Definition: giaFanout.c:38
int nFansAlloc
Definition: gia.h:128
static int * Gia_FanoutObj(int *pData, int ObjId)
Definition: giaFanout.c:37
static int Gia_ObjWhatFanin(Gia_Obj_t *pObj, Gia_Obj_t *pFanin)
Definition: gia.h:473
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
int * pFanData
Definition: gia.h:127
static int Gia_IsComplement(Gia_Obj_t *p)
Definition: gia.h:380
#define assert(ex)
Definition: util_old.h:213
static ABC_NAMESPACE_IMPL_START int Gia_FanoutCreate(int FanId, int Num)
DECLARATIONS ///.
Definition: giaFanout.c:36