abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcCas.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [abcCas.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Network and node package.]
8 
9  Synopsis [Decomposition of shared BDDs into LUT cascade.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: abcCas.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "base/abc/abc.h"
22 #include "misc/extra/extraBdd.h"
23 
25 
26 
27 /*
28  This LUT cascade synthesis algorithm is described in the paper:
29  A. Mishchenko and T. Sasao, "Encoding of Boolean functions and its
30  application to LUT cascade synthesis", Proc. IWLS '02, pp. 115-120.
31  http://www.eecs.berkeley.edu/~alanmi/publications/2002/iwls02_enc.pdf
32 */
33 
34 ////////////////////////////////////////////////////////////////////////
35 /// DECLARATIONS ///
36 ////////////////////////////////////////////////////////////////////////
37 
38 extern int Abc_CascadeExperiment( char * pFileGeneric, DdManager * dd, DdNode ** pOutputs, int nInputs, int nOutputs, int nLutSize, int fCheck, int fVerbose );
39 
40 ////////////////////////////////////////////////////////////////////////
41 /// FUNCTION DEFINITIONS ///
42 ////////////////////////////////////////////////////////////////////////
43 
44 /**Function*************************************************************
45 
46  Synopsis []
47 
48  Description []
49 
50  SideEffects []
51 
52  SeeAlso []
53 
54 ***********************************************************************/
55 Abc_Ntk_t * Abc_NtkCascade( Abc_Ntk_t * pNtk, int nLutSize, int fCheck, int fVerbose )
56 {
57  DdManager * dd;
58  DdNode ** ppOutputs;
59  Abc_Ntk_t * pNtkNew;
60  Abc_Obj_t * pNode;
61  char * pFileGeneric;
62  int fBddSizeMax = 500000;
63  int i, fReorder = 1;
64  abctime clk = Abc_Clock();
65 
66  assert( Abc_NtkIsStrash(pNtk) );
67  // compute the global BDDs
68  if ( Abc_NtkBuildGlobalBdds(pNtk, fBddSizeMax, 1, fReorder, fVerbose) == NULL )
69  return NULL;
70 
71  if ( fVerbose )
72  {
73  DdManager * dd = (DdManager *)Abc_NtkGlobalBddMan( pNtk );
74  printf( "Shared BDD size = %6d nodes. ", Cudd_ReadKeys(dd) - Cudd_ReadDead(dd) );
75  ABC_PRT( "BDD construction time", Abc_Clock() - clk );
76  }
77 
78  // collect global BDDs
79  dd = (DdManager *)Abc_NtkGlobalBddMan( pNtk );
80  ppOutputs = ABC_ALLOC( DdNode *, Abc_NtkCoNum(pNtk) );
81  Abc_NtkForEachCo( pNtk, pNode, i )
82  ppOutputs[i] = (DdNode *)Abc_ObjGlobalBdd(pNode);
83 
84  // call the decomposition
85  pFileGeneric = Extra_FileNameGeneric( pNtk->pSpec );
86  if ( !Abc_CascadeExperiment( pFileGeneric, dd, ppOutputs, Abc_NtkCiNum(pNtk), Abc_NtkCoNum(pNtk), nLutSize, fCheck, fVerbose ) )
87  {
88  // the LUT size is too small
89  }
90 
91  // for now, duplicate the network
92  pNtkNew = Abc_NtkDup( pNtk );
93 
94  // cleanup
95  Abc_NtkFreeGlobalBdds( pNtk, 1 );
96  ABC_FREE( ppOutputs );
97  ABC_FREE( pFileGeneric );
98 
99 // if ( pNtk->pExdc )
100 // pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc );
101  // make sure that everything is okay
102  if ( !Abc_NtkCheck( pNtkNew ) )
103  {
104  printf( "Abc_NtkCollapse: The network check has failed.\n" );
105  Abc_NtkDelete( pNtkNew );
106  return NULL;
107  }
108  return pNtkNew;
109 }
110 
111 ////////////////////////////////////////////////////////////////////////
112 /// END OF FILE ///
113 ////////////////////////////////////////////////////////////////////////
114 
115 
117 
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
Definition: cudd.h:278
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:419
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
static void * Abc_ObjGlobalBdd(Abc_Obj_t *pObj)
Definition: abc.h:431
ABC_DLL void * Abc_NtkFreeGlobalBdds(Abc_Ntk_t *pNtk, int fFreeMan)
Definition: abcNtbdd.c:476
char * Extra_FileNameGeneric(char *FileName)
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
char * pSpec
Definition: abc.h:159
static void * Abc_NtkGlobalBddMan(Abc_Ntk_t *pNtk)
Definition: abc.h:429
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_PRT(a, t)
Definition: abc_global.h:220
unsigned int Cudd_ReadKeys(DdManager *dd)
Definition: cuddAPI.c:1626
ABC_NAMESPACE_IMPL_START int Abc_CascadeExperiment(char *pFileGeneric, DdManager *dd, DdNode **pOutputs, int nInputs, int nOutputs, int nLutSize, int fCheck, int fVerbose)
DECLARATIONS ///.
Definition: casCore.c:79
#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_NtkCascade(Abc_Ntk_t *pNtk, int nLutSize, int fCheck, int fVerbose)
FUNCTION DEFINITIONS ///.
Definition: abcCas.c:55