ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
rwrTemp.c
Go to the documentation of this file.
1
20
21#include "rwr.h"
22
24
25
29
30static int pTruths[13719];
31static int pFreqs[13719];
32static int pPerm[13719];
33
37
49int Rwr_TempCompare( int * pNum1, int * pNum2 )
50{
51 int Freq1 = pFreqs[*pNum1];
52 int Freq2 = pFreqs[*pNum2];
53 if ( Freq1 < Freq2 )
54 return 1;
55 if ( Freq1 > Freq2 )
56 return -1;
57 return 0;
58}
59
72{
73 char Buffer[32];
74 int nFuncs = 13719;
75 int nEntries = 100;
76 unsigned uTruth;
77 int i, k;
78 FILE * pFile;
79
80 pFile = fopen( "nnclass_stats5.txt", "r" );
81 for ( i = 0; i < 13719; i++ )
82 {
83 int RetValue = fscanf( pFile, "%s%d", Buffer, &pFreqs[i] );
84 Extra_ReadHexadecimal( &uTruth, Buffer+2, 5 );
85 pTruths[i] = uTruth;
86 }
87 fclose( pFile );
88
89 for ( i = 0; i < 13719; i++ )
90 pPerm[i] = i;
91
92 qsort( (void *)pPerm, (size_t)13719, sizeof(int),
93 (int (*)(const void *, const void *)) Rwr_TempCompare );
94
95
96 pFile = fopen( "5npn_100.blif", "w" );
97 fprintf( pFile, "# Most frequent NPN classes of 5 vars.\n" );
98 fprintf( pFile, ".model 5npn\n" );
99 fprintf( pFile, ".inputs a b c d e\n" );
100 fprintf( pFile, ".outputs" );
101 for ( i = 0; i < nEntries; i++ )
102 fprintf( pFile, " %02d", i );
103 fprintf( pFile, "\n" );
104
105 for ( i = 0; i < nEntries; i++ )
106 {
107 fprintf( pFile, ".names a b c d e %02d\n", i );
108 uTruth = pTruths[pPerm[i]];
109 for ( k = 0; k < 32; k++ )
110 if ( uTruth & (1 << k) )
111 {
112 Extra_PrintBinary( pFile, (unsigned *)&k, 5 );
113 fprintf( pFile, " 1\n" );
114 }
115 }
116 fprintf( pFile, ".end\n" );
117 fclose( pFile );
118}
119
123
124
126
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
int Extra_ReadHexadecimal(unsigned Sign[], char *pString, int nVars)
void Extra_PrintBinary(FILE *pFile, unsigned Sign[], int nBits)
int Rwr_TempCompare(int *pNum1, int *pNum2)
FUNCTION DEFINITIONS ///.
Definition rwrTemp.c:49
void Rwr_Temp()
Definition rwrTemp.c:71