#include "rwr.h"
Go to the source code of this file.
Data Structures | |
struct | Rwr_Man4_t_ |
struct | Rwr_Man5_t_ |
Typedefs | |
typedef struct Rwr_Man4_t_ | Rwr_Man4_t |
typedef struct Rwr_Man5_t_ | Rwr_Man5_t |
Functions | |
void | Rwt_Man4ExploreStart () |
void | Rwt_Man4ExploreCount (unsigned uTruth) |
void | Rwt_Man4ExplorePrint () |
void | Rwt_Man5ExploreStart () |
void | Rwt_Man5ExploreCount (unsigned uTruth) |
void | Rwt_Man5ExplorePrint () |
Variables | |
static Rwr_Man4_t * | s_pManRwrExp4 = NULL |
static Rwr_Man5_t * | s_pManRwrExp5 = NULL |
typedef struct Rwr_Man4_t_ Rwr_Man4_t |
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 [
] DECLARATIONS ///
typedef struct Rwr_Man5_t_ Rwr_Man5_t |
void Rwt_Man4ExploreCount | ( | unsigned | uTruth | ) |
Function*************************************************************
Synopsis [Collects stats about 4-var functions appearing in netlists.]
Description []
SideEffects []
SeeAlso []
Definition at line 90 of file rwrExp.c.
00091 { 00092 assert( uTruth < (1<<16) ); 00093 s_pManRwrExp4->pnCounts[ s_pManRwrExp4->puCanons[uTruth] ]++; 00094 }
void Rwt_Man4ExplorePrint | ( | ) |
Function*************************************************************
Synopsis [Collects stats about 4-var functions appearing in netlists.]
Description []
SideEffects []
SeeAlso []
Definition at line 107 of file rwrExp.c.
00108 { 00109 FILE * pFile; 00110 int i, CountMax, CountWrite, nCuts, nClasses; 00111 int * pDistrib; 00112 int * pReprs; 00113 // find the max number of occurences 00114 nCuts = nClasses = 0; 00115 CountMax = 0; 00116 for ( i = 0; i < s_pManRwrExp4->nFuncs; i++ ) 00117 { 00118 if ( CountMax < s_pManRwrExp4->pnCounts[i] ) 00119 CountMax = s_pManRwrExp4->pnCounts[i]; 00120 nCuts += s_pManRwrExp4->pnCounts[i]; 00121 if ( s_pManRwrExp4->pnCounts[i] > 0 ) 00122 nClasses++; 00123 } 00124 printf( "Number of cuts considered = %8d.\n", nCuts ); 00125 printf( "Classes occurring at least once = %8d.\n", nClasses ); 00126 // print the distribution of classes 00127 pDistrib = ALLOC( int, CountMax + 1 ); 00128 pReprs = ALLOC( int, CountMax + 1 ); 00129 memset( pDistrib, 0, sizeof(int)*(CountMax + 1) ); 00130 for ( i = 0; i < s_pManRwrExp4->nFuncs; i++ ) 00131 { 00132 pDistrib[ s_pManRwrExp4->pnCounts[i] ]++; 00133 pReprs[ s_pManRwrExp4->pnCounts[i] ] = i; 00134 } 00135 00136 printf( "Occurence = %6d. Num classes = %4d. \n", 0, 2288-nClasses ); 00137 for ( i = 1; i <= CountMax; i++ ) 00138 if ( pDistrib[i] ) 00139 { 00140 printf( "Occurence = %6d. Num classes = %4d. Repr = ", i, pDistrib[i] ); 00141 Extra_PrintBinary( stdout, (unsigned*)&(pReprs[i]), 16 ); 00142 printf( "\n" ); 00143 } 00144 free( pDistrib ); 00145 free( pReprs ); 00146 // write into a file all classes above limit (5) 00147 CountWrite = 0; 00148 pFile = fopen( "npnclass_stats4.txt", "w" ); 00149 for ( i = 0; i < s_pManRwrExp4->nFuncs; i++ ) 00150 if ( s_pManRwrExp4->pnCounts[i] > 0 ) 00151 { 00152 Extra_PrintHex( pFile, i, 4 ); 00153 fprintf( pFile, " %10d\n", s_pManRwrExp4->pnCounts[i] ); 00154 // fprintf( pFile, "%d ", i ); 00155 CountWrite++; 00156 } 00157 fclose( pFile ); 00158 printf( "%d classes written into file \"%s\".\n", CountWrite, "npnclass_stats4.txt" ); 00159 }
void Rwt_Man4ExploreStart | ( | ) |
FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis [Collects stats about 4-var functions appearing in netlists.]
Description []
SideEffects []
SeeAlso []
Definition at line 64 of file rwrExp.c.
00065 { 00066 Rwr_Man4_t * p; 00067 p = ALLOC( Rwr_Man4_t, 1 ); 00068 memset( p, 0, sizeof(Rwr_Man4_t) ); 00069 // canonical forms 00070 p->nFuncs = (1<<16); 00071 // canonical forms, phases, perms 00072 Extra_Truth4VarNPN( &p->puCanons, NULL, NULL, NULL ); 00073 // counters 00074 p->pnCounts = ALLOC( int, p->nFuncs ); 00075 memset( p->pnCounts, 0, sizeof(int) * p->nFuncs ); 00076 s_pManRwrExp4 = p; 00077 }
void Rwt_Man5ExploreCount | ( | unsigned | uTruth | ) |
Function*************************************************************
Synopsis [Collects stats about 4-var functions appearing in netlists.]
Description []
SideEffects []
SeeAlso []
Definition at line 199 of file rwrExp.c.
00200 { 00201 int * pCounter; 00202 if ( !stmm_find_or_add( s_pManRwrExp5->tTableNN, (char *)uTruth, (char***)&pCounter ) ) 00203 *pCounter = 0; 00204 (*pCounter)++; 00205 }
void Rwt_Man5ExplorePrint | ( | ) |
Function*************************************************************
Synopsis [Collects stats about 4-var functions appearing in netlists.]
Description []
SideEffects []
SeeAlso []
Definition at line 218 of file rwrExp.c.
00219 { 00220 FILE * pFile; 00221 stmm_generator * gen; 00222 int i, CountMax, nCuts, Counter; 00223 int * pDistrib; 00224 unsigned * pReprs; 00225 unsigned uTruth, uTruthC; 00226 int clk = clock(); 00227 Vec_Int_t * vClassesNN, * vClassesNPN; 00228 00229 // find the max number of occurences 00230 nCuts = 0; 00231 CountMax = 0; 00232 stmm_foreach_item( s_pManRwrExp5->tTableNN, gen, (char **)&uTruth, (char **)&Counter ) 00233 { 00234 nCuts += Counter; 00235 if ( CountMax < Counter ) 00236 CountMax = Counter; 00237 } 00238 printf( "Number of cuts considered = %8d.\n", nCuts ); 00239 printf( "Classes occurring at least once = %8d.\n", stmm_count(s_pManRwrExp5->tTableNN) ); 00240 printf( "The largest number of occurence = %8d.\n", CountMax ); 00241 00242 // print the distribution of classes 00243 pDistrib = ALLOC( int, CountMax + 1 ); 00244 pReprs = ALLOC( unsigned, CountMax + 1 ); 00245 memset( pDistrib, 0, sizeof(int)*(CountMax + 1) ); 00246 stmm_foreach_item( s_pManRwrExp5->tTableNN, gen, (char **)&uTruth, (char **)&Counter ) 00247 { 00248 assert( Counter <= CountMax ); 00249 pDistrib[ Counter ]++; 00250 pReprs[ Counter ] = uTruth; 00251 } 00252 00253 for ( i = 1; i <= CountMax; i++ ) 00254 if ( pDistrib[i] ) 00255 { 00256 printf( "Occurence = %6d. Num classes = %4d. Repr = ", i, pDistrib[i] ); 00257 Extra_PrintBinary( stdout, pReprs + i, 32 ); 00258 printf( "\n" ); 00259 } 00260 free( pDistrib ); 00261 free( pReprs ); 00262 00263 00264 // put them into an array 00265 vClassesNN = Vec_IntAlloc( stmm_count(s_pManRwrExp5->tTableNN) ); 00266 stmm_foreach_item( s_pManRwrExp5->tTableNN, gen, (char **)&uTruth, NULL ) 00267 Vec_IntPush( vClassesNN, (int)uTruth ); 00268 Vec_IntSortUnsigned( vClassesNN ); 00269 00270 // write into a file all classes 00271 pFile = fopen( "nnclass_stats5.txt", "w" ); 00272 Vec_IntForEachEntry( vClassesNN, uTruth, i ) 00273 { 00274 if ( !stmm_lookup( s_pManRwrExp5->tTableNN, (char *)uTruth, (char **)&Counter ) ) 00275 { 00276 assert( 0 ); 00277 } 00278 Extra_PrintHex( pFile, uTruth, 5 ); 00279 fprintf( pFile, " %10d\n", Counter ); 00280 } 00281 fclose( pFile ); 00282 printf( "%d classes written into file \"%s\".\n", vClassesNN->nSize, "nnclass_stats5.txt" ); 00283 00284 00285 clk = clock(); 00286 // how many NPN classes exist? 00287 Vec_IntForEachEntry( vClassesNN, uTruth, i ) 00288 { 00289 int * pCounter; 00290 uTruthC = Extra_TruthCanonNPN( uTruth, 5 ); 00291 if ( !stmm_find_or_add( s_pManRwrExp5->tTableNPN, (char *)uTruthC, (char***)&pCounter ) ) 00292 *pCounter = 0; 00293 if ( !stmm_lookup( s_pManRwrExp5->tTableNN, (char *)uTruth, (char **)&Counter ) ) 00294 { 00295 assert( 0 ); 00296 } 00297 (*pCounter) += Counter; 00298 } 00299 printf( "The numbe of NPN classes = %d.\n", stmm_count(s_pManRwrExp5->tTableNPN) ); 00300 PRT( "Computing NPN classes", clock() - clk ); 00301 00302 // put them into an array 00303 vClassesNPN = Vec_IntAlloc( stmm_count(s_pManRwrExp5->tTableNPN) ); 00304 stmm_foreach_item( s_pManRwrExp5->tTableNPN, gen, (char **)&uTruth, NULL ) 00305 Vec_IntPush( vClassesNPN, (int)uTruth ); 00306 Vec_IntSortUnsigned( vClassesNPN ); 00307 00308 // write into a file all classes 00309 pFile = fopen( "npnclass_stats5.txt", "w" ); 00310 Vec_IntForEachEntry( vClassesNPN, uTruth, i ) 00311 { 00312 if ( !stmm_lookup( s_pManRwrExp5->tTableNPN, (char *)uTruth, (char **)&Counter ) ) 00313 { 00314 assert( 0 ); 00315 } 00316 Extra_PrintHex( pFile, uTruth, 5 ); 00317 fprintf( pFile, " %10d\n", Counter ); 00318 } 00319 fclose( pFile ); 00320 printf( "%d classes written into file \"%s\".\n", vClassesNPN->nSize, "npnclass_stats5.txt" ); 00321 00322 00323 // can they be uniquely characterized? 00324 00325 }
void Rwt_Man5ExploreStart | ( | ) |
Function*************************************************************
Synopsis [Collects stats about 4-var functions appearing in netlists.]
Description []
SideEffects []
SeeAlso []
Definition at line 175 of file rwrExp.c.
00176 { 00177 Rwr_Man5_t * p; 00178 p = ALLOC( Rwr_Man5_t, 1 ); 00179 memset( p, 0, sizeof(Rwr_Man5_t) ); 00180 p->tTableNN = stmm_init_table( st_numcmp, st_numhash ); 00181 p->tTableNPN = stmm_init_table( st_numcmp, st_numhash ); 00182 s_pManRwrExp5 = p; 00183 00184 //Extra_PrintHex( stdout, Extra_TruthCanonNPN( 0x0000FFFF, 5 ), 5 ); 00185 //printf( "\n" ); 00186 }
Rwr_Man4_t* s_pManRwrExp4 = NULL [static] |
Rwr_Man5_t* s_pManRwrExp5 = NULL [static] |