abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcCollapse.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
Abc_Ntk_t
Abc_NtkFromGlobalBdds (Abc_Ntk_t *pNtk)
 DECLARATIONS ///. More...
 
static Abc_Obj_tAbc_NodeFromGlobalBdds (Abc_Ntk_t *pNtkNew, DdManager *dd, DdNode *bFunc)
 
Abc_Ntk_tAbc_NtkCollapse (Abc_Ntk_t *pNtk, int fBddSizeMax, int fDualRail, int fReorder, int fVerbose)
 FUNCTION DEFINITIONS ///. More...
 

Function Documentation

Abc_Obj_t * Abc_NodeFromGlobalBdds ( Abc_Ntk_t pNtkNew,
DdManager dd,
DdNode bFunc 
)
static

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

Synopsis [Derives the network with the given global BDD.]

Description []

SideEffects []

SeeAlso []

Definition at line 199 of file abcCollapse.c.

200 {
201  Abc_Obj_t * pNodeNew, * pTemp;
202  int i;
203  // create a new node
204  pNodeNew = Abc_NtkCreateNode( pNtkNew );
205  // add the fanins in the order, in which they appear in the reordered manager
206  Abc_NtkForEachCi( pNtkNew, pTemp, i )
207  Abc_ObjAddFanin( pNodeNew, Abc_NtkCi(pNtkNew, dd->invperm[i]) );
208  // transfer the function
209  pNodeNew->pData = Extra_TransferLevelByLevel( dd, (DdManager *)pNtkNew->pManFunc, bFunc ); Cudd_Ref( (DdNode *)pNodeNew->pData );
210  return pNodeNew;
211 }
Definition: cudd.h:278
static Abc_Obj_t * Abc_NtkCi(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:317
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
DdNode * Extra_TransferLevelByLevel(DdManager *ddSource, DdManager *ddDestination, DdNode *f)
Definition: extraBddMisc.c:112
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
Definition: abc.h:308
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
Abc_Ntk_t* Abc_NtkCollapse ( Abc_Ntk_t pNtk,
int  fBddSizeMax,
int  fDualRail,
int  fReorder,
int  fVerbose 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Collapses the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 49 of file abcCollapse.c.

50 {
51  Abc_Ntk_t * pNtkNew;
52  abctime clk = Abc_Clock();
53 
54  assert( Abc_NtkIsStrash(pNtk) );
55  // compute the global BDDs
56  if ( Abc_NtkBuildGlobalBdds(pNtk, fBddSizeMax, 1, fReorder, fVerbose) == NULL )
57  return NULL;
58  if ( fVerbose )
59  {
60  DdManager * dd = (DdManager *)Abc_NtkGlobalBddMan( pNtk );
61  printf( "Shared BDD size = %6d nodes. ", Cudd_ReadKeys(dd) - Cudd_ReadDead(dd) );
62  ABC_PRT( "BDD construction time", Abc_Clock() - clk );
63  }
64 
65  // create the new network
66  pNtkNew = Abc_NtkFromGlobalBdds( pNtk );
67 // Abc_NtkFreeGlobalBdds( pNtk );
68  Abc_NtkFreeGlobalBdds( pNtk, 1 );
69  if ( pNtkNew == NULL )
70  {
71 // Cudd_Quit( pNtk->pManGlob );
72 // pNtk->pManGlob = NULL;
73  return NULL;
74  }
75 // Extra_StopManager( pNtk->pManGlob );
76 // pNtk->pManGlob = NULL;
77 
78  // make the network minimum base
79  Abc_NtkMinimumBase( pNtkNew );
80 
81  if ( pNtk->pExdc )
82  pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc );
83 
84  // make sure that everything is okay
85  if ( !Abc_NtkCheck( pNtkNew ) )
86  {
87  printf( "Abc_NtkCollapse: The network check has failed.\n" );
88  Abc_NtkDelete( pNtkNew );
89  return NULL;
90  }
91  return pNtkNew;
92 }
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
static abctime Abc_Clock()
Definition: abc_global.h:279
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
ABC_DLL void * Abc_NtkFreeGlobalBdds(Abc_Ntk_t *pNtk, int fFreeMan)
Definition: abcNtbdd.c:476
static ABC_NAMESPACE_IMPL_START Abc_Ntk_t * Abc_NtkFromGlobalBdds(Abc_Ntk_t *pNtk)
DECLARATIONS ///.
Definition: abcCollapse.c:108
static void * Abc_NtkGlobalBddMan(Abc_Ntk_t *pNtk)
Definition: abc.h:429
#define ABC_PRT(a, t)
Definition: abc_global.h:220
unsigned int Cudd_ReadKeys(DdManager *dd)
Definition: cuddAPI.c:1626
#define assert(ex)
Definition: util_old.h:213
ABC_DLL void * Abc_NtkBuildGlobalBdds(Abc_Ntk_t *pNtk, int fBddSizeMax, int fDropInternal, int fReorder, int fVerbose)
Definition: abcNtbdd.c:251
unsigned int Cudd_ReadDead(DdManager *dd)
Definition: cuddAPI.c:1646
ABC_INT64_T abctime
Definition: abc_global.h:278
Abc_Ntk_t * Abc_NtkFromGlobalBdds ( Abc_Ntk_t pNtk)
static

DECLARATIONS ///.

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

FileName [abcCollapse.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Collapsing the network into two-levels.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

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

Synopsis [Derives the network with the given global BDD.]

Description []

SideEffects []

SeeAlso []

Definition at line 108 of file abcCollapse.c.

109 {
110 // extern void Extra_ShuffleTest( reo_man * p, DdManager * dd, DdNode * Func );
111 // reo_man * pReo;
112 
113  ProgressBar * pProgress;
114  Abc_Ntk_t * pNtkNew;
115  Abc_Obj_t * pNode, * pDriver, * pNodeNew;
116 // DdManager * dd = pNtk->pManGlob;
117  DdManager * dd = (DdManager *)Abc_NtkGlobalBddMan( pNtk );
118  int i;
119 
120  // extract don't-care and compute ISOP
121  if ( pNtk->pExdc )
122  {
123  DdManager * ddExdc = NULL;
124  DdNode * bBddMin, * bBddDc, * bBddL, * bBddU;
125  assert( Abc_NtkIsStrash(pNtk->pExdc) );
126  assert( Abc_NtkCoNum(pNtk->pExdc) == 1 );
127  // compute the global BDDs
128  if ( Abc_NtkBuildGlobalBdds(pNtk->pExdc, 10000000, 1, 1, 0) == NULL )
129  return NULL;
130  // transfer tot the same manager
131  ddExdc = (DdManager *)Abc_NtkGlobalBddMan( pNtk->pExdc );
132  bBddDc = (DdNode *)Abc_ObjGlobalBdd(Abc_NtkCo(pNtk->pExdc, 0));
133  bBddDc = Cudd_bddTransfer( ddExdc, dd, bBddDc ); Cudd_Ref( bBddDc );
134  Abc_NtkFreeGlobalBdds( pNtk->pExdc, 1 );
135  // minimize the output
136  Abc_NtkForEachCo( pNtk, pNode, i )
137  {
138  bBddMin = (DdNode *)Abc_ObjGlobalBdd(pNode);
139  // derive lower and uppwer bound
140  bBddL = Cudd_bddAnd( dd, bBddMin, Cudd_Not(bBddDc) ); Cudd_Ref( bBddL );
141  bBddU = Cudd_bddAnd( dd, Cudd_Not(bBddMin), Cudd_Not(bBddDc) ); Cudd_Ref( bBddU );
142  Cudd_RecursiveDeref( dd, bBddMin );
143  // compute new one
144  bBddMin = Cudd_bddIsop( dd, bBddL, Cudd_Not(bBddU) ); Cudd_Ref( bBddMin );
145  Cudd_RecursiveDeref( dd, bBddL );
146  Cudd_RecursiveDeref( dd, bBddU );
147  // update global BDD
148  Abc_ObjSetGlobalBdd( pNode, bBddMin );
149  //Extra_bddPrint( dd, bBddMin ); printf( "\n" );
150  }
151  Cudd_RecursiveDeref( dd, bBddDc );
152  }
153 
154 // pReo = Extra_ReorderInit( Abc_NtkCiNum(pNtk), 1000 );
155 // runtime1 = runtime2 = 0;
156 
157  // start the new network
158  pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_BDD );
159  // make sure the new manager has the same number of inputs
160  Cudd_bddIthVar( (DdManager *)pNtkNew->pManFunc, dd->size-1 );
161  // process the POs
162  pProgress = Extra_ProgressBarStart( stdout, Abc_NtkCoNum(pNtk) );
163  Abc_NtkForEachCo( pNtk, pNode, i )
164  {
165  Extra_ProgressBarUpdate( pProgress, i, NULL );
166  pDriver = Abc_ObjFanin0(pNode);
167  if ( Abc_ObjIsCi(pDriver) && !strcmp(Abc_ObjName(pNode), Abc_ObjName(pDriver)) )
168  {
169  Abc_ObjAddFanin( pNode->pCopy, pDriver->pCopy );
170  continue;
171  }
172 // pNodeNew = Abc_NodeFromGlobalBdds( pNtkNew, dd, Vec_PtrEntry(pNtk->vFuncsGlob, i) );
173  pNodeNew = Abc_NodeFromGlobalBdds( pNtkNew, dd, (DdNode *)Abc_ObjGlobalBdd(pNode) );
174  Abc_ObjAddFanin( pNode->pCopy, pNodeNew );
175 
176 // Extra_ShuffleTest( pReo, dd, Abc_ObjGlobalBdd(pNode) );
177 
178  }
179  Extra_ProgressBarStop( pProgress );
180 
181 // Extra_ReorderQuit( pReo );
182 //ABC_PRT( "Reo ", runtime1 );
183 //ABC_PRT( "Cudd", runtime2 );
184 
185  return pNtkNew;
186 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
Abc_Ntk_t * pExdc
Definition: abc.h:201
int size
Definition: cuddInt.h:361
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
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
DdNode * Cudd_bddTransfer(DdManager *ddSource, DdManager *ddDestination, DdNode *f)
Definition: cuddBridge.c:409
static Abc_Obj_t * Abc_NtkCo(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:318
static void * Abc_ObjGlobalBdd(Abc_Obj_t *pObj)
Definition: abc.h:431
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
int strcmp()
ABC_DLL void * Abc_NtkFreeGlobalBdds(Abc_Ntk_t *pNtk, int fFreeMan)
Definition: abcNtbdd.c:476
void * pManFunc
Definition: abc.h:191
DECLARATIONS ///.
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition: abcNtk.c:106
Abc_Obj_t * pCopy
Definition: abc.h:148
void Extra_ProgressBarStop(ProgressBar *p)
static void Abc_ObjSetGlobalBdd(Abc_Obj_t *pObj, void *bF)
Definition: abc.h:432
DdNode * Cudd_bddIsop(DdManager *dd, DdNode *L, DdNode *U)
Definition: cuddZddIsop.c:174
static void * Abc_NtkGlobalBddMan(Abc_Ntk_t *pNtk)
Definition: abc.h:429
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
DdNode * Cudd_bddIthVar(DdManager *dd, int i)
Definition: cuddAPI.c:416
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
DdNode * Cudd_bddAnd(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddBddIte.c:314
#define assert(ex)
Definition: util_old.h:213
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
ABC_DLL void * Abc_NtkBuildGlobalBdds(Abc_Ntk_t *pNtk, int fBddSizeMax, int fDropInternal, int fReorder, int fVerbose)
Definition: abcNtbdd.c:251
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
static Abc_Obj_t * Abc_NodeFromGlobalBdds(Abc_Ntk_t *pNtkNew, DdManager *dd, DdNode *bFunc)
Definition: abcCollapse.c:199