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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START
Hop_Obj_t
Hop_ObjCreatePi (Hop_Man_t *p)
 DECLARATIONS ///. More...
 
Hop_Obj_tHop_ObjCreatePo (Hop_Man_t *p, Hop_Obj_t *pDriver)
 
Hop_Obj_tHop_ObjCreate (Hop_Man_t *p, Hop_Obj_t *pGhost)
 
void Hop_ObjConnect (Hop_Man_t *p, Hop_Obj_t *pObj, Hop_Obj_t *pFan0, Hop_Obj_t *pFan1)
 
void Hop_ObjDisconnect (Hop_Man_t *p, Hop_Obj_t *pObj)
 
void Hop_ObjDelete (Hop_Man_t *p, Hop_Obj_t *pObj)
 
void Hop_ObjDelete_rec (Hop_Man_t *p, Hop_Obj_t *pObj)
 
Hop_Obj_tHop_ObjRepr (Hop_Obj_t *pObj)
 
void Hop_ObjCreateChoice (Hop_Obj_t *pOld, Hop_Obj_t *pNew)
 

Function Documentation

void Hop_ObjConnect ( Hop_Man_t p,
Hop_Obj_t pObj,
Hop_Obj_t pFan0,
Hop_Obj_t pFan1 
)

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

Synopsis [Connect the object to the fanin.]

Description []

SideEffects []

SeeAlso []

Definition at line 125 of file hopObj.c.

