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

Go to the source code of this file.

Functions

static ABC_NAMESPACE_IMPL_START int Aig_FanoutCreate (int FanId, int Num)
 DECLARATIONS ///. More...
 
static int * Aig_FanoutObj (int *pData, int ObjId)
 
static int * Aig_FanoutPrev (int *pData, int iFan)
 
static int * Aig_FanoutNext (int *pData, int iFan)
 
void Aig_ManFanoutStart (Aig_Man_t *p)
 FUNCTION DEFINITIONS ///. More...
 
void Aig_ManFanoutStop (Aig_Man_t *p)
 
void Aig_ObjAddFanout (Aig_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pFanout)
 
void Aig_ObjRemoveFanout (Aig_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pFanout)
 

Function Documentation

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

DECLARATIONS ///.

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

FileName [aigFanout.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [AIG package.]

Synopsis [Fanout manipulation.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - April 28, 2007.]

Revision [

Id:
aigFanout.c,v 1.00 2007/04/28 00:00:00 alanmi Exp

]

Definition at line 36 of file aigFanout.c.

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

Definition at line 39 of file aigFanout.c.

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

Definition at line 37 of file aigFanout.c.

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

Definition at line 38 of file aigFanout.c.

38 { return pData + 5*(iFan >> 1) + 1 + (iFan & 1); }
void Aig_ManFanoutStart ( Aig_Man_t p)

FUNCTION DEFINITIONS ///.

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 56 of file aigFanout.c.

57 {
58  Aig_Obj_t * pObj;
59  int i;
60  assert( Aig_ManBufNum(p) == 0 );
61  // allocate fanout datastructure
62  assert( p->pFanData == NULL );
63  p->nFansAlloc = 2 * Aig_ManObjNumMax(p);
64  if ( p->nFansAlloc < (1<<12) )
65  p->nFansAlloc = (1<<12);
66  p->pFanData = ABC_ALLOC( int, 5 * p->nFansAlloc );
67  memset( p->pFanData, 0, sizeof(int) * 5 * p->nFansAlloc );
68  // add fanouts for all objects
69  Aig_ManForEachObj( p, pObj, i )
70  {
71  if ( Aig_ObjChild0(pObj) )
72  Aig_ObjAddFanout( p, Aig_ObjFanin0(pObj), pObj );
73  if ( Aig_ObjChild1(pObj) )
74  Aig_ObjAddFanout( p, Aig_ObjFanin1(pObj), pObj );
75  }
76 }
char * memset()
static Aig_Obj_t * Aig_ObjChild0(Aig_Obj_t *pObj)
Definition: aig.h:310
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static int Aig_ManBufNum(Aig_Man_t *p)
Definition: aig.h:253
void Aig_ObjAddFanout(Aig_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pFanout)
Definition: aigFanout.c:107
static Aig_Obj_t * Aig_ObjChild1(Aig_Obj_t *pObj)
Definition: aig.h:311
Definition: aig.h:69
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
#define assert(ex)
Definition: util_old.h:213
void Aig_ManFanoutStop ( Aig_Man_t p)

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 89 of file aigFanout.c.

90 {
91  assert( p->pFanData != NULL );
92  ABC_FREE( p->pFanData );
93  p->nFansAlloc = 0;
94 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define assert(ex)
Definition: util_old.h:213
void Aig_ObjAddFanout ( Aig_Man_t p,
Aig_Obj_t pObj,
Aig_Obj_t pFanout 
)

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 107 of file aigFanout.c.

108 {
109  int iFan, * pFirst, * pPrevC, * pNextC, * pPrev, * pNext;
110  assert( p->pFanData );
111  assert( !Aig_IsComplement(pObj) && !Aig_IsComplement(pFanout) );
112  assert( pFanout->Id > 0 );
113  if ( pObj->Id >= p->nFansAlloc || pFanout->Id >= p->nFansAlloc )
114  {
115  int nFansAlloc = 2 * Abc_MaxInt( pObj->Id, pFanout->Id );
116  p->pFanData = ABC_REALLOC( int, p->pFanData, 5 * nFansAlloc );
117  memset( p->pFanData + 5 * p->nFansAlloc, 0, sizeof(int) * 5 * (nFansAlloc - p->nFansAlloc) );
118  p->nFansAlloc = nFansAlloc;
119  }
120  assert( pObj->Id < p->nFansAlloc && pFanout->Id < p->nFansAlloc );
121  iFan = Aig_FanoutCreate( pFanout->Id, Aig_ObjWhatFanin(pFanout, pObj) );
122  pPrevC = Aig_FanoutPrev( p->pFanData, iFan );
123  pNextC = Aig_FanoutNext( p->pFanData, iFan );
124  pFirst = Aig_FanoutObj( p->pFanData, pObj->Id );
125  if ( *pFirst == 0 )
126  {
127  *pFirst = iFan;
128  *pPrevC = iFan;
129  *pNextC = iFan;
130  }
131  else
132  {
133  pPrev = Aig_FanoutPrev( p->pFanData, *pFirst );
134  pNext = Aig_FanoutNext( p->pFanData, *pPrev );
135  assert( *pNext == *pFirst );
136  *pPrevC = *pPrev;
137  *pNextC = *pFirst;
138  *pPrev = iFan;
139  *pNext = iFan;
140  }
141 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
static int Aig_ObjWhatFanin(Aig_Obj_t *pObj, Aig_Obj_t *pFanin)
Definition: aig.h:332
static int * Aig_FanoutObj(int *pData, int ObjId)
Definition: aigFanout.c:37
static int * Aig_FanoutPrev(int *pData, int iFan)
Definition: aigFanout.c:38
static int * Aig_FanoutNext(int *pData, int iFan)
Definition: aigFanout.c:39
static ABC_NAMESPACE_IMPL_START int Aig_FanoutCreate(int FanId, int Num)
DECLARATIONS ///.
Definition: aigFanout.c:36
#define assert(ex)
Definition: util_old.h:213
int Id
Definition: aig.h:85
void Aig_ObjRemoveFanout ( Aig_Man_t p,
Aig_Obj_t pObj,
Aig_Obj_t pFanout 
)

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 154 of file aigFanout.c.

155 {
156  int iFan, * pFirst, * pPrevC, * pNextC, * pPrev, * pNext;
157  assert( p->pFanData && pObj->Id < p->nFansAlloc && pFanout->Id < p->nFansAlloc );
158  assert( !Aig_IsComplement(pObj) && !Aig_IsComplement(pFanout) );
159  assert( pFanout->Id > 0 );
160  iFan = Aig_FanoutCreate( pFanout->Id, Aig_ObjWhatFanin(pFanout, pObj) );
161  pPrevC = Aig_FanoutPrev( p->pFanData, iFan );
162  pNextC = Aig_FanoutNext( p->pFanData, iFan );
163  pPrev = Aig_FanoutPrev( p->pFanData, *pNextC );
164  pNext = Aig_FanoutNext( p->pFanData, *pPrevC );
165  assert( *pPrev == iFan );
166  assert( *pNext == iFan );
167  pFirst = Aig_FanoutObj( p->pFanData, pObj->Id );
168  assert( *pFirst > 0 );
169  if ( *pFirst == iFan )
170  {
171  if ( *pNextC == iFan )
172  {
173  *pFirst = 0;
174  *pPrev = 0;
175  *pNext = 0;
176  *pPrevC = 0;
177  *pNextC = 0;
178  return;
179  }
180  *pFirst = *pNextC;
181  }
182  *pPrev = *pPrevC;
183  *pNext = *pNextC;
184  *pPrevC = 0;
185  *pNextC = 0;
186 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static int Aig_ObjWhatFanin(Aig_Obj_t *pObj, Aig_Obj_t *pFanin)
Definition: aig.h:332
static int * Aig_FanoutObj(int *pData, int ObjId)
Definition: aigFanout.c:37
static int * Aig_FanoutPrev(int *pData, int iFan)
Definition: aigFanout.c:38
static int * Aig_FanoutNext(int *pData, int iFan)
Definition: aigFanout.c:39
static ABC_NAMESPACE_IMPL_START int Aig_FanoutCreate(int FanId, int Num)
DECLARATIONS ///.
Definition: aigFanout.c:36
#define assert(ex)
Definition: util_old.h:213
int Id
Definition: aig.h:85