abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcMulti.c File Reference
#include "base/abc/abc.h"
#include "misc/extra/extraBdd.h"

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START void 
Abc_NtkMultiInt (Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew)
 DECLARATIONS ///. More...
 
static Abc_Obj_tAbc_NtkMulti_rec (Abc_Ntk_t *pNtkNew, Abc_Obj_t *pNodeOld)
 
static DdNodeAbc_NtkMultiDeriveBdd_rec (DdManager *dd, Abc_Obj_t *pNodeOld, Vec_Ptr_t *vFanins)
 
static DdNodeAbc_NtkMultiDeriveBdd (DdManager *dd, Abc_Obj_t *pNodeOld, Vec_Ptr_t *vFaninsOld)
 
static void Abc_NtkMultiSetBounds (Abc_Ntk_t *pNtk, int nThresh, int nFaninMax)
 
static void Abc_NtkMultiSetBoundsCnf (Abc_Ntk_t *pNtk)
 
static void Abc_NtkMultiSetBoundsMulti (Abc_Ntk_t *pNtk, int nThresh)
 
static void Abc_NtkMultiSetBoundsSimple (Abc_Ntk_t *pNtk)
 
static void Abc_NtkMultiSetBoundsFactor (Abc_Ntk_t *pNtk)
 
static void Abc_NtkMultiCone (Abc_Obj_t *pNode, Vec_Ptr_t *vCone)
 
Abc_Ntk_tAbc_NtkMulti (Abc_Ntk_t *pNtk, int nThresh, int nFaninMax, int fCnf, int fMulti, int fSimple, int fFactor)
 FUNCTION DEFINITIONS ///. More...
 
int Abc_NtkMultiLimit_rec (Abc_Obj_t *pNode, Vec_Ptr_t *vCone, int nFaninMax, int fCanStop, int fFirst)
 
int Abc_NtkMultiLimit (Abc_Obj_t *pNode, Vec_Ptr_t *vCone, int nFaninMax)
 
void Abc_NtkMultiCone_rec (Abc_Obj_t *pNode, Vec_Ptr_t *vCone)
 

Function Documentation

Abc_Ntk_t* Abc_NtkMulti ( Abc_Ntk_t pNtk,
int  nThresh,
int  nFaninMax,
int  fCnf,
int  fMulti,
int  fSimple,
int  fFactor 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Transforms the AIG into nodes.]

Description [Threhold is the max number of nodes duplicated at a node.]

SideEffects []

SeeAlso []

Definition at line 59 of file abcMulti.c.

