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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Fraig_NodeAddFaninFanout (Fraig_Node_t *pFanin, Fraig_Node_t *pFanout)
 DECLARATIONS ///. More...
 
void Fraig_NodeRemoveFaninFanout (Fraig_Node_t *pFanin, Fraig_Node_t *pFanoutToRemove)
 
void Fraig_NodeTransferFanout (Fraig_Node_t *pNodeFrom, Fraig_Node_t *pNodeTo)
 
int Fraig_NodeGetFanoutNum (Fraig_Node_t *pNode)
 

Function Documentation

ABC_NAMESPACE_IMPL_START void Fraig_NodeAddFaninFanout ( Fraig_Node_t pFanin,
Fraig_Node_t pFanout 
)

DECLARATIONS ///.

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

FileName [fraigFanout.c]

PackageName [FRAIG: Functionally reduced AND-INV graphs.]

Synopsis [Procedures to manipulate fanouts of the FRAIG nodes.]

Author [Alan Mishchenko alanm.nosp@m.i@ee.nosp@m.cs.be.nosp@m.rkel.nosp@m.ey.ed.nosp@m.u]

Affiliation [UC Berkeley]

Date [Ver. 2.0. Started - October 1, 2004]

Revision [

Id:
fraigFanout.c,v 1.5 2005/07/08 01:01:31 alanmi Exp

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

Synopsis [Add the fanout to the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file fraigFanout.c.

46 {
47  Fraig_Node_t * pPivot;
48 
49  // pFanins is a fanin of pFanout
50  assert( !Fraig_IsComplement(pFanin) );
51  assert( !Fraig_IsComplement(pFanout) );
52  assert( Fraig_Regular(pFanout->p1) == pFanin || Fraig_Regular(pFanout->p2) == pFanin );
53 
54  pPivot = pFanin->pFanPivot;
55  if ( pPivot == NULL )
56  {
57  pFanin->pFanPivot = pFanout;
58  return;
59  }
60 
61  if ( Fraig_Regular(pPivot->p1) == pFanin )
62  {
63  if ( Fraig_Regular(pFanout->p1) == pFanin )
64  {
65  pFanout->pFanFanin1 = pPivot->pFanFanin1;
66  pPivot->pFanFanin1 = pFanout;
67  }
68  else // if ( Fraig_Regular(pFanout->p2) == pFanin )
69  {
70  pFanout->pFanFanin2 = pPivot->pFanFanin1;
71  pPivot->pFanFanin1 = pFanout;
72  }
73  }
74  else // if ( Fraig_Regular(pPivot->p2) == pFanin )
75  {
76  assert( Fraig_Regular(pPivot->p2) == pFanin );
77  if ( Fraig_Regular(pFanout->p1) == pFanin )
78  {
79  pFanout->pFanFanin1 = pPivot->pFanFanin2;
80  pPivot->pFanFanin2 = pFanout;
81  }
82  else // if ( Fraig_Regular(pFanout->p2) == pFanin )
83  {
84  pFanout->pFanFanin2 = pPivot->pFanFanin2;
85  pPivot->pFanFanin2 = pFanout;
86  }
87  }
88 }
Fraig_Node_t * pFanFanin1
Definition: fraigInt.h:257
Fraig_Node_t * p2
Definition: fraigInt.h:233
Fraig_Node_t * p1
Definition: fraigInt.h:232
Fraig_Node_t * pFanFanin2
Definition: fraigInt.h:258
#define Fraig_IsComplement(p)
GLOBAL VARIABLES ///.
Definition: fraig.h:107
#define Fraig_Regular(p)
Definition: fraig.h:108
Fraig_Node_t * pFanPivot
Definition: fraigInt.h:256
#define assert(ex)
Definition: util_old.h:213
int Fraig_NodeGetFanoutNum ( Fraig_Node_t pNode)

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

Synopsis [Returns the number of fanouts of a node.]

Description []

SideEffects []

SeeAlso []

Definition at line 164 of file fraigFanout.c.

165 {
166  Fraig_Node_t * pFanout;
167  int Counter = 0;
168  Fraig_NodeForEachFanout( pNode, pFanout )
169  Counter++;
170  return Counter;
171 }
#define Fraig_NodeForEachFanout(pNode, pFanout)
Definition: fraigInt.h:288
static int Counter
void Fraig_NodeRemoveFaninFanout ( Fraig_Node_t pFanin,
Fraig_Node_t pFanoutToRemove 
)

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

Synopsis [Add the fanout to the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 101 of file fraigFanout.c.

102 {
103  Fraig_Node_t * pFanout, * pFanout2, ** ppFanList;
104  // start the linked list of fanouts
105  ppFanList = &pFanin->pFanPivot;
106  // go through the fanouts
107  Fraig_NodeForEachFanoutSafe( pFanin, pFanout, pFanout2 )
108  {
109  // skip the fanout-to-remove
110  if ( pFanout == pFanoutToRemove )
111  continue;
112  // add useful fanouts to the list
113  *ppFanList = pFanout;
114  ppFanList = Fraig_NodeReadNextFanoutPlace( pFanin, pFanout );
115  }
116  *ppFanList = NULL;
117 }
#define Fraig_NodeReadNextFanoutPlace(pNode, pFanout)
Definition: fraigInt.h:284
#define Fraig_NodeForEachFanoutSafe(pNode, pFanout, pFanout2)
Definition: fraigInt.h:292
Fraig_Node_t * pFanPivot
Definition: fraigInt.h:256
void Fraig_NodeTransferFanout ( Fraig_Node_t pNodeFrom,
Fraig_Node_t pNodeTo 
)

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

Synopsis [Transfers fanout to a different node.]

Description [Assumes that the other node currently has no fanouts.]

SideEffects []

SeeAlso []

Definition at line 130 of file fraigFanout.c.

131 {
132  Fraig_Node_t * pFanout;
133  assert( pNodeTo->pFanPivot == NULL );
134  assert( pNodeTo->pFanFanin1 == NULL );
135  assert( pNodeTo->pFanFanin2 == NULL );
136  // go through the fanouts and update their fanins
137  Fraig_NodeForEachFanout( pNodeFrom, pFanout )
138  {
139  if ( Fraig_Regular(pFanout->p1) == pNodeFrom )
140  pFanout->p1 = Fraig_NotCond( pNodeTo, Fraig_IsComplement(pFanout->p1) );
141  else if ( Fraig_Regular(pFanout->p2) == pNodeFrom )
142  pFanout->p2 = Fraig_NotCond( pNodeTo, Fraig_IsComplement(pFanout->p2) );
143  }
144  // move the pointers
145  pNodeTo->pFanPivot = pNodeFrom->pFanPivot;
146  pNodeTo->pFanFanin1 = pNodeFrom->pFanFanin1;
147  pNodeTo->pFanFanin2 = pNodeFrom->pFanFanin2;
148  pNodeFrom->pFanPivot = NULL;
149  pNodeFrom->pFanFanin1 = NULL;
150  pNodeFrom->pFanFanin2 = NULL;
151 }
Fraig_Node_t * pFanFanin1
Definition: fraigInt.h:257
Fraig_Node_t * p2
Definition: fraigInt.h:233
#define Fraig_NodeForEachFanout(pNode, pFanout)
Definition: fraigInt.h:288
Fraig_Node_t * p1
Definition: fraigInt.h:232
Fraig_Node_t * pFanFanin2
Definition: fraigInt.h:258
#define Fraig_IsComplement(p)
GLOBAL VARIABLES ///.
Definition: fraig.h:107
#define Fraig_Regular(p)
Definition: fraig.h:108
#define Fraig_NotCond(p, c)
Definition: fraig.h:110
Fraig_Node_t * pFanPivot
Definition: fraigInt.h:256
#define assert(ex)
Definition: util_old.h:213