ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
acecSt.c
Go to the documentation of this file.
1
20
21#include "acecInt.h"
22#include "misc/vec/vecWec.h"
23#include "misc/extra/extra.h"
24#include "aig/aig/aig.h"
25#include "opt/dar/dar.h"
26
28
32
33int Npn3Table[256][2] = {
34 {0x00, 0}, // 0x00 = 0
35 {0x01, 1}, // 0x01 = 1
36 {0x01, 1}, // 0x02 = 2
37 {0x03, 2}, // 0x03 = 3
38 {0x01, 1}, // 0x04 = 4
39 {0x03, 2}, // 0x05 = 5
40 {0x06, 3}, // 0x06 = 6
41 {0x07, 4}, // 0x07 = 7
42 {0x01, 1}, // 0x08 = 8
43 {0x06, 3}, // 0x09 = 9
44 {0x03, 2}, // 0x0A = 10
45 {0x07, 4}, // 0x0B = 11
46 {0x03, 2}, // 0x0C = 12
47 {0x07, 4}, // 0x0D = 13
48 {0x07, 4}, // 0x0E = 14
49 {0x0F, 5}, // 0x0F = 15
50 {0x01, 1}, // 0x10 = 16
51 {0x03, 2}, // 0x11 = 17
52 {0x06, 3}, // 0x12 = 18
53 {0x07, 4}, // 0x13 = 19
54 {0x06, 3}, // 0x14 = 20
55 {0x07, 4}, // 0x15 = 21
56 {0x16, 6}, // 0x16 = 22
57 {0x17, 7}, // 0x17 = 23
58 {0x18, 8}, // 0x18 = 24
59 {0x19, 9}, // 0x19 = 25
60 {0x19, 9}, // 0x1A = 26
61 {0x1B, 10}, // 0x1B = 27
62 {0x19, 9}, // 0x1C = 28
63 {0x1B, 10}, // 0x1D = 29
64 {0x1E, 11}, // 0x1E = 30
65 {0x07, 4}, // 0x1F = 31
66 {0x01, 1}, // 0x20 = 32
67 {0x06, 3}, // 0x21 = 33
68 {0x03, 2}, // 0x22 = 34
69 {0x07, 4}, // 0x23 = 35
70 {0x18, 8}, // 0x24 = 36
71 {0x19, 9}, // 0x25 = 37
72 {0x19, 9}, // 0x26 = 38
73 {0x1B, 10}, // 0x27 = 39
74 {0x06, 3}, // 0x28 = 40
75 {0x16, 6}, // 0x29 = 41
76 {0x07, 4}, // 0x2A = 42
77 {0x17, 7}, // 0x2B = 43
78 {0x19, 9}, // 0x2C = 44
79 {0x1E, 11}, // 0x2D = 45
80 {0x1B, 10}, // 0x2E = 46
81 {0x07, 4}, // 0x2F = 47
82 {0x03, 2}, // 0x30 = 48
83 {0x07, 4}, // 0x31 = 49
84 {0x07, 4}, // 0x32 = 50
85 {0x0F, 5}, // 0x33 = 51
86 {0x19, 9}, // 0x34 = 52
87 {0x1B, 10}, // 0x35 = 53
88 {0x1E, 11}, // 0x36 = 54
89 {0x07, 4}, // 0x37 = 55
90 {0x19, 9}, // 0x38 = 56
91 {0x1E, 11}, // 0x39 = 57
92 {0x1B, 10}, // 0x3A = 58
93 {0x07, 4}, // 0x3B = 59
94 {0x3C, 12}, // 0x3C = 60
95 {0x19, 9}, // 0x3D = 61
96 {0x19, 9}, // 0x3E = 62
97 {0x03, 2}, // 0x3F = 63
98 {0x01, 1}, // 0x40 = 64
99 {0x06, 3}, // 0x41 = 65
100 {0x18, 8}, // 0x42 = 66
101 {0x19, 9}, // 0x43 = 67
102 {0x03, 2}, // 0x44 = 68
103 {0x07, 4}, // 0x45 = 69
104 {0x19, 9}, // 0x46 = 70
105 {0x1B, 10}, // 0x47 = 71
106 {0x06, 3}, // 0x48 = 72
107 {0x16, 6}, // 0x49 = 73
108 {0x19, 9}, // 0x4A = 74
109 {0x1E, 11}, // 0x4B = 75
110 {0x07, 4}, // 0x4C = 76
111 {0x17, 7}, // 0x4D = 77
112 {0x1B, 10}, // 0x4E = 78
113 {0x07, 4}, // 0x4F = 79
114 {0x03, 2}, // 0x50 = 80
115 {0x07, 4}, // 0x51 = 81
116 {0x19, 9}, // 0x52 = 82
117 {0x1B, 10}, // 0x53 = 83
118 {0x07, 4}, // 0x54 = 84
119 {0x0F, 5}, // 0x55 = 85
120 {0x1E, 11}, // 0x56 = 86
121 {0x07, 4}, // 0x57 = 87
122 {0x19, 9}, // 0x58 = 88
123 {0x1E, 11}, // 0x59 = 89
124 {0x3C, 12}, // 0x5A = 90
125 {0x19, 9}, // 0x5B = 91
126 {0x1B, 10}, // 0x5C = 92
127 {0x07, 4}, // 0x5D = 93
128 {0x19, 9}, // 0x5E = 94
129 {0x03, 2}, // 0x5F = 95
130 {0x06, 3}, // 0x60 = 96
131 {0x16, 6}, // 0x61 = 97
132 {0x19, 9}, // 0x62 = 98
133 {0x1E, 11}, // 0x63 = 99
134 {0x19, 9}, // 0x64 = 100
135 {0x1E, 11}, // 0x65 = 101
136 {0x3C, 12}, // 0x66 = 102
137 {0x19, 9}, // 0x67 = 103
138 {0x16, 6}, // 0x68 = 104
139 {0x69, 13}, // 0x69 = 105
140 {0x1E, 11}, // 0x6A = 106
141 {0x16, 6}, // 0x6B = 107
142 {0x1E, 11}, // 0x6C = 108
143 {0x16, 6}, // 0x6D = 109
144 {0x19, 9}, // 0x6E = 110
145 {0x06, 3}, // 0x6F = 111
146 {0x07, 4}, // 0x70 = 112
147 {0x17, 7}, // 0x71 = 113
148 {0x1B, 10}, // 0x72 = 114
149 {0x07, 4}, // 0x73 = 115
150 {0x1B, 10}, // 0x74 = 116
151 {0x07, 4}, // 0x75 = 117
152 {0x19, 9}, // 0x76 = 118
153 {0x03, 2}, // 0x77 = 119
154 {0x1E, 11}, // 0x78 = 120
155 {0x16, 6}, // 0x79 = 121
156 {0x19, 9}, // 0x7A = 122
157 {0x06, 3}, // 0x7B = 123
158 {0x19, 9}, // 0x7C = 124
159 {0x06, 3}, // 0x7D = 125
160 {0x18, 8}, // 0x7E = 126
161 {0x01, 1}, // 0x7F = 127
162 {0x01, 1}, // 0x80 = 128
163 {0x18, 8}, // 0x81 = 129
164 {0x06, 3}, // 0x82 = 130
165 {0x19, 9}, // 0x83 = 131
166 {0x06, 3}, // 0x84 = 132
167 {0x19, 9}, // 0x85 = 133
168 {0x16, 6}, // 0x86 = 134
169 {0x1E, 11}, // 0x87 = 135
170 {0x03, 2}, // 0x88 = 136
171 {0x19, 9}, // 0x89 = 137
172 {0x07, 4}, // 0x8A = 138
173 {0x1B, 10}, // 0x8B = 139
174 {0x07, 4}, // 0x8C = 140
175 {0x1B, 10}, // 0x8D = 141
176 {0x17, 7}, // 0x8E = 142
177 {0x07, 4}, // 0x8F = 143
178 {0x06, 3}, // 0x90 = 144
179 {0x19, 9}, // 0x91 = 145
180 {0x16, 6}, // 0x92 = 146
181 {0x1E, 11}, // 0x93 = 147
182 {0x16, 6}, // 0x94 = 148
183 {0x1E, 11}, // 0x95 = 149
184 {0x69, 13}, // 0x96 = 150
185 {0x16, 6}, // 0x97 = 151
186 {0x19, 9}, // 0x98 = 152
187 {0x3C, 12}, // 0x99 = 153
188 {0x1E, 11}, // 0x9A = 154
189 {0x19, 9}, // 0x9B = 155
190 {0x1E, 11}, // 0x9C = 156
191 {0x19, 9}, // 0x9D = 157
192 {0x16, 6}, // 0x9E = 158
193 {0x06, 3}, // 0x9F = 159
194 {0x03, 2}, // 0xA0 = 160
195 {0x19, 9}, // 0xA1 = 161
196 {0x07, 4}, // 0xA2 = 162
197 {0x1B, 10}, // 0xA3 = 163
198 {0x19, 9}, // 0xA4 = 164
199 {0x3C, 12}, // 0xA5 = 165
200 {0x1E, 11}, // 0xA6 = 166
201 {0x19, 9}, // 0xA7 = 167
202 {0x07, 4}, // 0xA8 = 168
203 {0x1E, 11}, // 0xA9 = 169
204 {0x0F, 5}, // 0xAA = 170
205 {0x07, 4}, // 0xAB = 171
206 {0x1B, 10}, // 0xAC = 172
207 {0x19, 9}, // 0xAD = 173
208 {0x07, 4}, // 0xAE = 174
209 {0x03, 2}, // 0xAF = 175
210 {0x07, 4}, // 0xB0 = 176
211 {0x1B, 10}, // 0xB1 = 177
212 {0x17, 7}, // 0xB2 = 178
213 {0x07, 4}, // 0xB3 = 179
214 {0x1E, 11}, // 0xB4 = 180
215 {0x19, 9}, // 0xB5 = 181
216 {0x16, 6}, // 0xB6 = 182
217 {0x06, 3}, // 0xB7 = 183
218 {0x1B, 10}, // 0xB8 = 184
219 {0x19, 9}, // 0xB9 = 185
220 {0x07, 4}, // 0xBA = 186
221 {0x03, 2}, // 0xBB = 187
222 {0x19, 9}, // 0xBC = 188
223 {0x18, 8}, // 0xBD = 189
224 {0x06, 3}, // 0xBE = 190
225 {0x01, 1}, // 0xBF = 191
226 {0x03, 2}, // 0xC0 = 192
227 {0x19, 9}, // 0xC1 = 193
228 {0x19, 9}, // 0xC2 = 194
229 {0x3C, 12}, // 0xC3 = 195
230 {0x07, 4}, // 0xC4 = 196
231 {0x1B, 10}, // 0xC5 = 197
232 {0x1E, 11}, // 0xC6 = 198
233 {0x19, 9}, // 0xC7 = 199
234 {0x07, 4}, // 0xC8 = 200
235 {0x1E, 11}, // 0xC9 = 201
236 {0x1B, 10}, // 0xCA = 202
237 {0x19, 9}, // 0xCB = 203
238 {0x0F, 5}, // 0xCC = 204
239 {0x07, 4}, // 0xCD = 205
240 {0x07, 4}, // 0xCE = 206
241 {0x03, 2}, // 0xCF = 207
242 {0x07, 4}, // 0xD0 = 208
243 {0x1B, 10}, // 0xD1 = 209
244 {0x1E, 11}, // 0xD2 = 210
245 {0x19, 9}, // 0xD3 = 211
246 {0x17, 7}, // 0xD4 = 212
247 {0x07, 4}, // 0xD5 = 213
248 {0x16, 6}, // 0xD6 = 214
249 {0x06, 3}, // 0xD7 = 215
250 {0x1B, 10}, // 0xD8 = 216
251 {0x19, 9}, // 0xD9 = 217
252 {0x19, 9}, // 0xDA = 218
253 {0x18, 8}, // 0xDB = 219
254 {0x07, 4}, // 0xDC = 220
255 {0x03, 2}, // 0xDD = 221
256 {0x06, 3}, // 0xDE = 222
257 {0x01, 1}, // 0xDF = 223
258 {0x07, 4}, // 0xE0 = 224
259 {0x1E, 11}, // 0xE1 = 225
260 {0x1B, 10}, // 0xE2 = 226
261 {0x19, 9}, // 0xE3 = 227
262 {0x1B, 10}, // 0xE4 = 228
263 {0x19, 9}, // 0xE5 = 229
264 {0x19, 9}, // 0xE6 = 230
265 {0x18, 8}, // 0xE7 = 231
266 {0x17, 7}, // 0xE8 = 232
267 {0x16, 6}, // 0xE9 = 233
268 {0x07, 4}, // 0xEA = 234
269 {0x06, 3}, // 0xEB = 235
270 {0x07, 4}, // 0xEC = 236
271 {0x06, 3}, // 0xED = 237
272 {0x03, 2}, // 0xEE = 238
273 {0x01, 1}, // 0xEF = 239
274 {0x0F, 5}, // 0xF0 = 240
275 {0x07, 4}, // 0xF1 = 241
276 {0x07, 4}, // 0xF2 = 242
277 {0x03, 2}, // 0xF3 = 243
278 {0x07, 4}, // 0xF4 = 244
279 {0x03, 2}, // 0xF5 = 245
280 {0x06, 3}, // 0xF6 = 246
281 {0x01, 1}, // 0xF7 = 247
282 {0x07, 4}, // 0xF8 = 248
283 {0x06, 3}, // 0xF9 = 249
284 {0x03, 2}, // 0xFA = 250
285 {0x01, 1}, // 0xFB = 251
286 {0x03, 2}, // 0xFC = 252
287 {0x01, 1}, // 0xFD = 253
288 {0x01, 1}, // 0xFE = 254
289 {0x00, 0} // 0xFF = 255
290};
291
292
293
297
310{
311 int Table[256], Classes[16], Map[256];
312 int i, k, nClasses = 0;
313 for ( i = 0; i < 256; i++ )
314 Table[i] = Extra_TruthCanonNPN( i, 3 );
315 for ( i = 0; i < 256; i++ )
316 {
317 printf( "{" );
318 Extra_PrintHex( stdout, (unsigned *)&Table[i], 3 );
319 printf( ", " );
320 // find the class
321 for ( k = 0; k < nClasses; k++ )
322 if ( Table[i] == Classes[k] )
323 break;
324 if ( k == nClasses )
325 Classes[nClasses++] = Table[i];
326 Map[i] = k;
327 // print
328 printf( "%2d}, // ", k );
329 Extra_PrintHex( stdout, (unsigned *)&i, 3 );
330 printf( " = %3d\n", i );
331 }
332}
333
345void Acec_StatsCollect( Gia_Man_t * p, int fVerbose )
346{
347 extern int Dar_LibReturnClass( unsigned uTruth );
348 extern char ** Kit_DsdNpn4ClassNames();
349 char ** pNames = Kit_DsdNpn4ClassNames();
350
351 int Map[256] = {0};
352 Vec_Wrd_t * vTruths = Vec_WrdStart( Gia_ManObjNum(p) );
353 Vec_Wrd_t * vTemp = Vec_WrdStart( Gia_ManObjNum(p) );
354 word Truth, TruthF;
355 int iTruth, iTruthF;
356 int iFan, iLut, i, k, Class;
357 assert( Gia_ManHasMapping(p) );
358 assert( Gia_ManLutSizeMax(p) < 4 );
359 // collect truth tables
360 Gia_ManForEachLut( p, iLut )
361 {
362 Truth = Gia_ObjComputeTruthTable6Lut( p, iLut, vTemp );
363 Vec_WrdWriteEntry( vTruths, iLut, Truth );
364 }
365 Vec_WrdFree( vTemp );
366 // collect pairs
367 Gia_ManForEachLut( p, iLut )
368 {
369 Truth = Vec_WrdEntry( vTruths, iLut ) & 0xFF;
370 iTruth = Npn3Table[Truth][1];
371 assert( iTruth < 15 );
372 Gia_LutForEachFanin( p, iLut, iFan, k )
373 {
374 TruthF = Vec_WrdEntry( vTruths, iFan ) & 0xFF;
375 iTruthF = Npn3Table[TruthF][1];
376 assert( iTruthF < 15 );
377 Map[(iTruthF << 4) + iTruth]++;
378 }
379 }
380 Gia_ManForEachCoDriverId( p, iFan, k )
381 {
382 TruthF = Vec_WrdEntry( vTruths, iFan );
383 iTruthF = Npn3Table[TruthF & 0xFF][1];
384 assert( iTruthF < 15 );
385 Map[(iTruthF << 4)]++;
386 }
387 Vec_WrdFree( vTruths );
388 // print statistics
389 printf( "fi / fo" );
390 for ( i = 0; i < 14; i++ )
391 printf( "%6d ", i );
392 printf( "\n" );
393 for ( i = 0; i < 14; i++ )
394 {
395 printf( "%6d ", i );
396 for ( k = 0; k < 14; k++ )
397 if ( Map[(i << 4) | k] )
398 printf( "%6d ", Map[(i << 4) | k] );
399 else
400 printf( "%6s ", "." );
401 printf( "\n" );
402 }
403 // print class formulas
404 printf( "\nClasses:\n" );
405 for ( i = 0; i < 14; i++ )
406 {
407 for ( k = 0; k < 256; k++ )
408 if ( Npn3Table[k][1] == i )
409 break;
410 assert( k < 256 );
411 Class = Dar_LibReturnClass( (Npn3Table[k][0] << 8) | Npn3Table[k][0] );
412 printf( "%2d : %s\n", i, pNames[Class] );
413 }
414}
415
419
420
422
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
void Acec_StatsCollect(Gia_Man_t *p, int fVerbose)
Definition acecSt.c:345
ABC_NAMESPACE_IMPL_START int Npn3Table[256][2]
DECLARATIONS ///.
Definition acecSt.c:33
void Acec_GenerateNpnTable()
FUNCTION DEFINITIONS ///.
Definition acecSt.c:309
int Dar_LibReturnClass(unsigned uTruth)
Definition darLib.c:194
Cube * p
Definition exorList.c:222
unsigned Extra_TruthCanonNPN(unsigned uTruth, int nVars)
void Extra_PrintHex(FILE *pFile, unsigned *pTruth, int nVars)
#define Gia_ManForEachCoDriverId(p, DriverId, i)
Definition gia.h:1246
#define Gia_ManForEachLut(p, i)
Definition gia.h:1157
#define Gia_LutForEachFanin(p, i, iFan, k)
Definition gia.h:1161
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
int Gia_ManLutSizeMax(Gia_Man_t *p)
Definition giaIf.c:127
word Gia_ObjComputeTruthTable6Lut(Gia_Man_t *p, int iObj, Vec_Wrd_t *vTemp)
Definition giaTruth.c:289
char ** Kit_DsdNpn4ClassNames()
Definition kitDsd.c:3049
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
#define assert(ex)
Definition util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition vecWrd.h:42