abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcUnate.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [abcUnate.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Network and node package.]
8 
9  Synopsis []
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: abcUnate.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 /// DECLARATIONS ///
29 ////////////////////////////////////////////////////////////////////////
30 
31 static void Abc_NtkPrintUnateBdd( Abc_Ntk_t * pNtk, int fUseNaive, int fVerbose );
32 static void Abc_NtkPrintUnateSat( Abc_Ntk_t * pNtk, int fVerbose );
33 
34 ////////////////////////////////////////////////////////////////////////
35 /// FUNCTION DEFINITIONS ///
36 ////////////////////////////////////////////////////////////////////////
37 
38 /**Function*************************************************************
39 
40  Synopsis [Detects unate variables of the multi-output function.]
41 
42  Description []
43 
44  SideEffects []
45 
46  SeeAlso []
47 
48 ***********************************************************************/
49 void Abc_NtkPrintUnate( Abc_Ntk_t * pNtk, int fUseBdds, int fUseNaive, int fVerbose )
50 {
51  if ( fUseBdds || fUseNaive )
52  Abc_NtkPrintUnateBdd( pNtk, fUseNaive, fVerbose );
53  else
54  Abc_NtkPrintUnateSat( pNtk, fVerbose );
55 }
56 
57 /**Function*************************************************************
58 
59  Synopsis [Detects unate variables using BDDs.]
60 
61  Description []
62 
63  SideEffects []
64 
65  SeeAlso []
66 
67 ***********************************************************************/
68 void Abc_NtkPrintUnateBdd( Abc_Ntk_t * pNtk, int fUseNaive, int fVerbose )
69 {
70  Abc_Obj_t * pNode;
72  DdManager * dd; // the BDD manager used to hold shared BDDs
73 // DdNode ** pbGlobal; // temporary storage for global BDDs
74  int TotalSupps = 0;
75  int TotalUnate = 0;
76  int i;
77  abctime clk = Abc_Clock();
78  abctime clkBdd, clkUnate;
79 
80  // compute the global BDDs
81  dd = (DdManager *)Abc_NtkBuildGlobalBdds(pNtk, 10000000, 1, 1, fVerbose);
82  if ( dd == NULL )
83  return;
84 clkBdd = Abc_Clock() - clk;
85 
86  // get information about the network
87 // dd = pNtk->pManGlob;
88 // dd = (DdManager *)Abc_NtkGlobalBddMan( pNtk );
89 // pbGlobal = (DdNode **)Vec_PtrArray( pNtk->vFuncsGlob );
90 
91  // print the size of the BDDs
92  printf( "Shared BDD size = %6d nodes.\n", Cudd_ReadKeys(dd) - Cudd_ReadDead(dd) );
93 
94  // perform naive BDD-based computation
95  if ( fUseNaive )
96  {
97  Abc_NtkForEachCo( pNtk, pNode, i )
98  {
99 // p = Extra_UnateComputeSlow( dd, pbGlobal[i] );
100  p = Extra_UnateComputeSlow( dd, (DdNode *)Abc_ObjGlobalBdd(pNode) );
101  if ( fVerbose )
103  TotalSupps += p->nVars;
104  TotalUnate += p->nUnate;
106  }
107  }
108  // perform smart BDD-based computation
109  else
110  {
111  // create ZDD variables in the manager
112  Cudd_zddVarsFromBddVars( dd, 2 );
113  Abc_NtkForEachCo( pNtk, pNode, i )
114  {
115 // p = Extra_UnateComputeFast( dd, pbGlobal[i] );
116  p = Extra_UnateComputeFast( dd, (DdNode *)Abc_ObjGlobalBdd(pNode) );
117  if ( fVerbose )
119  TotalSupps += p->nVars;
120  TotalUnate += p->nUnate;
122  }
123  }
124 clkUnate = Abc_Clock() - clk - clkBdd;
125 
126  // print stats
127  printf( "Ins/Outs = %4d/%4d. Total supp = %5d. Total unate = %5d.\n",
128  Abc_NtkCiNum(pNtk), Abc_NtkCoNum(pNtk), TotalSupps, TotalUnate );
129  ABC_PRT( "Glob BDDs", clkBdd );
130  ABC_PRT( "Unateness", clkUnate );
131  ABC_PRT( "Total ", Abc_Clock() - clk );
132 
133  // deref the PO functions
134 // Abc_NtkFreeGlobalBdds( pNtk );
135  // stop the global BDD manager
136 // Extra_StopManager( pNtk->pManGlob );
137 // pNtk->pManGlob = NULL;
138  Abc_NtkFreeGlobalBdds( pNtk, 1 );
139 }
140 
141 /**Function*************************************************************
142 
143  Synopsis [Detects unate variables using SAT.]
144 
145  Description []
146 
147  SideEffects []
148 
149  SeeAlso []
150 
151 ***********************************************************************/
152 void Abc_NtkPrintUnateSat( Abc_Ntk_t * pNtk, int fVerbose )
153 {
154 }
155 
156 ////////////////////////////////////////////////////////////////////////
157 /// END OF FILE ///
158 ////////////////////////////////////////////////////////////////////////
159 
160 
162 
void Abc_NtkPrintUnate(Abc_Ntk_t *pNtk, int fUseBdds, int fUseNaive, int fVerbose)
FUNCTION DEFINITIONS ///.
Definition: abcUnate.c:49
Definition: cudd.h:278
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Abc_NtkPrintUnateSat(Abc_Ntk_t *pNtk, int fVerbose)
Definition: abcUnate.c:152
static ABC_NAMESPACE_IMPL_START void Abc_NtkPrintUnateBdd(Abc_Ntk_t *pNtk, int fUseNaive, int fVerbose)
DECLARATIONS ///.
Definition: abcUnate.c:68
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static abctime Abc_Clock()
Definition: abc_global.h:279
void Extra_UnateInfoPrint(Extra_UnateInfo_t *)
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
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
Extra_UnateInfo_t * Extra_UnateComputeSlow(DdManager *dd, DdNode *bFunc)
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
Extra_UnateInfo_t * Extra_UnateComputeFast(DdManager *dd, DdNode *bFunc)
Definition: extraBddUnate.c:73
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
#define ABC_PRT(a, t)
Definition: abc_global.h:220
unsigned int Cudd_ReadKeys(DdManager *dd)
Definition: cuddAPI.c:1626
int Cudd_zddVarsFromBddVars(DdManager *dd, int multiplicity)
Definition: cuddAPI.c:519
void Extra_UnateInfoDissolve(Extra_UnateInfo_t *)
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