nysol-zdd 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/zdd_so/BDD.cc +495 -0
- data/ext/zdd_so/BDD.h +356 -0
- data/ext/zdd_so/BDDDG.cc +1818 -0
- data/ext/zdd_so/BDDDG.h +107 -0
- data/ext/zdd_so/BDDHASH.cc +91 -0
- data/ext/zdd_so/BtoI.cc +503 -0
- data/ext/zdd_so/BtoI.h +144 -0
- data/ext/zdd_so/CtoI.cc +1072 -0
- data/ext/zdd_so/CtoI.h +186 -0
- data/ext/zdd_so/MLZBDDV.cc +153 -0
- data/ext/zdd_so/MLZBDDV.h +42 -0
- data/ext/zdd_so/SOP.cc +608 -0
- data/ext/zdd_so/SOP.h +199 -0
- data/ext/zdd_so/ZBDD.cc +1035 -0
- data/ext/zdd_so/ZBDD.h +243 -0
- data/ext/zdd_so/ZBDDDG.cc +1834 -0
- data/ext/zdd_so/ZBDDDG.h +105 -0
- data/ext/zdd_so/ZBDDHASH.cc +91 -0
- data/ext/zdd_so/bddc.c +2816 -0
- data/ext/zdd_so/bddc.h +132 -0
- data/ext/zdd_so/extconf.rb +25 -0
- data/ext/zdd_so/include/aheap.c +211 -0
- data/ext/zdd_so/include/aheap.h +111 -0
- data/ext/zdd_so/include/base.c +93 -0
- data/ext/zdd_so/include/base.h +60 -0
- data/ext/zdd_so/include/itemset.c +473 -0
- data/ext/zdd_so/include/itemset.h +153 -0
- data/ext/zdd_so/include/problem.c +371 -0
- data/ext/zdd_so/include/problem.h +160 -0
- data/ext/zdd_so/include/queue.c +518 -0
- data/ext/zdd_so/include/queue.h +177 -0
- data/ext/zdd_so/include/sgraph.c +331 -0
- data/ext/zdd_so/include/sgraph.h +170 -0
- data/ext/zdd_so/include/stdlib2.c +832 -0
- data/ext/zdd_so/include/stdlib2.h +746 -0
- data/ext/zdd_so/include/trsact.c +723 -0
- data/ext/zdd_so/include/trsact.h +167 -0
- data/ext/zdd_so/include/vec.c +583 -0
- data/ext/zdd_so/include/vec.h +159 -0
- data/ext/zdd_so/lcm-vsop.cc +596 -0
- data/ext/zdd_so/print.cc +683 -0
- data/ext/zdd_so/table.cc +330 -0
- data/ext/zdd_so/vsop.h +88 -0
- data/ext/zdd_so/zdd_so.cpp +3277 -0
- data/lib/nysol/zdd.rb +31 -0
- metadata +131 -0
data/ext/zdd_so/print.cc
ADDED
@@ -0,0 +1,683 @@
|
|
1
|
+
// VSOP Print (v1.36)
|
2
|
+
// Shin-ichi MINATO (Dec. 18, 2010)
|
3
|
+
|
4
|
+
#include <cstdio>
|
5
|
+
#include <iostream>
|
6
|
+
#include <fstream>
|
7
|
+
#include <cstring>
|
8
|
+
#include "CtoI.h"
|
9
|
+
#include "vsop.h"
|
10
|
+
#include "ZBDDDG.h"
|
11
|
+
using namespace std;
|
12
|
+
|
13
|
+
#define LINE 70
|
14
|
+
|
15
|
+
BOut::BOut() {
|
16
|
+
_ffp=&cout;
|
17
|
+
_column = 0;
|
18
|
+
_isStdout=true;
|
19
|
+
}
|
20
|
+
BOut::BOut(char * str) {
|
21
|
+
_fp.open(str);
|
22
|
+
_ffp=&_fp;
|
23
|
+
_column = 0;
|
24
|
+
_isStdout=false;
|
25
|
+
}
|
26
|
+
BOut::~BOut() {
|
27
|
+
if(_isStdout==false){
|
28
|
+
_fp.close();
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
BOut& BOut::operator << (const char* str)
|
33
|
+
//BOut& BOut::operator << (char* str)
|
34
|
+
{
|
35
|
+
_column += strlen(str);
|
36
|
+
*_ffp << str;
|
37
|
+
return *this;
|
38
|
+
}
|
39
|
+
|
40
|
+
void BOut::Delimit()
|
41
|
+
{
|
42
|
+
if(_column >= LINE)
|
43
|
+
{
|
44
|
+
_column = 2;
|
45
|
+
*_ffp << "\n ";
|
46
|
+
_ffp->flush();
|
47
|
+
}
|
48
|
+
else
|
49
|
+
{
|
50
|
+
_column++;
|
51
|
+
*_ffp << " ";
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
void BOut::Return()
|
56
|
+
{
|
57
|
+
_column = 0;
|
58
|
+
*_ffp << "\n";
|
59
|
+
_ffp->flush();
|
60
|
+
}
|
61
|
+
void BOut::Set(char *str)
|
62
|
+
{
|
63
|
+
_ffp->flush();
|
64
|
+
if(_isStdout==false){
|
65
|
+
_fp.close();
|
66
|
+
}
|
67
|
+
_fp.open(str);
|
68
|
+
_ffp=&_fp;
|
69
|
+
_column = 0;
|
70
|
+
_isStdout=false;
|
71
|
+
}
|
72
|
+
void BOut::Unset()
|
73
|
+
{
|
74
|
+
_ffp->flush();
|
75
|
+
if(_isStdout==false){
|
76
|
+
_fp.close();
|
77
|
+
}
|
78
|
+
_ffp=&cout;
|
79
|
+
_column = 0;
|
80
|
+
_isStdout=true;
|
81
|
+
}
|
82
|
+
|
83
|
+
BOut bout;
|
84
|
+
|
85
|
+
static int PutNum(CtoI a, int base);
|
86
|
+
int PutNum(CtoI a, int base)
|
87
|
+
{
|
88
|
+
if(a.TopItem() > 0) a = a.MaxVal();
|
89
|
+
int d = a.TopDigit() / 3 + 14;
|
90
|
+
char* s = new char[d];
|
91
|
+
if(s == 0) return 1;
|
92
|
+
|
93
|
+
int err;
|
94
|
+
if(base == 16) err = a.StrNum16(s);
|
95
|
+
else err = a.StrNum10(s);
|
96
|
+
if(err == 1)
|
97
|
+
{
|
98
|
+
delete[] s;
|
99
|
+
return 1;
|
100
|
+
}
|
101
|
+
int len = strlen(s);
|
102
|
+
bout << s;
|
103
|
+
delete[] s;
|
104
|
+
return 0;
|
105
|
+
}
|
106
|
+
|
107
|
+
static int Depth;
|
108
|
+
static int* S_Var;
|
109
|
+
static int PFflag;
|
110
|
+
static int PF(CtoI, int);
|
111
|
+
static int PF(CtoI a, int base)
|
112
|
+
{
|
113
|
+
if(a.IsConst())
|
114
|
+
{
|
115
|
+
if(a.TopDigit() & 1) { bout.Delimit(); bout << "-"; a = -a; }
|
116
|
+
else if(PFflag == 1) { bout.Delimit(); bout << "+"; }
|
117
|
+
|
118
|
+
PFflag = 1;
|
119
|
+
int c1 = (a != 1);
|
120
|
+
if(c1 || Depth == 0)
|
121
|
+
{
|
122
|
+
bout.Delimit();
|
123
|
+
if(PutNum(a, base) == 1) return 1;
|
124
|
+
}
|
125
|
+
for(int i=0; i<Depth; i++)
|
126
|
+
{
|
127
|
+
bout.Delimit();
|
128
|
+
bout << VTable.GetName(S_Var[i]);
|
129
|
+
}
|
130
|
+
return 0;
|
131
|
+
}
|
132
|
+
|
133
|
+
int v = a.TopItem();
|
134
|
+
CtoI b = a.Factor1(v);
|
135
|
+
if(b == CtoI_Null()) return 1;
|
136
|
+
S_Var[Depth] = v;
|
137
|
+
Depth++;
|
138
|
+
if(PF(b, base) == 1) return 1;
|
139
|
+
Depth--;
|
140
|
+
b = a.Factor0(v);
|
141
|
+
if(b == 0) return 0;
|
142
|
+
if(b == CtoI_Null()) return 1;
|
143
|
+
return PF(b, base);
|
144
|
+
}
|
145
|
+
|
146
|
+
int PrintCtoI(CtoI a)
|
147
|
+
{
|
148
|
+
if(a == CtoI_Null()) return 1;
|
149
|
+
|
150
|
+
if(a == 0) bout << " 0";
|
151
|
+
else
|
152
|
+
{
|
153
|
+
int lev = BDD_LevOfVar(a.TopItem());
|
154
|
+
Depth = 0;
|
155
|
+
S_Var = new int[lev];
|
156
|
+
PFflag = 0;
|
157
|
+
int err = PF(a, 10);
|
158
|
+
delete[] S_Var;
|
159
|
+
if(err == 1)
|
160
|
+
{
|
161
|
+
bout << "...";
|
162
|
+
bout.Return();
|
163
|
+
return 1;
|
164
|
+
}
|
165
|
+
}
|
166
|
+
bout.Return();
|
167
|
+
return 0;
|
168
|
+
}
|
169
|
+
|
170
|
+
int PrintCtoI_16(CtoI a)
|
171
|
+
{
|
172
|
+
if(a == CtoI_Null()) return 1;
|
173
|
+
|
174
|
+
if(a == 0) bout << " 0";
|
175
|
+
else
|
176
|
+
{
|
177
|
+
int lev = BDD_LevOfVar(a.TopItem());
|
178
|
+
Depth = 0;
|
179
|
+
S_Var = new int[lev];
|
180
|
+
PFflag = 0;
|
181
|
+
int err = PF(a, 16);
|
182
|
+
delete[] S_Var;
|
183
|
+
if(err == 1)
|
184
|
+
{
|
185
|
+
bout << "...";
|
186
|
+
bout.Return();
|
187
|
+
return 1;
|
188
|
+
}
|
189
|
+
}
|
190
|
+
bout.Return();
|
191
|
+
return 0;
|
192
|
+
}
|
193
|
+
|
194
|
+
int PrintDigital(CtoI a)
|
195
|
+
{
|
196
|
+
int d = a.TopDigit();
|
197
|
+
for(int i=d; i>=0; i--)
|
198
|
+
{
|
199
|
+
if(d > 1)
|
200
|
+
{
|
201
|
+
char s[10];
|
202
|
+
sprintf(s, "%3d:", i);
|
203
|
+
bout << s;
|
204
|
+
}
|
205
|
+
if(PrintCtoI(a.Digit(i)) == 1) return 1;
|
206
|
+
}
|
207
|
+
return 0;
|
208
|
+
}
|
209
|
+
|
210
|
+
int PrintCase(CtoI a)
|
211
|
+
{
|
212
|
+
char s[80];
|
213
|
+
while(CtoI_GT(a, 0) != 0)
|
214
|
+
{
|
215
|
+
if(a == CtoI_Null())
|
216
|
+
{
|
217
|
+
bout << "...";
|
218
|
+
bout.Return();
|
219
|
+
return 1;
|
220
|
+
}
|
221
|
+
CtoI b = a.MaxVal();
|
222
|
+
b.StrNum10(s);
|
223
|
+
bout << s << ": ";
|
224
|
+
CtoI c = a.EQ_Const(b);
|
225
|
+
PrintCtoI(c);
|
226
|
+
a = a.FilterElse(c);
|
227
|
+
}
|
228
|
+
while(CtoI_LT(a, 0) != 0)
|
229
|
+
{
|
230
|
+
if(a == CtoI_Null())
|
231
|
+
{
|
232
|
+
bout << "...";
|
233
|
+
bout.Return();
|
234
|
+
return 1;
|
235
|
+
}
|
236
|
+
CtoI b = a.MinVal();
|
237
|
+
b.StrNum10(s);
|
238
|
+
bout << s << ": ";
|
239
|
+
CtoI c = a.EQ_Const(b);
|
240
|
+
PrintCtoI(c);
|
241
|
+
a = a.FilterElse(c);
|
242
|
+
}
|
243
|
+
return 0;
|
244
|
+
}
|
245
|
+
|
246
|
+
static void PutCode(int, int);
|
247
|
+
void PutCode(int num, int digit) // num < 8, digit <=3
|
248
|
+
{
|
249
|
+
for(int i=3; i>=0; i--)
|
250
|
+
if(i >= digit) bout << " ";
|
251
|
+
else if((num & (1 << i)) == 0) bout << "0";
|
252
|
+
else bout << "1";
|
253
|
+
}
|
254
|
+
|
255
|
+
static int MapVar[6];
|
256
|
+
|
257
|
+
static int MapNum(CtoI a);
|
258
|
+
int MapNum(CtoI a)
|
259
|
+
{
|
260
|
+
int ovf = 0;
|
261
|
+
if(a.TopItem() > 0)
|
262
|
+
{
|
263
|
+
a = a.MaxVal();
|
264
|
+
ovf = 1;
|
265
|
+
}
|
266
|
+
int d = a.TopDigit() / 3 + 14;
|
267
|
+
char* s = new char[d];
|
268
|
+
if(s == 0) return 1;
|
269
|
+
|
270
|
+
int err;
|
271
|
+
err = a.StrNum10(s);
|
272
|
+
if(err == 1)
|
273
|
+
{
|
274
|
+
delete[] s;
|
275
|
+
return 1;
|
276
|
+
}
|
277
|
+
int len = strlen(s);
|
278
|
+
if(ovf == 0)
|
279
|
+
{
|
280
|
+
for(int i=0; i<5-len; i++) bout << " ";
|
281
|
+
bout << " " << s;
|
282
|
+
}
|
283
|
+
else
|
284
|
+
{
|
285
|
+
for(int i=0; i<4-len; i++) bout << " ";
|
286
|
+
bout << "(" << s << ")";
|
287
|
+
}
|
288
|
+
delete[] s;
|
289
|
+
return 0;
|
290
|
+
}
|
291
|
+
|
292
|
+
static int Map(CtoI, int);
|
293
|
+
int Map(CtoI a, int dim)
|
294
|
+
{
|
295
|
+
if(a == CtoI_Null()) return 1;
|
296
|
+
int x, y;
|
297
|
+
switch(dim)
|
298
|
+
{
|
299
|
+
case 0:
|
300
|
+
if(MapNum(a) == 1) return 1;
|
301
|
+
bout.Return();
|
302
|
+
return 0;
|
303
|
+
case 1:
|
304
|
+
bout << " " << VTable.GetName(MapVar[0]);
|
305
|
+
bout.Return();
|
306
|
+
PutCode(0, 1);
|
307
|
+
bout << " |";
|
308
|
+
if(MapNum(a.Factor0(MapVar[0])) == 1) return 1;
|
309
|
+
bout.Return();
|
310
|
+
PutCode(1, 1);
|
311
|
+
bout << " |";
|
312
|
+
if(MapNum(a.Factor1(MapVar[0])) == 1) return 1;
|
313
|
+
bout.Return();
|
314
|
+
return 0;
|
315
|
+
case 2:
|
316
|
+
case 3:
|
317
|
+
case 4:
|
318
|
+
case 5:
|
319
|
+
case 6:
|
320
|
+
y = dim / 2;
|
321
|
+
x = dim - y;
|
322
|
+
break;
|
323
|
+
default: ;
|
324
|
+
}
|
325
|
+
int mx = 1 << x;
|
326
|
+
int my = 1 << y;
|
327
|
+
for(int i=0; i<y; i++)
|
328
|
+
bout << " " << VTable.GetName(MapVar[i]);
|
329
|
+
bout << " :";
|
330
|
+
for(int i=y; i<dim; i++)
|
331
|
+
bout << " " << VTable.GetName(MapVar[i]);
|
332
|
+
bout.Return();
|
333
|
+
bout << " ";
|
334
|
+
for(int i=0; i<mx; i++)
|
335
|
+
{
|
336
|
+
if(i == 0 || i == 4) bout << " |";
|
337
|
+
int m = i ^ (i >> 1);
|
338
|
+
bout << " ";
|
339
|
+
PutCode(m, x);
|
340
|
+
}
|
341
|
+
bout.Return();
|
342
|
+
for(int j=0; j<my; j++)
|
343
|
+
{
|
344
|
+
if(j == 4)
|
345
|
+
{
|
346
|
+
bout << " |";
|
347
|
+
if(x == 3) bout << " |";
|
348
|
+
bout.Return();
|
349
|
+
}
|
350
|
+
int n = j ^ (j >> 1);
|
351
|
+
PutCode(n, y);
|
352
|
+
n <<= x;
|
353
|
+
for(int i=0; i<mx; i++)
|
354
|
+
{
|
355
|
+
if(i == 0 || i == 4) bout << " |";
|
356
|
+
int m = n | (i ^ (i >> 1));
|
357
|
+
CtoI ax = a;
|
358
|
+
for(int k=0; k<dim; k++)
|
359
|
+
if((m & (1 << (dim-k-1))) == 0)
|
360
|
+
ax = ax.Factor0(MapVar[k]);
|
361
|
+
else ax = ax.Factor1(MapVar[k]);
|
362
|
+
if(MapNum(ax) == 1) return 1;
|
363
|
+
}
|
364
|
+
bout.Return();
|
365
|
+
}
|
366
|
+
return 0;
|
367
|
+
}
|
368
|
+
|
369
|
+
int MapAll(CtoI a)
|
370
|
+
{
|
371
|
+
int i=0;
|
372
|
+
int n = VTable.Used();
|
373
|
+
for(int j=0; j<n; j++)
|
374
|
+
{
|
375
|
+
MapVar[i++] = BDD_VarOfLev(n-j);
|
376
|
+
if(i == 6) break;
|
377
|
+
}
|
378
|
+
return Map(a, i);
|
379
|
+
}
|
380
|
+
|
381
|
+
int MapSel(CtoI a)
|
382
|
+
{
|
383
|
+
int i=0;
|
384
|
+
int n = VTable.Used();
|
385
|
+
for(int j=0; j<n; j++)
|
386
|
+
{
|
387
|
+
int var = BDD_VarOfLev(n-j);
|
388
|
+
if(a == CtoI_Null()) return 1;
|
389
|
+
if(a == a.Factor0(var)) continue;
|
390
|
+
MapVar[i++] = var;
|
391
|
+
if(i == 6) break;
|
392
|
+
}
|
393
|
+
return Map(a, i);
|
394
|
+
}
|
395
|
+
|
396
|
+
static void PrintD(ZBDDDG *, bddword);
|
397
|
+
void PrintD(ZBDDDG* dg, bddword ndx)
|
398
|
+
{
|
399
|
+
ZBDDDG_Tag tag, tag2;
|
400
|
+
tag.Set(dg, ndx);
|
401
|
+
bddword ndx0, ndx2;
|
402
|
+
int top;
|
403
|
+
switch(tag.Type())
|
404
|
+
{
|
405
|
+
case ZBDDDG_C0:
|
406
|
+
bout << "0";
|
407
|
+
break;
|
408
|
+
case ZBDDDG_P1:
|
409
|
+
bout << "OR(";
|
410
|
+
bout.Delimit();
|
411
|
+
ndx0 = tag.TopNdx();
|
412
|
+
tag2.Set(dg, ndx0);
|
413
|
+
if(tag2.Type() != ZBDDDG_OR)
|
414
|
+
PrintD(dg, ndx0);
|
415
|
+
else
|
416
|
+
{
|
417
|
+
ndx0 = tag2.TopNdx();
|
418
|
+
PrintD(dg, ndx0);
|
419
|
+
ndx0 = tag2.NextNdx();
|
420
|
+
while(ndx0 != ZBDDDG_NIL)
|
421
|
+
{
|
422
|
+
bout.Delimit();
|
423
|
+
PrintD(dg, ndx0);
|
424
|
+
ndx0 = tag2.NextNdx();
|
425
|
+
}
|
426
|
+
}
|
427
|
+
bout.Delimit();
|
428
|
+
bout << "1";
|
429
|
+
bout.Delimit();
|
430
|
+
bout << ")";
|
431
|
+
break;
|
432
|
+
case ZBDDDG_LIT:
|
433
|
+
top = tag.Func().Top();
|
434
|
+
bout << VTable.GetName(top);
|
435
|
+
break;
|
436
|
+
case ZBDDDG_AND:
|
437
|
+
bout << "AND(";
|
438
|
+
bout.Delimit();
|
439
|
+
ndx0 = tag.TopNdx();
|
440
|
+
PrintD(dg, ndx0);
|
441
|
+
ndx0 = tag.NextNdx();
|
442
|
+
while(ndx0 != ZBDDDG_NIL)
|
443
|
+
{
|
444
|
+
bout.Delimit();
|
445
|
+
PrintD(dg, ndx0);
|
446
|
+
ndx0 = tag.NextNdx();
|
447
|
+
}
|
448
|
+
bout.Delimit();
|
449
|
+
bout << ")";
|
450
|
+
break;
|
451
|
+
case ZBDDDG_OR:
|
452
|
+
bout << "OR(";
|
453
|
+
bout.Delimit();
|
454
|
+
ndx0 = tag.TopNdx();
|
455
|
+
PrintD(dg, ndx0);
|
456
|
+
ndx0 = tag.NextNdx();
|
457
|
+
while(ndx0 != ZBDDDG_NIL)
|
458
|
+
{
|
459
|
+
bout.Delimit();
|
460
|
+
PrintD(dg, ndx0);
|
461
|
+
ndx0 = tag.NextNdx();
|
462
|
+
}
|
463
|
+
bout.Delimit();
|
464
|
+
bout << ")";
|
465
|
+
break;
|
466
|
+
case ZBDDDG_OTHER:
|
467
|
+
bout << "[";
|
468
|
+
bout.Delimit();
|
469
|
+
ndx0 = tag.TopNdx();
|
470
|
+
PrintD(dg, ndx0);
|
471
|
+
ndx0 = tag.NextNdx();
|
472
|
+
while(ndx0 != ZBDDDG_NIL)
|
473
|
+
{
|
474
|
+
bout.Delimit();
|
475
|
+
PrintD(dg, ndx0);
|
476
|
+
ndx0 = tag.NextNdx();
|
477
|
+
}
|
478
|
+
bout.Delimit();
|
479
|
+
bout << "]";
|
480
|
+
break;
|
481
|
+
default:
|
482
|
+
bout << "???";
|
483
|
+
bout.Delimit();
|
484
|
+
break;
|
485
|
+
}
|
486
|
+
}
|
487
|
+
|
488
|
+
int PrintDecomp(CtoI a)
|
489
|
+
{
|
490
|
+
if(a == CtoI_Null()) return 1;
|
491
|
+
a = a.NonZero();
|
492
|
+
if(a == CtoI_Null()) return 1;
|
493
|
+
ZBDD f = a.GetZBDD();
|
494
|
+
ZBDDDG* dg = new ZBDDDG();
|
495
|
+
if(dg == 0) return 1;
|
496
|
+
bddword ndx = dg->Decomp(f);
|
497
|
+
if(ndx == ZBDDDG_NIL) { delete dg; return 1; }
|
498
|
+
|
499
|
+
PrintD(dg, ndx);
|
500
|
+
bout.Return();
|
501
|
+
delete dg;
|
502
|
+
return 0;
|
503
|
+
}
|
504
|
+
|
505
|
+
static int PrintDD_N;
|
506
|
+
static void PrintDD(ZBDDDG *, bddword);
|
507
|
+
void PrintDD(ZBDDDG* dg, bddword ndx)
|
508
|
+
{
|
509
|
+
ZBDDDG_Tag tag, tag2;
|
510
|
+
tag.Set(dg, ndx);
|
511
|
+
bddword ndx0, ndx2;
|
512
|
+
char s[20];
|
513
|
+
int top;
|
514
|
+
int n;
|
515
|
+
switch(tag.Type())
|
516
|
+
{
|
517
|
+
case ZBDDDG_C0:
|
518
|
+
bout << "n0 [label=0];";
|
519
|
+
break;
|
520
|
+
case ZBDDDG_P1:
|
521
|
+
n = PrintDD_N++;
|
522
|
+
sprintf(s, "n%d", n); bout << s;
|
523
|
+
bout << " [label=OR];";
|
524
|
+
bout.Return();
|
525
|
+
|
526
|
+
sprintf(s, "n%d", n); bout << s;
|
527
|
+
bout << " -> ";
|
528
|
+
sprintf(s, "n%d", PrintDD_N); bout << s;
|
529
|
+
bout << ";";
|
530
|
+
bout.Return();
|
531
|
+
|
532
|
+
ndx0 = tag.TopNdx();
|
533
|
+
tag2.Set(dg, ndx0);
|
534
|
+
if(tag2.Type() != ZBDDDG_OR)
|
535
|
+
PrintDD(dg, ndx0);
|
536
|
+
else
|
537
|
+
{
|
538
|
+
ndx0 = tag2.TopNdx();
|
539
|
+
PrintDD(dg, ndx0);
|
540
|
+
ndx0 = tag2.NextNdx();
|
541
|
+
while(ndx0 != ZBDDDG_NIL)
|
542
|
+
{
|
543
|
+
sprintf(s, "n%d", n); bout << s;
|
544
|
+
bout << " -> ";
|
545
|
+
sprintf(s, "n%d", PrintDD_N); bout << s;
|
546
|
+
bout << ";";
|
547
|
+
bout.Return();
|
548
|
+
|
549
|
+
PrintDD(dg, ndx0);
|
550
|
+
ndx0 = tag2.NextNdx();
|
551
|
+
}
|
552
|
+
}
|
553
|
+
sprintf(s, "n%d", PrintDD_N); bout << s;
|
554
|
+
bout << " [label=1];";
|
555
|
+
bout.Return();
|
556
|
+
|
557
|
+
sprintf(s, "n%d", n); bout << s;
|
558
|
+
bout << " -> ";
|
559
|
+
sprintf(s, "n%d", PrintDD_N); bout << s;
|
560
|
+
bout << ";";
|
561
|
+
bout.Return();
|
562
|
+
PrintDD_N++;
|
563
|
+
|
564
|
+
break;
|
565
|
+
case ZBDDDG_LIT:
|
566
|
+
top = tag.Func().Top();
|
567
|
+
|
568
|
+
n = PrintDD_N++;
|
569
|
+
sprintf(s, "n%d", n); bout << s;
|
570
|
+
bout << " [label=";
|
571
|
+
bout << VTable.GetName(top);
|
572
|
+
bout << "];";
|
573
|
+
bout.Return();
|
574
|
+
|
575
|
+
break;
|
576
|
+
case ZBDDDG_AND:
|
577
|
+
n = PrintDD_N++;
|
578
|
+
sprintf(s, "n%d", n); bout << s;
|
579
|
+
bout << " [label=AND];";
|
580
|
+
bout.Return();
|
581
|
+
|
582
|
+
sprintf(s, "n%d", n); bout << s;
|
583
|
+
bout << " -> ";
|
584
|
+
sprintf(s, "n%d", PrintDD_N); bout << s;
|
585
|
+
bout << ";";
|
586
|
+
bout.Return();
|
587
|
+
|
588
|
+
ndx0 = tag.TopNdx();
|
589
|
+
PrintDD(dg, ndx0);
|
590
|
+
ndx0 = tag.NextNdx();
|
591
|
+
while(ndx0 != ZBDDDG_NIL)
|
592
|
+
{
|
593
|
+
sprintf(s, "n%d", n); bout << s;
|
594
|
+
bout << " -> ";
|
595
|
+
sprintf(s, "n%d", PrintDD_N); bout << s;
|
596
|
+
bout << ";";
|
597
|
+
bout.Return();
|
598
|
+
|
599
|
+
PrintDD(dg, ndx0);
|
600
|
+
ndx0 = tag.NextNdx();
|
601
|
+
}
|
602
|
+
break;
|
603
|
+
case ZBDDDG_OR:
|
604
|
+
n = PrintDD_N++;
|
605
|
+
sprintf(s, "n%d", n); bout << s;
|
606
|
+
bout << " [label=OR];";
|
607
|
+
bout.Return();
|
608
|
+
|
609
|
+
sprintf(s, "n%d", n); bout << s;
|
610
|
+
bout << " -> ";
|
611
|
+
sprintf(s, "n%d", PrintDD_N); bout << s;
|
612
|
+
bout << ";";
|
613
|
+
bout.Return();
|
614
|
+
|
615
|
+
ndx0 = tag.TopNdx();
|
616
|
+
PrintDD(dg, ndx0);
|
617
|
+
ndx0 = tag.NextNdx();
|
618
|
+
while(ndx0 != ZBDDDG_NIL)
|
619
|
+
{
|
620
|
+
sprintf(s, "n%d", n); bout << s;
|
621
|
+
bout << " -> ";
|
622
|
+
sprintf(s, "n%d", PrintDD_N); bout << s;
|
623
|
+
bout << ";";
|
624
|
+
bout.Return();
|
625
|
+
|
626
|
+
PrintDD(dg, ndx0);
|
627
|
+
ndx0 = tag.NextNdx();
|
628
|
+
}
|
629
|
+
break;
|
630
|
+
case ZBDDDG_OTHER:
|
631
|
+
n = PrintDD_N++;
|
632
|
+
sprintf(s, "n%d", n); bout << s;
|
633
|
+
bout << " [label=OTHER];";
|
634
|
+
bout.Return();
|
635
|
+
|
636
|
+
sprintf(s, "n%d", n); bout << s;
|
637
|
+
bout << " -> ";
|
638
|
+
sprintf(s, "n%d", PrintDD_N); bout << s;
|
639
|
+
bout << ";";
|
640
|
+
bout.Return();
|
641
|
+
|
642
|
+
ndx0 = tag.TopNdx();
|
643
|
+
PrintDD(dg, ndx0);
|
644
|
+
ndx0 = tag.NextNdx();
|
645
|
+
while(ndx0 != ZBDDDG_NIL)
|
646
|
+
{
|
647
|
+
sprintf(s, "n%d", n); bout << s;
|
648
|
+
bout << " -> ";
|
649
|
+
sprintf(s, "n%d", PrintDD_N); bout << s;
|
650
|
+
bout << ";";
|
651
|
+
bout.Return();
|
652
|
+
|
653
|
+
PrintDD(dg, ndx0);
|
654
|
+
ndx0 = tag.NextNdx();
|
655
|
+
}
|
656
|
+
break;
|
657
|
+
default:
|
658
|
+
bout << "???";
|
659
|
+
break;
|
660
|
+
}
|
661
|
+
}
|
662
|
+
|
663
|
+
int PrintDecompDot(CtoI a)
|
664
|
+
{
|
665
|
+
if(a == CtoI_Null()) return 1;
|
666
|
+
a = a.NonZero();
|
667
|
+
if(a == CtoI_Null()) return 1;
|
668
|
+
ZBDD f = a.GetZBDD();
|
669
|
+
ZBDDDG* dg = new ZBDDDG();
|
670
|
+
if(dg == 0) return 1;
|
671
|
+
bddword ndx = dg->Decomp(f);
|
672
|
+
if(ndx == ZBDDDG_NIL) { delete dg; return 1; }
|
673
|
+
|
674
|
+
bout << "digraph G {";
|
675
|
+
bout.Return();
|
676
|
+
PrintDD_N = 0;
|
677
|
+
PrintDD(dg, ndx);
|
678
|
+
bout << "}";
|
679
|
+
bout.Return();
|
680
|
+
delete dg;
|
681
|
+
return 0;
|
682
|
+
}
|
683
|
+
|