126 {
127  assert( !Hop_IsComplement(pObj) );
128  assert( Hop_ObjIsNode(pObj) );
129  // add the first fanin
130  pObj->pFanin0 = pFan0;
131  pObj->pFanin1 = pFan1;
132  // increment references of the fanins and add their fanouts
133  if ( p->fRefCount )
134  {
135  if ( pFan0 != NULL )
136  Hop_ObjRef( Hop_ObjFanin0(pObj) );
137  if ( pFan1 != NULL )
138  Hop_ObjRef( Hop_ObjFanin1(pObj) );
139  }
140  else
141  pObj->nRefs = Hop_ObjLevelNew( pObj );
142  // set the phase
143  pObj->fPhase = Hop_ObjPhaseCompl(pFan0) & Hop_ObjPhaseCompl(pFan1);
144  // add the node to the structural hash table
145  Hop_TableInsert( p, pObj );
146 }
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Hop_TableInsert(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition: hopTable.c:100
static int Hop_ObjIsNode(Hop_Obj_t *pObj)
Definition: hop.h:160
Hop_Obj_t * pFanin1
Definition: hop.h:74
unsigned int nRefs
Definition: hop.h:79
unsigned int fPhase
Definition: hop.h:76
static int Hop_ObjPhaseCompl(Hop_Obj_t *pObj)
Definition: hop.h:192
Hop_Obj_t * pFanin0
Definition: hop.h:73
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
static void Hop_ObjRef(Hop_Obj_t *pObj)
Definition: hop.h:177
#define assert(ex)
Definition: util_old.h:213
static int Hop_ObjLevelNew(Hop_Obj_t *pObj)
Definition: hop.h:191
Hop_Obj_t* Hop_ObjCreate ( Hop_Man_t p,
Hop_Obj_t pGhost 
)

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

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

Description []

SideEffects []

SeeAlso []

Definition at line 97 of file hopObj.c.

98 {
99  Hop_Obj_t * pObj;
100  assert( !Hop_IsComplement(pGhost) );
101  assert( Hop_ObjIsNode(pGhost) );
102  assert( pGhost == &p->Ghost );
103  // get memory for the new object
104  pObj = Hop_ManFetchMemory( p );
105  pObj->Type = pGhost->Type;
106  // add connections
107  Hop_ObjConnect( p, pObj, pGhost->pFanin0, pGhost->pFanin1 );
108  // update node counters of the manager
109  p->nObjs[Hop_ObjType(pObj)]++;
110  assert( pObj->pData == NULL );
111  return pObj;
112 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Hop_ObjIsNode(Hop_Obj_t *pObj)
Definition: hop.h:160
static Hop_Type_t Hop_ObjType(Hop_Obj_t *pObj)
Definition: hop.h:153
Hop_Obj_t * pFanin1
Definition: hop.h:74
unsigned int Type
Definition: hop.h:75
Definition: hop.h:65
void Hop_ObjConnect(Hop_Man_t *p, Hop_Obj_t *pObj, Hop_Obj_t *pFan0, Hop_Obj_t *pFan1)
Definition: hopObj.c:125
Hop_Obj_t * pFanin0
Definition: hop.h:73
static Hop_Obj_t * Hop_ManFetchMemory(Hop_Man_t *p)
Definition: hop.h:230
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
void * pData
Definition: hop.h:68
#define assert(ex)
Definition: util_old.h:213
void Hop_ObjCreateChoice ( Hop_Obj_t pOld,
Hop_Obj_t pNew 
)

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

Synopsis [Sets an equivalence relation between the nodes.]

Description [Makes the representative of pNew point to the representaive of pOld.]

SideEffects []

SeeAlso []

Definition at line 260 of file hopObj.c.

261 {
262  Hop_Obj_t * pOldRepr;
263  Hop_Obj_t * pNewRepr;
264  assert( pOld != NULL && pNew != NULL );
265  pOldRepr = Hop_ObjRepr(pOld);
266  pNewRepr = Hop_ObjRepr(pNew);
267  if ( pNewRepr != pOldRepr )
268  pNewRepr->pData = pOldRepr;
269 }
Definition: hop.h:65
Hop_Obj_t * Hop_ObjRepr(Hop_Obj_t *pObj)
Definition: hopObj.c:241
void * pData
Definition: hop.h:68
#define assert(ex)
Definition: util_old.h:213
ABC_NAMESPACE_IMPL_START Hop_Obj_t* Hop_ObjCreatePi ( Hop_Man_t p)

DECLARATIONS ///.

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

FileName [hopObj.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Minimalistic And-Inverter Graph package.]

Synopsis [Adding/removing objects.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Creates primary input.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file hopObj.c.

46 {
47  Hop_Obj_t * pObj;
48  pObj = Hop_ManFetchMemory( p );
49  pObj->Type = AIG_PI;
50  pObj->PioNum = Vec_PtrSize( p->vPis );
51  Vec_PtrPush( p->vPis, pObj );
52  p->nObjs[AIG_PI]++;
53  return pObj;
54 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
unsigned int Type
Definition: hop.h:75
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Definition: hop.h:65
Definition: hop.h:57
int PioNum
Definition: hop.h:72
static Hop_Obj_t * Hop_ManFetchMemory(Hop_Man_t *p)
Definition: hop.h:230
Hop_Obj_t* Hop_ObjCreatePo ( Hop_Man_t p,
Hop_Obj_t pDriver 
)

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

Synopsis [Creates primary output with the given driver.]

Description []

SideEffects []

SeeAlso []

Definition at line 67 of file hopObj.c.

68 {
69  Hop_Obj_t * pObj;
70  pObj = Hop_ManFetchMemory( p );
71  pObj->Type = AIG_PO;
72  Vec_PtrPush( p->vPos, pObj );
73  // add connections
74  pObj->pFanin0 = pDriver;
75  if ( p->fRefCount )
76  Hop_ObjRef( Hop_Regular(pDriver) );
77  else
78  pObj->nRefs = Hop_ObjLevel( Hop_Regular(pDriver) );
79  // set the phase
80  pObj->fPhase = Hop_ObjPhaseCompl(pDriver);
81  // update node counters of the manager
82  p->nObjs[AIG_PO]++;
83  return pObj;
84 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
unsigned int Type
Definition: hop.h:75
unsigned int nRefs
Definition: hop.h:79
Definition: hop.h:65
unsigned int fPhase
Definition: hop.h:76
static int Hop_ObjPhaseCompl(Hop_Obj_t *pObj)
Definition: hop.h:192
Hop_Obj_t * pFanin0
Definition: hop.h:73
static Hop_Obj_t * Hop_ManFetchMemory(Hop_Man_t *p)
Definition: hop.h:230
Definition: hop.h:58
static int Hop_ObjLevel(Hop_Obj_t *pObj)
Definition: hop.h:190
static void Hop_ObjRef(Hop_Obj_t *pObj)
Definition: hop.h:177
static Hop_Obj_t * Hop_Regular(Hop_Obj_t *p)
Definition: hop.h:126
void Hop_ObjDelete ( Hop_Man_t p,
Hop_Obj_t pObj 
)

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

Synopsis [Deletes the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 186 of file hopObj.c.

187 {
188  assert( !Hop_IsComplement(pObj) );
189  assert( !Hop_ObjIsTerm(pObj) );
190  assert( Hop_ObjRefs(pObj) == 0 );
191  // update node counters of the manager
192  p->nObjs[pObj->Type]--;
193  p->nDeleted++;
194  // remove connections
195  Hop_ObjDisconnect( p, pObj );
196  // remove PIs/POs from the arrays
197  if ( Hop_ObjIsPi(pObj) )
198  Vec_PtrRemove( p->vPis, pObj );
199  // free the node
200  Hop_ManRecycleMemory( p, pObj );
201 }
static int Hop_ObjRefs(Hop_Obj_t *pObj)
Definition: hop.h:176
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Hop_ObjIsPi(Hop_Obj_t *pObj)
Definition: hop.h:156
unsigned int Type
Definition: hop.h:75
static void Vec_PtrRemove(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:714
static void Hop_ManRecycleMemory(Hop_Man_t *p, Hop_Obj_t *pEntry)
Definition: hop.h:246
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
static int Hop_ObjIsTerm(Hop_Obj_t *pObj)
Definition: hop.h:161
void Hop_ObjDisconnect(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition: hopObj.c:159
#define assert(ex)
Definition: util_old.h:213
void Hop_ObjDelete_rec ( Hop_Man_t p,
Hop_Obj_t pObj 
)

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

Synopsis [Deletes the MFFC of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 214 of file hopObj.c.

215 {
216  Hop_Obj_t * pFanin0, * pFanin1;
217  assert( !Hop_IsComplement(pObj) );
218  if ( Hop_ObjIsConst1(pObj) || Hop_ObjIsPi(pObj) )
219  return;
220  assert( Hop_ObjIsNode(pObj) );
221  pFanin0 = Hop_ObjFanin0(pObj);
222  pFanin1 = Hop_ObjFanin1(pObj);
223  Hop_ObjDelete( p, pObj );
224  if ( pFanin0 && !Hop_ObjIsNone(pFanin0) && Hop_ObjRefs(pFanin0) == 0 )
225  Hop_ObjDelete_rec( p, pFanin0 );
226  if ( pFanin1 && !Hop_ObjIsNone(pFanin1) && Hop_ObjRefs(pFanin1) == 0 )
227  Hop_ObjDelete_rec( p, pFanin1 );
228 }
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
static int Hop_ObjRefs(Hop_Obj_t *pObj)
Definition: hop.h:176
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Hop_ObjIsPi(Hop_Obj_t *pObj)
Definition: hop.h:156
static int Hop_ObjIsNode(Hop_Obj_t *pObj)
Definition: hop.h:160
Definition: hop.h:65
static int Hop_ObjIsNone(Hop_Obj_t *pObj)
Definition: hop.h:154
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
void Hop_ObjDelete(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition: hopObj.c:186
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
static int Hop_ObjIsConst1(Hop_Obj_t *pObj)
Definition: hop.h:155
#define assert(ex)
Definition: util_old.h:213
void Hop_ObjDelete_rec(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition: hopObj.c:214
void Hop_ObjDisconnect ( Hop_Man_t p,
Hop_Obj_t pObj 
)

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

Synopsis [Connect the object to the fanin.]

Description []

SideEffects []

SeeAlso []

Definition at line 159 of file hopObj.c.

160 {
161  assert( !Hop_IsComplement(pObj) );
162  assert( Hop_ObjIsNode(pObj) );
163  // remove connections
164  if ( pObj->pFanin0 != NULL )
166  if ( pObj->pFanin1 != NULL )
168  // remove the node from the structural hash table
169  Hop_TableDelete( p, pObj );
170  // add the first fanin
171  pObj->pFanin0 = NULL;
172  pObj->pFanin1 = NULL;
173 }
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Hop_ObjIsNode(Hop_Obj_t *pObj)
Definition: hop.h:160
Hop_Obj_t * pFanin1
Definition: hop.h:74
Hop_Obj_t * pFanin0
Definition: hop.h:73
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
static void Hop_ObjDeref(Hop_Obj_t *pObj)
Definition: hop.h:178
void Hop_TableDelete(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition: hopTable.c:123
#define assert(ex)
Definition: util_old.h:213
Hop_Obj_t* Hop_ObjRepr ( Hop_Obj_t pObj)

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

Synopsis [Returns the representative of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 241 of file hopObj.c.

242 {
243  assert( !Hop_IsComplement(pObj) );
244  if ( pObj->pData == NULL || pObj->pData == pObj )
245  return pObj;
246  return Hop_ObjRepr( (Hop_Obj_t *)pObj->pData );
247 }
Definition: hop.h:65
Hop_Obj_t * Hop_ObjRepr(Hop_Obj_t *pObj)
Definition: hopObj.c:241
static int Hop_IsComplement(Hop_Obj_t *p)
Definition: hop.h:129
void * pData
Definition: hop.h:68
#define assert(ex)
Definition: util_old.h:213