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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START
Ivy_Obj_t
Ivy_ObjCreatePi (Ivy_Man_t *p)
 DECLARATIONS ///. More...
 
Ivy_Obj_tIvy_ObjCreatePo (Ivy_Man_t *p, Ivy_Obj_t *pDriver)
 
Ivy_Obj_tIvy_ObjCreate (Ivy_Man_t *p, Ivy_Obj_t *pGhost)
 
void Ivy_ObjConnect (Ivy_Man_t *p, Ivy_Obj_t *pObj, Ivy_Obj_t *pFan0, Ivy_Obj_t *pFan1)
 
void Ivy_ObjDisconnect (Ivy_Man_t *p, Ivy_Obj_t *pObj)
 
void Ivy_ObjPatchFanin0 (Ivy_Man_t *p, Ivy_Obj_t *pObj, Ivy_Obj_t *pFaninNew)
 
void Ivy_ObjDelete (Ivy_Man_t *p, Ivy_Obj_t *pObj, int fFreeTop)
 
void Ivy_ObjDelete_rec (Ivy_Man_t *p, Ivy_Obj_t *pObj, int fFreeTop)
 
void Ivy_ObjReplace (Ivy_Man_t *p, Ivy_Obj_t *pObjOld, Ivy_Obj_t *pObjNew, int fDeleteOld, int fFreeTop, int fUpdateLevel)
 
void Ivy_NodeFixBufferFanins (Ivy_Man_t *p, Ivy_Obj_t *pNode, int fUpdateLevel)
 

Function Documentation

void Ivy_NodeFixBufferFanins ( Ivy_Man_t p,
Ivy_Obj_t pNode,
int  fUpdateLevel 
)

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

Synopsis [Fixes buffer fanins.]

Description [This situation happens because NodeReplace is a lazy procedure, which does not propagate the change to the fanouts but instead records the change in the form of a buf/inv node.]

SideEffects []

SeeAlso []

Definition at line 442 of file ivyObj.c.

443 {
444  Ivy_Obj_t * pFanReal0, * pFanReal1, * pResult;
445  if ( Ivy_ObjIsPo(pNode) )
446  {
447  if ( !Ivy_ObjIsBuf(Ivy_ObjFanin0(pNode)) )
448  return;
449  pFanReal0 = Ivy_ObjReal( Ivy_ObjChild0(pNode) );
450  Ivy_ObjPatchFanin0( p, pNode, pFanReal0 );
451 // Ivy_ManCheckFanouts( p );
452  return;
453  }
454  if ( !Ivy_ObjIsBuf(Ivy_ObjFanin0(pNode)) && !Ivy_ObjIsBuf(Ivy_ObjFanin1(pNode)) )
455  return;
456  // get the real fanins
457  pFanReal0 = Ivy_ObjReal( Ivy_ObjChild0(pNode) );
458  pFanReal1 = Ivy_ObjReal( Ivy_ObjChild1(pNode) );
459  // get the new node
460  if ( Ivy_ObjIsNode(pNode) )
461  pResult = Ivy_Oper( p, pFanReal0, pFanReal1, Ivy_ObjType(pNode) );
462  else if ( Ivy_ObjIsLatch(pNode) )
463  pResult = Ivy_Latch( p, pFanReal0, Ivy_ObjInit(pNode) );
464  else
465  assert( 0 );
466 
467 //printf( "===== Replacing %d by %d.\n", pNode->Id, pResult->Id );
468 //Ivy_ObjPrintVerbose( p, pNode, 0 ); printf( "\n" );
469 //Ivy_ObjPrintVerbose( p, pResult, 0 ); printf( "\n" );
470 
471  // perform the replacement
472  Ivy_ObjReplace( p, pNode, pResult, 1, 0, fUpdateLevel );
473 }
Ivy_Obj_t * Ivy_Latch(Ivy_Man_t *p, Ivy_Obj_t *pObj, Ivy_Init_t Init)
Definition: ivyOper.c:287
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Ivy_Obj_t * Ivy_Oper(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1, Ivy_Type_t Type)
FUNCTION DEFINITIONS ///.
Definition: ivyOper.c:63
static int Ivy_ObjIsLatch(Ivy_Obj_t *pObj)
Definition: ivy.h:241
static Ivy_Obj_t * Ivy_ObjFanin1(Ivy_Obj_t *pObj)
Definition: ivy.h:272
static Ivy_Obj_t * Ivy_ObjFanin0(Ivy_Obj_t *pObj)
Definition: ivy.h:271
Ivy_Obj_t * Ivy_ObjReal(Ivy_Obj_t *pObj)
Definition: ivyUtil.c:609
Definition: ivy.h:73
static Ivy_Type_t Ivy_ObjType(Ivy_Obj_t *pObj)
Definition: ivy.h:231
static int Ivy_ObjIsNode(Ivy_Obj_t *pObj)
Definition: ivy.h:245
void Ivy_ObjReplace(Ivy_Man_t *p, Ivy_Obj_t *pObjOld, Ivy_Obj_t *pObjNew, int fDeleteOld, int fFreeTop, int fUpdateLevel)
Definition: ivyObj.c:328
static Ivy_Obj_t * Ivy_ObjChild0(Ivy_Obj_t *pObj)
Definition: ivy.h:273
void Ivy_ObjPatchFanin0(Ivy_Man_t *p, Ivy_Obj_t *pObj, Ivy_Obj_t *pFaninNew)
Definition: ivyObj.c:224
static int Ivy_ObjIsBuf(Ivy_Obj_t *pObj)
Definition: ivy.h:244
static Ivy_Obj_t * Ivy_ObjChild1(Ivy_Obj_t *pObj)
Definition: ivy.h:274
static int Ivy_ObjIsPo(Ivy_Obj_t *pObj)
Definition: ivy.h:237
#define assert(ex)
Definition: util_old.h:213
static Ivy_Init_t Ivy_ObjInit(Ivy_Obj_t *pObj)
Definition: ivy.h:232
void Ivy_ObjConnect ( Ivy_Man_t p,
Ivy_Obj_t pObj,
Ivy_Obj_t pFan0,
Ivy_Obj_t pFan1 
)

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

