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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START
Aig_Obj_t
Aig_ObjCreateCi (Aig_Man_t *p)
 DECLARATIONS ///. More...
 
Aig_Obj_tAig_ObjCreateCo (Aig_Man_t *p, Aig_Obj_t *pDriver)
 
Aig_Obj_tAig_ObjCreate (Aig_Man_t *p, Aig_Obj_t *pGhost)
 
void Aig_ObjConnect (Aig_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pFan0, Aig_Obj_t *pFan1)
 
void Aig_ObjDisconnect (Aig_Man_t *p, Aig_Obj_t *pObj)
 
void Aig_ObjDelete (Aig_Man_t *p, Aig_Obj_t *pObj)
 
void Aig_ObjDelete_rec (Aig_Man_t *p, Aig_Obj_t *pObj, int fFreeTop)
 
void Aig_ObjDeletePo (Aig_Man_t *p, Aig_Obj_t *pObj)
 
void Aig_ObjPatchFanin0 (Aig_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pFaninNew)
 
void Aig_ObjPrint (Aig_Man_t *p, Aig_Obj_t *pObj)
 
void Aig_NodeFixBufferFanins (Aig_Man_t *p, Aig_Obj_t *pObj, int fUpdateLevel)
 
int Aig_ManPropagateBuffers (Aig_Man_t *p, int fUpdateLevel)
 
void Aig_ObjReplace (Aig_Man_t *p, Aig_Obj_t *pObjOld, Aig_Obj_t *pObjNew, int fUpdateLevel)
 

Function Documentation

int Aig_ManPropagateBuffers ( Aig_Man_t p,
int  fUpdateLevel 
)

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

Synopsis [Returns the number of dangling nodes removed.]

Description []

SideEffects []

SeeAlso []

Definition at line 432 of file aigObj.c.

433 {
434  Aig_Obj_t * pObj;
435  int nSteps;
436  assert( p->pFanData );
437  for ( nSteps = 0; Vec_PtrSize(p->vBufs) > 0; nSteps++ )
438  {
439  // get the node with a buffer fanin
440  for ( pObj = (Aig_Obj_t *)Vec_PtrEntryLast(p->vBufs); Aig_ObjIsBuf(pObj); pObj = Aig_ObjFanout0(p, pObj) );
441  // replace this node by a node without buffer
442  Aig_NodeFixBufferFanins( p, pObj, fUpdateLevel );
443  // stop if a cycle occured
444  if ( nSteps > 1000000 )
445  {
446  printf( "Error: A cycle is encountered while propagating buffers.\n" );
447  break;
448  }
449  }
450  return nSteps;
451 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Aig_ObjIsBuf(Aig_Obj_t *pObj)
Definition: aig.h:277
void Aig_NodeFixBufferFanins(Aig_Man_t *p, Aig_Obj_t *pObj, int fUpdateLevel)
Definition: aigObj.c:393
static void * Vec_PtrEntryLast(Vec_Ptr_t *p)
Definition: vecPtr.h:413
Definition: aig.h:69
static Aig_Obj_t * Aig_ObjFanout0(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:327
#define assert(ex)
Definition: util_old.h:213
void Aig_NodeFixBufferFanins ( Aig_Man_t p,
Aig_Obj_t pObj,
int  fUpdateLevel 
)

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

Synopsis [Replaces node with a buffer fanin by a node without them.]

Description []

SideEffects []

SeeAlso []

Definition at line 393 of file aigObj.c.

394 {
395  Aig_Obj_t * pFanReal0, * pFanReal1, * pResult;
396  p->nBufFixes++;
397  if ( Aig_ObjIsCo(pObj) )
398  {
400  pFanReal0 = Aig_ObjReal_rec( Aig_ObjChild0(pObj) );
401  assert( Aig_ObjPhaseReal(Aig_ObjChild0(pObj)) == Aig_ObjPhaseReal(pFanReal0) );
402  Aig_ObjPatchFanin0( p, pObj, pFanReal0 );
403  return;
404  }
405  assert( Aig_ObjIsNode(pObj) );
407  // get the real fanins
408  pFanReal0 = Aig_ObjReal_rec( Aig_ObjChild0(pObj) );
409  pFanReal1 = Aig_ObjReal_rec( Aig_ObjChild1(pObj) );
410  // get the new node
411  if ( Aig_ObjIsNode(pObj) )
412  pResult = Aig_Oper( p, pFanReal0, pFanReal1, Aig_ObjType(pObj) );
413 // else if ( Aig_ObjIsLatch(pObj) )
414 // pResult = Aig_Latch( p, pFanReal0, Aig_ObjInit(pObj) );
415  else
416  assert( 0 );
417  // replace the node with buffer by the node without buffer
418  Aig_ObjReplace( p, pObj, pResult, fUpdateLevel );
419 }
static Aig_Type_t Aig_ObjType(Aig_Obj_t *pObj)
Definition: aig.h:272
static Aig_Obj_t * Aig_ObjChild0(Aig_Obj_t *pObj)
Definition: aig.h:310
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Aig_ObjPatchFanin0(Aig_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pFaninNew)
Definition: aigObj.c:282
Aig_Obj_t * Aig_ObjReal_rec(Aig_Obj_t *pObj)
Definition: aigUtil.c:476
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
Aig_Obj_t * Aig_Oper(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1, Aig_Type_t Type)
Definition: aigOper.c:83
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
static int Aig_ObjIsBuf(Aig_Obj_t *pObj)
Definition: aig.h:277
static Aig_Obj_t * Aig_ObjChild1(Aig_Obj_t *pObj)
Definition: aig.h:311
static int Aig_ObjPhaseReal(Aig_Obj_t *pObj)
Definition: aig.h:299
Definition: aig.h:69
void Aig_ObjReplace(Aig_Man_t *p, Aig_Obj_t *pObjOld, Aig_Obj_t *pObjNew, int fUpdateLevel)
Definition: aigObj.c:467
#define assert(ex)
Definition: util_old.h:213
static int Aig_ObjIsCo(Aig_Obj_t *pObj)
Definition: aig.h:276
void Aig_ObjConnect ( Aig_Man_t p,
Aig_Obj_t pObj,
Aig_Obj_t pFan0,
Aig_Obj_t pFan1 
)

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

Synopsis [Connect the object to the fanin.]

Description []

SideEffects []

SeeAlso []

Definition at line 126 of file aigObj.c.

127 {
128  assert( !Aig_IsComplement(pObj) );
129  assert( !Aig_ObjIsCi(pObj) );
130  // add the first fanin
131  pObj->pFanin0 = pFan0;
132  pObj->pFanin1 = pFan1;
133  // increment references of the fanins and add their fanouts
134  if ( pFan0 != NULL )
135  {
136  assert( Aig_ObjFanin0(pObj)->Type > 0 );
137  Aig_ObjRef( Aig_ObjFanin0(pObj) );
138  if ( p->pFanData )
139  Aig_ObjAddFanout( p, Aig_ObjFanin0(pObj), pObj );
140  }
141  if ( pFan1 != NULL )
142  {
143  assert( Aig_ObjFanin1(pObj)->Type > 0 );
144  Aig_ObjRef( Aig_ObjFanin1(pObj) );
145  if ( p->pFanData )
146  Aig_ObjAddFanout( p, Aig_ObjFanin1(pObj), pObj );
147  }
148  // set level and phase
149  pObj->Level = Aig_ObjLevelNew( pObj );
150  pObj->fPhase = Aig_ObjPhaseReal(pFan0) & Aig_ObjPhaseReal(pFan1);
151  // add the node to the structural hash table
152  if ( p->pTable && Aig_ObjIsHash(pObj) )
153  Aig_TableInsert( p, pObj );
154  // add the node to the dynamically updated topological order
155 // if ( p->pOrderData && Aig_ObjIsNode(pObj) )
156 // Aig_ObjOrderInsert( p, pObj->Id );
157  assert( !Aig_ObjIsNode(pObj) || pObj->Level > 0 );
158 }
static int Aig_ObjLevelNew(Aig_Obj_t *pObj)
Definition: aig.h:324
unsigned Level
Definition: aig.h:82
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Aig_Obj_t * pFanin1
Definition: aig.h:76
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static void Aig_ObjRef(Aig_Obj_t *pObj)
Definition: aig.h:301
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
static int Aig_ObjPhaseReal(Aig_Obj_t *pObj)
Definition: aig.h:299
unsigned int fPhase
Definition: aig.h:78
void Aig_TableInsert(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aigTable.c:173
#define assert(ex)
Definition: util_old.h:213
void Aig_ObjAddFanout(Aig_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pFanout)
Definition: aigFanout.c:107
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
Aig_Obj_t * pFanin0
Definition: aig.h:75
static int Aig_ObjIsHash(Aig_Obj_t *pObj)
Definition: aig.h:282
Aig_Obj_t* Aig_ObjCreate ( Aig_Man_t p,
Aig_Obj_t pGhost 
)

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

Synopsis [Create the new node assuming it does not exist.]

Description []

SideEffects []

SeeAlso []

Definition at line 89 of file aigObj.c.

90 {
91  Aig_Obj_t * pObj;
92  assert( !Aig_IsComplement(pGhost) );
93  assert( Aig_ObjIsHash(pGhost) );
94 // assert( pGhost == &p->Ghost );
95  // get memory for the new object
96  pObj = Aig_ManFetchMemory( p );
97  pObj->Type = pGhost->Type;
98  // add connections
99  Aig_ObjConnect( p, pObj, pGhost->pFanin0, pGhost->pFanin1 );
100  // update node counters of the manager
101  p->nObjs[Aig_ObjType(pObj)]++;
102  assert( pObj->pData == NULL );
103  // create the power counter
104  if ( p->vProbs )
105  {
106  float Prob0 = Abc_Int2Float( Vec_IntEntry( p->vProbs, Aig_ObjFaninId0(pObj) ) );
107  float Prob1 = Abc_Int2Float( Vec_IntEntry( p->vProbs, Aig_ObjFaninId1(pObj) ) );
108  Prob0 = Aig_ObjFaninC0(pObj)? 1.0 - Prob0 : Prob0;
109  Prob1 = Aig_ObjFaninC1(pObj)? 1.0 - Prob1 : Prob1;
110  Vec_IntSetEntry( p->vProbs, pObj->Id, Abc_Float2Int(Prob0 * Prob1) );
111  }
112  return pObj;
113 }
static Aig_Type_t Aig_ObjType(Aig_Obj_t *pObj)
Definition: aig.h:272
static int Aig_ObjFaninId0(Aig_Obj_t *pObj)
Definition: aig.h:304
static Aig_Obj_t * Aig_ManFetchMemory(Aig_Man_t *p)
Definition: aig.h:368
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Aig_Obj_t * pFanin1
Definition: aig.h:76
unsigned int Type
Definition: aig.h:77
void * pData
Definition: aig.h:87
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static void Vec_IntSetEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:418
static int Aig_ObjFaninId1(Aig_Obj_t *pObj)
Definition: aig.h:305
static int Abc_Float2Int(float Val)
Definition: abc_global.h:249
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
Definition: aig.h:69
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static float Abc_Int2Float(int Num)
Definition: abc_global.h:250
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
#define assert(ex)
Definition: util_old.h:213
void Aig_ObjConnect(Aig_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pFan0, Aig_Obj_t *pFan1)
Definition: aigObj.c:126
Aig_Obj_t * pFanin0
Definition: aig.h:75
int Id
Definition: aig.h:85
static int Aig_ObjIsHash(Aig_Obj_t *pObj)
Definition: aig.h:282
ABC_NAMESPACE_IMPL_START Aig_Obj_t* Aig_ObjCreateCi ( Aig_Man_t p)

DECLARATIONS ///.

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

FileName [aigObj.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [AIG package.]

Synopsis [Adding/removing objects.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Creates primary input.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file aigObj.c.

46 {
47  Aig_Obj_t * pObj;
48  pObj = Aig_ManFetchMemory( p );
49  pObj->Type = AIG_OBJ_CI;
50  Vec_PtrPush( p->vCis, pObj );
51  p->nObjs[AIG_OBJ_CI]++;
52  return pObj;
53 }
static Aig_Obj_t * Aig_ManFetchMemory(Aig_Man_t *p)
Definition: aig.h:368
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned int Type
Definition: aig.h:77
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
Definition: aig.h:69
Definition: aig.h:60
Aig_Obj_t* Aig_ObjCreateCo ( Aig_Man_t p,
Aig_Obj_t pDriver 
)

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

Synopsis [Creates primary output with the given driver.]

Description []

SideEffects []

SeeAlso []

Definition at line 66 of file aigObj.c.

67 {
68  Aig_Obj_t * pObj;
69  pObj = Aig_ManFetchMemory( p );
70  pObj->Type = AIG_OBJ_CO;
71  Vec_PtrPush( p->vCos, pObj );
72  Aig_ObjConnect( p, pObj, pDriver, NULL );
73  p->nObjs[AIG_OBJ_CO]++;
74  return pObj;
75 }
static Aig_Obj_t * Aig_ManFetchMemory(Aig_Man_t *p)
Definition: aig.h:368
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: aig.h:61
unsigned int Type
Definition: aig.h:77
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
Definition: aig.h:69
void Aig_ObjConnect(Aig_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pFan0, Aig_Obj_t *pFan1)
Definition: aigObj.c:126
void Aig_ObjDelete ( Aig_Man_t p,
Aig_Obj_t pObj 
)

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

Synopsis [Deletes the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 209 of file aigObj.c.

210 {
211  assert( !Aig_IsComplement(pObj) );
212  assert( !Aig_ObjIsTerm(pObj) );
213  assert( Aig_ObjRefs(pObj) == 0 );
214  if ( p->pFanData && Aig_ObjIsBuf(pObj) )
215  Vec_PtrRemove( p->vBufs, pObj );
216  p->nObjs[pObj->Type]--;
217  Vec_PtrWriteEntry( p->vObjs, pObj->Id, NULL );
218  Aig_ManRecycleMemory( p, pObj );
219 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned int Type
Definition: aig.h:77
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static void Vec_PtrRemove(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:714
static int Aig_ObjIsBuf(Aig_Obj_t *pObj)
Definition: aig.h:277
static int Aig_ObjIsTerm(Aig_Obj_t *pObj)
Definition: aig.h:281
static void Aig_ManRecycleMemory(Aig_Man_t *p, Aig_Obj_t *pEntry)
Definition: aig.h:378
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
#define assert(ex)
Definition: util_old.h:213
static int Aig_ObjRefs(Aig_Obj_t *pObj)
Definition: aig.h:300
int Id
Definition: aig.h:85
void Aig_ObjDelete_rec ( Aig_Man_t p,
Aig_Obj_t pObj,
int  fFreeTop 
)

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

Synopsis [Deletes the MFFC of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 232 of file aigObj.c.

233 {
234  Aig_Obj_t * pFanin0, * pFanin1;
235  assert( !Aig_IsComplement(pObj) );
236  if ( Aig_ObjIsConst1(pObj) || Aig_ObjIsCi(pObj) )
237  return;
238  assert( !Aig_ObjIsCo(pObj) );
239  pFanin0 = Aig_ObjFanin0(pObj);
240  pFanin1 = Aig_ObjFanin1(pObj);
241  Aig_ObjDisconnect( p, pObj );
242  if ( fFreeTop )
243  Aig_ObjDelete( p, pObj );
244  if ( pFanin0 && !Aig_ObjIsNone(pFanin0) && Aig_ObjRefs(pFanin0) == 0 )
245  Aig_ObjDelete_rec( p, pFanin0, 1 );
246  if ( pFanin1 && !Aig_ObjIsNone(pFanin1) && Aig_ObjRefs(pFanin1) == 0 )
247  Aig_ObjDelete_rec( p, pFanin1, 1 );
248 }
void Aig_ObjDelete_rec(Aig_Man_t *p, Aig_Obj_t *pObj, int fFreeTop)
Definition: aigObj.c:232
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static int Aig_ObjIsNone(Aig_Obj_t *pObj)
Definition: aig.h:273
static int Aig_ObjIsConst1(Aig_Obj_t *pObj)
Definition: aig.h:274
Definition: aig.h:69
void Aig_ObjDelete(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aigObj.c:209
void Aig_ObjDisconnect(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aigObj.c:171
#define assert(ex)
Definition: util_old.h:213
static int Aig_ObjRefs(Aig_Obj_t *pObj)
Definition: aig.h:300
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
static int Aig_ObjIsCo(Aig_Obj_t *pObj)
Definition: aig.h:276
void Aig_ObjDeletePo ( Aig_Man_t p,
Aig_Obj_t pObj 
)

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

Synopsis [Deletes the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 261 of file aigObj.c.

262 {
263  assert( Aig_ObjIsCo(pObj) );
265  pObj->pFanin0 = NULL;
266  p->nObjs[pObj->Type]--;
267  Vec_PtrWriteEntry( p->vObjs, pObj->Id, NULL );
268  Aig_ManRecycleMemory( p, pObj );
269 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Aig_ObjDeref(Aig_Obj_t *pObj)
Definition: aig.h:302
unsigned int Type
Definition: aig.h:77
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static void Aig_ManRecycleMemory(Aig_Man_t *p, Aig_Obj_t *pEntry)
Definition: aig.h:378
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
#define assert(ex)
Definition: util_old.h:213
Aig_Obj_t * pFanin0
Definition: aig.h:75
int Id
Definition: aig.h:85
static int Aig_ObjIsCo(Aig_Obj_t *pObj)
Definition: aig.h:276
void Aig_ObjDisconnect ( Aig_Man_t p,
Aig_Obj_t pObj 
)

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

Synopsis [Disconnects the object from the fanins.]

Description []

SideEffects []

SeeAlso []

Definition at line 171 of file aigObj.c.

172 {
173  assert( !Aig_IsComplement(pObj) );
174  // remove connections
175  if ( pObj->pFanin0 != NULL )
176  {
177  if ( p->pFanData )
178  Aig_ObjRemoveFanout( p, Aig_ObjFanin0(pObj), pObj );
180  }
181  if ( pObj->pFanin1 != NULL )
182  {
183  if ( p->pFanData )
184  Aig_ObjRemoveFanout( p, Aig_ObjFanin1(pObj), pObj );
186  }
187  // remove the node from the structural hash table
188  if ( p->pTable && Aig_ObjIsHash(pObj) )
189  Aig_TableDelete( p, pObj );
190  // add the first fanin
191  pObj->pFanin0 = NULL;
192  pObj->pFanin1 = NULL;
193  // remove the node from the dynamically updated topological order
194 // if ( p->pOrderData && Aig_ObjIsNode(pObj) )
195 // Aig_ObjOrderRemove( p, pObj->Id );
196 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Aig_ObjDeref(Aig_Obj_t *pObj)
Definition: aig.h:302
Aig_Obj_t * pFanin1
Definition: aig.h:76
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
void Aig_TableDelete(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aigTable.c:196
void Aig_ObjRemoveFanout(Aig_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pFanout)
Definition: aigFanout.c:154
#define assert(ex)
Definition: util_old.h:213
Aig_Obj_t * pFanin0
Definition: aig.h:75
static int Aig_ObjIsHash(Aig_Obj_t *pObj)
Definition: aig.h:282
void Aig_ObjPatchFanin0 ( Aig_Man_t p,
Aig_Obj_t pObj,
Aig_Obj_t pFaninNew 
)

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

Synopsis [Replaces the first fanin of the node by the new fanin.]

Description []

SideEffects []

SeeAlso []

Definition at line 282 of file aigObj.c.

283 {
284  Aig_Obj_t * pFaninOld;
285  assert( !Aig_IsComplement(pObj) );
286  assert( Aig_ObjIsCo(pObj) );
287  pFaninOld = Aig_ObjFanin0(pObj);
288  // decrement ref and remove fanout
289  if ( p->pFanData )
290  Aig_ObjRemoveFanout( p, pFaninOld, pObj );
291  Aig_ObjDeref( pFaninOld );
292  // update the fanin
293  pObj->pFanin0 = pFaninNew;
294  pObj->Level = Aig_ObjLevelNew( pObj );
295  pObj->fPhase = Aig_ObjPhaseReal(pObj->pFanin0);
296  // increment ref and add fanout
297  if ( p->pFanData )
298  Aig_ObjAddFanout( p, Aig_ObjFanin0(pObj), pObj );
299  Aig_ObjRef( Aig_ObjFanin0(pObj) );
300  // get rid of old fanin
301  if ( !Aig_ObjIsCi(pFaninOld) && !Aig_ObjIsConst1(pFaninOld) && Aig_ObjRefs(pFaninOld) == 0 )
302  Aig_ObjDelete_rec( p, pFaninOld, 1 );
303 }
static int Aig_ObjLevelNew(Aig_Obj_t *pObj)
Definition: aig.h:324
void Aig_ObjDelete_rec(Aig_Man_t *p, Aig_Obj_t *pObj, int fFreeTop)
Definition: aigObj.c:232
unsigned Level
Definition: aig.h:82
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Aig_ObjDeref(Aig_Obj_t *pObj)
Definition: aig.h:302
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static void Aig_ObjRef(Aig_Obj_t *pObj)
Definition: aig.h:301
static int Aig_ObjIsConst1(Aig_Obj_t *pObj)
Definition: aig.h:274
static int Aig_ObjPhaseReal(Aig_Obj_t *pObj)
Definition: aig.h:299
Definition: aig.h:69
void Aig_ObjRemoveFanout(Aig_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pFanout)
Definition: aigFanout.c:154
unsigned int fPhase
Definition: aig.h:78
#define assert(ex)
Definition: util_old.h:213
static int Aig_ObjRefs(Aig_Obj_t *pObj)
Definition: aig.h:300
void Aig_ObjAddFanout(Aig_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pFanout)
Definition: aigFanout.c:107
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
Aig_Obj_t * pFanin0
Definition: aig.h:75
static int Aig_ObjIsCo(Aig_Obj_t *pObj)
Definition: aig.h:276
void Aig_ObjPrint ( Aig_Man_t p,
Aig_Obj_t pObj 
)

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

Synopsis [Verbose printing of the AIG node.]

Description []

SideEffects []

SeeAlso []

Definition at line 316 of file aigObj.c.

317 {
318  int fShowFanouts = 0;
319  Aig_Obj_t * pTemp;
320  if ( pObj == NULL )
321  {
322  printf( "Object is NULL." );
323  return;
324  }
325  if ( Aig_IsComplement(pObj) )
326  {
327  printf( "Compl " );
328  pObj = Aig_Not(pObj);
329  }
330  assert( !Aig_IsComplement(pObj) );
331  printf( "Node %4d : ", Aig_ObjId(pObj) );
332  if ( Aig_ObjIsConst1(pObj) )
333  printf( "constant 1" );
334  else if ( Aig_ObjIsCi(pObj) )
335  printf( "PI" );
336  else if ( Aig_ObjIsCo(pObj) )
337  printf( "PO( %4d%s )", Aig_ObjFanin0(pObj)->Id, (Aig_ObjFaninC0(pObj)? "\'" : " ") );
338  else if ( Aig_ObjIsBuf(pObj) )
339  printf( "BUF( %d%s )", Aig_ObjFanin0(pObj)->Id, (Aig_ObjFaninC0(pObj)? "\'" : " ") );
340  else
341  printf( "AND( %4d%s, %4d%s )",
342  Aig_ObjFanin0(pObj)->Id, (Aig_ObjFaninC0(pObj)? "\'" : " "),
343  Aig_ObjFanin1(pObj)->Id, (Aig_ObjFaninC1(pObj)? "\'" : " ") );
344  printf( " (refs = %3d)", Aig_ObjRefs(pObj) );
345  if ( fShowFanouts && p->pFanData )
346  {
347  Aig_Obj_t * pFanout;
348  int i;
349  int iFan = -1; // Suppress "might be used uninitialized"
350  printf( "\nFanouts:\n" );
351  Aig_ObjForEachFanout( p, pObj, pFanout, iFan, i )
352  {
353  printf( " " );
354  printf( "Node %4d : ", Aig_ObjId(pFanout) );
355  if ( Aig_ObjIsCo(pFanout) )
356  printf( "PO( %4d%s )", Aig_ObjFanin0(pFanout)->Id, (Aig_ObjFaninC0(pFanout)? "\'" : " ") );
357  else if ( Aig_ObjIsBuf(pFanout) )
358  printf( "BUF( %d%s )", Aig_ObjFanin0(pFanout)->Id, (Aig_ObjFaninC0(pFanout)? "\'" : " ") );
359  else
360  printf( "AND( %4d%s, %4d%s )",
361  Aig_ObjFanin0(pFanout)->Id, (Aig_ObjFaninC0(pFanout)? "\'" : " "),
362  Aig_ObjFanin1(pFanout)->Id, (Aig_ObjFaninC1(pFanout)? "\'" : " ") );
363  printf( "\n" );
364  }
365  return;
366  }
367  // there are choices
368  if ( p->pEquivs && p->pEquivs[pObj->Id] )
369  {
370  // print equivalence class
371  printf( " { %4d ", pObj->Id );
372  for ( pTemp = p->pEquivs[pObj->Id]; pTemp; pTemp = p->pEquivs[pTemp->Id] )
373  printf( " %4d%s", pTemp->Id, (pTemp->fPhase != pObj->fPhase)? "\'" : " " );
374  printf( " }" );
375  return;
376  }
377  // this is a secondary node
378  if ( p->pReprs && p->pReprs[pObj->Id] )
379  printf( " class of %d", pObj->Id );
380 }
#define Aig_ObjForEachFanout(p, pObj, pFanout, iFan, i)
Definition: aig.h:427
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_Not(Aig_Obj_t *p)
Definition: aig.h:247
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static int Aig_ObjIsBuf(Aig_Obj_t *pObj)
Definition: aig.h:277
static int Aig_ObjIsConst1(Aig_Obj_t *pObj)
Definition: aig.h:274
Definition: aig.h:69
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
unsigned int fPhase
Definition: aig.h:78
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
static int Aig_ObjId(Aig_Obj_t *pObj)
Definition: aig.h:286
#define assert(ex)
Definition: util_old.h:213
static int Aig_ObjRefs(Aig_Obj_t *pObj)
Definition: aig.h:300
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
int Id
Definition: aig.h:85
static int Aig_ObjIsCo(Aig_Obj_t *pObj)
Definition: aig.h:276
void Aig_ObjReplace ( Aig_Man_t p,
Aig_Obj_t pObjOld,
Aig_Obj_t pObjNew,
int  fUpdateLevel 
)

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

Synopsis [Replaces one object by another.]

Description [The new object (pObjNew) should be used instead of the old object (pObjOld). If the new object is complemented or used, the buffer is added and the new object remains in the manager; otherwise, the new object is deleted.]

SideEffects []

SeeAlso []

Definition at line 467 of file aigObj.c.

468 {
469  Aig_Obj_t * pObjNewR = Aig_Regular(pObjNew);
470  // the object to be replaced cannot be complemented
471  assert( !Aig_IsComplement(pObjOld) );
472  // the object to be replaced cannot be a terminal
473  assert( !Aig_ObjIsCi(pObjOld) && !Aig_ObjIsCo(pObjOld) );
474  // the object to be used cannot be a buffer or a PO
475  assert( !Aig_ObjIsBuf(pObjNewR) && !Aig_ObjIsCo(pObjNewR) );
476  // the object cannot be the same
477  assert( pObjOld != pObjNewR );
478  // make sure object is not pointing to itself
479  assert( pObjOld != Aig_ObjFanin0(pObjNewR) );
480  assert( pObjOld != Aig_ObjFanin1(pObjNewR) );
481  if ( pObjOld == Aig_ObjFanin0(pObjNewR) || pObjOld == Aig_ObjFanin1(pObjNewR) )
482  {
483  printf( "Aig_ObjReplace(): Internal error!\n" );
484  exit(1);
485  }
486  // recursively delete the old node - but leave the object there
487  pObjNewR->nRefs++;
488  Aig_ObjDelete_rec( p, pObjOld, 0 );
489  pObjNewR->nRefs--;
490  // if the new object is complemented or already used, create a buffer
491  p->nObjs[pObjOld->Type]--;
492  if ( Aig_IsComplement(pObjNew) || Aig_ObjRefs(pObjNew) > 0 || !Aig_ObjIsNode(pObjNew) )
493  {
494  pObjOld->Type = AIG_OBJ_BUF;
495  Aig_ObjConnect( p, pObjOld, pObjNew, NULL );
496  p->nBufReplaces++;
497  }
498  else
499  {
500  Aig_Obj_t * pFanin0 = pObjNew->pFanin0;
501  Aig_Obj_t * pFanin1 = pObjNew->pFanin1;
502  int LevelOld = pObjOld->Level;
503  pObjOld->Type = pObjNew->Type;
504  Aig_ObjDisconnect( p, pObjNew );
505  Aig_ObjConnect( p, pObjOld, pFanin0, pFanin1 );
506  // delete the new object
507  Aig_ObjDelete( p, pObjNew );
508  // update levels
509  if ( p->pFanData )
510  {
511  pObjOld->Level = LevelOld;
512  Aig_ManUpdateLevel( p, pObjOld );
513  }
514  if ( fUpdateLevel )
515  {
516  Aig_ObjClearReverseLevel( p, pObjOld );
517  Aig_ManUpdateReverseLevel( p, pObjOld );
518  }
519  }
520  p->nObjs[pObjOld->Type]++;
521  // store buffers if fanout is allocated
522  if ( p->pFanData && Aig_ObjIsBuf(pObjOld) )
523  {
524  Vec_PtrPush( p->vBufs, pObjOld );
525  p->nBufMax = Abc_MaxInt( p->nBufMax, Vec_PtrSize(p->vBufs) );
526  Aig_ManPropagateBuffers( p, fUpdateLevel );
527  }
528 }
VOID_HACK exit()
void Aig_ObjDelete_rec(Aig_Man_t *p, Aig_Obj_t *pObj, int fFreeTop)
Definition: aigObj.c:232
unsigned Level
Definition: aig.h:82
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Aig_Obj_t * pFanin1
Definition: aig.h:76
unsigned int Type
Definition: aig.h:77
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_Regular(Aig_Obj_t *p)
Definition: aig.h:246
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
int Aig_ManPropagateBuffers(Aig_Man_t *p, int fUpdateLevel)
Definition: aigObj.c:432
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
void Aig_ManUpdateReverseLevel(Aig_Man_t *p, Aig_Obj_t *pObjNew)
Definition: aigTiming.c:247
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
static int Aig_ObjIsBuf(Aig_Obj_t *pObj)
Definition: aig.h:277
void Aig_ObjClearReverseLevel(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aigTiming.c:83
Definition: aig.h:69
void Aig_ObjDelete(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aigObj.c:209
void Aig_ObjDisconnect(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aigObj.c:171
#define assert(ex)
Definition: util_old.h:213
static int Aig_ObjRefs(Aig_Obj_t *pObj)
Definition: aig.h:300
void Aig_ObjConnect(Aig_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pFan0, Aig_Obj_t *pFan1)
Definition: aigObj.c:126
void Aig_ManUpdateLevel(Aig_Man_t *p, Aig_Obj_t *pObjNew)
Definition: aigTiming.c:195
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
Aig_Obj_t * pFanin0
Definition: aig.h:75
static int Aig_ObjIsCo(Aig_Obj_t *pObj)
Definition: aig.h:276
unsigned int nRefs
Definition: aig.h:81