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

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START void 
Abc_NtkSymmetriesUsingBdds (Abc_Ntk_t *pNtk, int fNaive, int fReorder, int fVerbose)
 DECLARATIONS ///. More...
 
static void Abc_NtkSymmetriesUsingSandS (Abc_Ntk_t *pNtk, int fVerbose)
 
static void Ntk_NetworkSymmsBdd (DdManager *dd, Abc_Ntk_t *pNtk, int fNaive, int fVerbose)
 
static void Ntk_NetworkSymmsPrint (Abc_Ntk_t *pNtk, Extra_SymmInfo_t *pSymms)
 
void Abc_NtkSymmetries (Abc_Ntk_t *pNtk, int fUseBdds, int fNaive, int fReorder, int fVerbose)
 FUNCTION DEFINITIONS ///. More...
 

Function Documentation

void Abc_NtkSymmetries ( Abc_Ntk_t pNtk,
int  fUseBdds,
int  fNaive,
int  fReorder,
int  fVerbose 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [The top level procedure to compute symmetries.]

Description []

SideEffects []

SeeAlso []

Definition at line 52 of file abcSymm.c.

53 {
54  if ( fUseBdds || fNaive )
55  Abc_NtkSymmetriesUsingBdds( pNtk, fNaive, fReorder, fVerbose );
56  else
57  Abc_NtkSymmetriesUsingSandS( pNtk, fVerbose );
58 }
static ABC_NAMESPACE_IMPL_START void Abc_NtkSymmetriesUsingBdds(Abc_Ntk_t *pNtk, int fNaive, int fReorder, int fVerbose)
DECLARATIONS ///.
Definition: abcSymm.c:89
static void Abc_NtkSymmetriesUsingSandS(Abc_Ntk_t *pNtk, int fVerbose)
Definition: abcSymm.c:71
void Abc_NtkSymmetriesUsingBdds ( Abc_Ntk_t pNtk,
int  fNaive,
int  fReorder,
int  fVerbose 
)
static

DECLARATIONS ///.

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

FileName [abcSymm.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Computation of two-variable symmetries.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

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

Synopsis [Symmetry computation using BDDs (both naive and smart).]

Description []

SideEffects []

SeeAlso []

Definition at line 89 of file abcSymm.c.

90 {
91  DdManager * dd;
92  abctime clk, clkBdd, clkSym;
93  int fGarbCollect = 1;
94 
95  // compute the global functions
96 clk = Abc_Clock();
97  dd = (DdManager *)Abc_NtkBuildGlobalBdds( pNtk, 10000000, 1, fReorder, fVerbose );
98  printf( "Shared BDD size = %d nodes.\n", Abc_NtkSizeOfGlobalBdds(pNtk) );
99  Cudd_AutodynDisable( dd );
100  if ( !fGarbCollect )
102  Cudd_zddVarsFromBddVars( dd, 2 );
103 clkBdd = Abc_Clock() - clk;
104  // create the collapsed network
105 clk = Abc_Clock();
106  Ntk_NetworkSymmsBdd( dd, pNtk, fNaive, fVerbose );
107 clkSym = Abc_Clock() - clk;
108  // undo the global functions
109  Abc_NtkFreeGlobalBdds( pNtk, 1 );
110 printf( "Statistics of BDD-based symmetry detection:\n" );
111 printf( "Algorithm = %s. Reordering = %s. Garbage collection = %s.\n",
112  fNaive? "naive" : "fast", fReorder? "yes" : "no", fGarbCollect? "yes" : "no" );
113 ABC_PRT( "Constructing BDDs", clkBdd );
114 ABC_PRT( "Computing symms ", clkSym );
115 ABC_PRT( "TOTAL ", clkBdd + clkSym );
116 }
static void Ntk_NetworkSymmsBdd(DdManager *dd, Abc_Ntk_t *pNtk, int fNaive, int fVerbose)
Definition: abcSymm.c:129
static abctime Abc_Clock()
Definition: abc_global.h:279
ABC_DLL void * Abc_NtkFreeGlobalBdds(Abc_Ntk_t *pNtk, int fFreeMan)
Definition: abcNtbdd.c:476
void Cudd_AutodynDisable(DdManager *unique)
Definition: cuddAPI.c:708
ABC_DLL int Abc_NtkSizeOfGlobalBdds(Abc_Ntk_t *pNtk)
Definition: abcNtbdd.c:492
void Cudd_DisableGarbageCollection(DdManager *dd)
Definition: cuddAPI.c:2563
#define ABC_PRT(a, t)
Definition: abc_global.h:220
int Cudd_zddVarsFromBddVars(DdManager *dd, int multiplicity)
Definition: cuddAPI.c:519
ABC_DLL void * Abc_NtkBuildGlobalBdds(Abc_Ntk_t *pNtk, int fBddSizeMax, int fDropInternal, int fReorder, int fVerbose)
Definition: abcNtbdd.c:251
ABC_INT64_T abctime
Definition: abc_global.h:278
void Abc_NtkSymmetriesUsingSandS ( Abc_Ntk_t pNtk,
int  fVerbose 
)
static

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

Synopsis [Symmetry computation using simulation and SAT.]

Description []

SideEffects []

SeeAlso []

Definition at line 71 of file abcSymm.c.

72 {
73 // extern int Sim_ComputeTwoVarSymms( Abc_Ntk_t * pNtk, int fVerbose );
74  int nSymms = Sim_ComputeTwoVarSymms( pNtk, fVerbose );
75  printf( "The total number of symmetries is %d.\n", nSymms );
76 }
int Sim_ComputeTwoVarSymms(Abc_Ntk_t *pNtk, int fVerbose)
DECLARATIONS ///.
Definition: simSym.c:46
void Ntk_NetworkSymmsBdd ( DdManager dd,
Abc_Ntk_t pNtk,
int  fNaive,
int  fVerbose 
)
static

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

Synopsis [Symmetry computation using BDDs (both naive and smart).]

Description []

SideEffects []

SeeAlso []

Definition at line 129 of file abcSymm.c.

130 {
131  Extra_SymmInfo_t * pSymms;
132  Abc_Obj_t * pNode;
133  DdNode * bFunc;
134  int nSymms = 0;
135  int nSupps = 0;
136  int i;
137 
138  // compute symmetry info for each PO
139  Abc_NtkForEachCo( pNtk, pNode, i )
140  {
141 // bFunc = pNtk->vFuncsGlob->pArray[i];
142  bFunc = (DdNode *)Abc_ObjGlobalBdd( pNode );
143  nSupps += Cudd_SupportSize( dd, bFunc );
144  if ( Cudd_IsConstant(bFunc) )
145  continue;
146  if ( fNaive )
147  pSymms = Extra_SymmPairsComputeNaive( dd, bFunc );
148  else
149  pSymms = Extra_SymmPairsCompute( dd, bFunc );
150  nSymms += pSymms->nSymms;
151  if ( fVerbose )
152  {
153  printf( "Output %6s (%d): ", Abc_ObjName(pNode), pSymms->nSymms );
154  Ntk_NetworkSymmsPrint( pNtk, pSymms );
155  }
156 //Extra_SymmPairsPrint( pSymms );
157  Extra_SymmPairsDissolve( pSymms );
158  }
159  printf( "Total number of vars in functional supports = %8d.\n", nSupps );
160  printf( "Total number of two-variable symmetries = %8d.\n", nSymms );
161 }
Definition: cudd.h:278
Extra_SymmInfo_t * Extra_SymmPairsComputeNaive(DdManager *dd, DdNode *bFunc)
Definition: extraBddSymm.c:396
#define Cudd_IsConstant(node)
Definition: cudd.h:352
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static void Ntk_NetworkSymmsPrint(Abc_Ntk_t *pNtk, Extra_SymmInfo_t *pSymms)
Definition: abcSymm.c:174
Extra_SymmInfo_t * Extra_SymmPairsCompute(DdManager *dd, DdNode *bFunc)
Definition: extraBddSymm.c:73
static void * Abc_ObjGlobalBdd(Abc_Obj_t *pObj)
Definition: abc.h:431
void Extra_SymmPairsDissolve(Extra_SymmInfo_t *)
Definition: extraBddSymm.c:238
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
int Cudd_SupportSize(DdManager *dd, DdNode *f)
Definition: cuddUtil.c:857
void Ntk_NetworkSymmsPrint ( Abc_Ntk_t pNtk,
Extra_SymmInfo_t pSymms 
)
static

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

Synopsis [Printing symmetry groups from the symmetry data structure.]

Description []

SideEffects []

SeeAlso []

Definition at line 174 of file abcSymm.c.

175 {
176  char ** pInputNames;
177  int * pVarTaken;
178  int i, k, nVars, nSize, fStart;
179 
180  // get variable names
181  nVars = Abc_NtkCiNum(pNtk);
182  pInputNames = Abc_NtkCollectCioNames( pNtk, 0 );
183 
184  // alloc the array of marks
185  pVarTaken = ABC_ALLOC( int, nVars );
186  memset( pVarTaken, 0, sizeof(int) * nVars );
187 
188  // print the groups
189  fStart = 1;
190  nSize = pSymms->nVars;
191  for ( i = 0; i < nSize; i++ )
192  {
193  // skip the variable already considered
194  if ( pVarTaken[i] )
195  continue;
196  // find all the vars symmetric with this one
197  for ( k = 0; k < nSize; k++ )
198  {
199  if ( k == i )
200  continue;
201  if ( pSymms->pSymms[i][k] == 0 )
202  continue;
203  // vars i and k are symmetric
204  assert( pVarTaken[k] == 0 );
205  // there is a new symmetry pair
206  if ( fStart == 1 )
207  { // start a new symmetry class
208  fStart = 0;
209  printf( " { %s", pInputNames[ pSymms->pVars[i] ] );
210  // mark the var as taken
211  pVarTaken[i] = 1;
212  }
213  printf( " %s", pInputNames[ pSymms->pVars[k] ] );
214  // mark the var as taken
215  pVarTaken[k] = 1;
216  }
217  if ( fStart == 0 )
218  {
219  printf( " }" );
220  fStart = 1;
221  }
222  }
223  printf( "\n" );
224 
225  ABC_FREE( pInputNames );
226  ABC_FREE( pVarTaken );
227 }
char * memset()
char ** pSymms
Definition: extraBdd.h:219
ABC_DLL char ** Abc_NtkCollectCioNames(Abc_Ntk_t *pNtk, int fCollectCos)
Definition: abcNames.c:278
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define assert(ex)
Definition: util_old.h:213