abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
rwrExp.c File Reference
#include "rwr.h"

Go to the source code of this file.

Data Structures

struct  Rwr_Man4_t_
 
struct  Rwr_Man5_t_
 

Typedefs

typedef
typedefABC_NAMESPACE_IMPL_START
struct Rwr_Man4_t_ 
Rwr_Man4_t
 DECLARATIONS ///. More...
 
typedef struct Rwr_Man5_t_ Rwr_Man5_t
 

Functions

void Rwt_Man4ExploreStart ()
 FUNCTION DEFINITIONS ///. More...
 
void Rwt_Man4ExploreCount (unsigned uTruth)
 
void Rwt_Man4ExplorePrint ()
 
void Rwt_Man5ExploreStart ()
 
void Rwt_Man5ExploreCount (unsigned uTruth)
 
void Rwt_Man5ExplorePrint ()
 

Variables

static Rwr_Man4_ts_pManRwrExp4 = NULL
 
static Rwr_Man5_ts_pManRwrExp5 = NULL
 

Typedef Documentation

typedef typedefABC_NAMESPACE_IMPL_START struct Rwr_Man4_t_ Rwr_Man4_t

DECLARATIONS ///.

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

FileName [rwrExp.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [DAG-aware AIG rewriting package.]

Synopsis [Computation of practically used NN-classes of 4-input cuts.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 30 of file rwrExp.c.

typedef struct Rwr_Man5_t_ Rwr_Man5_t

Definition at line 41 of file rwrExp.c.

Function Documentation

void Rwt_Man4ExploreCount ( unsigned  uTruth)

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

Synopsis [Collects stats about 4-var functions appearing in netlists.]

Description []

SideEffects []

SeeAlso []

Definition at line 93 of file rwrExp.c.

94 {
95  assert( uTruth < (1<<16) );
96  s_pManRwrExp4->pnCounts[ s_pManRwrExp4->puCanons[uTruth] ]++;
97 }
static Rwr_Man4_t * s_pManRwrExp4
Definition: rwrExp.c:49
#define assert(ex)
Definition: util_old.h:213
void Rwt_Man4ExplorePrint ( )

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

Synopsis [Collects stats about 4-var functions appearing in netlists.]

Description []

SideEffects []

SeeAlso []

Definition at line 110 of file rwrExp.c.

111 {
112  FILE * pFile;
113  int i, CountMax, CountWrite, nCuts, nClasses;
114  int * pDistrib;
115  int * pReprs;
116  // find the max number of occurences
117  nCuts = nClasses = 0;
118  CountMax = 0;
119  for ( i = 0; i < s_pManRwrExp4->nFuncs; i++ )
120  {
121  if ( CountMax < s_pManRwrExp4->pnCounts[i] )
122  CountMax = s_pManRwrExp4->pnCounts[i];
123  nCuts += s_pManRwrExp4->pnCounts[i];
124  if ( s_pManRwrExp4->pnCounts[i] > 0 )
125  nClasses++;
126  }
127  printf( "Number of cuts considered = %8d.\n", nCuts );
128  printf( "Classes occurring at least once = %8d.\n", nClasses );
129  // print the distribution of classes
130  pDistrib = ABC_ALLOC( int, CountMax + 1 );
131  pReprs = ABC_ALLOC( int, CountMax + 1 );
132  memset( pDistrib, 0, sizeof(int)*(CountMax + 1) );
133  for ( i = 0; i < s_pManRwrExp4->nFuncs; i++ )
134  {
135  pDistrib[ s_pManRwrExp4->pnCounts[i] ]++;
136  pReprs[ s_pManRwrExp4->pnCounts[i] ] = i;
137  }
138 
139  printf( "Occurence = %6d. Num classes = %4d. \n", 0, 2288-nClasses );
140  for ( i = 1; i <= CountMax; i++ )
141  if ( pDistrib[i] )
142  {
143  printf( "Occurence = %6d. Num classes = %4d. Repr = ", i, pDistrib[i] );
144  Extra_PrintBinary( stdout, (unsigned*)&(pReprs[i]), 16 );
145  printf( "\n" );
146  }
147  ABC_FREE( pDistrib );
148  ABC_FREE( pReprs );
149  // write into a file all classes above limit (5)
150  CountWrite = 0;
151  pFile = fopen( "npnclass_stats4.txt", "w" );
152  for ( i = 0; i < s_pManRwrExp4->nFuncs; i++ )
153  if ( s_pManRwrExp4->pnCounts[i] > 0 )
154  {
155  Extra_PrintHex( pFile, (unsigned *)&i, 4 );
156  fprintf( pFile, " %10d\n", s_pManRwrExp4->pnCounts[i] );
157 // fprintf( pFile, "%d ", i );
158  CountWrite++;
159  }
160  fclose( pFile );
161  printf( "%d classes written into file \"%s\".\n", CountWrite, "npnclass_stats4.txt" );
162 }
char * memset()
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
void Extra_PrintHex(FILE *pFile, unsigned *pTruth, int nVars)
void Extra_PrintBinary(FILE *pFile, unsigned Sign[], int nBits)
#define ABC_FREE(obj)
Definition: abc_global.h:232
static Rwr_Man4_t * s_pManRwrExp4
Definition: rwrExp.c:49
void Rwt_Man4ExploreStart ( )

FUNCTION DEFINITIONS ///.

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

Synopsis [Collects stats about 4-var functions appearing in netlists.]

Description []

SideEffects []

SeeAlso []

Definition at line 67 of file rwrExp.c.

68 {
69  Rwr_Man4_t * p;
70  p = ABC_ALLOC( Rwr_Man4_t, 1 );
71  memset( p, 0, sizeof(Rwr_Man4_t) );
72  // canonical forms
73  p->nFuncs = (1<<16);
74  // canonical forms, phases, perms
75  Extra_Truth4VarNPN( &p->puCanons, NULL, NULL, NULL );
76  // counters
77  p->pnCounts = ABC_ALLOC( int, p->nFuncs );
78  memset( p->pnCounts, 0, sizeof(int) * p->nFuncs );
79  s_pManRwrExp4 = p;
80 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
typedefABC_NAMESPACE_IMPL_START struct Rwr_Man4_t_ Rwr_Man4_t
DECLARATIONS ///.
Definition: rwrExp.c:30
static Rwr_Man4_t * s_pManRwrExp4
Definition: rwrExp.c:49
void Extra_Truth4VarNPN(unsigned short **puCanons, char **puPhases, char **puPerms, unsigned char **puMap)
void Rwt_Man5ExploreCount ( unsigned  uTruth)

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

Synopsis [Collects stats about 4-var functions appearing in netlists.]

Description []

SideEffects []

SeeAlso []

Definition at line 202 of file rwrExp.c.

203 {
204  int * pCounter;
205  if ( !stmm_find_or_add( s_pManRwrExp5->tTableNN, (char *)(ABC_PTRUINT_T)uTruth, (char***)&pCounter ) )
206  *pCounter = 0;
207  (*pCounter)++;
208 }
static Rwr_Man5_t * s_pManRwrExp5
Definition: rwrExp.c:50
stmm_table * tTableNN
Definition: rwrExp.c:45
int stmm_find_or_add(stmm_table *table, char *key, char ***slot)
Definition: stmm.c:266
void Rwt_Man5ExplorePrint ( )

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

Synopsis [Collects stats about 4-var functions appearing in netlists.]

Description []

SideEffects []

SeeAlso []

Definition at line 221 of file rwrExp.c.

222 {
223  FILE * pFile;
224  stmm_generator * gen;
225  int i, CountMax, nCuts, Counter;
226  int * pDistrib;
227  unsigned * pReprs;
228  unsigned uTruth, uTruthC;
229  abctime clk = Abc_Clock();
230  Vec_Int_t * vClassesNN, * vClassesNPN;
231 
232  // find the max number of occurences
233  nCuts = 0;
234  CountMax = 0;
235  stmm_foreach_item( s_pManRwrExp5->tTableNN, gen, (char **)&uTruth, (char **)&Counter )
236  {
237  nCuts += Counter;
238  if ( CountMax < Counter )
239  CountMax = Counter;
240  }
241  printf( "Number of cuts considered = %8d.\n", nCuts );
242  printf( "Classes occurring at least once = %8d.\n", stmm_count(s_pManRwrExp5->tTableNN) );
243  printf( "The largest number of occurence = %8d.\n", CountMax );
244 
245  // print the distribution of classes
246  pDistrib = ABC_ALLOC( int, CountMax + 1 );
247  pReprs = ABC_ALLOC( unsigned, CountMax + 1 );
248  memset( pDistrib, 0, sizeof(int)*(CountMax + 1) );
249  stmm_foreach_item( s_pManRwrExp5->tTableNN, gen, (char **)&uTruth, (char **)&Counter )
250  {
251  assert( Counter <= CountMax );
252  pDistrib[ Counter ]++;
253  pReprs[ Counter ] = uTruth;
254  }
255 
256  for ( i = 1; i <= CountMax; i++ )
257  if ( pDistrib[i] )
258  {
259  printf( "Occurence = %6d. Num classes = %4d. Repr = ", i, pDistrib[i] );
260  Extra_PrintBinary( stdout, pReprs + i, 32 );
261  printf( "\n" );
262  }
263  ABC_FREE( pDistrib );
264  ABC_FREE( pReprs );
265 
266 
267  // put them into an array
268  vClassesNN = Vec_IntAlloc( stmm_count(s_pManRwrExp5->tTableNN) );
269  stmm_foreach_item( s_pManRwrExp5->tTableNN, gen, (char **)&uTruth, NULL )
270  Vec_IntPush( vClassesNN, (int)uTruth );
271  Vec_IntSortUnsigned( vClassesNN );
272 
273  // write into a file all classes
274  pFile = fopen( "nnclass_stats5.txt", "w" );
275  Vec_IntForEachEntry( vClassesNN, uTruth, i )
276  {
277  if ( !stmm_lookup( s_pManRwrExp5->tTableNN, (char *)(ABC_PTRUINT_T)uTruth, (char **)&Counter ) )
278  {
279  assert( 0 );
280  }
281  Extra_PrintHex( pFile, &uTruth, 5 );
282  fprintf( pFile, " %10d\n", Counter );
283  }
284  fclose( pFile );
285  printf( "%d classes written into file \"%s\".\n", vClassesNN->nSize, "nnclass_stats5.txt" );
286 
287 
288 clk = Abc_Clock();
289  // how many NPN classes exist?
290  Vec_IntForEachEntry( vClassesNN, uTruth, i )
291  {
292  int * pCounter;
293  uTruthC = Extra_TruthCanonNPN( uTruth, 5 );
294  if ( !stmm_find_or_add( s_pManRwrExp5->tTableNPN, (char *)(ABC_PTRUINT_T)uTruthC, (char***)&pCounter ) )
295  *pCounter = 0;
296  if ( !stmm_lookup( s_pManRwrExp5->tTableNN, (char *)(ABC_PTRUINT_T)uTruth, (char **)&Counter ) )
297  {
298  assert( 0 );
299  }
300  (*pCounter) += Counter;
301  }
302  printf( "The numbe of NPN classes = %d.\n", stmm_count(s_pManRwrExp5->tTableNPN) );
303 ABC_PRT( "Computing NPN classes", Abc_Clock() - clk );
304 
305  // put them into an array
306  vClassesNPN = Vec_IntAlloc( stmm_count(s_pManRwrExp5->tTableNPN) );
307  stmm_foreach_item( s_pManRwrExp5->tTableNPN, gen, (char **)&uTruth, NULL )
308  Vec_IntPush( vClassesNPN, (int)uTruth );
309  Vec_IntSortUnsigned( vClassesNPN );
310 
311  // write into a file all classes
312  pFile = fopen( "npnclass_stats5.txt", "w" );
313  Vec_IntForEachEntry( vClassesNPN, uTruth, i )
314  {
315  if ( !stmm_lookup( s_pManRwrExp5->tTableNPN, (char *)(ABC_PTRUINT_T)uTruth, (char **)&Counter ) )
316  {
317  assert( 0 );
318  }
319  Extra_PrintHex( pFile, &uTruth, 5 );
320  fprintf( pFile, " %10d\n", Counter );
321  }
322  fclose( pFile );
323  printf( "%d classes written into file \"%s\".\n", vClassesNPN->nSize, "npnclass_stats5.txt" );
324 
325 
326  // can they be uniquely characterized?
327 
328 }
char * memset()
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static Rwr_Man5_t * s_pManRwrExp5
Definition: rwrExp.c:50
#define stmm_count(table)
Definition: stmm.h:76
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
stmm_table * tTableNN
Definition: rwrExp.c:45
static abctime Abc_Clock()
Definition: abc_global.h:279
void Extra_PrintHex(FILE *pFile, unsigned *pTruth, int nVars)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
int stmm_lookup(stmm_table *table, char *key, char **value)
Definition: stmm.c:134
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Counter
int stmm_find_or_add(stmm_table *table, char *key, char ***slot)
Definition: stmm.c:266
unsigned Extra_TruthCanonNPN(unsigned uTruth, int nVars)
stmm_table * tTableNPN
Definition: rwrExp.c:46
void Extra_PrintBinary(FILE *pFile, unsigned Sign[], int nBits)
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_PRT(a, t)
Definition: abc_global.h:220
static void Vec_IntSortUnsigned(Vec_Int_t *p)
Definition: vecInt.h:1511
#define assert(ex)
Definition: util_old.h:213
#define stmm_foreach_item(table, gen, key, value)
Definition: stmm.h:121
ABC_INT64_T abctime
Definition: abc_global.h:278
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
void Rwt_Man5ExploreStart ( )

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

Synopsis [Collects stats about 4-var functions appearing in netlists.]

Description []

SideEffects []

SeeAlso []

Definition at line 178 of file rwrExp.c.

179 {
180  Rwr_Man5_t * p;
181  p = ABC_ALLOC( Rwr_Man5_t, 1 );
182  memset( p, 0, sizeof(Rwr_Man5_t) );
185  s_pManRwrExp5 = p;
186 
187 //Extra_PrintHex( stdout, Extra_TruthCanonNPN( 0x0000FFFF, 5 ), 5 );
188 //printf( "\n" );
189 }
char * memset()
stmm_table * stmm_init_table(stmm_compare_func_type compare, stmm_hash_func_type hash)
Definition: stmm.c:69
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Rwr_Man5_t * s_pManRwrExp5
Definition: rwrExp.c:50
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
stmm_table * tTableNN
Definition: rwrExp.c:45
int st__numcmp(const char *, const char *)
Definition: st.c:474
stmm_table * tTableNPN
Definition: rwrExp.c:46
int st__numhash(const char *, int)
Definition: st.c:462

Variable Documentation

Rwr_Man4_t* s_pManRwrExp4 = NULL
static

Definition at line 49 of file rwrExp.c.

Rwr_Man5_t* s_pManRwrExp5 = NULL
static

Definition at line 50 of file rwrExp.c.