Synopsis [Connect the object to the fanin.]

Description []

SideEffects []

SeeAlso []

Definition at line 150 of file ivyObj.c.

151 {
152  assert( !Ivy_IsComplement(pObj) );
153  assert( Ivy_ObjIsPi(pObj) || Ivy_ObjIsOneFanin(pObj) || pFan1 != NULL );
154  // add the first fanin
155  pObj->pFanin0 = pFan0;
156  pObj->pFanin1 = pFan1;
157  // increment references of the fanins and add their fanouts
158  if ( Ivy_ObjFanin0(pObj) != NULL )
159  {
160  Ivy_ObjRefsInc( Ivy_ObjFanin0(pObj) );
161  if ( p->fFanout )
162  Ivy_ObjAddFanout( p, Ivy_ObjFanin0(pObj), pObj );
163  }
164  if ( Ivy_ObjFanin1(pObj) != NULL )
165  {
166  Ivy_ObjRefsInc( Ivy_ObjFanin1(pObj) );
167  if ( p->fFanout )
168  Ivy_ObjAddFanout( p, Ivy_ObjFanin1(pObj), pObj );
169  }
170  // add the node to the structural hash table
171  Ivy_TableInsert( p, pObj );
172 }
static int Ivy_IsComplement(Ivy_Obj_t *p)
Definition: ivy.h:196
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Ivy_ObjIsPi(Ivy_Obj_t *pObj)
Definition: ivy.h:236
Ivy_Obj_t * pFanin1
Definition: ivy.h:87
static void Ivy_ObjRefsInc(Ivy_Obj_t *pObj)
Definition: ivy.h:265
static Ivy_Obj_t * Ivy_ObjFanin1(Ivy_Obj_t *pObj)
Definition: ivy.h:272
void Ivy_ObjAddFanout(Ivy_Man_t *p, Ivy_Obj_t *pObj, Ivy_Obj_t *pFanout)
Definition: ivyFanout.c:183
Ivy_Obj_t * pFanin0
Definition: ivy.h:86
void Ivy_TableInsert(Ivy_Man_t *p, Ivy_Obj_t *pObj)
Definition: ivyTable.c:105
static Ivy_Obj_t * Ivy_ObjFanin0(Ivy_Obj_t *pObj)
Definition: ivy.h:271
static int Ivy_ObjIsOneFanin(Ivy_Obj_t *pObj)
Definition: ivy.h:248
#define assert(ex)
Definition: util_old.h:213
Ivy_Obj_t* Ivy_ObjCreate ( Ivy_Man_t p,
Ivy_Obj_t pGhost 
)

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 77 of file ivyObj.c.

