ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
rwrExp.c File Reference
#include "rwr.h"
Include dependency graph for rwrExp.c:

Go to the source code of this file.

Classes

struct  Rwr_Man4_t_
 
struct  Rwr_Man5_t_
 

Typedefs

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

Functions

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

Typedef Documentation

◆ Rwr_Man4_t

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.

◆ Rwr_Man5_t

typedef struct Rwr_Man5_t_ Rwr_Man5_t

Definition at line 41 of file rwrExp.c.

Function Documentation

◆ Rwt_Man4ExploreCount()

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}
#define assert(ex)
Definition util_old.h:213

◆ Rwt_Man4ExplorePrint()

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}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
void Extra_PrintHex(FILE *pFile, unsigned *pTruth, int nVars)
void Extra_PrintBinary(FILE *pFile, unsigned Sign[], int nBits)
char * memset()
Here is the call graph for this function:

◆ Rwt_Man4ExploreStart()

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}
Cube * p
Definition exorList.c:222
void Extra_Truth4VarNPN(unsigned short **puCanons, char **puPhases, char **puPerms, unsigned char **puMap)
typedefABC_NAMESPACE_IMPL_START struct Rwr_Man4_t_ Rwr_Man4_t
DECLARATIONS ///.
Definition rwrExp.c:30
Here is the call graph for this function:

◆ Rwt_Man5ExploreCount()

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}
int stmm_find_or_add(stmm_table *table, char *key, char ***slot)
Definition stmm.c:266
Here is the call graph for this function:

◆ Rwt_Man5ExplorePrint()

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 occurrence = %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
288clk = 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) );
303ABC_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}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
unsigned Extra_TruthCanonNPN(unsigned uTruth, int nVars)
int stmm_lookup(stmm_table *table, char *key, char **value)
Definition stmm.c:134
#define stmm_count(table)
Definition stmm.h:76
#define stmm_foreach_item(table, gen, key, value)
Definition stmm.h:121
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the call graph for this function:

◆ Rwt_Man5ExploreStart()

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) );
183 p->tTableNN = stmm_init_table( st__numcmp, st__numhash );
184 p->tTableNPN = stmm_init_table( st__numcmp, st__numhash );
185 s_pManRwrExp5 = p;
186
187//Extra_PrintHex( stdout, Extra_TruthCanonNPN( 0x0000FFFF, 5 ), 5 );
188//printf( "\n" );
189}
struct Rwr_Man5_t_ Rwr_Man5_t
Definition rwrExp.c:41
int st__numhash(const char *, int)
Definition st.c:461
int st__numcmp(const char *, const char *)
Definition st.c:473
stmm_table * stmm_init_table(stmm_compare_func_type compare, stmm_hash_func_type hash)
Definition stmm.c:69
Here is the call graph for this function: