1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
|
/**CFile****************************************************************
FileName [dauNonDsd.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [DAG-aware unmapping.]
Synopsis []
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: dauNonDsd.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "dauInt.h"
#include "misc/util/utilTruth.h"
ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Checks decomposability with given BS variables.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline void Dau_DecGetMinterm( word * p, int g, int nVarsS, int uMaskAll )
{
int m, c, v;
for ( m = c = v = 0; v < nVarsS; v++ )
if ( !((uMaskAll >> v) & 1) ) // not shared bound set variable
{
if ( (g >> v) & 1 )
m |= (1 << c);
c++;
}
assert( c >= 2 );
p[m>>6] |= (((word)1)<<(m & 63));
}
static inline int Dau_DecCheckSet5( word * p, int nVars, int nVarsF, int uMaskAll, int uMaskValue, word * pCof0, word * pCof1, word * pDec )
{
int fFound0 = 0, fFound1 = 0;
int g, gMax = (1 << (nVars - nVarsF));
int Shift = 6 - nVarsF, Mask = (1 << Shift) - 1;
word Mask2 = (((word)1) << (1 << nVarsF)) - 1;
word Cof0 = 0, Cof1 = 0, Value;
assert( nVarsF >= 1 && nVarsF <= 5 );
if ( pDec ) *pDec = 0;
for ( g = 0; g < gMax; g++ )
if ( (g & uMaskAll) == uMaskValue ) // this minterm g matches shared variable minterm uMaskValue
{
Value = (p[g>>Shift] >> ((g&Mask)<<nVarsF)) & Mask2;
if ( !fFound0 )
Cof0 = Value, fFound0 = 1;
else if ( Cof0 == Value )
continue;
else if ( !fFound1 )
{
Cof1 = Value, fFound1 = 1;
if ( pDec ) Dau_DecGetMinterm( pDec, g, nVars-nVarsF, uMaskAll );
}
else if ( Cof1 == Value )
{
if ( pDec ) Dau_DecGetMinterm( pDec, g, nVars-nVarsF, uMaskAll );
continue;
}
else
return 0;
}
if ( pCof0 )
{
assert( fFound0 );
Cof1 = fFound1 ? Cof1 : Cof0;
*pCof0 = Abc_Tt6Stretch( Cof0, nVarsF );
*pCof1 = Abc_Tt6Stretch( Cof1, nVarsF );
}
return 1;
}
static inline int Dau_DecCheckSet6( word * p, int nVars, int nVarsF, int uMaskAll, int uMaskValue, word * pCof0, word * pCof1, word * pDec )
{
int fFound0 = 0, fFound1 = 0;
int g, gMax = (1 << (nVars - nVarsF));
int nWords = Abc_TtWordNum(nVarsF);
word * Cof0 = NULL, * Cof1 = NULL;
assert( nVarsF >= 6 && nVarsF <= nVars - 2 );
if ( pDec ) *pDec = 0;
for ( g = 0; g < gMax; g++ )
if ( (g & uMaskAll) == uMaskValue )
{
if ( !fFound0 )
Cof0 = p + g * nWords, fFound0 = 1;
else if ( !memcmp(Cof0, p + g * nWords, sizeof(word) * nWords) )
continue;
else if ( !fFound1 )
{
Cof1 = p + g * nWords, fFound1 = 1;
if ( pDec ) Dau_DecGetMinterm( pDec, g, nVars-nVarsF, uMaskAll );
}
else if ( !memcmp(Cof1, p + g * nWords, sizeof(word) * nWords) )
{
if ( pDec ) Dau_DecGetMinterm( pDec, g, nVars-nVarsF, uMaskAll );
continue;
}
else
return 0;
}
if ( pCof0 )
{
assert( fFound0 );
Cof1 = fFound1 ? Cof1 : Cof0;
memcpy( pCof0, Cof0, sizeof(word) * nWords );
memcpy( pCof1, Cof1, sizeof(word) * nWords );
}
return 1;
}
static inline int Dau_DecCheckSetAny( word * p, int nVars, int nVarsF, int uMaskAll, int uMaskValue, word * pCof0, word * pCof1, word * pDec )
{
assert( nVarsF >= 1 && nVarsF <= nVars - 2 );
if ( nVarsF < 6 )
return Dau_DecCheckSet5( p, nVars, nVarsF, uMaskAll, uMaskValue, pCof0, pCof1, pDec );
else
return Dau_DecCheckSet6( p, nVars, nVarsF, uMaskAll, uMaskValue, pCof0, pCof1, pDec );
}
int Dau_DecCheckSetTop( word * p, int nVars, int nVarsF, int nVarsB, int nVarsS, int maskS, word ** pCof0, word ** pCof1, word ** pDec )
{
int i, pVarsS[16];
int v, m, mMax = (1 << nVarsS), uMaskValue;
assert( nVars >= 3 && nVars <= 16 );
assert( nVars == nVarsF + nVarsB );
assert( nVarsF >= 1 && nVarsF <= nVars - 2 );
assert( nVarsB >= 2 && nVarsB <= nVars - 1 );
assert( nVarsS >= 0 && nVarsS <= nVarsB - 2 );
if ( nVarsS == 0 )
return Dau_DecCheckSetAny( p, nVars, nVarsF, 0, 0, pCof0? pCof0[0] : 0, pCof1? pCof1[0] : 0, pDec? pDec[0] : 0 );
// collect shared variables
assert( maskS > 0 && maskS < (1 << nVarsB) );
for ( i = 0, v = 0; v < nVarsB; v++ )
if ( (maskS >> v) & 1 )
pVarsS[i++] = v;
assert( i == nVarsS );
// go through shared set minterms
for ( m = 0; m < mMax; m++ )
{
// generate share set mask
uMaskValue = 0;
for ( v = 0; v < nVarsS; v++ )
if ( (m >> v) & 1 )
uMaskValue |= (1 << pVarsS[v]);
assert( (maskS & uMaskValue) == uMaskValue );
// check decomposition
if ( !Dau_DecCheckSetAny( p, nVars, nVarsF, maskS, uMaskValue, pCof0? pCof0[m] : 0, pCof1? pCof1[m] : 0, pDec? pDec[m] : 0 ) )
return 0;
}
return 1;
}
/**Function*************************************************************
Synopsis [Variable sets.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline unsigned Dau_DecCreateSet( int * pVarsB, int sizeB, int maskS )
{
unsigned uSet = 0; int v;
for ( v = 0; v < sizeB; v++ )
{
uSet |= (1 << (pVarsB[v] << 1));
if ( (maskS >> v) & 1 )
uSet |= (1 << ((pVarsB[v] << 1)+1));
}
return uSet;
}
static inline int Dau_DecSetHas01( unsigned Mask )
{
return (Mask & ((~Mask) >> 1) & 0x55555555);
}
static inline int Dau_DecSetIsContained( Vec_Int_t * vSets, unsigned New )
// Old=abcD contains New=abcDE
// Old=abcD contains New=abCD
{
unsigned Old;
int i, Entry;
Vec_IntForEachEntry( vSets, Entry, i )
{
Old = (unsigned)Entry;
if ( (Old & ~New) == 0 && !Dau_DecSetHas01(~Old & New))
return 1;
}
return 0;
}
void Dau_DecPrintSet( unsigned set, int nVars, int fNewLine )
{
int v, Counter = 0;
int nUnique = 0, nShared = 0, nFree = 0;
for ( v = 0; v < nVars; v++ )
{
int Value = ((set >> (v << 1)) & 3);
if ( Value == 1 )
nUnique++;
else if ( Value == 3 )
nShared++;
else if ( Value == 0 )
nFree++;
else assert( 0 );
}
printf( "S =%2d D =%2d C =%2d ", nShared, nUnique+nShared, nShared+nFree+1 );
printf( "x=" );
for ( v = 0; v < nVars; v++ )
{
int Value = ((set >> (v << 1)) & 3);
if ( Value == 1 )
printf( "%c", 'a' + v ), Counter++;
else if ( Value == 3 )
printf( "%c", 'A' + v ), Counter++;
else assert( Value == 0 );
}
printf( " y=x" );
for ( v = 0; v < nVars; v++ )
{
int Value = ((set >> (v << 1)) & 3);
if ( Value == 0 )
printf( "%c", 'a' + v ), Counter++;
else if ( Value == 3 )
printf( "%c", 'A' + v ), Counter++;
}
for ( ; Counter < 15; Counter++ )
printf( " " );
if ( fNewLine )
printf( "\n" );
}
unsigned Dau_DecReadSet( char * pStr )
{
unsigned uSet = 0; int v;
for ( v = 0; pStr[v]; v++ )
{
if ( pStr[v] >= 'a' && pStr[v] <= 'z' )
uSet |= (1 << ((pStr[v] - 'a') << 1));
else if ( pStr[v] >= 'A' && pStr[v] <= 'Z' )
uSet |= (1 << ((pStr[v] - 'a') << 1)) | (1 << (((pStr[v] - 'a') << 1)+1));
else break;
}
return uSet;
}
void Dau_DecPrintSets( Vec_Int_t * vSets, int nVars )
{
int i, Entry;
printf( "The set contains %d entries:\n", Vec_IntSize(vSets) );
Vec_IntForEachEntry( vSets, Entry, i )
Dau_DecPrintSet( (unsigned)Entry, nVars, 1 );
printf( "\n" );
}
/**Function*************************************************************
Synopsis [Find decomposable bound-sets of the given function.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Dau_DecMoveFreeToLSB( word * p, int nVars, int * V2P, int * P2V, int maskB, int sizeB )
{
int v, c = 0;
for ( v = 0; v < nVars; v++ )
if ( !((maskB >> v) & 1) )
Abc_TtMoveVar( p, nVars, V2P, P2V, v, c++ );
assert( c == nVars - sizeB );
}
Vec_Int_t * Dau_DecFindSets( word * p, int nVars )
{
Vec_Int_t * vSets = Vec_IntAlloc( 32 );
int V2P[16], P2V[16], pVarsB[16];
int Limit = (1 << nVars);
int c, v, sizeB, sizeS, maskB, maskS;
unsigned setMixed;
for ( v = 0; v < nVars; v++ )
assert( Abc_TtHasVar( p, nVars, v ) );
// initialize permutation
for ( v = 0; v < nVars; v++ )
V2P[v] = P2V[v] = v;
// iterate through bound sets of each size in increasing order
for ( sizeB = 2; sizeB < nVars; sizeB++ ) // bound set size
for ( maskB = 0; maskB < Limit; maskB++ ) // bound set
if ( Abc_TtBitCount16(maskB) == sizeB )
{
// permute variables to have bound set on top
Dau_DecMoveFreeToLSB( p, nVars, V2P, P2V, maskB, sizeB );
// collect bound set vars on levels nVars-sizeB to nVars-1
for ( c = 0; c < sizeB; c++ )
pVarsB[c] = P2V[nVars-sizeB+c];
// check disjoint
if ( Dau_DecCheckSetTop(p, nVars, nVars-sizeB, sizeB, 0, 0, NULL, NULL, NULL) )
{
Vec_IntPush( vSets, Dau_DecCreateSet(pVarsB, sizeB, 0) );
continue;
}
if ( sizeB == 2 )
continue;
// iterate through shared sets of each size in the increasing order
for ( sizeS = 1; sizeS <= sizeB - 2; sizeS++ ) // shared set size
// sizeS = 1;
for ( maskS = 0; maskS < (1 << sizeB); maskS++ ) // shared set
if ( Abc_TtBitCount16(maskS) == sizeS )
{
setMixed = Dau_DecCreateSet( pVarsB, sizeB, maskS );
// printf( "Considering %10d ", setMixed );
// Dau_DecPrintSet( setMixed, nVars );
// check if it exists
if ( Dau_DecSetIsContained(vSets, setMixed) )
continue;
// check if it can be added
if ( Dau_DecCheckSetTop(p, nVars, nVars-sizeB, sizeB, sizeS, maskS, NULL, NULL, NULL) )
Vec_IntPush( vSets, setMixed );
}
}
return vSets;
}
void Dau_DecFindSetsTest2()
{
Vec_Int_t * vSets;
word a0 = (~s_Truths6[1] & s_Truths6[2]) | (s_Truths6[1] & s_Truths6[3]);
word a1 = (~s_Truths6[1] & s_Truths6[4]) | (s_Truths6[1] & s_Truths6[5]);
word t = (~s_Truths6[0] & a0) | (s_Truths6[0] & a1);
// word t = ABC_CONST(0x7EFFFFFFFFFFFF7E); // and(gam1,gam2)
// word t = ABC_CONST(0xB0F0BBFFB0F0BAFE); // some funct
// word t = ABC_CONST(0x2B0228022B022802); // 5-var non-dec0x0F7700000F770000
// word t = ABC_CONST(0x0F7700000F770000); // (!<(ab)cd>e)
// word t = ABC_CONST(0x7F00000000000000); // (!(abc)def)
int nVars = 5;
vSets = Dau_DecFindSets( &t, nVars );
Dau_DecPrintSets( vSets, nVars );
Vec_IntFree( vSets );
}
/**Function*************************************************************
Synopsis [Replaces variables in the string.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Dau_DecVarReplace( char * pStr, int * pPerm, int nVars )
{
int v;
for ( v = 0; pStr[v]; v++ )
if ( pStr[v] >= 'a' && pStr[v] <= 'z' )
{
assert( pStr[v] - 'a' < nVars );
pStr[v] = 'a' + pPerm[pStr[v] - 'a'];
}
}
/**Function*************************************************************
Synopsis [Decomposes with the given bound-set.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Dau_DecDecomposeSet( word * pInit, int nVars, unsigned uSet, word * pComp, word * pDec, int * pPermC, int * pPermD, int * pnVarsC, int * pnVarsD )
{
word p[1<<13], Cof[64], Cof0[64], Cof1[64], Decs[64];
word * pCof0[64], * pCof1[64], * pDecs[64], MintC, MintD;
int V2P[16], P2V[16], pVarsU[16], pVarsS[16], pVarsF[16];
int nVarsU = 0, nVarsS = 0, nVarsF = 0;
int nWords = Abc_TtWordNum(nVars);
int v, d, c, Status, nDecs;
assert( nVars <= 16 );
for ( v = 0; v < nVars; v++ )
V2P[v] = P2V[v] = v;
memcpy( p, pInit, sizeof(word) * nWords );
// sort variables
for ( v = 0; v < nVars; v++ )
{
int Value = (uSet >> (v<<1)) & 3;
if ( Value == 0 )
pVarsF[nVarsF++] = v;
else if ( Value == 1 )
pVarsU[nVarsU++] = v;
else if ( Value == 3 )
pVarsS[nVarsS++] = v;
else assert(0);
}
assert( nVarsS >= 0 && nVarsS <= 6 );
assert( nVarsF + nVarsS + 1 <= 6 );
assert( nVarsU + nVarsS <= 6 );
// init space for decomposition functions
nDecs = (1 << nVarsS);
for ( d = 0; d < nDecs; d++ )
{
pCof0[d] = Cof0 + d;
pCof1[d] = Cof1 + d;
pDecs[d] = Decs + d;
}
// permute variables
c = 0;
for ( v = 0; v < nVarsF; v++ )
Abc_TtMoveVar( p, nVars, V2P, P2V, pVarsF[v], c++ );
for ( v = 0; v < nVarsS; v++ )
Abc_TtMoveVar( p, nVars, V2P, P2V, pVarsS[v], c++ );
for ( v = 0; v < nVarsU; v++ )
Abc_TtMoveVar( p, nVars, V2P, P2V, pVarsU[v], c++ );
assert( c == nVars );
// check decomposition
Status = Dau_DecCheckSetTop( p, nVars, nVarsF, nVarsS+nVarsU, nVarsS, Abc_InfoMask(nVarsS), pCof0, pCof1, pDecs );
if ( !Status )
return 0;
// compute cofactors
assert( nVarsF + nVarsS < 6 );
for ( d = 0; d < nDecs; d++ )
{
Cof[d] = (pCof1[d][0] & s_Truths6[nVarsF + nVarsS]) | (pCof0[d][0] & ~s_Truths6[nVarsF + nVarsS]);
pDecs[d][0] = Abc_Tt6Stretch( pDecs[d][0], nVarsU );
}
// compute the resulting functions
pComp[0] = 0;
pDec[0] = 0;
for ( d = 0; d < nDecs; d++ )
{
// compute minterms for composition/decomposition function
MintC = MintD = ~((word)0);
for ( v = 0; v < nVarsS; v++ )
{
MintC &= ((d >> v) & 1) ? s_Truths6[nVarsF+v] : ~s_Truths6[nVarsF+v];
MintD &= ((d >> v) & 1) ? s_Truths6[nVarsU+v] : ~s_Truths6[nVarsU+v];
}
// derive functions
pComp[0] |= MintC & Cof[d];
pDec[0] |= MintD & pDecs[d][0];
}
// derive variable permutations
if ( pPermC )
{
for ( v = 0; v < nVarsF; v++ )
pPermC[v] = pVarsF[v];
for ( v = 0; v < nVarsS; v++ )
pPermC[nVarsF+v] = pVarsS[v];
pPermC[nVarsF + nVarsS] = nVars;
}
if ( pPermD )
{
for ( v = 0; v < nVarsU; v++ )
pPermD[v] = pVarsU[v];
for ( v = 0; v < nVarsS; v++ )
pPermD[nVarsU+v] = pVarsS[v];
}
if ( pnVarsC )
*pnVarsC = nVarsF + nVarsS + 1;
if ( pnVarsD )
*pnVarsD = nVarsU + nVarsS;
return 1;
}
/**Function*************************************************************
Synopsis [Testing procedures.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Dau_DecVerify( word * pInit, int nVars, char * pDsdC, char * pDsdD )
{
word pC[1<<13], pD[1<<13], pRes[1<<13]; // max = 16
int nWordsC = Abc_TtWordNum(nVars+1);
int nWordsD = Abc_TtWordNum(nVars);
assert( nVars < 16 );
memcpy( pC, Dau_DsdToTruth(pDsdC, nVars+1), sizeof(word) * nWordsC );
memcpy( pD, Dau_DsdToTruth(pDsdD, nVars), sizeof(word) * nWordsD );
// Dau_DsdPrintFromTruth( stdout, pC, nVars+1 ); //printf( "\n" );
// Dau_DsdPrintFromTruth( stdout, pD, nVars ); //printf( "\n" );
if ( nVars >= 6 )
{
assert( nWordsD >= 1 );
assert( nWordsC > 1 );
Abc_TtMux( pRes, pD, pC + nWordsD, pC, nWordsD );
}
else
{
word pC0 = Abc_Tt6Stretch( pC[0], nVars );
word pC1 = Abc_Tt6Stretch( (pC[0] >> (1 << nVars)), nVars );
Abc_TtMux( pRes, pD, &pC1, &pC0, nWordsD );
}
if ( Abc_TtEqual(pInit, pRes, nWordsD) )
printf( " Verification successful\n" );
else
printf( " Verification failed\n" );
return 1;
}
int Dau_DecPerform( word * p, int nVars, unsigned uSet )
{
word tComp = 0, tDec = 0;
char pDsdC[1000], pDsdD[1000];
int pPermC[16], pPermD[16], nVarsC, nVarsD;
int status, ResC, ResD;
status = Dau_DecDecomposeSet( p, nVars, uSet, &tComp, &tDec, pPermC, pPermD, &nVarsC, &nVarsD );
// Dau_DecPrintSet( uSet, nVars );
// printf( "Decomposition %s\n", status ? "exists" : "does not exist" );
if ( !status )
{
printf( " Decomposition does not exist\n" );
return 0;
}
// Dau_DsdPrintFromTruth( stdout, p, nVars ); //printf( "\n" );
// Dau_DsdPrintFromTruth( stdout, &tComp, nVars ); //printf( "\n" );
// Dau_DsdPrintFromTruth( stdout, &tDec, nVars ); //printf( "\n" );
// decompose
ResC = Dau_DsdDecompose( &tComp, nVarsC, 0, 1, pDsdC );
ResD = Dau_DsdDecompose( &tDec, nVarsD, 0, 1, pDsdD );
/*
printf( "%s\n", pDsdC );
printf( "%s\n", pDsdD );
for ( v = 0; v < nVarsC; v++ )
printf( "%d ", pPermC[v] );
printf( "\n" );
for ( v = 0; v < nVarsD; v++ )
printf( "%d ", pPermD[v] );
printf( "\n" );
*/
// replace variables
Dau_DecVarReplace( pDsdD, pPermD, nVarsD );
Dau_DecVarReplace( pDsdC, pPermC, nVarsC );
printf( "%24s ", pDsdD );
printf( "%24s ", pDsdC );
Dau_DecVerify( p, nVars, pDsdC, pDsdD );
return 1;
}
void Dau_DecTrySets( word * p, int nVars )
{
Vec_Int_t * vSets;
word t0 = *p;
int i, Entry;
vSets = Dau_DecFindSets( p, nVars );
Dau_DsdPrintFromTruth( stdout, &t0, nVars );
printf( "There are %d support-reducing decompositions:\n", Vec_IntSize(vSets) );
Vec_IntForEachEntry( vSets, Entry, i )
{
unsigned uSet = (unsigned)Entry;
Dau_DecPrintSet( uSet, nVars, 0 );
Dau_DecPerform( &t0, nVars, uSet );
}
// printf( "\n" );
Vec_IntFree( vSets );
}
void Dau_DecFindSetsTest3()
{
word a0 = (~s_Truths6[1] & s_Truths6[2]) | (s_Truths6[1] & s_Truths6[3]);
word a1 = (~s_Truths6[1] & s_Truths6[4]) | (s_Truths6[1] & s_Truths6[5]);
word t = (~s_Truths6[0] & a0) | (s_Truths6[0] & a1);
// word t = ABC_CONST(0x0F7700000F770000); // (!<(ab)cd>e)
int nVars = 6;
char * pStr = "Bcd";
// char * pStr = "Abcd";
// char * pStr = "ab";
unsigned uSet = Dau_DecReadSet( pStr );
Dau_DecPerform( &t, nVars, uSet );
}
void Dau_DecFindSetsTest()
{
int nVars = 6;
// word a0 = (~s_Truths6[1] & s_Truths6[2]) | (s_Truths6[1] & s_Truths6[3]);
// word a1 = (~s_Truths6[1] & s_Truths6[4]) | (s_Truths6[1] & s_Truths6[5]);
// word t = (~s_Truths6[0] & a0) | (s_Truths6[0] & a1);
// word t = ABC_CONST(0x7EFFFFFFFFFFFF7E); // and(gam1,gam2)
// word t = ABC_CONST(0xB0F0BBFFB0F0BAFE); // some funct
// word t = ABC_CONST(0x00000000901FFFFF); // some funct
word t = ABC_CONST(0x000030F00D0D3FFF); // some funct
// word t = ABC_CONST(0x00000000690006FF); // some funct
// word t = ABC_CONST(0x7000F80007FF0FFF); // some funct
// word t = ABC_CONST(0x4133CB334133CB33); // some funct 5 var
// word t = ABC_CONST(0x2B0228022B022802); // 5-var non-dec0x0F7700000F770000
// word t = ABC_CONST(0x0F7700000F770000); // (!<(ab)cd>e)
// word t = ABC_CONST(0x7F00000000000000); // (!(abc)def)
Dau_DecTrySets( &t, nVars );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_IMPL_END
|