78 {
79  Ivy_Obj_t * pObj;
80  assert( !Ivy_IsComplement(pGhost) );
81  assert( Ivy_ObjIsGhost(pGhost) );
82  assert( Ivy_TableLookup(p, pGhost) == NULL );
83  // get memory for the new object
84  pObj = Ivy_ManFetchMemory( p );
85  assert( Ivy_ObjIsNone(pObj) );
86  pObj->Id = Vec_PtrSize(p->vObjs);
87  Vec_PtrPush( p->vObjs, pObj );
88  // add basic info (fanins, compls, type, init)
89  pObj->Type = pGhost->Type;
90  pObj->Init = pGhost->Init;
91  // add connections
92  Ivy_ObjConnect( p, pObj, pGhost->pFanin0, pGhost->pFanin1 );
93  // compute level
94  if ( Ivy_ObjIsNode(pObj) )
95  pObj->Level = Ivy_ObjLevelNew(pObj);
96  else if ( Ivy_ObjIsLatch(pObj) )
97  pObj->Level = 0;
98  else if ( Ivy_ObjIsOneFanin(pObj) )
99  pObj->Level = Ivy_ObjFanin0(pObj)->Level;
100  else if ( !Ivy_ObjIsPi(pObj) )
101  assert( 0 );
102  // create phase
103  if ( Ivy_ObjIsNode(pObj) )
105  else if ( Ivy_ObjIsOneFanin(pObj) )
106  pObj->fPhase = Ivy_ObjFaninPhase(Ivy_ObjChild0(pObj));
107  // set the fail TFO flag
108  if ( Ivy_ObjIsNode(pObj) )
109  pObj->fFailTfo = Ivy_ObjFanin0(pObj)->fFailTfo | Ivy_ObjFanin1(pObj)->fFailTfo;
110  // mark the fanins in a special way if the node is EXOR
111  if ( Ivy_ObjIsExor(pObj) )
112  {
113  Ivy_ObjFanin0(pObj)->fExFan = 1;
114  Ivy_ObjFanin1(pObj)->fExFan = 1;
115  }
116  // add PIs/POs to the arrays
117  if ( Ivy_ObjIsPi(pObj) )
118  Vec_PtrPush( p->vPis, pObj );
119  else if ( Ivy_ObjIsPo(pObj) )
120  Vec_PtrPush( p->vPos, pObj );
121 // else if ( Ivy_ObjIsBuf(pObj) )
122 // Vec_PtrPush( p->vBufs, pObj );
123  if ( p->vRequired && Vec_IntSize(p->vRequired) <= pObj->Id )
124  Vec_IntFillExtra( p->vRequired, 2 * Vec_IntSize(p->vRequired), 1000000 );
125  // update node counters of the manager
126  p->nObjs[Ivy_ObjType(pObj)]++;
127  p->nCreated++;
128 
129 // printf( "Adding %sAIG node: ", p->pHaig==NULL? "H":" " );
130 // Ivy_ObjPrintVerbose( p, pObj, p->pHaig==NULL );
131 // printf( "\n" );
132 
133  // if HAIG is defined, create a corresponding node
134  if ( p->pHaig )
135  Ivy_ManHaigCreateObj( p, pObj );
136  return pObj;
137 }
static int Ivy_IsComplement(Ivy_Obj_t *p)
Definition: ivy.h:196
unsigned Level
Definition: ivy.h:84
unsigned Init
Definition: ivy.h:83
static int Ivy_ObjLevelNew(Ivy_Obj_t *pObj)
Definition: ivy.h:279
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_IntFillExtra(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:376
static int Ivy_ObjIsPi(Ivy_Obj_t *pObj)
Definition: ivy.h:236
Ivy_Obj_t * pFanin1
Definition: ivy.h:87
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Ivy_ObjIsNone(Ivy_Obj_t *pObj)
Definition: ivy.h:235
int Id
Definition: ivy.h:75
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Ivy_ObjIsLatch(Ivy_Obj_t *pObj)
Definition: ivy.h:241
static Ivy_Obj_t * Ivy_ObjFanin1(Ivy_Obj_t *pObj)
Definition: ivy.h:272
unsigned fExFan
Definition: ivy.h:80
Ivy_Obj_t * pFanin0
Definition: ivy.h:86
static Ivy_Obj_t * Ivy_ObjFanin0(Ivy_Obj_t *pObj)
Definition: ivy.h:271
Ivy_Obj_t * Ivy_TableLookup(Ivy_Man_t *p, Ivy_Obj_t *pObj)
FUNCTION DEFINITIONS ///.
Definition: ivyTable.c:71
unsigned fPhase
Definition: ivy.h:81
unsigned Type
Definition: ivy.h:77
static int Ivy_ObjIsOneFanin(Ivy_Obj_t *pObj)
Definition: ivy.h:248
Definition: ivy.h:73
static Ivy_Type_t Ivy_ObjType(Ivy_Obj_t *pObj)
Definition: ivy.h:231
static int Ivy_ObjIsNode(Ivy_Obj_t *pObj)
Definition: ivy.h:245
static Ivy_Obj_t * Ivy_ObjChild0(Ivy_Obj_t *pObj)
Definition: ivy.h:273
unsigned fFailTfo
Definition: ivy.h:82
void Ivy_ObjConnect(Ivy_Man_t *p, Ivy_Obj_t *pObj, Ivy_Obj_t *pFan0, Ivy_Obj_t *pFan1)
Definition: ivyObj.c:150
static int Ivy_ObjIsExor(Ivy_Obj_t *pObj)
Definition: ivy.h:243
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Ivy_ObjIsGhost(Ivy_Obj_t *pObj)
Definition: ivy.h:234
static Ivy_Obj_t * Ivy_ObjChild1(Ivy_Obj_t *pObj)
Definition: ivy.h:274
static int Ivy_ObjFaninPhase(Ivy_Obj_t *pObj)
Definition: ivy.h:280
static int Ivy_ObjIsPo(Ivy_Obj_t *pObj)
Definition: ivy.h:237
#define assert(ex)
Definition: util_old.h:213
static Ivy_Obj_t * Ivy_ManFetchMemory(Ivy_Man_t *p)
Definition: ivy.h:364
void Ivy_ManHaigCreateObj(Ivy_Man_t *p, Ivy_Obj_t *pObj)
Definition: ivyHaig.c:183
ABC_NAMESPACE_IMPL_START Ivy_Obj_t* Ivy_ObjCreatePi ( Ivy_Man_t p)

DECLARATIONS ///.

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

FileName [ivyObj.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [And-Inverter Graph package.]

Synopsis [Adding/removing objects.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - May 11, 2006.]

Revision [

Id:
ivyObj.c,v 1.00 2006/05/11 00:00:00 alanmi Exp

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file ivyObj.c.

46 {
47  return Ivy_ObjCreate( p, Ivy_ObjCreateGhost(p, NULL, NULL, IVY_PI, IVY_INIT_NONE) );
48 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Ivy_Obj_t * Ivy_ObjCreateGhost(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1, Ivy_Type_t Type, Ivy_Init_t Init)
Definition: ivy.h:308
Ivy_Obj_t * Ivy_ObjCreate(Ivy_Man_t *p, Ivy_Obj_t *pGhost)
Definition: ivyObj.c:77
Definition: ivy.h:54
Ivy_Obj_t* Ivy_ObjCreatePo ( Ivy_Man_t p,
Ivy_Obj_t pDriver 
)

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 61 of file ivyObj.c.

62 {
63  return Ivy_ObjCreate( p, Ivy_ObjCreateGhost(p, pDriver, NULL, IVY_PO, IVY_INIT_NONE) );
64 }
Definition: ivy.h:55
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Ivy_Obj_t * Ivy_ObjCreateGhost(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1, Ivy_Type_t Type, Ivy_Init_t Init)
Definition: ivy.h:308
Ivy_Obj_t * Ivy_ObjCreate(Ivy_Man_t *p, Ivy_Obj_t *pGhost)
Definition: ivyObj.c:77
void Ivy_ObjDelete ( Ivy_Man_t p,
Ivy_Obj_t pObj,
int  fFreeTop 
)

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

Synopsis [Deletes the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 255 of file ivyObj.c.

256 {
257  assert( !Ivy_IsComplement(pObj) );
258  assert( Ivy_ObjRefs(pObj) == 0 || !fFreeTop );
259  // update node counters of the manager
260  p->nObjs[pObj->Type]--;
261  p->nDeleted++;
262  // remove connections
263  Ivy_ObjDisconnect( p, pObj );
264  // remove PIs/POs from the arrays
265  if ( Ivy_ObjIsPi(pObj) )
266  Vec_PtrRemove( p->vPis, pObj );
267  else if ( Ivy_ObjIsPo(pObj) )
268  Vec_PtrRemove( p->vPos, pObj );
269  else if ( p->fFanout && Ivy_ObjIsBuf(pObj) )
270  Vec_PtrRemove( p->vBufs, pObj );
271  // clean and recycle the entry
272  if ( fFreeTop )
273  {
274  // free the node
275  Vec_PtrWriteEntry( p->vObjs, pObj->Id, NULL );
276  Ivy_ManRecycleMemory( p, pObj );
277  }
278  else
279  {
280  int nRefsOld = pObj->nRefs;
281  Ivy_Obj_t * pFanout = pObj->pFanout;
282  Ivy_ObjClean( pObj );
283  pObj->pFanout = pFanout;
284  pObj->nRefs = nRefsOld;
285  }
286 }
static int Ivy_IsComplement(Ivy_Obj_t *p)
Definition: ivy.h:196
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Ivy_ObjIsPi(Ivy_Obj_t *pObj)
Definition: ivy.h:236
Ivy_Obj_t * pFanout
Definition: ivy.h:88
int Id
Definition: ivy.h:75
static void Vec_PtrRemove(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:714
static int Ivy_ObjRefs(Ivy_Obj_t *pObj)
Definition: ivy.h:264
void Ivy_ObjDisconnect(Ivy_Man_t *p, Ivy_Obj_t *pObj)
Definition: ivyObj.c:185
unsigned Type
Definition: ivy.h:77
Definition: ivy.h:73
static void Ivy_ObjClean(Ivy_Obj_t *pObj)
Definition: ivy.h:282
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
static void Ivy_ManRecycleMemory(Ivy_Man_t *p, Ivy_Obj_t *pEntry)
Definition: ivy.h:374
static int Ivy_ObjIsBuf(Ivy_Obj_t *pObj)
Definition: ivy.h:244
static int Ivy_ObjIsPo(Ivy_Obj_t *pObj)
Definition: ivy.h:237
#define assert(ex)
Definition: util_old.h:213
int nRefs
Definition: ivy.h:85
void Ivy_ObjDelete_rec ( Ivy_Man_t p,
Ivy_Obj_t pObj,
int  fFreeTop 
)

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

Synopsis [Deletes the MFFC of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 299 of file ivyObj.c.

300 {
301  Ivy_Obj_t * pFanin0, * pFanin1;
302  assert( !Ivy_IsComplement(pObj) );
303  assert( !Ivy_ObjIsNone(pObj) );
304  if ( Ivy_ObjIsConst1(pObj) || Ivy_ObjIsPi(pObj) )
305  return;
306  pFanin0 = Ivy_ObjFanin0(pObj);
307  pFanin1 = Ivy_ObjFanin1(pObj);
308  Ivy_ObjDelete( p, pObj, fFreeTop );
309  if ( pFanin0 && !Ivy_ObjIsNone(pFanin0) && Ivy_ObjRefs(pFanin0) == 0 )
310  Ivy_ObjDelete_rec( p, pFanin0, 1 );
311  if ( pFanin1 && !Ivy_ObjIsNone(pFanin1) && Ivy_ObjRefs(pFanin1) == 0 )
312  Ivy_ObjDelete_rec( p, pFanin1, 1 );
313 }
static int Ivy_IsComplement(Ivy_Obj_t *p)
Definition: ivy.h:196
void Ivy_ObjDelete_rec(Ivy_Man_t *p, Ivy_Obj_t *pObj, int fFreeTop)
Definition: ivyObj.c:299
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Ivy_ObjIsPi(Ivy_Obj_t *pObj)
Definition: ivy.h:236
static int Ivy_ObjIsNone(Ivy_Obj_t *pObj)
Definition: ivy.h:235
void Ivy_ObjDelete(Ivy_Man_t *p, Ivy_Obj_t *pObj, int fFreeTop)
Definition: ivyObj.c:255
static Ivy_Obj_t * Ivy_ObjFanin1(Ivy_Obj_t *pObj)
Definition: ivy.h:272
static Ivy_Obj_t * Ivy_ObjFanin0(Ivy_Obj_t *pObj)
Definition: ivy.h:271
static int Ivy_ObjRefs(Ivy_Obj_t *pObj)
Definition: ivy.h:264
Definition: ivy.h:73
static int Ivy_ObjIsConst1(Ivy_Obj_t *pObj)
Definition: ivy.h:233
#define assert(ex)
Definition: util_old.h:213
void Ivy_ObjDisconnect ( Ivy_Man_t p,
Ivy_Obj_t pObj 
)

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

Synopsis [Connect the object to the fanin.]

Description []

SideEffects []

SeeAlso []

Definition at line 185 of file ivyObj.c.

186 {
187  assert( !Ivy_IsComplement(pObj) );
188  assert( Ivy_ObjIsPi(pObj) || Ivy_ObjIsOneFanin(pObj) || Ivy_ObjFanin1(pObj) != NULL );
189  // remove connections
190  if ( pObj->pFanin0 != NULL )
191  {
193  if ( p->fFanout )
194  Ivy_ObjDeleteFanout( p, Ivy_ObjFanin0(pObj), pObj );
195  }
196  if ( pObj->pFanin1 != NULL )
197  {
199  if ( p->fFanout )
200  Ivy_ObjDeleteFanout( p, Ivy_ObjFanin1(pObj), pObj );
201  }
202  assert( pObj->pNextFan0 == NULL );
203  assert( pObj->pNextFan1 == NULL );
204  assert( pObj->pPrevFan0 == NULL );
205  assert( pObj->pPrevFan1 == NULL );
206  // remove the node from the structural hash table
207  Ivy_TableDelete( p, pObj );
208  // add the first fanin
209  pObj->pFanin0 = NULL;
210  pObj->pFanin1 = NULL;
211 }
static int Ivy_IsComplement(Ivy_Obj_t *p)
Definition: ivy.h:196
Ivy_Obj_t * pPrevFan0
Definition: ivy.h:91
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Ivy_ObjIsPi(Ivy_Obj_t *pObj)
Definition: ivy.h:236
Ivy_Obj_t * pFanin1
Definition: ivy.h:87
void Ivy_TableDelete(Ivy_Man_t *p, Ivy_Obj_t *pObj)
Definition: ivyTable.c:132
Ivy_Obj_t * pNextFan0
Definition: ivy.h:89
static Ivy_Obj_t * Ivy_ObjFanin1(Ivy_Obj_t *pObj)
Definition: ivy.h:272
Ivy_Obj_t * pNextFan1
Definition: ivy.h:90
Ivy_Obj_t * pFanin0
Definition: ivy.h:86
void Ivy_ObjDeleteFanout(Ivy_Man_t *p, Ivy_Obj_t *pObj, Ivy_Obj_t *pFanout)
Definition: ivyFanout.c:205
static Ivy_Obj_t * Ivy_ObjFanin0(Ivy_Obj_t *pObj)
Definition: ivy.h:271
static void Ivy_ObjRefsDec(Ivy_Obj_t *pObj)
Definition: ivy.h:266
static int Ivy_ObjIsOneFanin(Ivy_Obj_t *pObj)
Definition: ivy.h:248
#define assert(ex)
Definition: util_old.h:213
Ivy_Obj_t * pPrevFan1
Definition: ivy.h:92
void Ivy_ObjPatchFanin0 ( Ivy_Man_t p,
Ivy_Obj_t pObj,
Ivy_Obj_t pFaninNew 
)

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 224 of file ivyObj.c.

225 {
226  Ivy_Obj_t * pFaninOld;
227  assert( !Ivy_IsComplement(pObj) );
228  pFaninOld = Ivy_ObjFanin0(pObj);
229  // decrement ref and remove fanout
230  Ivy_ObjRefsDec( pFaninOld );
231  if ( p->fFanout )
232  Ivy_ObjDeleteFanout( p, pFaninOld, pObj );
233  // update the fanin
234  pObj->pFanin0 = pFaninNew;
235  // increment ref and add fanout
236  Ivy_ObjRefsInc( Ivy_Regular(pFaninNew) );
237  if ( p->fFanout )
238  Ivy_ObjAddFanout( p, Ivy_Regular(pFaninNew), pObj );
239  // get rid of old fanin
240  if ( !Ivy_ObjIsPi(pFaninOld) && !Ivy_ObjIsConst1(pFaninOld) && Ivy_ObjRefs(pFaninOld) == 0 )
241  Ivy_ObjDelete_rec( p, pFaninOld, 1 );
242 }
static int Ivy_IsComplement(Ivy_Obj_t *p)
Definition: ivy.h:196
void Ivy_ObjDelete_rec(Ivy_Man_t *p, Ivy_Obj_t *pObj, int fFreeTop)
Definition: ivyObj.c:299
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Ivy_ObjIsPi(Ivy_Obj_t *pObj)
Definition: ivy.h:236
static void Ivy_ObjRefsInc(Ivy_Obj_t *pObj)
Definition: ivy.h:265
void Ivy_ObjAddFanout(Ivy_Man_t *p, Ivy_Obj_t *pObj, Ivy_Obj_t *pFanout)
Definition: ivyFanout.c:183
Ivy_Obj_t * pFanin0
Definition: ivy.h:86
void Ivy_ObjDeleteFanout(Ivy_Man_t *p, Ivy_Obj_t *pObj, Ivy_Obj_t *pFanout)
Definition: ivyFanout.c:205
static Ivy_Obj_t * Ivy_ObjFanin0(Ivy_Obj_t *pObj)
Definition: ivy.h:271
static int Ivy_ObjRefs(Ivy_Obj_t *pObj)
Definition: ivy.h:264
static void Ivy_ObjRefsDec(Ivy_Obj_t *pObj)
Definition: ivy.h:266
Definition: ivy.h:73
static Ivy_Obj_t * Ivy_Regular(Ivy_Obj_t *p)
Definition: ivy.h:193
static int Ivy_ObjIsConst1(Ivy_Obj_t *pObj)
Definition: ivy.h:233
#define assert(ex)
Definition: util_old.h:213
void Ivy_ObjReplace ( Ivy_Man_t p,
Ivy_Obj_t pObjOld,
Ivy_Obj_t pObjNew,
int  fDeleteOld,
int  fFreeTop,
int  fUpdateLevel 
)

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

Synopsis [Replaces one object by another.]

Description [Both objects are currently in the manager. 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.]

SideEffects []

SeeAlso []

Definition at line 328 of file ivyObj.c.

329 {
330  int nRefsOld;//, clk;
331  // the object to be replaced cannot be complemented
332  assert( !Ivy_IsComplement(pObjOld) );
333  // the object to be replaced cannot be a terminal
334  assert( Ivy_ObjIsNone(pObjOld) || !Ivy_ObjIsPi(pObjOld) );
335  // the object to be used cannot be a PO or assert
336  assert( !Ivy_ObjIsBuf(Ivy_Regular(pObjNew)) );
337  // the object cannot be the same
338  assert( pObjOld != Ivy_Regular(pObjNew) );
339 //printf( "Replacing %d by %d.\n", Ivy_Regular(pObjOld)->Id, Ivy_Regular(pObjNew)->Id );
340 
341  // if HAIG is defined, create the choice node
342  if ( p->pHaig )
343  {
344 // if ( pObjOld->Id == 31 )
345 // {
346 // Ivy_ManShow( p, 0 );
347 // Ivy_ManShow( p->pHaig, 1 );
348 // }
349  Ivy_ManHaigCreateChoice( p, pObjOld, pObjNew );
350  }
351  // if the new object is complemented or already used, add the buffer
352  if ( Ivy_IsComplement(pObjNew) || Ivy_ObjIsLatch(pObjNew) || Ivy_ObjRefs(pObjNew) > 0 || Ivy_ObjIsPi(pObjNew) || Ivy_ObjIsConst1(pObjNew) )
353  pObjNew = Ivy_ObjCreate( p, Ivy_ObjCreateGhost(p, pObjNew, NULL, IVY_BUF, IVY_INIT_NONE) );
354  assert( !Ivy_IsComplement(pObjNew) );
355  if ( fUpdateLevel )
356  {
357 //clk = Abc_Clock();
358  // if the new node's arrival time is different, recursively update arrival time of the fanouts
359  if ( p->fFanout && !Ivy_ObjIsBuf(pObjNew) && pObjOld->Level != pObjNew->Level )
360  {
361  assert( Ivy_ObjIsNode(pObjOld) );
362  pObjOld->Level = pObjNew->Level;
363  Ivy_ObjUpdateLevel_rec( p, pObjOld );
364  }
365 //p->time1 += Abc_Clock() - clk;
366  // if the new node's required time has changed, recursively update required time of the fanins
367 //clk = Abc_Clock();
368  if ( p->vRequired )
369  {
370  int ReqNew = Vec_IntEntry(p->vRequired, pObjOld->Id);
371  if ( ReqNew < Vec_IntEntry(p->vRequired, pObjNew->Id) )
372  {
373  Vec_IntWriteEntry( p->vRequired, pObjNew->Id, ReqNew );
374  Ivy_ObjUpdateLevelR_rec( p, pObjNew, ReqNew );
375  }
376  }
377 //p->time2 += Abc_Clock() - clk;
378  }
379  // delete the old object
380  if ( fDeleteOld )
381  Ivy_ObjDelete_rec( p, pObjOld, fFreeTop );
382  // make sure object is not pointing to itself
383  assert( Ivy_ObjFanin0(pObjNew) == NULL || pObjOld != Ivy_ObjFanin0(pObjNew) );
384  assert( Ivy_ObjFanin1(pObjNew) == NULL || pObjOld != Ivy_ObjFanin1(pObjNew) );
385  // make sure the old node has no fanin fanout pointers
386  if ( p->fFanout )
387  {
388  assert( pObjOld->pFanout != NULL );
389  assert( pObjNew->pFanout == NULL );
390  pObjNew->pFanout = pObjOld->pFanout;
391  }
392  // transfer the old object
393  assert( Ivy_ObjRefs(pObjNew) == 0 );
394  nRefsOld = pObjOld->nRefs;
395  Ivy_ObjOverwrite( pObjOld, pObjNew );
396  pObjOld->nRefs = nRefsOld;
397  // patch the fanout of the fanins
398  if ( p->fFanout )
399  {
400  Ivy_ObjPatchFanout( p, Ivy_ObjFanin0(pObjOld), pObjNew, pObjOld );
401  if ( Ivy_ObjFanin1(pObjOld) )
402  Ivy_ObjPatchFanout( p, Ivy_ObjFanin1(pObjOld), pObjNew, pObjOld );
403  }
404  // update the hash table
405  Ivy_TableUpdate( p, pObjNew, pObjOld->Id );
406  // recycle the object that was taken over by pObjOld
407  Vec_PtrWriteEntry( p->vObjs, pObjNew->Id, NULL );
408  Ivy_ManRecycleMemory( p, pObjNew );
409  // if the new node is the buffer propagate it
410  if ( p->fFanout && Ivy_ObjIsBuf(pObjOld) )
411  Vec_PtrPush( p->vBufs, pObjOld );
412 // Ivy_ManCheckFanouts( p );
413 // printf( "\n" );
414 /*
415  if ( p->pHaig )
416  {
417  int x;
418  Ivy_ManShow( p, 0, NULL );
419  Ivy_ManShow( p->pHaig, 1, NULL );
420  x = 0;
421  }
422 */
423 // if ( Ivy_ManCheckFanoutNums(p) )
424 // {
425 // int x = 0;
426 // }
427 }
static int Ivy_IsComplement(Ivy_Obj_t *p)
Definition: ivy.h:196
unsigned Level
Definition: ivy.h:84
void Ivy_ObjDelete_rec(Ivy_Man_t *p, Ivy_Obj_t *pObj, int fFreeTop)
Definition: ivyObj.c:299
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Ivy_ObjIsPi(Ivy_Obj_t *pObj)
Definition: ivy.h:236
static void Ivy_ObjOverwrite(Ivy_Obj_t *pBase, Ivy_Obj_t *pData)
Definition: ivy.h:288
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Ivy_ObjIsNone(Ivy_Obj_t *pObj)
Definition: ivy.h:235
Ivy_Obj_t * pFanout
Definition: ivy.h:88
int Id
Definition: ivy.h:75
static int Ivy_ObjIsLatch(Ivy_Obj_t *pObj)
Definition: ivy.h:241
void Ivy_ObjUpdateLevel_rec(Ivy_Man_t *p, Ivy_Obj_t *pObj)
Definition: ivyUtil.c:382
static Ivy_Obj_t * Ivy_ObjFanin1(Ivy_Obj_t *pObj)
Definition: ivy.h:272
static Ivy_Obj_t * Ivy_ObjFanin0(Ivy_Obj_t *pObj)
Definition: ivy.h:271
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Ivy_ObjRefs(Ivy_Obj_t *pObj)
Definition: ivy.h:264
void Ivy_ManHaigCreateChoice(Ivy_Man_t *p, Ivy_Obj_t *pObjOld, Ivy_Obj_t *pObjNew)
Definition: ivyHaig.c:246
Definition: ivy.h:60
static Ivy_Obj_t * Ivy_Regular(Ivy_Obj_t *p)
Definition: ivy.h:193
void Ivy_ObjPatchFanout(Ivy_Man_t *p, Ivy_Obj_t *pObj, Ivy_Obj_t *pFanoutOld, Ivy_Obj_t *pFanoutNew)
Definition: ivyFanout.c:237
static int Ivy_ObjIsNode(Ivy_Obj_t *pObj)
Definition: ivy.h:245
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
static Ivy_Obj_t * Ivy_ObjCreateGhost(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1, Ivy_Type_t Type, Ivy_Init_t Init)
Definition: ivy.h:308
static int Ivy_ObjIsConst1(Ivy_Obj_t *pObj)
Definition: ivy.h:233
static void Ivy_ManRecycleMemory(Ivy_Man_t *p, Ivy_Obj_t *pEntry)
Definition: ivy.h:374
static int Ivy_ObjIsBuf(Ivy_Obj_t *pObj)
Definition: ivy.h:244
void Ivy_ObjUpdateLevelR_rec(Ivy_Man_t *p, Ivy_Obj_t *pObj, int ReqNew)
Definition: ivyUtil.c:444
void Ivy_TableUpdate(Ivy_Man_t *p, Ivy_Obj_t *pObj, int ObjIdNew)
Definition: ivyTable.c:165
#define assert(ex)
Definition: util_old.h:213
Ivy_Obj_t * Ivy_ObjCreate(Ivy_Man_t *p, Ivy_Obj_t *pGhost)
Definition: ivyObj.c:77
int nRefs
Definition: ivy.h:85