ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
abcFanio.c File Reference
#include "abc.h"
Include dependency graph for abcFanio.c:

Go to the source code of this file.

Functions

void Abc_ObjAddFanin (Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
 
void Abc_ObjDeleteFanin (Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
 
void Abc_ObjRemoveFanins (Abc_Obj_t *pObj)
 
void Abc_ObjPatchFanin (Abc_Obj_t *pObj, Abc_Obj_t *pFaninOld, Abc_Obj_t *pFaninNew)
 
void Abc_ObjPatchFanoutFanin (Abc_Obj_t *pObj, int iObjNew)
 
Abc_Obj_tAbc_ObjInsertBetween (Abc_Obj_t *pNodeIn, Abc_Obj_t *pNodeOut, Abc_ObjType_t Type)
 
void Abc_ObjTransferFanout (Abc_Obj_t *pNodeFrom, Abc_Obj_t *pNodeTo)
 
void Abc_ObjReplace (Abc_Obj_t *pNodeOld, Abc_Obj_t *pNodeNew)
 
void Abc_ObjReplaceByConstant (Abc_Obj_t *pNode, int fConst1)
 
int Abc_ObjFanoutFaninNum (Abc_Obj_t *pFanout, Abc_Obj_t *pFanin)
 

Function Documentation

◆ Abc_ObjAddFanin()

void Abc_ObjAddFanin ( Abc_Obj_t * pObj,
Abc_Obj_t * pFanin )

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

Synopsis [Creates fanout/fanin relationship between the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 84 of file abcFanio.c.

85{
86 Abc_Obj_t * pFaninR = Abc_ObjRegular(pFanin);
87 assert( !Abc_ObjIsComplement(pObj) );
88 assert( pObj->pNtk == pFaninR->pNtk );
89 assert( pObj->Id >= 0 && pFaninR->Id >= 0 );
90 assert( !Abc_ObjIsPi(pObj) && !Abc_ObjIsPo(pFaninR) ); // fanin of PI or fanout of PO
91 assert( !Abc_ObjIsCo(pObj) || !Abc_ObjFaninNum(pObj) ); // CO with two fanins
92 assert( !Abc_ObjIsNet(pObj) || !Abc_ObjFaninNum(pObj) ); // net with two fanins
93 Vec_IntPushMem( pObj->pNtk->pMmStep, &pObj->vFanins, pFaninR->Id );
94 Vec_IntPushMem( pObj->pNtk->pMmStep, &pFaninR->vFanouts, pObj->Id );
95 if ( Abc_ObjIsComplement(pFanin) )
96 Abc_ObjSetFaninC( pObj, Abc_ObjFaninNum(pObj)-1 );
97}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
Mem_Step_t * pMmStep
Definition abc.h:190
Vec_Int_t vFanins
Definition abc.h:143
Abc_Ntk_t * pNtk
Definition abc.h:130
int Id
Definition abc.h:132
Vec_Int_t vFanouts
Definition abc.h:144
#define assert(ex)
Definition util_old.h:213

◆ Abc_ObjDeleteFanin()

void Abc_ObjDeleteFanin ( Abc_Obj_t * pObj,
Abc_Obj_t * pFanin )

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

Synopsis [Destroys fanout/fanin relationship between the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 111 of file abcFanio.c.

112{
113 assert( !Abc_ObjIsComplement(pObj) );
114 assert( !Abc_ObjIsComplement(pFanin) );
115 assert( pObj->pNtk == pFanin->pNtk );
116 assert( pObj->Id >= 0 && pFanin->Id >= 0 );
117 if ( !Vec_IntRemove( &pObj->vFanins, pFanin->Id ) )
118 {
119 printf( "The obj %d is not found among the fanins of obj %d ...\n", pFanin->Id, pObj->Id );
120 return;
121 }
122 if ( !Vec_IntRemove( &pFanin->vFanouts, pObj->Id ) )
123 {
124 printf( "The obj %d is not found among the fanouts of obj %d ...\n", pObj->Id, pFanin->Id );
125 return;
126 }
127}
Here is the caller graph for this function:

◆ Abc_ObjFanoutFaninNum()

int Abc_ObjFanoutFaninNum ( Abc_Obj_t * pFanout,
Abc_Obj_t * pFanin )

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

Synopsis [Returns the index of the fanin in the fanin list of the fanout.]

Description []

SideEffects []

SeeAlso []

Definition at line 373 of file abcFanio.c.

374{
375 Abc_Obj_t * pObj;
376 int i;
377 Abc_ObjForEachFanin( pFanout, pObj, i )
378 if ( pObj == pFanin )
379 return i;
380 return -1;
381}
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
Here is the caller graph for this function:

◆ Abc_ObjInsertBetween()

Abc_Obj_t * Abc_ObjInsertBetween ( Abc_Obj_t * pNodeIn,
Abc_Obj_t * pNodeOut,
Abc_ObjType_t Type )

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

Synopsis [Inserts one-input node of the type specified between the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 251 of file abcFanio.c.

252{
253 Abc_Obj_t * pNodeNew;
254 int iFanoutIndex, iFaninIndex;
255 // find pNodeOut among the fanouts of pNodeIn
256 if ( (iFanoutIndex = Vec_IntFind( &pNodeIn->vFanouts, pNodeOut->Id )) == -1 )
257 {
258 printf( "Node %s is not among", Abc_ObjName(pNodeOut) );
259 printf( " the fanouts of node %s...\n", Abc_ObjName(pNodeIn) );
260 return NULL;
261 }
262 // find pNodeIn among the fanins of pNodeOut
263 if ( (iFaninIndex = Vec_IntFind( &pNodeOut->vFanins, pNodeIn->Id )) == -1 )
264 {
265 printf( "Node %s is not among", Abc_ObjName(pNodeIn) );
266 printf( " the fanins of node %s...\n", Abc_ObjName(pNodeOut) );
267 return NULL;
268 }
269 // create the new node
270 pNodeNew = Abc_NtkCreateObj( pNodeIn->pNtk, Type );
271 // add pNodeIn as fanin and pNodeOut as fanout
272 Vec_IntPushMem( pNodeNew->pNtk->pMmStep, &pNodeNew->vFanins, pNodeIn->Id );
273 Vec_IntPushMem( pNodeNew->pNtk->pMmStep, &pNodeNew->vFanouts, pNodeOut->Id );
274 // update the fanout of pNodeIn
275 Vec_IntWriteEntry( &pNodeIn->vFanouts, iFanoutIndex, pNodeNew->Id );
276 // update the fanin of pNodeOut
277 Vec_IntWriteEntry( &pNodeOut->vFanins, iFaninIndex, pNodeNew->Id );
278 return pNodeNew;
279}
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition abcNames.c:49
ABC_DLL Abc_Obj_t * Abc_NtkCreateObj(Abc_Ntk_t *pNtk, Abc_ObjType_t Type)
Definition abcObj.c:109
Here is the call graph for this function:

◆ Abc_ObjPatchFanin()

void Abc_ObjPatchFanin ( Abc_Obj_t * pObj,
Abc_Obj_t * pFaninOld,
Abc_Obj_t * pFaninNew )

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

Synopsis [Replaces a fanin of the node.]

Description [The node is pObj. An old fanin of this node (pFaninOld) has to be replaced by a new fanin (pFaninNew). Assumes that the node and the old fanin are not complemented. The new fanin can be complemented. In this case, the polarity of the new fanin will change, compared to the polarity of the old fanin.]

SideEffects []

SeeAlso []

Definition at line 172 of file abcFanio.c.

173{
174 Abc_Obj_t * pFaninNewR = Abc_ObjRegular(pFaninNew);
175 int iFanin;//, nLats;//, fCompl;
176 assert( !Abc_ObjIsComplement(pObj) );
177 assert( !Abc_ObjIsComplement(pFaninOld) );
178 assert( pFaninOld != pFaninNewR );
179// assert( pObj != pFaninOld );
180// assert( pObj != pFaninNewR );
181 assert( pObj->pNtk == pFaninOld->pNtk );
182 assert( pObj->pNtk == pFaninNewR->pNtk );
183 if ( (iFanin = Vec_IntFind( &pObj->vFanins, pFaninOld->Id )) == -1 )
184 {
185 printf( "Node %s is not among", Abc_ObjName(pFaninOld) );
186 printf( " the fanins of node %s...\n", Abc_ObjName(pObj) );
187 return;
188 }
189
190 // remember the attributes of the old fanin
191// fCompl = Abc_ObjFaninC(pObj, iFanin);
192 // replace the old fanin entry by the new fanin entry (removes attributes)
193 Vec_IntWriteEntry( &pObj->vFanins, iFanin, pFaninNewR->Id );
194 // set the attributes of the new fanin
195// if ( fCompl ^ Abc_ObjIsComplement(pFaninNew) )
196// Abc_ObjSetFaninC( pObj, iFanin );
197 if ( Abc_ObjIsComplement(pFaninNew) )
198 Abc_ObjXorFaninC( pObj, iFanin );
199
200// if ( Abc_NtkIsSeq(pObj->pNtk) && (nLats = Seq_ObjFaninL(pObj, iFanin)) )
201// Seq_ObjSetFaninL( pObj, iFanin, nLats );
202 // update the fanout of the fanin
203 if ( !Vec_IntRemove( &pFaninOld->vFanouts, pObj->Id ) )
204 {
205 printf( "Node %s is not among", Abc_ObjName(pObj) );
206 printf( " the fanouts of its old fanin %s...\n", Abc_ObjName(pFaninOld) );
207// return;
208 }
209 Vec_IntPushMem( pObj->pNtk->pMmStep, &pFaninNewR->vFanouts, pObj->Id );
210}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_ObjPatchFanoutFanin()

void Abc_ObjPatchFanoutFanin ( Abc_Obj_t * pObj,
int iObjNew )

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

Synopsis [Replaces pObj by iObjNew in the fanin arrays of the fanouts.]

Description []

SideEffects []

SeeAlso []

Definition at line 223 of file abcFanio.c.

224{
225 Abc_Obj_t * pFanout;
226 int i, k, Entry;
227 // update fanouts of the node to point to this one
228 Abc_ObjForEachFanout( pObj, pFanout, i )
229 {
230 Vec_IntForEachEntry( &pFanout->vFanins, Entry, k )
231 if ( Entry == (int)Abc_ObjId(pObj) )
232 {
233 Vec_IntWriteEntry( &pFanout->vFanins, k, iObjNew );
234 break;
235 }
236 assert( k < Vec_IntSize(&pFanout->vFanins) );
237 }
238}
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition abc.h:529
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54

◆ Abc_ObjRemoveFanins()

void Abc_ObjRemoveFanins ( Abc_Obj_t * pObj)

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

Synopsis [Destroys fanout/fanin relationship between the nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 141 of file abcFanio.c.

142{
143 Vec_Int_t * vFaninsOld;
144 Abc_Obj_t * pFanin;
145 int k;
146 // remove old fanins
147 vFaninsOld = &pObj->vFanins;
148 for ( k = vFaninsOld->nSize - 1; k >= 0; k-- )
149 {
150 pFanin = Abc_NtkObj( pObj->pNtk, vFaninsOld->pArray[k] );
151 Abc_ObjDeleteFanin( pObj, pFanin );
152 }
153 pObj->fCompl0 = 0;
154 pObj->fCompl1 = 0;
155 assert( vFaninsOld->nSize == 0 );
156}
void Abc_ObjDeleteFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition abcFanio.c:111
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
unsigned fCompl1
Definition abc.h:141
unsigned fCompl0
Definition abc.h:140
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_ObjReplace()

void Abc_ObjReplace ( Abc_Obj_t * pNodeOld,
Abc_Obj_t * pNodeNew )

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

Synopsis [Replaces the node by a new node.]

Description []

SideEffects []

SeeAlso []

Definition at line 325 of file abcFanio.c.

326{
327 assert( !Abc_ObjIsComplement(pNodeOld) );
328 assert( !Abc_ObjIsComplement(pNodeNew) );
329 assert( pNodeOld->pNtk == pNodeNew->pNtk );
330 assert( pNodeOld != pNodeNew );
331 assert( Abc_ObjFanoutNum(pNodeOld) > 0 );
332 // transfer the fanouts to the old node
333 Abc_ObjTransferFanout( pNodeOld, pNodeNew );
334 // remove the old node
335 Abc_NtkDeleteObj_rec( pNodeOld, 1 );
336}
void Abc_ObjTransferFanout(Abc_Obj_t *pNodeFrom, Abc_Obj_t *pNodeTo)
Definition abcFanio.c:292
ABC_DLL void Abc_NtkDeleteObj_rec(Abc_Obj_t *pObj, int fOnlyNodes)
Definition abcObj.c:278
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_ObjReplaceByConstant()

void Abc_ObjReplaceByConstant ( Abc_Obj_t * pNode,
int fConst1 )

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

Synopsis [Replaces a node by a constant.]

Description []

SideEffects []

SeeAlso []

Definition at line 349 of file abcFanio.c.

350{
351 Abc_Obj_t * pNodeNew;
352 assert( Abc_NtkIsLogic(pNode->pNtk) );
353 assert( !Abc_ObjIsCo(pNode) );
354 pNodeNew = fConst1 ? Abc_NtkCreateNodeConst1(pNode->pNtk) : Abc_NtkCreateNodeConst0(pNode->pNtk);
355 // transfer the fanouts to the old node
356 Abc_ObjTransferFanout( pNode, pNodeNew );
357 // remove the old node
358 if ( Abc_ObjIsNode(pNode) )
359 Abc_NtkDeleteObj_rec( pNode, 1 );
360}
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
Definition abcObj.c:643
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst0(Abc_Ntk_t *pNtk)
Definition abcObj.c:612
Here is the call graph for this function:

◆ Abc_ObjTransferFanout()

void Abc_ObjTransferFanout ( Abc_Obj_t * pNodeFrom,
Abc_Obj_t * pNodeTo )

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

Synopsis [Transfers fanout from the old node to the new node.]

Description []

SideEffects []

SeeAlso []

Definition at line 292 of file abcFanio.c.

293{
294 Vec_Ptr_t * vFanouts;
295 int nFanoutsOld, i;
296 assert( !Abc_ObjIsComplement(pNodeFrom) );
297 assert( !Abc_ObjIsComplement(pNodeTo) );
298 assert( !Abc_ObjIsPo(pNodeFrom) && !Abc_ObjIsPo(pNodeTo) );
299 assert( pNodeFrom->pNtk == pNodeTo->pNtk );
300 assert( pNodeFrom != pNodeTo );
301 assert( !Abc_ObjIsNode(pNodeFrom) || Abc_ObjFanoutNum(pNodeFrom) > 0 );
302 // get the fanouts of the old node
303 nFanoutsOld = Abc_ObjFanoutNum(pNodeTo);
304 vFanouts = Vec_PtrAlloc( nFanoutsOld );
305 Abc_NodeCollectFanouts( pNodeFrom, vFanouts );
306 // patch the fanin of each of them
307 for ( i = 0; i < vFanouts->nSize; i++ )
308 Abc_ObjPatchFanin( (Abc_Obj_t *)vFanouts->pArray[i], pNodeFrom, pNodeTo );
309 assert( Abc_ObjFanoutNum(pNodeFrom) == 0 );
310 assert( Abc_ObjFanoutNum(pNodeTo) == nFanoutsOld + vFanouts->nSize );
311 Vec_PtrFree( vFanouts );
312}
void Abc_ObjPatchFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFaninOld, Abc_Obj_t *pFaninNew)
Definition abcFanio.c:172
ABC_DLL void Abc_NodeCollectFanouts(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition abcUtil.c:1647
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the call graph for this function:
Here is the caller graph for this function: