ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
hopObj.c
Go to the documentation of this file.
1
20
21#include "hop.h"
22
24
25
29
33
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}
55
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}
85
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}
113
125void Hop_ObjConnect( Hop_Man_t * p, Hop_Obj_t * pObj, Hop_Obj_t * pFan0, Hop_Obj_t * pFan1 )
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}
147
160{
161 assert( !Hop_IsComplement(pObj) );
162 assert( Hop_ObjIsNode(pObj) );
163 // remove connections
164 if ( pObj->pFanin0 != NULL )
165 Hop_ObjDeref(Hop_ObjFanin0(pObj));
166 if ( pObj->pFanin1 != NULL )
167 Hop_ObjDeref(Hop_ObjFanin1(pObj));
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}
174
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}
202
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}
229
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}
248
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}
270
274
275
277
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Cube * p
Definition exorList.c:222
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 * Hop_ObjCreatePo(Hop_Man_t *p, Hop_Obj_t *pDriver)
Definition hopObj.c:67
Hop_Obj_t * Hop_ObjCreate(Hop_Man_t *p, Hop_Obj_t *pGhost)
Definition hopObj.c:97
void Hop_ObjDelete_rec(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition hopObj.c:214
ABC_NAMESPACE_IMPL_START Hop_Obj_t * Hop_ObjCreatePi(Hop_Man_t *p)
DECLARATIONS ///.
Definition hopObj.c:45
void Hop_ObjCreateChoice(Hop_Obj_t *pOld, Hop_Obj_t *pNew)
Definition hopObj.c:260
void Hop_ObjDelete(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition hopObj.c:186
void Hop_ObjDisconnect(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition hopObj.c:159
Hop_Obj_t * Hop_ObjRepr(Hop_Obj_t *pObj)
Definition hopObj.c:241
void Hop_TableDelete(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition hopTable.c:123
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Definition hop.h:49
void Hop_TableInsert(Hop_Man_t *p, Hop_Obj_t *pObj)
Definition hopTable.c:100
@ AIG_PI
Definition hop.h:57
@ AIG_PO
Definition hop.h:58
struct Hop_Obj_t_ Hop_Obj_t
Definition hop.h:50
unsigned int Type
Definition hop.h:75
unsigned int nRefs
Definition hop.h:79
unsigned int fPhase
Definition hop.h:76
Hop_Obj_t * pFanin1
Definition hop.h:74
Hop_Obj_t * pFanin0
Definition hop.h:73
int PioNum
Definition hop.h:72
void * pData
Definition hop.h:68
#define assert(ex)
Definition util_old.h:213