abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
rwrTemp.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [rwrCut.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [DAG-aware AIG rewriting package.]
8 
9  Synopsis [Cut computation.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: rwrCut.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "rwr.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 static int pTruths[13719];
31 static int pFreqs[13719];
32 static int pPerm[13719];
33 
34 ////////////////////////////////////////////////////////////////////////
35 /// FUNCTION DEFINITIONS ///
36 ////////////////////////////////////////////////////////////////////////
37 
38 /**Function*************************************************************
39 
40  Synopsis []
41 
42  Description []
43 
44  SideEffects []
45 
46  SeeAlso []
47 
48 ***********************************************************************/
49 int 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 
60 /**Function*************************************************************
61 
62  Synopsis []
63 
64  Description []
65 
66  SideEffects []
67 
68  SeeAlso []
69 
70 ***********************************************************************/
71 void Rwr_Temp()
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, 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 
120 ////////////////////////////////////////////////////////////////////////
121 /// END OF FILE ///
122 ////////////////////////////////////////////////////////////////////////
123 
124 
126 
static ABC_NAMESPACE_IMPL_START int pTruths[13719]
DECLARATIONS ///.
Definition: rwrTemp.c:30
static int pFreqs[13719]
Definition: rwrTemp.c:31
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
int Extra_ReadHexadecimal(unsigned Sign[], char *pString, int nVars)
int Rwr_TempCompare(int *pNum1, int *pNum2)
FUNCTION DEFINITIONS ///.
Definition: rwrTemp.c:49
static int pPerm[13719]
Definition: rwrTemp.c:32
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
void Extra_PrintBinary(FILE *pFile, unsigned Sign[], int nBits)
void Rwr_Temp()
Definition: rwrTemp.c:71