00001 00021 #include "rwr.h" 00022 00026 00027 static int pTruths[13719]; 00028 static int pFreqs[13719]; 00029 static int pPerm[13719]; 00030 00034 00046 int Rwr_TempCompare( int * pNum1, int * pNum2 ) 00047 { 00048 int Freq1 = pFreqs[*pNum1]; 00049 int Freq2 = pFreqs[*pNum2]; 00050 if ( Freq1 < Freq2 ) 00051 return 1; 00052 if ( Freq1 > Freq2 ) 00053 return -1; 00054 return 0; 00055 } 00056 00068 void Rwr_Temp() 00069 { 00070 char Buffer[32]; 00071 int nFuncs = 13719; 00072 int nEntries = 100; 00073 unsigned uTruth; 00074 int i, k; 00075 FILE * pFile; 00076 00077 pFile = fopen( "nnclass_stats5.txt", "r" ); 00078 for ( i = 0; i < 13719; i++ ) 00079 { 00080 fscanf( pFile, "%s%d", Buffer, &pFreqs[i] ); 00081 Extra_ReadHexadecimal( &uTruth, Buffer+2, 5 ); 00082 pTruths[i] = uTruth; 00083 } 00084 fclose( pFile ); 00085 00086 for ( i = 0; i < 13719; i++ ) 00087 pPerm[i] = i; 00088 00089 qsort( (void *)pPerm, 13719, sizeof(int), 00090 (int (*)(const void *, const void *)) Rwr_TempCompare ); 00091 00092 00093 pFile = fopen( "5npn_100.blif", "w" ); 00094 fprintf( pFile, "# Most frequent NPN classes of 5 vars.\n" ); 00095 fprintf( pFile, ".model 5npn\n" ); 00096 fprintf( pFile, ".inputs a b c d e\n" ); 00097 fprintf( pFile, ".outputs" ); 00098 for ( i = 0; i < nEntries; i++ ) 00099 fprintf( pFile, " %02d", i ); 00100 fprintf( pFile, "\n" ); 00101 00102 for ( i = 0; i < nEntries; i++ ) 00103 { 00104 fprintf( pFile, ".names a b c d e %02d\n", i ); 00105 uTruth = pTruths[pPerm[i]]; 00106 for ( k = 0; k < 32; k++ ) 00107 if ( uTruth & (1 << k) ) 00108 { 00109 Extra_PrintBinary( pFile, &k, 5 ); 00110 fprintf( pFile, " 1\n" ); 00111 } 00112 } 00113 fprintf( pFile, ".end\n" ); 00114 fclose( pFile ); 00115 } 00116 00120 00121