60 {
61  Abc_Ntk_t * pNtkNew;
62 
63  assert( Abc_NtkIsStrash(pNtk) );
64  assert( nThresh >= 0 );
65  assert( nFaninMax > 1 );
66 
67  // print a warning about choice nodes
68  if ( Abc_NtkGetChoiceNum( pNtk ) )
69  printf( "Warning: The choice nodes in the AIG are removed by renoding.\n" );
70 
71  // define the boundary
72  if ( fCnf )
74  else if ( fMulti )
75  Abc_NtkMultiSetBoundsMulti( pNtk, nThresh );
76  else if ( fSimple )
78  else if ( fFactor )
80  else
81  Abc_NtkMultiSetBounds( pNtk, nThresh, nFaninMax );
82 
83  // perform renoding for this boundary
84  pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_BDD );
85  Abc_NtkMultiInt( pNtk, pNtkNew );
86  Abc_NtkFinalize( pNtk, pNtkNew );
87 
88  // make the network minimum base
89  Abc_NtkMinimumBase( pNtkNew );
90 
91  // fix the problem with complemented and duplicated CO edges
92  Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
93 
94  // report the number of CNF objects
95  if ( fCnf )
96  {
97 // int nClauses = Abc_NtkGetClauseNum(pNtkNew) + 2*Abc_NtkPoNum(pNtkNew) + 2*Abc_NtkLatchNum(pNtkNew);
98 // printf( "CNF variables = %d. CNF clauses = %d.\n", Abc_NtkNodeNum(pNtkNew), nClauses );
99  }
100 //printf( "Maximum fanin = %d.\n", Abc_NtkGetFaninMax(pNtkNew) );
101 
102  if ( pNtk->pExdc )
103  pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc );
104  // make sure everything is okay
105  if ( !Abc_NtkCheck( pNtkNew ) )
106  {
107  printf( "Abc_NtkMulti: The network check has failed.\n" );
108  Abc_NtkDelete( pNtkNew );
109  return NULL;
110  }
111  return pNtkNew;
112 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
ABC_DLL int Abc_NtkMinimumBase(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcMinBase.c:48
Abc_Ntk_t * pExdc
Definition: abc.h:201
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:419
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
ABC_DLL int Abc_NtkGetChoiceNum(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:430
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition: abcNtk.c:106
static void Abc_NtkMultiSetBoundsSimple(Abc_Ntk_t *pNtk)
Definition: abcMulti.c:562
static void Abc_NtkMultiSetBoundsCnf(Abc_Ntk_t *pNtk)
Definition: abcMulti.c:450
ABC_DLL void Abc_NtkFinalize(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew)
Definition: abcNtk.c:302
static void Abc_NtkMultiSetBoundsFactor(Abc_Ntk_t *pNtk)
Definition: abcMulti.c:585
static ABC_NAMESPACE_IMPL_START void Abc_NtkMultiInt(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew)
DECLARATIONS ///.
Definition: abcMulti.c:125
ABC_DLL int Abc_NtkLogicMakeSimpleCos(Abc_Ntk_t *pNtk, int fDuplicate)
Definition: abcUtil.c:1047
#define assert(ex)
Definition: util_old.h:213
static void Abc_NtkMultiSetBoundsMulti(Abc_Ntk_t *pNtk, int nThresh)
Definition: abcMulti.c:516
static void Abc_NtkMultiSetBounds(Abc_Ntk_t *pNtk, int nThresh, int nFaninMax)
Definition: abcMulti.c:383
Abc_Obj_t * Abc_NtkMulti_rec ( Abc_Ntk_t pNtkNew,
Abc_Obj_t pNodeOld 
)
static

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

Synopsis [Find the best multi-input node rooted at the given node.]

Description []

SideEffects []

SeeAlso []

Definition at line 170 of file abcMulti.c.

171 {
172  Vec_Ptr_t * vCone;
173  Abc_Obj_t * pNodeNew;
174  int i;
175 
176  assert( !Abc_ObjIsComplement(pNodeOld) );
177  // return if the result if known
178  if ( pNodeOld->pCopy )
179  return pNodeOld->pCopy;
180  assert( Abc_ObjIsNode(pNodeOld) );
181  assert( !Abc_AigNodeIsConst(pNodeOld) );
182  assert( pNodeOld->fMarkA );
183 
184 //printf( "%d ", Abc_NodeMffcSizeSupp(pNodeOld) );
185 
186  // collect the renoding cone
187  vCone = Vec_PtrAlloc( 10 );
188  Abc_NtkMultiCone( pNodeOld, vCone );
189 
190  // create a new node
191  pNodeNew = Abc_NtkCreateNode( pNtkNew );
192  for ( i = 0; i < vCone->nSize; i++ )
193  Abc_ObjAddFanin( pNodeNew, Abc_NtkMulti_rec(pNtkNew, (Abc_Obj_t *)vCone->pArray[i]) );
194 
195  // derive the function of this node
196  pNodeNew->pData = Abc_NtkMultiDeriveBdd( (DdManager *)pNtkNew->pManFunc, pNodeOld, vCone );
197  Cudd_Ref( (DdNode *)pNodeNew->pData );
198  Vec_PtrFree( vCone );
199 
200  // remember the node
201  pNodeOld->pCopy = pNodeNew;
202  return pNodeOld->pCopy;
203 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static DdNode * Abc_NtkMultiDeriveBdd(DdManager *dd, Abc_Obj_t *pNodeOld, Vec_Ptr_t *vFaninsOld)
Definition: abcMulti.c:217
unsigned fMarkA
Definition: abc.h:134
Definition: cudd.h:278
static int Abc_AigNodeIsConst(Abc_Obj_t *pNode)
Definition: abc.h:396
static Abc_Obj_t * Abc_NtkMulti_rec(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pNodeOld)
Definition: abcMulti.c:170
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
void * pManFunc
Definition: abc.h:191
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
Abc_Obj_t * pCopy
Definition: abc.h:148
static void Abc_NtkMultiCone(Abc_Obj_t *pNode, Vec_Ptr_t *vCone)
Definition: abcMulti.c:634
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
Definition: abc.h:308
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Abc_NtkMultiCone ( Abc_Obj_t pNode,
Vec_Ptr_t vCone 
)
static

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

Synopsis [Collects the fanins of a large node.]

Description []

SideEffects []

SeeAlso []

Definition at line 634 of file abcMulti.c.

635 {
636  assert( !Abc_ObjIsComplement(pNode) );
637  assert( Abc_ObjIsNode(pNode) );
638  vCone->nSize = 0;
639  Abc_NtkMultiCone_rec( Abc_ObjFanin(pNode,0), vCone );
640  Abc_NtkMultiCone_rec( Abc_ObjFanin(pNode,1), vCone );
641 }
void Abc_NtkMultiCone_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vCone)
Definition: abcMulti.c:611
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
#define assert(ex)
Definition: util_old.h:213
static Abc_Obj_t * Abc_ObjFanin(Abc_Obj_t *pObj, int i)
Definition: abc.h:372
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322
void Abc_NtkMultiCone_rec ( Abc_Obj_t pNode,
Vec_Ptr_t vCone 
)

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

Synopsis [Collects the fanins of a large node.]

Description []

SideEffects []

SeeAlso []

Definition at line 611 of file abcMulti.c.

612 {
613  assert( !Abc_ObjIsComplement(pNode) );
614  if ( pNode->fMarkA || !Abc_ObjIsNode(pNode) )
615  {
616  Vec_PtrPushUnique( vCone, pNode );
617  return;
618  }
619  Abc_NtkMultiCone_rec( Abc_ObjFanin(pNode,0), vCone );
620  Abc_NtkMultiCone_rec( Abc_ObjFanin(pNode,1), vCone );
621 }
unsigned fMarkA
Definition: abc.h:134
static int Vec_PtrPushUnique(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:656
void Abc_NtkMultiCone_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vCone)
Definition: abcMulti.c:611
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
#define assert(ex)
Definition: util_old.h:213
static Abc_Obj_t * Abc_ObjFanin(Abc_Obj_t *pObj, int i)
Definition: abc.h:372
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322
DdNode * Abc_NtkMultiDeriveBdd ( DdManager dd,
Abc_Obj_t pNodeOld,
Vec_Ptr_t vFaninsOld 
)
static

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

Synopsis [Derives the local BDD of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 217 of file abcMulti.c.

218 {
219  Abc_Obj_t * pFaninOld;
220  DdNode * bFunc;
221  int i;
222  assert( !Abc_AigNodeIsConst(pNodeOld) );
223  assert( Abc_ObjIsNode(pNodeOld) );
224  // set the elementary BDD variables for the input nodes
225  for ( i = 0; i < vFaninsOld->nSize; i++ )
226  {
227  pFaninOld = (Abc_Obj_t *)vFaninsOld->pArray[i];
228  pFaninOld->pData = Cudd_bddIthVar( dd, i ); Cudd_Ref( (DdNode *)pFaninOld->pData );
229  pFaninOld->fMarkC = 1;
230  }
231  // call the recursive BDD computation
232  bFunc = Abc_NtkMultiDeriveBdd_rec( dd, pNodeOld, vFaninsOld ); Cudd_Ref( bFunc );
233  // dereference the intermediate nodes
234  for ( i = 0; i < vFaninsOld->nSize; i++ )
235  {
236  pFaninOld = (Abc_Obj_t *)vFaninsOld->pArray[i];
237  Cudd_RecursiveDeref( dd, (DdNode *)pFaninOld->pData );
238  pFaninOld->fMarkC = 0;
239  }
240  Cudd_Deref( bFunc );
241  return bFunc;
242 }
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
void Cudd_Deref(DdNode *node)
Definition: cuddRef.c:438
static int Abc_AigNodeIsConst(Abc_Obj_t *pNode)
Definition: abc.h:396
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
static DdNode * Abc_NtkMultiDeriveBdd_rec(DdManager *dd, Abc_Obj_t *pNodeOld, Vec_Ptr_t *vFanins)
Definition: abcMulti.c:255
unsigned fMarkC
Definition: abc.h:136
DdNode * Cudd_bddIthVar(DdManager *dd, int i)
Definition: cuddAPI.c:416
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
DdNode * Abc_NtkMultiDeriveBdd_rec ( DdManager dd,
Abc_Obj_t pNode,
Vec_Ptr_t vFanins 
)
static

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

Synopsis [Derives the local BDD of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 255 of file abcMulti.c.

256 {
257  DdNode * bFunc, * bFunc0, * bFunc1;
258  assert( !Abc_ObjIsComplement(pNode) );
259  // if the result is available return
260  if ( pNode->fMarkC )
261  {
262  assert( pNode->pData ); // network has a cycle
263  return (DdNode *)pNode->pData;
264  }
265  // mark the node as visited
266  pNode->fMarkC = 1;
267  Vec_PtrPush( vFanins, pNode );
268  // compute the result for both branches
269  bFunc0 = Abc_NtkMultiDeriveBdd_rec( dd, Abc_ObjFanin(pNode,0), vFanins ); Cudd_Ref( bFunc0 );
270  bFunc1 = Abc_NtkMultiDeriveBdd_rec( dd, Abc_ObjFanin(pNode,1), vFanins ); Cudd_Ref( bFunc1 );
271  bFunc0 = Cudd_NotCond( bFunc0, (long)Abc_ObjFaninC0(pNode) );
272  bFunc1 = Cudd_NotCond( bFunc1, (long)Abc_ObjFaninC1(pNode) );
273  // get the final result
274  bFunc = Cudd_bddAnd( dd, bFunc0, bFunc1 ); Cudd_Ref( bFunc );
275  Cudd_RecursiveDeref( dd, bFunc0 );
276  Cudd_RecursiveDeref( dd, bFunc1 );
277  // set the result
278  pNode->pData = bFunc;
279  assert( pNode->pData );
280  return bFunc;
281 }
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
Definition: abc.h:378
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static DdNode * Abc_NtkMultiDeriveBdd_rec(DdManager *dd, Abc_Obj_t *pNodeOld, Vec_Ptr_t *vFanins)
Definition: abcMulti.c:255
unsigned fMarkC
Definition: abc.h:136
#define Cudd_NotCond(node, c)
Definition: cudd.h:383
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
static Abc_Obj_t * Abc_ObjFanin(Abc_Obj_t *pObj, int i)
Definition: abc.h:372
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322
void Abc_NtkMultiInt ( Abc_Ntk_t pNtk,
Abc_Ntk_t pNtkNew 
)
static

DECLARATIONS ///.

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

FileName [abcMulti.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Procedures which transform an AIG into multi-input AND-graph.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
abcMulti.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

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

Synopsis [Transforms the AIG into nodes.]

Description [Threhold is the max number of nodes duplicated at a node.]

SideEffects []

SeeAlso []

Definition at line 125 of file abcMulti.c.

126 {
127  ProgressBar * pProgress;
128  Abc_Obj_t * pNode, * pConst1, * pNodeNew;
129  int i;
130 
131  // set the constant node
132  pConst1 = Abc_AigConst1(pNtk);
133  if ( Abc_ObjFanoutNum(pConst1) > 0 )
134  {
135  pNodeNew = Abc_NtkCreateNode( pNtkNew );
136  pNodeNew->pData = Cudd_ReadOne( (DdManager *)pNtkNew->pManFunc ); Cudd_Ref( (DdNode *)pNodeNew->pData );
137  pConst1->pCopy = pNodeNew;
138  }
139 
140  // perform renoding for POs
141  pProgress = Extra_ProgressBarStart( stdout, Abc_NtkCoNum(pNtk) );
142  Abc_NtkForEachCo( pNtk, pNode, i )
143  {
144  Extra_ProgressBarUpdate( pProgress, i, NULL );
145  if ( Abc_ObjIsCi(Abc_ObjFanin0(pNode)) )
146  continue;
147  Abc_NtkMulti_rec( pNtkNew, Abc_ObjFanin0(pNode) );
148  }
149  Extra_ProgressBarStop( pProgress );
150 
151  // clean the boundaries and data field in the old network
152  Abc_NtkForEachObj( pNtk, pNode, i )
153  {
154  pNode->fMarkA = 0;
155  pNode->pData = NULL;
156  }
157 }
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
unsigned fMarkA
Definition: abc.h:134
Definition: cudd.h:278
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static Abc_Obj_t * Abc_NtkMulti_rec(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pNodeOld)
Definition: abcMulti.c:170
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
void * pManFunc
Definition: abc.h:191
DECLARATIONS ///.
Abc_Obj_t * pCopy
Definition: abc.h:148
void Extra_ProgressBarStop(ProgressBar *p)
DdNode * Cudd_ReadOne(DdManager *dd)
Definition: cuddAPI.c:987
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
Definition: abc.h:308
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
void * pData
Definition: abc.h:145
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
int Abc_NtkMultiLimit ( Abc_Obj_t pNode,
Vec_Ptr_t vCone,
int  nFaninMax 
)

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

Synopsis [Limits the cones to be no more than the given size.]

Description [Returns 1 if the last cone was limited. Returns 0 if no changes.]

SideEffects []

SeeAlso []

Definition at line 365 of file abcMulti.c.

366 {
367  vCone->nSize = 0;
368  return Abc_NtkMultiLimit_rec( pNode, vCone, nFaninMax, 1, 1 );
369 }
int Abc_NtkMultiLimit_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vCone, int nFaninMax, int fCanStop, int fFirst)
Definition: abcMulti.c:296
int Abc_NtkMultiLimit_rec ( Abc_Obj_t pNode,
Vec_Ptr_t vCone,
int  nFaninMax,
int  fCanStop,
int  fFirst 
)

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

Synopsis [Limits the cones to be no more than the given size.]

Description [Returns 1 if the last cone was limited. Returns 0 if no changes.]

SideEffects []

SeeAlso []

Definition at line 296 of file abcMulti.c.

297 {
298  int nNodes0, nNodes1;
299  assert( !Abc_ObjIsComplement(pNode) );
300  // check if the node should be added to the fanins
301  if ( !fFirst && (pNode->fMarkA || !Abc_ObjIsNode(pNode)) )
302  {
303  Vec_PtrPushUnique( vCone, pNode );
304  return 0;
305  }
306  // if we cannot stop in this branch, collect all nodes
307  if ( !fCanStop )
308  {
309  Abc_NtkMultiLimit_rec( Abc_ObjFanin(pNode,0), vCone, nFaninMax, 0, 0 );
310  Abc_NtkMultiLimit_rec( Abc_ObjFanin(pNode,1), vCone, nFaninMax, 0, 0 );
311  return 0;
312  }
313  // if we can stop, try the left branch first, and return if we stopped
314  assert( vCone->nSize == 0 );
315  if ( Abc_NtkMultiLimit_rec( Abc_ObjFanin(pNode,0), vCone, nFaninMax, 1, 0 ) )
316  return 1;
317  // save the number of nodes in the left branch and call for the right branch
318  nNodes0 = vCone->nSize;
319  assert( nNodes0 <= nFaninMax );
320  Abc_NtkMultiLimit_rec( Abc_ObjFanin(pNode,1), vCone, nFaninMax, 0, 0 );
321  // check the number of nodes
322  if ( vCone->nSize <= nFaninMax )
323  return 0;
324  // the number of nodes exceeds the limit
325 
326  // get the number of nodes in the right branch
327  vCone->nSize = 0;
328  Abc_NtkMultiLimit_rec( Abc_ObjFanin(pNode,1), vCone, nFaninMax, 0, 0 );
329  // if this number exceeds the limit, solve the problem for this branch
330  if ( vCone->nSize > nFaninMax )
331  {
332  int RetValue;
333  vCone->nSize = 0;
334  RetValue = Abc_NtkMultiLimit_rec( Abc_ObjFanin(pNode,1), vCone, nFaninMax, 1, 0 );
335  assert( RetValue == 1 );
336  return 1;
337  }
338 
339  nNodes1 = vCone->nSize;
340  assert( nNodes1 <= nFaninMax );
341  if ( nNodes0 >= nNodes1 )
342  { // the left branch is larger - cut it
343  assert( Abc_ObjFanin(pNode,0)->fMarkA == 0 );
344  Abc_ObjFanin(pNode,0)->fMarkA = 1;
345  }
346  else
347  { // the right branch is larger - cut it
348  assert( Abc_ObjFanin(pNode,1)->fMarkA == 0 );
349  Abc_ObjFanin(pNode,1)->fMarkA = 1;
350  }
351  return 1;
352 }
unsigned fMarkA
Definition: abc.h:134
static int Vec_PtrPushUnique(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:656
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
int Abc_NtkMultiLimit_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vCone, int nFaninMax, int fCanStop, int fFirst)
Definition: abcMulti.c:296
#define assert(ex)
Definition: util_old.h:213
static Abc_Obj_t * Abc_ObjFanin(Abc_Obj_t *pObj, int i)
Definition: abc.h:372
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322
void Abc_NtkMultiSetBounds ( Abc_Ntk_t pNtk,
int  nThresh,
int  nFaninMax 
)
static

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

Synopsis [Sets the expansion boundary for multi-input nodes.]

Description [The boundary includes the set of PIs and all nodes such that when expanding over the node we duplicate no more than nThresh nodes.]

SideEffects []

SeeAlso []

Definition at line 383 of file abcMulti.c.

384 {
385  Vec_Ptr_t * vCone = Vec_PtrAlloc(10);
386  Abc_Obj_t * pNode;
387  int i, nFanouts, nConeSize;
388 
389  // make sure the mark is not set
390  Abc_NtkForEachObj( pNtk, pNode, i )
391  assert( pNode->fMarkA == 0 );
392 
393  // mark the nodes where expansion stops using pNode->fMarkA
394  Abc_NtkForEachNode( pNtk, pNode, i )
395  {
396  // skip PI/PO nodes
397 // if ( Abc_NodeIsConst(pNode) )
398 // continue;
399  // mark the nodes with multiple fanouts
400  nFanouts = Abc_ObjFanoutNum(pNode);
401  nConeSize = Abc_NodeMffcSize(pNode);
402  if ( (nFanouts - 1) * nConeSize > nThresh )
403  pNode->fMarkA = 1;
404  }
405 
406  // mark the PO drivers
407  Abc_NtkForEachCo( pNtk, pNode, i )
408  Abc_ObjFanin0(pNode)->fMarkA = 1;
409 
410  // make sure the fanin limit is met
411  Abc_NtkForEachNode( pNtk, pNode, i )
412  {
413  // skip PI/PO nodes
414 // if ( Abc_NodeIsConst(pNode) )
415 // continue;
416  if ( pNode->fMarkA == 0 )
417  continue;
418  // continue cutting branches until it meets the fanin limit
419  while ( Abc_NtkMultiLimit(pNode, vCone, nFaninMax) );
420  assert( vCone->nSize <= nFaninMax );
421  }
422  Vec_PtrFree(vCone);
423 /*
424  // make sure the fanin limit is met
425  Abc_NtkForEachNode( pNtk, pNode, i )
426  {
427  // skip PI/PO nodes
428 // if ( Abc_NodeIsConst(pNode) )
429 // continue;
430  if ( pNode->fMarkA == 0 )
431  continue;
432  Abc_NtkMultiCone( pNode, vCone );
433  assert( vCone->nSize <= nFaninMax );
434  }
435 */
436 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
ABC_DLL int Abc_NodeMffcSize(Abc_Obj_t *pNode)
FUNCTION DEFINITIONS ///.
Definition: abcRefs.c:48
int Abc_NtkMultiLimit(Abc_Obj_t *pNode, Vec_Ptr_t *vCone, int nFaninMax)
Definition: abcMulti.c:365
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define assert(ex)
Definition: util_old.h:213
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Abc_NtkMultiSetBoundsCnf ( Abc_Ntk_t pNtk)
static

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

Synopsis [Sets the expansion boundary for conversion into CNF.]

Description [The boundary includes the set of PIs, the roots of MUXes, the nodes with multiple fanouts and the nodes with complemented outputs.]

SideEffects []

SeeAlso []

Definition at line 450 of file abcMulti.c.

451 {
452  Abc_Obj_t * pNode;
453  int i, nMuxes;
454 
455  // make sure the mark is not set
456  Abc_NtkForEachObj( pNtk, pNode, i )
457  assert( pNode->fMarkA == 0 );
458 
459  // mark the nodes where expansion stops using pNode->fMarkA
460  Abc_NtkForEachNode( pNtk, pNode, i )
461  {
462  // skip PI/PO nodes
463 // if ( Abc_NodeIsConst(pNode) )
464 // continue;
465  // mark the nodes with multiple fanouts
466  if ( Abc_ObjFanoutNum(pNode) > 1 )
467  pNode->fMarkA = 1;
468  // mark the nodes that are roots of MUXes
469  if ( Abc_NodeIsMuxType( pNode ) )
470  {
471  pNode->fMarkA = 1;
472  Abc_ObjFanin0( Abc_ObjFanin0(pNode) )->fMarkA = 1;
473  Abc_ObjFanin0( Abc_ObjFanin1(pNode) )->fMarkA = 1;
474  Abc_ObjFanin1( Abc_ObjFanin0(pNode) )->fMarkA = 1;
475  Abc_ObjFanin1( Abc_ObjFanin1(pNode) )->fMarkA = 1;
476  }
477  else // mark the complemented edges
478  {
479  if ( Abc_ObjFaninC0(pNode) )
480  Abc_ObjFanin0(pNode)->fMarkA = 1;
481  if ( Abc_ObjFaninC1(pNode) )
482  Abc_ObjFanin1(pNode)->fMarkA = 1;
483  }
484  }
485 
486  // mark the PO drivers
487  Abc_NtkForEachCo( pNtk, pNode, i )
488  Abc_ObjFanin0(pNode)->fMarkA = 1;
489 
490  // count the number of MUXes
491  nMuxes = 0;
492  Abc_NtkForEachNode( pNtk, pNode, i )
493  {
494  // skip PI/PO nodes
495 // if ( Abc_NodeIsConst(pNode) )
496 // continue;
497  if ( Abc_NodeIsMuxType(pNode) &&
498  Abc_ObjFanin0(pNode)->fMarkA == 0 &&
499  Abc_ObjFanin1(pNode)->fMarkA == 0 )
500  nMuxes++;
501  }
502 // printf( "The number of MUXes detected = %d (%5.2f %% of logic).\n", nMuxes, 300.0*nMuxes/Abc_NtkNodeNum(pNtk) );
503 }
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
Definition: abc.h:374
unsigned fMarkA
Definition: abc.h:134
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
Definition: abc.h:378
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
ABC_DLL int Abc_NodeIsMuxType(Abc_Obj_t *pNode)
Definition: abcUtil.c:1301
static int nMuxes
Definition: abcSat.c:36
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
#define assert(ex)
Definition: util_old.h:213
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
void Abc_NtkMultiSetBoundsFactor ( Abc_Ntk_t pNtk)
static

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

Synopsis [Sets a factor-cut boundary.]

Description []

SideEffects []

SeeAlso []

Definition at line 585 of file abcMulti.c.

586 {
587  Abc_Obj_t * pNode;
588  int i;
589  // make sure the mark is not set
590  Abc_NtkForEachObj( pNtk, pNode, i )
591  assert( pNode->fMarkA == 0 );
592  // mark the nodes where expansion stops using pNode->fMarkA
593  Abc_NtkForEachNode( pNtk, pNode, i )
594  pNode->fMarkA = (pNode->vFanouts.nSize > 1 && !Abc_NodeIsMuxControlType(pNode));
595  // mark the PO drivers
596  Abc_NtkForEachCo( pNtk, pNode, i )
597  Abc_ObjFanin0(pNode)->fMarkA = 1;
598 }
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
ABC_DLL int Abc_NodeIsMuxControlType(Abc_Obj_t *pNode)
Definition: abcUtil.c:1357
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
#define assert(ex)
Definition: util_old.h:213
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
void Abc_NtkMultiSetBoundsMulti ( Abc_Ntk_t pNtk,
int  nThresh 
)
static

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

Synopsis [Sets the expansion boundary for conversion into multi-input AND graph.]

Description []

SideEffects []

SeeAlso []

Definition at line 516 of file abcMulti.c.

517 {
518  Abc_Obj_t * pNode;
519  int i, nFanouts, nConeSize;
520 
521  // make sure the mark is not set
522  Abc_NtkForEachObj( pNtk, pNode, i )
523  assert( pNode->fMarkA == 0 );
524 
525  // mark the nodes where expansion stops using pNode->fMarkA
526  Abc_NtkForEachNode( pNtk, pNode, i )
527  {
528  // skip PI/PO nodes
529 // if ( Abc_NodeIsConst(pNode) )
530 // continue;
531  // mark the nodes with multiple fanouts
532 // if ( Abc_ObjFanoutNum(pNode) > 1 )
533 // pNode->fMarkA = 1;
534  // mark the nodes with multiple fanouts
535  nFanouts = Abc_ObjFanoutNum(pNode);
536  nConeSize = Abc_NodeMffcSizeStop(pNode);
537  if ( (nFanouts - 1) * nConeSize > nThresh )
538  pNode->fMarkA = 1;
539  // mark the children if they are pointed by the complemented edges
540  if ( Abc_ObjFaninC0(pNode) )
541  Abc_ObjFanin0(pNode)->fMarkA = 1;
542  if ( Abc_ObjFaninC1(pNode) )
543  Abc_ObjFanin1(pNode)->fMarkA = 1;
544  }
545 
546  // mark the PO drivers
547  Abc_NtkForEachCo( pNtk, pNode, i )
548  Abc_ObjFanin0(pNode)->fMarkA = 1;
549 }
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
Definition: abc.h:374
unsigned fMarkA
Definition: abc.h:134
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
Definition: abc.h:378
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
ABC_DLL int Abc_NodeMffcSizeStop(Abc_Obj_t *pNode)
Definition: abcRefs.c:74
#define assert(ex)
Definition: util_old.h:213
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
void Abc_NtkMultiSetBoundsSimple ( Abc_Ntk_t pNtk)
static

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

Synopsis [Sets a simple boundary.]

Description []

SideEffects []

SeeAlso []

Definition at line 562 of file abcMulti.c.

563 {
564  Abc_Obj_t * pNode;
565  int i;
566  // make sure the mark is not set
567  Abc_NtkForEachObj( pNtk, pNode, i )
568  assert( pNode->fMarkA == 0 );
569  // mark the nodes where expansion stops using pNode->fMarkA
570  Abc_NtkForEachNode( pNtk, pNode, i )
571  pNode->fMarkA = 1;
572 }
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
#define assert(ex)
Definition: util_old.h:213
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446