ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
giaTtopt.cpp
Go to the documentation of this file.
1
20
21#ifdef _WIN32
22#ifndef __MINGW32__
23#pragma warning(disable : 4786) // warning C4786: identifier was truncated to '255' characters in the browser information
24#endif
25#endif
26
27#include <vector>
28#include <algorithm>
29#include <cassert>
30#include <bitset>
31
32#include "gia.h"
33#include "misc/vec/vecHash.h"
34
36
37namespace Ttopt {
38
40public:
41 static const int ww; // word width
42 static const int lww; // log word width
43 typedef std::bitset<64> bsw;
44
46 int nSize;
49 std::vector<word> t;
50
51 std::vector<std::vector<int> > vvIndices;
52 std::vector<std::vector<int> > vvRedundantIndices;
53 std::vector<int> vLevels;
54
55 std::vector<std::vector<word> > savedt;
56 std::vector<std::vector<std::vector<int> > > vvIndicesSaved;
57 std::vector<std::vector<std::vector<int> > > vvRedundantIndicesSaved;
58 std::vector<std::vector<int> > vLevelsSaved;
59
60 static const word ones[];
61 static const word swapmask[];
62
64 srand(0xABC);
65 if(nInputs >= lww) {
66 nSize = 1 << (nInputs - lww);
68 t.resize(nTotalSize);
69 } else {
70 nSize = 0;
71 nTotalSize = ((1 << nInputs) * nOutputs + ww - 1) / ww;
72 t.resize(nTotalSize);
73 }
74 vLevels.resize(nInputs);
75 for(int i = 0; i < nInputs; i++) {
76 vLevels[i] = i;
77 }
78 }
79
80 virtual void Save(unsigned i) {
81 if(savedt.size() < i + 1) {
82 savedt.resize(i + 1);
83 vLevelsSaved.resize(i + 1);
84 }
85 savedt[i] = t;
87 }
88
89 virtual void Load(unsigned i) {
90 assert(i < savedt.size());
91 t = savedt[i];
93 }
94
95 virtual void SaveIndices(unsigned i) {
96 if(vvIndicesSaved.size() < i + 1) {
97 vvIndicesSaved.resize(i + 1);
98 vvRedundantIndicesSaved.resize(i + 1);
99 }
102 }
103
104 virtual void LoadIndices(unsigned i) {
107 }
108
109 word GetValue(int index_lev, int lev) {
110 assert(index_lev >= 0);
111 assert(nInputs - lev <= lww);
112 int logwidth = nInputs - lev;
113 int index = index_lev >> (lww - logwidth);
114 int pos = (index_lev % (1 << (lww - logwidth))) << logwidth;
115 return (t[index] >> pos) & ones[logwidth];
116 }
117
118 int IsEq(int index1, int index2, int lev, bool fCompl = false) {
119 assert(index1 >= 0);
120 assert(index2 >= 0);
121 int logwidth = nInputs - lev;
122 bool fEq = true;
123 if(logwidth > lww) {
124 int nScopeSize = 1 << (logwidth - lww);
125 for(int i = 0; i < nScopeSize && (fEq || fCompl); i++) {
126 fEq &= (t[nScopeSize * index1 + i] == t[nScopeSize * index2 + i]);
127 fCompl &= (t[nScopeSize * index1 + i] == ~t[nScopeSize * index2 + i]);
128 }
129 } else {
130 word value = GetValue(index1, lev) ^ GetValue(index2, lev);
131 fEq &= !value;
132 fCompl &= !(value ^ ones[logwidth]);
133 }
134 return 2 * fCompl + fEq;
135 }
136
137 bool Imply(int index1, int index2, int lev) {
138 assert(index1 >= 0);
139 assert(index2 >= 0);
140 int logwidth = nInputs - lev;
141 if(logwidth > lww) {
142 int nScopeSize = 1 << (logwidth - lww);
143 for(int i = 0; i < nScopeSize; i++) {
144 if(t[nScopeSize * index1 + i] & ~t[nScopeSize * index2 + i]) {
145 return false;
146 }
147 }
148 return true;
149 }
150 return !(GetValue(index1, lev) & (GetValue(index2, lev) ^ ones[logwidth]));
151 }
152
153 int BDDNodeCountLevel(int lev) {
154 return vvIndices[lev].size() - vvRedundantIndices[lev].size();
155 }
156
158 int count = 1; // const node
159 for(int i = 0; i < nInputs; i++) {
160 count += BDDNodeCountLevel(i);
161 }
162 return count;
163 }
164
165 int BDDFind(int index, int lev) {
166 int logwidth = nInputs - lev;
167 if(logwidth > lww) {
168 int nScopeSize = 1 << (logwidth - lww);
169 bool fZero = true;
170 bool fOne = true;
171 for(int i = 0; i < nScopeSize && (fZero || fOne); i++) {
172 word value = t[nScopeSize * index + i];
173 fZero &= !value;
174 fOne &= !(~value);
175 }
176 if(fZero || fOne) {
177 return -2 ^ (int)fOne;
178 }
179 for(unsigned j = 0; j < vvIndices[lev].size(); j++) {
180 int index2 = vvIndices[lev][j];
181 bool fEq = true;
182 bool fCompl = true;
183 for(int i = 0; i < nScopeSize && (fEq || fCompl); i++) {
184 fEq &= (t[nScopeSize * index + i] == t[nScopeSize * index2 + i]);
185 fCompl &= (t[nScopeSize * index + i] == ~t[nScopeSize * index2 + i]);
186 }
187 if(fEq || fCompl) {
188 return (j << 1) ^ (int)fCompl;
189 }
190 }
191 } else {
192 word value = GetValue(index, lev);
193 if(!value) {
194 return -2;
195 }
196 if(!(value ^ ones[logwidth])) {
197 return -1;
198 }
199 for(unsigned j = 0; j < vvIndices[lev].size(); j++) {
200 int index2 = vvIndices[lev][j];
201 word value2 = value ^ GetValue(index2, lev);
202 if(!(value2)) {
203 return j << 1;
204 }
205 if(!(value2 ^ ones[logwidth])) {
206 return (j << 1) ^ 1;
207 }
208 }
209 }
210 return -3;
211 }
212
213 virtual int BDDBuildOne(int index, int lev) {
214 int r = BDDFind(index, lev);
215 if(r >= -2) {
216 return r;
217 }
218 vvIndices[lev].push_back(index);
219 return (vvIndices[lev].size() - 1) << 1;
220 }
221
222 virtual void BDDBuildStartup() {
223 vvIndices.clear();
224 vvIndices.resize(nInputs);
225 vvRedundantIndices.clear();
227 for(int i = 0; i < nOutputs; i++) {
228 BDDBuildOne(i, 0);
229 }
230 }
231
232 virtual void BDDBuildLevel(int lev) {
233 for(unsigned i = 0; i < vvIndices[lev-1].size(); i++) {
234 int index = vvIndices[lev-1][i];
235 int cof0 = BDDBuildOne(index << 1, lev);
236 int cof1 = BDDBuildOne((index << 1) ^ 1, lev);
237 if(cof0 == cof1) {
238 vvRedundantIndices[lev-1].push_back(index);
239 }
240 }
241 }
242
243 virtual int BDDBuild() {
245 for(int i = 1; i < nInputs; i++) {
246 BDDBuildLevel(i);
247 }
248 return BDDNodeCount();
249 }
250
251 virtual int BDDRebuild(int lev) {
252 vvIndices[lev].clear();
253 vvIndices[lev+1].clear();
254 for(int i = lev; i < lev + 2; i++) {
255 if(!i) {
256 for(int j = 0; j < nOutputs; j++) {
257 BDDBuildOne(j, 0);
258 }
259 } else {
260 vvRedundantIndices[i-1].clear();
261 BDDBuildLevel(i);
262 }
263 }
264 if(lev < nInputs - 2) {
265 vvRedundantIndices[lev+1].clear();
266 for(unsigned i = 0; i < vvIndices[lev+1].size(); i++) {
267 int index = vvIndices[lev+1][i];
268 if(IsEq(index << 1, (index << 1) ^ 1, lev + 2)) {
269 vvRedundantIndices[lev+1].push_back(index);
270 }
271 }
272 }
273 return BDDNodeCount();
274 }
275
276 virtual void Swap(int lev) {
277 assert(lev < nInputs - 1);
278 std::vector<int>::iterator it0 = std::find(vLevels.begin(), vLevels.end(), lev);
279 std::vector<int>::iterator it1 = std::find(vLevels.begin(), vLevels.end(), lev + 1);
280 std::swap(*it0, *it1);
281 if(nInputs - lev - 1 > lww) {
282 int nScopeSize = 1 << (nInputs - lev - 2 - lww);
283 for(int i = nScopeSize; i < nTotalSize; i += (nScopeSize << 2)) {
284 for(int j = 0; j < nScopeSize; j++) {
285 std::swap(t[i + j], t[i + nScopeSize + j]);
286 }
287 }
288 } else if(nInputs - lev - 1 == lww) {
289 for(int i = 0; i < nTotalSize; i += 2) {
290 t[i+1] ^= t[i] >> (ww / 2);
291 t[i] ^= t[i+1] << (ww / 2);
292 t[i+1] ^= t[i] >> (ww / 2);
293 }
294 } else {
295 for(int i = 0; i < nTotalSize; i++) {
296 int d = nInputs - lev - 2;
297 int shamt = 1 << d;
298 t[i] ^= (t[i] >> shamt) & swapmask[d];
299 t[i] ^= (t[i] & swapmask[d]) << shamt;
300 t[i] ^= (t[i] >> shamt) & swapmask[d];
301 }
302 }
303 }
304
305 void SwapIndex(int &index, int d) {
306 if((index >> d) % 4 == 1) {
307 index += 1 << d;
308 } else if((index >> d) % 4 == 2) {
309 index -= 1 << d;
310 }
311 }
312
313 virtual int BDDSwap(int lev) {
314 Swap(lev);
315 for(int i = lev + 2; i < nInputs; i++) {
316 for(unsigned j = 0; j < vvIndices[i].size(); j++) {
317 SwapIndex(vvIndices[i][j], i - (lev + 2));
318 }
319 }
320 // swapping vvRedundantIndices is unnecessary for node counting
321 return BDDRebuild(lev);
322 }
323
324 int SiftReo() {
325 int best = BDDBuild();
326 Save(0);
327 SaveIndices(0);
328 std::vector<int> vars(nInputs);
329 int i;
330 for(i = 0; i < nInputs; i++) {
331 vars[i] = i;
332 }
333 std::vector<unsigned> vCounts(nInputs);
334 for(i = 0; i < nInputs; i++) {
335 vCounts[i] = BDDNodeCountLevel(vLevels[i]);
336 }
337 for(i = 1; i < nInputs; i++) {
338 int j = i;
339 while(j > 0 && vCounts[vars[j-1]] < vCounts[vars[j]]) {
340 std::swap(vars[j], vars[j-1]);
341 j--;
342 }
343 }
344 bool turn = true;
345 unsigned j;
346 for(j = 0; j < vars.size(); j++) {
347 int var = vars[j];
348 bool updated = false;
349 int lev = vLevels[var];
350 for(int i = lev; i < nInputs - 1; i++) {
351 int count = BDDSwap(i);
352 if(best > count) {
353 best = count;
354 updated = true;
355 Save(turn);
356 SaveIndices(turn);
357 }
358 }
359 if(lev) {
360 Load(!turn);
361 LoadIndices(!turn);
362 for(int i = lev - 1; i >= 0; i--) {
363 int count = BDDSwap(i);
364 if(best > count) {
365 best = count;
366 updated = true;
367 Save(turn);
368 SaveIndices(turn);
369 }
370 }
371 }
372 turn ^= updated;
373 Load(!turn);
374 LoadIndices(!turn);
375 }
376 return best;
377 }
378
379 void Reo(std::vector<int> vLevelsNew) {
380 for(int i = 0; i < nInputs; i++) {
381 int var = std::find(vLevelsNew.begin(), vLevelsNew.end(), i) - vLevelsNew.begin();
382 int lev = vLevels[var];
383 if(lev < i) {
384 for(int j = lev; j < i; j++) {
385 Swap(j);
386 }
387 } else if(lev > i) {
388 for(int j = lev - 1; j >= i; j--) {
389 Swap(j);
390 }
391 }
392 }
393 assert(vLevels == vLevelsNew);
394 }
395
396 int RandomSiftReo(int nRound) {
397 int best = SiftReo();
398 Save(2);
399 for(int i = 0; i < nRound; i++) {
400 std::vector<int> vLevelsNew(nInputs);
401 int j;
402 for(j = 0; j < nInputs; j++) {
403 vLevelsNew[j] = j;
404 }
405 for(j = nInputs - 1; j > 0; j--) {
406 int d = rand() % j;
407 std::swap(vLevelsNew[j], vLevelsNew[d]);
408 }
409 Reo(vLevelsNew);
410 int r = SiftReo();
411 if(best > r) {
412 best = r;
413 Save(2);
414 }
415 }
416 Load(2);
417 return best;
418 }
419
420 int BDDGenerateAigRec(Gia_Man_t *pNew, std::vector<int> const &vInputs, std::vector<std::vector<int> > &vvNodes, int index, int lev) {
421 int r = BDDFind(index, lev);
422 if(r >= 0) {
423 return vvNodes[lev][r >> 1] ^ (r & 1);
424 }
425 if(r >= -2) {
426 return r + 2;
427 }
428 int cof0 = BDDGenerateAigRec(pNew, vInputs, vvNodes, index << 1, lev + 1);
429 int cof1 = BDDGenerateAigRec(pNew, vInputs, vvNodes, (index << 1) ^ 1, lev + 1);
430 if(cof0 == cof1) {
431 return cof0;
432 }
433 int node;
434 if(Imply(index << 1, (index << 1) ^ 1, lev + 1)) {
435 node = Gia_ManHashOr(pNew, Gia_ManHashAnd(pNew, vInputs[lev], cof1), cof0);
436 } else if(Imply((index << 1) ^ 1, index << 1, lev + 1)) {
437 node = Gia_ManHashOr(pNew, Gia_ManHashAnd(pNew, vInputs[lev] ^ 1, cof0), cof1);
438 } else {
439 node = Gia_ManHashMux(pNew, vInputs[lev], cof1, cof0);
440 }
441 vvIndices[lev].push_back(index);
442 vvNodes[lev].push_back(node);
443 return node;
444 }
445
446 virtual void BDDGenerateAig(Gia_Man_t *pNew, Vec_Int_t *vSupp) {
447 vvIndices.clear();
448 vvIndices.resize(nInputs);
449 std::vector<std::vector<int> > vvNodes(nInputs);
450 std::vector<int> vInputs(nInputs);
451 int i;
452 for(i = 0; i < nInputs; i++) {
453 vInputs[vLevels[i]] = Vec_IntEntry(vSupp, nInputs - i - 1) << 1;
454 }
455 for(i = 0; i < nOutputs; i++) {
456 int node = BDDGenerateAigRec(pNew, vInputs, vvNodes, i, 0);
457 Gia_ManAppendCo(pNew, node);
458 }
459 }
460};
461
462const int TruthTable::ww = 64;
463const int TruthTable::lww = 6;
464
465const word TruthTable::ones[7] = {ABC_CONST(0x0000000000000001),
466 ABC_CONST(0x0000000000000003),
467 ABC_CONST(0x000000000000000f),
468 ABC_CONST(0x00000000000000ff),
469 ABC_CONST(0x000000000000ffff),
470 ABC_CONST(0x00000000ffffffff),
471 ABC_CONST(0xffffffffffffffff)};
472
473const word TruthTable::swapmask[5] = {ABC_CONST(0x2222222222222222),
474 ABC_CONST(0x0c0c0c0c0c0c0c0c),
475 ABC_CONST(0x00f000f000f000f0),
476 ABC_CONST(0x0000ff000000ff00),
477 ABC_CONST(0x00000000ffff0000)};
478
479class TruthTableReo : public TruthTable {
480public:
481 bool fBuilt;
482 std::vector<std::vector<int> > vvChildren;
483 std::vector<std::vector<std::vector<int> > > vvChildrenSaved;
484
486 fBuilt = false;
487 }
488
489 void Save(unsigned i) {
490 if(vLevelsSaved.size() < i + 1) {
491 vLevelsSaved.resize(i + 1);
492 }
494 }
495
496 void Load(unsigned i) {
497 assert(i < vLevelsSaved.size());
499 }
500
501 void SaveIndices(unsigned i) {
503 if(vvChildrenSaved.size() < i + 1) {
504 vvChildrenSaved.resize(i + 1);
505 }
507 }
508
509 void LoadIndices(unsigned i) {
512 }
513
515 vvChildren.clear();
516 vvChildren.resize(nInputs);
518 }
519
520 void BDDBuildLevel(int lev) {
521 for(unsigned i = 0; i < vvIndices[lev-1].size(); i++) {
522 int index = vvIndices[lev-1][i];
523 int cof0 = BDDBuildOne(index << 1, lev);
524 int cof1 = BDDBuildOne((index << 1) ^ 1, lev);
525 vvChildren[lev-1].push_back(cof0);
526 vvChildren[lev-1].push_back(cof1);
527 if(cof0 == cof1) {
528 vvRedundantIndices[lev-1].push_back(index);
529 }
530 }
531 }
532
533 int BDDBuild() {
534 if(fBuilt) {
535 return BDDNodeCount();
536 }
537 fBuilt = true;
539 for(int i = 1; i < nInputs + 1; i++) {
540 BDDBuildLevel(i);
541 }
542 return BDDNodeCount();
543 }
544
545 int BDDRebuildOne(int index, int cof0, int cof1, int lev, Hash_IntMan_t *unique, std::vector<int> &vChildrenLow) {
546 if(cof0 < 0 && cof0 == cof1) {
547 return cof0;
548 }
549 bool fCompl = cof0 & 1;
550 if(fCompl) {
551 cof0 ^= 1;
552 cof1 ^= 1;
553 }
554 int *place = Hash_Int2ManLookup(unique, cof0, cof1);
555 if(*place) {
556 return (Hash_IntObjData2(unique, *place) << 1) ^ (int)fCompl;
557 }
558 vvIndices[lev].push_back(index);
559 Hash_Int2ManInsert(unique, cof0, cof1, vvIndices[lev].size() - 1);
560 vChildrenLow.push_back(cof0);
561 vChildrenLow.push_back(cof1);
562 if(cof0 == cof1) {
563 vvRedundantIndices[lev].push_back(index);
564 }
565 return ((vvIndices[lev].size() - 1) << 1) ^ (int)fCompl;
566 }
567
568 int BDDRebuild(int lev) {
569 vvRedundantIndices[lev].clear();
570 vvRedundantIndices[lev+1].clear();
571 std::vector<int> vChildrenHigh;
572 std::vector<int> vChildrenLow;
573 Hash_IntMan_t *unique = Hash_IntManStart(2 * vvIndices[lev+1].size());
574 vvIndices[lev+1].clear();
575 for(unsigned i = 0; i < vvIndices[lev].size(); i++) {
576 int index = vvIndices[lev][i];
577 int cof0index = vvChildren[lev][i+i] >> 1;
578 int cof1index = vvChildren[lev][i+i+1] >> 1;
579 bool cof0c = vvChildren[lev][i+i] & 1;
580 bool cof1c = vvChildren[lev][i+i+1] & 1;
581 int cof00, cof01, cof10, cof11;
582 if(cof0index < 0) {
583 cof00 = -2 ^ (int)cof0c;
584 cof01 = -2 ^ (int)cof0c;
585 } else {
586 cof00 = vvChildren[lev+1][cof0index+cof0index] ^ (int)cof0c;
587 cof01 = vvChildren[lev+1][cof0index+cof0index+1] ^ (int)cof0c;
588 }
589 if(cof1index < 0) {
590 cof10 = -2 ^ (int)cof1c;
591 cof11 = -2 ^ (int)cof1c;
592 } else {
593 cof10 = vvChildren[lev+1][cof1index+cof1index] ^ (int)cof1c;
594 cof11 = vvChildren[lev+1][cof1index+cof1index+1] ^ (int)cof1c;
595 }
596 int newcof0 = BDDRebuildOne(index << 1, cof00, cof10, lev + 1, unique, vChildrenLow);
597 int newcof1 = BDDRebuildOne((index << 1) ^ 1, cof01, cof11, lev + 1, unique, vChildrenLow);
598 vChildrenHigh.push_back(newcof0);
599 vChildrenHigh.push_back(newcof1);
600 if(newcof0 == newcof1) {
601 vvRedundantIndices[lev].push_back(index);
602 }
603 }
604 Hash_IntManStop(unique);
605 vvChildren[lev] = vChildrenHigh;
606 vvChildren[lev+1] = vChildrenLow;
607 return BDDNodeCount();
608 }
609
610 void Swap(int lev) {
611 assert(lev < nInputs - 1);
612 std::vector<int>::iterator it0 = std::find(vLevels.begin(), vLevels.end(), lev);
613 std::vector<int>::iterator it1 = std::find(vLevels.begin(), vLevels.end(), lev + 1);
614 std::swap(*it0, *it1);
615 BDDRebuild(lev);
616 }
617
618 int BDDSwap(int lev) {
619 Swap(lev);
620 return BDDNodeCount();
621 }
622
623 virtual void BDDGenerateAig(Gia_Man_t *pNew, Vec_Int_t *vSupp) {
624 abort();
625 }
626};
627
629public:
631
632 void SetValue(int index_lev, int lev, word value) {
633 assert(index_lev >= 0);
634 assert(nInputs - lev <= lww);
635 int logwidth = nInputs - lev;
636 int index = index_lev >> (lww - logwidth);
637 int pos = (index_lev % (1 << (lww - logwidth))) << logwidth;
638 t[index] &= ~(ones[logwidth] << pos);
639 t[index] ^= value << pos;
640 }
641
642 void CopyFunc(int index1, int index2, int lev, bool fCompl) {
643 assert(index1 >= 0);
644 int logwidth = nInputs - lev;
645 if(logwidth > lww) {
646 int nScopeSize = 1 << (logwidth - lww);
647 if(!fCompl) {
648 if(index2 < 0) {
649 for(int i = 0; i < nScopeSize; i++) {
650 t[nScopeSize * index1 + i] = 0;
651 }
652 } else {
653 for(int i = 0; i < nScopeSize; i++) {
654 t[nScopeSize * index1 + i] = t[nScopeSize * index2 + i];
655 }
656 }
657 } else {
658 if(index2 < 0) {
659 for(int i = 0; i < nScopeSize; i++) {
660 t[nScopeSize * index1 + i] = ones[lww];
661 }
662 } else {
663 for(int i = 0; i < nScopeSize; i++) {
664 t[nScopeSize * index1 + i] = ~t[nScopeSize * index2 + i];
665 }
666 }
667 }
668 } else {
669 word value = 0;
670 if(index2 >= 0) {
671 value = GetValue(index2, lev);
672 }
673 if(fCompl) {
674 value ^= ones[logwidth];
675 }
676 SetValue(index1, lev, value);
677 }
678 }
679
680 void ShiftToMajority(int index, int lev) {
681 assert(index >= 0);
682 int logwidth = nInputs - lev;
683 int count = 0;
684 if(logwidth > lww) {
685 int nScopeSize = 1 << (logwidth - lww);
686 for(int i = 0; i < nScopeSize; i++) {
687 count += bsw(t[nScopeSize * index + i]).count();
688 }
689 } else {
690 count = bsw(GetValue(index, lev)).count();
691 }
692 bool majority = count > (1 << (logwidth - 1));
693 CopyFunc(index, -1, lev, majority);
694 }
695};
696
698public:
699 std::vector<word> originalt;
700 std::vector<word> caret;
701 std::vector<word> care;
702
703 std::vector<std::vector<std::pair<int, int> > > vvMergedIndices;
704
705 std::vector<std::vector<word> > savedcare;
706 std::vector<std::vector<std::vector<std::pair<int, int> > > > vvMergedIndicesSaved;
707
709 if(nSize) {
710 care.resize(nSize);
711 } else {
712 care.resize(1);
713 }
714 }
715
716 void Save(unsigned i) {
718 if(savedcare.size() < i + 1) {
719 savedcare.resize(i + 1);
720 }
721 savedcare[i] = care;
722 }
723
724 void Load(unsigned i) {
726 care = savedcare[i];
727 }
728
729 void SaveIndices(unsigned i) {
731 if(vvMergedIndicesSaved.size() < i + 1) {
732 vvMergedIndicesSaved.resize(i + 1);
733 }
735 }
736
741
742 void Swap(int lev) {
743 TruthTable::Swap(lev);
744 if(nInputs - lev - 1 > lww) {
745 int nScopeSize = 1 << (nInputs - lev - 2 - lww);
746 for(int i = nScopeSize; i < nSize; i += (nScopeSize << 2)) {
747 for(int j = 0; j < nScopeSize; j++) {
748 std::swap(care[i + j], care[i + nScopeSize + j]);
749 }
750 }
751 } else if(nInputs - lev - 1 == lww) {
752 for(int i = 0; i < nSize; i += 2) {
753 care[i+1] ^= care[i] >> (ww / 2);
754 care[i] ^= care[i+1] << (ww / 2);
755 care[i+1] ^= care[i] >> (ww / 2);
756 }
757 } else {
758 for(int i = 0; i < nSize || (i == 0 && !nSize); i++) {
759 int d = nInputs - lev - 2;
760 int shamt = 1 << d;
761 care[i] ^= (care[i] >> shamt) & swapmask[d];
762 care[i] ^= (care[i] & swapmask[d]) << shamt;
763 care[i] ^= (care[i] >> shamt) & swapmask[d];
764 }
765 }
766 }
767
768 void RestoreCare() {
769 caret.clear();
770 if(nSize) {
771 for(int i = 0; i < nOutputs; i++) {
772 caret.insert(caret.end(), care.begin(), care.end());
773 }
774 } else {
775 caret.resize(nTotalSize);
776 for(int i = 0; i < nOutputs; i++) {
777 int padding = i * (1 << nInputs);
778 caret[padding / ww] |= care[0] << (padding % ww);
779 }
780 }
781 }
782
783 word GetCare(int index_lev, int lev) {
784 assert(index_lev >= 0);
785 assert(nInputs - lev <= lww);
786 int logwidth = nInputs - lev;
787 int index = index_lev >> (lww - logwidth);
788 int pos = (index_lev % (1 << (lww - logwidth))) << logwidth;
789 return (caret[index] >> pos) & ones[logwidth];
790 }
791
792 void CopyFuncMasked(int index1, int index2, int lev, bool fCompl) {
793 assert(index1 >= 0);
794 assert(index2 >= 0);
795 int logwidth = nInputs - lev;
796 if(logwidth > lww) {
797 int nScopeSize = 1 << (logwidth - lww);
798 for(int i = 0; i < nScopeSize; i++) {
799 word value = t[nScopeSize * index2 + i];
800 if(fCompl) {
801 value = ~value;
802 }
803 word cvalue = caret[nScopeSize * index2 + i];
804 t[nScopeSize * index1 + i] &= ~cvalue;
805 t[nScopeSize * index1 + i] |= cvalue & value;
806 }
807 } else {
808 word one = ones[logwidth];
809 word value1 = GetValue(index1, lev);
810 word value2 = GetValue(index2, lev);
811 if(fCompl) {
812 value2 ^= one;
813 }
814 word cvalue = GetCare(index2, lev);
815 value1 &= cvalue ^ one;
816 value1 |= cvalue & value2;
817 SetValue(index1, lev, value1);
818 }
819 }
820
821 bool IsDC(int index, int lev) {
822 if(nInputs - lev > lww) {
823 int nScopeSize = 1 << (nInputs - lev - lww);
824 for(int i = 0; i < nScopeSize; i++) {
825 if(caret[nScopeSize * index + i]) {
826 return false;
827 }
828 }
829 } else if(GetCare(index, lev)) {
830 return false;
831 }
832 return true;
833 }
834
835 int Include(int index1, int index2, int lev, bool fCompl) {
836 assert(index1 >= 0);
837 assert(index2 >= 0);
838 int logwidth = nInputs - lev;
839 bool fEq = true;
840 if(logwidth > lww) {
841 int nScopeSize = 1 << (logwidth - lww);
842 for(int i = 0; i < nScopeSize && (fEq || fCompl); i++) {
843 word cvalue = caret[nScopeSize * index2 + i];
844 if(~caret[nScopeSize * index1 + i] & cvalue) {
845 return 0;
846 }
847 word value = t[nScopeSize * index1 + i] ^ t[nScopeSize * index2 + i];
848 fEq &= !(value & cvalue);
849 fCompl &= !(~value & cvalue);
850 }
851 } else {
852 word cvalue = GetCare(index2, lev);
853 if((GetCare(index1, lev) ^ ones[logwidth]) & cvalue) {
854 return 0;
855 }
856 word value = GetValue(index1, lev) ^ GetValue(index2, lev);
857 fEq &= !(value & cvalue);
858 fCompl &= !((value ^ ones[logwidth]) & cvalue);
859 }
860 return 2 * fCompl + fEq;
861 }
862
863 int Intersect(int index1, int index2, int lev, bool fCompl, bool fEq = true) {
864 assert(index1 >= 0);
865 assert(index2 >= 0);
866 int logwidth = nInputs - lev;
867 if(logwidth > lww) {
868 int nScopeSize = 1 << (logwidth - lww);
869 for(int i = 0; i < nScopeSize && (fEq || fCompl); i++) {
870 word value = t[nScopeSize * index1 + i] ^ t[nScopeSize * index2 + i];
871 word cvalue = caret[nScopeSize * index1 + i] & caret[nScopeSize * index2 + i];
872 fEq &= !(value & cvalue);
873 fCompl &= !(~value & cvalue);
874 }
875 } else {
876 word value = GetValue(index1, lev) ^ GetValue(index2, lev);
877 word cvalue = GetCare(index1, lev) & GetCare(index2, lev);
878 fEq &= !(value & cvalue);
879 fCompl &= !((value ^ ones[logwidth]) & cvalue);
880 }
881 return 2 * fCompl + fEq;
882 }
883
884 void MergeCare(int index1, int index2, int lev) {
885 assert(index1 >= 0);
886 assert(index2 >= 0);
887 int logwidth = nInputs - lev;
888 if(logwidth > lww) {
889 int nScopeSize = 1 << (logwidth - lww);
890 for(int i = 0; i < nScopeSize; i++) {
891 caret[nScopeSize * index1 + i] |= caret[nScopeSize * index2 + i];
892 }
893 } else {
894 word value = GetCare(index2, lev);
895 int index = index1 >> (lww - logwidth);
896 int pos = (index1 % (1 << (lww - logwidth))) << logwidth;
897 caret[index] |= value << pos;
898 }
899 }
900
901 void Merge(int index1, int index2, int lev, bool fCompl) {
902 MergeCare(index1, index2, lev);
903 vvMergedIndices[lev].push_back(std::make_pair((index1 << 1) ^ (int)fCompl, index2));
904 }
905
906 int BDDBuildOne(int index, int lev) {
907 int r = BDDFind(index, lev);
908 if(r >= -2) {
909 if(r >= 0) {
910 Merge(vvIndices[lev][r >> 1], index, lev, r & 1);
911 }
912 return r;
913 }
914 vvIndices[lev].push_back(index);
915 return (vvIndices[lev].size() - 1) << 1;
916 }
917
919 for(int i = nInputs - 1; i >= 0; i--) {
920 for(std::vector<std::pair<int, int> >::reverse_iterator it = vvMergedIndices[i].rbegin(); it != vvMergedIndices[i].rend(); it++) {
921 CopyFunc((*it).second, (*it).first >> 1, i, (*it).first & 1);
922 }
923 }
924 }
925
927 RestoreCare();
928 vvIndices.clear();
929 vvIndices.resize(nInputs);
930 vvRedundantIndices.clear();
932 vvMergedIndices.clear();
933 vvMergedIndices.resize(nInputs);
934 for(int i = 0; i < nOutputs; i++) {
935 if(!IsDC(i, 0)) {
936 BDDBuildOne(i, 0);
937 }
938 }
939 }
940
941 virtual void BDDRebuildByMerge(int lev) {
942 for(unsigned i = 0; i < vvMergedIndices[lev].size(); i++) {
943 std::pair<int, int> &p = vvMergedIndices[lev][i];
944 MergeCare(p.first >> 1, p.second, lev);
945 }
946 }
947
948 int BDDRebuild(int lev) {
949 RestoreCare();
950 int i;
951 for(i = lev; i < nInputs; i++) {
952 vvIndices[i].clear();
953 vvMergedIndices[i].clear();
954 if(i) {
955 vvRedundantIndices[i-1].clear();
956 }
957 }
958 for(i = 0; i < lev; i++) {
960 }
961 for(i = lev; i < nInputs; i++) {
962 if(!i) {
963 for(int j = 0; j < nOutputs; j++) {
964 if(!IsDC(j, 0)) {
965 BDDBuildOne(j, 0);
966 }
967 }
968 } else {
969 BDDBuildLevel(i);
970 }
971 }
972 return BDDNodeCount();
973 }
974
975 int BDDSwap(int lev) {
976 Swap(lev);
977 return BDDRebuild(lev);
978 }
979
981 originalt = t;
982 RestoreCare();
983 vvIndices.clear();
984 vvIndices.resize(nInputs);
985 vvMergedIndices.clear();
986 vvMergedIndices.resize(nInputs);
987 for(int i = 0; i < nOutputs; i++) {
988 if(!IsDC(i, 0)) {
989 BDDBuildOne(i, 0);
990 } else {
991 ShiftToMajority(i, 0);
992 }
993 }
994 }
995
996 virtual void Optimize() {
998 for(int i = 1; i < nInputs; i++) {
999 for(unsigned j = 0; j < vvIndices[i-1].size(); j++) {
1000 int index = vvIndices[i-1][j];
1001 BDDBuildOne(index << 1, i);
1002 BDDBuildOne((index << 1) ^ 1, i);
1003 }
1004 }
1005 CompleteMerge();
1006 }
1007};
1008
1010public:
1012
1013 int BDDFindTSM(int index, int lev) {
1014 int logwidth = nInputs - lev;
1015 if(logwidth > lww) {
1016 int nScopeSize = 1 << (logwidth - lww);
1017 bool fZero = true;
1018 bool fOne = true;
1019 for(int i = 0; i < nScopeSize && (fZero || fOne); i++) {
1020 word value = t[nScopeSize * index + i];
1021 word cvalue = caret[nScopeSize * index + i];
1022 fZero &= !(value & cvalue);
1023 fOne &= !(~value & cvalue);
1024 }
1025 if(fZero || fOne) {
1026 return -2 ^ (int)fOne;
1027 }
1028 for(unsigned j = 0; j < vvIndices[lev].size(); j++) {
1029 int index2 = vvIndices[lev][j];
1030 bool fEq = true;
1031 bool fCompl = true;
1032 for(int i = 0; i < nScopeSize && (fEq || fCompl); i++) {
1033 word value = t[nScopeSize * index + i] ^ t[nScopeSize * index2 + i];
1034 word cvalue = caret[nScopeSize * index + i] & caret[nScopeSize * index2 + i];
1035 fEq &= !(value & cvalue);
1036 fCompl &= !(~value & cvalue);
1037 }
1038 if(fEq || fCompl) {
1039 return (index2 << 1) ^ (int)!fEq;
1040 }
1041 }
1042 } else {
1043 word one = ones[logwidth];
1044 word value = GetValue(index, lev);
1045 word cvalue = GetCare(index, lev);
1046 if(!(value & cvalue)) {
1047 return -2;
1048 }
1049 if(!((value ^ one) & cvalue)) {
1050 return -1;
1051 }
1052 for(unsigned j = 0; j < vvIndices[lev].size(); j++) {
1053 int index2 = vvIndices[lev][j];
1054 word value2 = value ^ GetValue(index2, lev);
1055 word cvalue2 = cvalue & GetCare(index2, lev);
1056 if(!(value2 & cvalue2)) {
1057 return index2 << 1;
1058 }
1059 if(!((value2 ^ one) & cvalue2)) {
1060 return (index2 << 1) ^ 1;
1061 }
1062 }
1063 }
1064 return -3;
1065 }
1066
1067 int BDDBuildOne(int index, int lev) {
1068 int r = BDDFindTSM(index, lev);
1069 if(r >= -2) {
1070 if(r >= 0) {
1071 CopyFuncMasked(r >> 1, index, lev, r & 1);
1072 Merge(r >> 1, index, lev, r & 1);
1073 } else {
1074 vvMergedIndices[lev].push_back(std::make_pair(r, index));
1075 }
1076 return r;
1077 }
1078 vvIndices[lev].push_back(index);
1079 return index << 1;
1080 }
1081
1082 int BDDBuild() {
1084 int r = TruthTable::BDDBuild();
1086 return r;
1087 }
1088
1089 void BDDRebuildByMerge(int lev) {
1090 for(unsigned i = 0; i < vvMergedIndices[lev].size(); i++) {
1091 std::pair<int, int> &p = vvMergedIndices[lev][i];
1092 if(p.first >= 0) {
1093 CopyFuncMasked(p.first >> 1, p.second, lev, p.first & 1);
1094 MergeCare(p.first >> 1, p.second, lev);
1095 }
1096 }
1097 }
1098
1099 int BDDRebuild(int lev) {
1101 int r = TruthTableCare::BDDRebuild(lev);
1103 return r;
1104 }
1105};
1106
1107}
1108
1109Gia_Man_t * Gia_ManTtopt( Gia_Man_t * p, int nIns, int nOuts, int nRounds )
1110{
1111 Gia_Man_t * pNew;
1112 Gia_Obj_t * pObj;
1113 Vec_Int_t * vSupp;
1114 word v;
1115 word * pTruth;
1116 int i, g, k, nInputs;
1117 Gia_ManLevelNum( p );
1118 pNew = Gia_ManStart( Gia_ManObjNum(p) );
1119 pNew->pName = Abc_UtilStrsav( p->pName );
1120 pNew->pSpec = Abc_UtilStrsav( p->pSpec );
1121 Gia_ManForEachCi( p, pObj, k )
1122 Gia_ManAppendCi( pNew );
1124 Gia_ManHashStart( pNew );
1125 for ( g = 0; g < Gia_ManCoNum(p); g += nOuts )
1126 {
1127 vSupp = Gia_ManCollectSuppNew( p, g, nOuts );
1128 nInputs = Vec_IntSize( vSupp );
1129 Ttopt::TruthTableReo tt( nInputs, nOuts );
1130 for ( k = 0; k < nOuts; k++ )
1131 {
1132 pObj = Gia_ManCo( p, g+k );
1133 pTruth = Gia_ObjComputeTruthTableCut( p, Gia_ObjFanin0(pObj), vSupp );
1134 if ( nInputs >= 6 )
1135 for ( i = 0; i < tt.nSize; i++ )
1136 tt.t[i + tt.nSize * k] = Gia_ObjFaninC0(pObj)? ~pTruth[i]: pTruth[i];
1137 else
1138 {
1139 i = k * (1 << nInputs);
1140 v = (Gia_ObjFaninC0(pObj)? ~pTruth[0]: pTruth[0]) & tt.ones[nInputs];
1141 tt.t[i / tt.ww] |= v << (i % tt.ww);
1142 }
1143 }
1144 tt.RandomSiftReo( nRounds );
1145 Ttopt::TruthTable tt2( nInputs, nOuts );
1146 tt2.t = tt.t;
1147 tt2.Reo( tt.vLevels );
1148 tt2.BDDGenerateAig( pNew, vSupp );
1149 Vec_IntFree( vSupp );
1150 }
1152 Gia_ManHashStop( pNew );
1153 Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
1154 return pNew;
1155}
1156
1157Gia_Man_t * Gia_ManTtoptCare( Gia_Man_t * p, int nIns, int nOuts, int nRounds, char * pFileName, int nRarity )
1158{
1159 int fVerbose = 0;
1160 Gia_Man_t * pNew;
1161 Gia_Obj_t * pObj;
1162 Vec_Int_t * vSupp;
1163 word v;
1164 word * pTruth, * pCare;
1165 int i, g, k, nInputs;
1166 Vec_Wrd_t * vSimI = Vec_WrdReadBin( pFileName, fVerbose );
1167 Gia_ManLevelNum( p );
1168 pNew = Gia_ManStart( Gia_ManObjNum(p) );
1169 pNew->pName = Abc_UtilStrsav( p->pName );
1170 pNew->pSpec = Abc_UtilStrsav( p->pSpec );
1171 Gia_ManForEachCi( p, pObj, k )
1172 Gia_ManAppendCi( pNew );
1174 Gia_ManHashStart( pNew );
1175 for ( g = 0; g < Gia_ManCoNum(p); g += nOuts )
1176 {
1177 vSupp = Gia_ManCollectSuppNew( p, g, nOuts );
1178 nInputs = Vec_IntSize( vSupp );
1179 if ( nInputs == 0 )
1180 {
1181 for ( k = 0; k < nOuts; k++ )
1182 {
1183 pObj = Gia_ManCo( p, g+k );
1184 pTruth = Gia_ObjComputeTruthTableCut( p, Gia_ObjFanin0(pObj), vSupp );
1185 Gia_ManAppendCo( pNew, pTruth[0] & 1 );
1186 }
1187 Vec_IntFree( vSupp );
1188 continue;
1189 }
1190 Ttopt::TruthTableLevelTSM tt( nInputs, nOuts );
1191 for ( k = 0; k < nOuts; k++ )
1192 {
1193 pObj = Gia_ManCo( p, g+k );
1194 pTruth = Gia_ObjComputeTruthTableCut( p, Gia_ObjFanin0(pObj), vSupp );
1195 if ( nInputs >= 6 )
1196 for ( i = 0; i < tt.nSize; i++ )
1197 tt.t[i + tt.nSize * k] = Gia_ObjFaninC0(pObj)? ~pTruth[i]: pTruth[i];
1198 else
1199 {
1200 i = k * (1 << nInputs);
1201 v = (Gia_ObjFaninC0(pObj)? ~pTruth[0]: pTruth[0]) & tt.ones[nInputs];
1202 tt.t[i / tt.ww] |= v << (i % tt.ww);
1203 }
1204 }
1205 i = 1 << Vec_IntSize( vSupp );
1206 pCare = Gia_ManCountFraction( p, vSimI, vSupp, nRarity, fVerbose, &i );
1207 tt.care[0] = pCare[0];
1208 for ( i = 1; i < tt.nSize; i++ )
1209 tt.care[i] = pCare[i];
1210 ABC_FREE( pCare );
1211 tt.RandomSiftReo( nRounds );
1212 tt.Optimize();
1213 tt.BDDGenerateAig( pNew, vSupp );
1214 Vec_IntFree( vSupp );
1215 }
1217 Gia_ManHashStop( pNew );
1218 Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
1219 Vec_WrdFreeP( &vSimI );
1220 return pNew;
1221}
1222
1224
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_CONST(number)
PARAMETERS ///.
Definition abc_global.h:240
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
ABC_NAMESPACE_IMPL_START typedef signed char value
void Save(unsigned i)
Definition giaTtopt.cpp:716
std::vector< std::vector< word > > savedcare
Definition giaTtopt.cpp:705
void Swap(int lev)
Definition giaTtopt.cpp:742
void LoadIndices(unsigned i)
Definition giaTtopt.cpp:737
void CopyFuncMasked(int index1, int index2, int lev, bool fCompl)
Definition giaTtopt.cpp:792
bool IsDC(int index, int lev)
Definition giaTtopt.cpp:821
virtual void BDDRebuildByMerge(int lev)
Definition giaTtopt.cpp:941
void SaveIndices(unsigned i)
Definition giaTtopt.cpp:729
std::vector< std::vector< std::pair< int, int > > > vvMergedIndices
Definition giaTtopt.cpp:703
word GetCare(int index_lev, int lev)
Definition giaTtopt.cpp:783
int BDDBuildOne(int index, int lev)
Definition giaTtopt.cpp:906
std::vector< std::vector< std::vector< std::pair< int, int > > > > vvMergedIndicesSaved
Definition giaTtopt.cpp:706
std::vector< word > caret
Definition giaTtopt.cpp:700
void MergeCare(int index1, int index2, int lev)
Definition giaTtopt.cpp:884
virtual void Optimize()
Definition giaTtopt.cpp:996
int Intersect(int index1, int index2, int lev, bool fCompl, bool fEq=true)
Definition giaTtopt.cpp:863
std::vector< word > originalt
Definition giaTtopt.cpp:699
TruthTableCare(int nInputs, int nOutputs)
Definition giaTtopt.cpp:708
void Merge(int index1, int index2, int lev, bool fCompl)
Definition giaTtopt.cpp:901
int BDDSwap(int lev)
Definition giaTtopt.cpp:975
std::vector< word > care
Definition giaTtopt.cpp:701
void Load(unsigned i)
Definition giaTtopt.cpp:724
int BDDRebuild(int lev)
Definition giaTtopt.cpp:948
int Include(int index1, int index2, int lev, bool fCompl)
Definition giaTtopt.cpp:835
void BDDRebuildByMerge(int lev)
int BDDBuildOne(int index, int lev)
TruthTableLevelTSM(int nInputs, int nOutputs)
int BDDFindTSM(int index, int lev)
int BDDRebuild(int lev)
Definition giaTtopt.cpp:568
void Load(unsigned i)
Definition giaTtopt.cpp:496
int BDDSwap(int lev)
Definition giaTtopt.cpp:618
std::vector< std::vector< std::vector< int > > > vvChildrenSaved
Definition giaTtopt.cpp:483
TruthTableReo(int nInputs, int nOutputs)
Definition giaTtopt.cpp:485
virtual void BDDGenerateAig(Gia_Man_t *pNew, Vec_Int_t *vSupp)
Definition giaTtopt.cpp:623
int BDDRebuildOne(int index, int cof0, int cof1, int lev, Hash_IntMan_t *unique, std::vector< int > &vChildrenLow)
Definition giaTtopt.cpp:545
void LoadIndices(unsigned i)
Definition giaTtopt.cpp:509
std::vector< std::vector< int > > vvChildren
Definition giaTtopt.cpp:482
void SaveIndices(unsigned i)
Definition giaTtopt.cpp:501
void Swap(int lev)
Definition giaTtopt.cpp:610
void BDDBuildLevel(int lev)
Definition giaTtopt.cpp:520
void Save(unsigned i)
Definition giaTtopt.cpp:489
void SetValue(int index_lev, int lev, word value)
Definition giaTtopt.cpp:632
void CopyFunc(int index1, int index2, int lev, bool fCompl)
Definition giaTtopt.cpp:642
void ShiftToMajority(int index, int lev)
Definition giaTtopt.cpp:680
TruthTableRewrite(int nInputs, int nOutputs)
Definition giaTtopt.cpp:630
virtual void BDDBuildStartup()
Definition giaTtopt.cpp:222
virtual void Swap(int lev)
Definition giaTtopt.cpp:276
static const word swapmask[]
Definition giaTtopt.cpp:61
std::vector< std::vector< int > > vvRedundantIndices
Definition giaTtopt.cpp:52
bool Imply(int index1, int index2, int lev)
Definition giaTtopt.cpp:137
std::vector< int > vLevels
Definition giaTtopt.cpp:53
virtual int BDDSwap(int lev)
Definition giaTtopt.cpp:313
void Reo(std::vector< int > vLevelsNew)
Definition giaTtopt.cpp:379
word GetValue(int index_lev, int lev)
Definition giaTtopt.cpp:109
virtual void BDDGenerateAig(Gia_Man_t *pNew, Vec_Int_t *vSupp)
Definition giaTtopt.cpp:446
int RandomSiftReo(int nRound)
Definition giaTtopt.cpp:396
virtual int BDDBuild()
Definition giaTtopt.cpp:243
int BDDGenerateAigRec(Gia_Man_t *pNew, std::vector< int > const &vInputs, std::vector< std::vector< int > > &vvNodes, int index, int lev)
Definition giaTtopt.cpp:420
std::vector< std::vector< int > > vLevelsSaved
Definition giaTtopt.cpp:58
std::vector< std::vector< std::vector< int > > > vvRedundantIndicesSaved
Definition giaTtopt.cpp:57
std::vector< word > t
Definition giaTtopt.cpp:49
int BDDNodeCountLevel(int lev)
Definition giaTtopt.cpp:153
virtual void LoadIndices(unsigned i)
Definition giaTtopt.cpp:104
static const int lww
Definition giaTtopt.cpp:42
std::vector< std::vector< std::vector< int > > > vvIndicesSaved
Definition giaTtopt.cpp:56
static const word ones[]
Definition giaTtopt.cpp:60
virtual int BDDBuildOne(int index, int lev)
Definition giaTtopt.cpp:213
TruthTable(int nInputs, int nOutputs)
Definition giaTtopt.cpp:63
virtual void BDDBuildLevel(int lev)
Definition giaTtopt.cpp:232
void SwapIndex(int &index, int d)
Definition giaTtopt.cpp:305
virtual void Save(unsigned i)
Definition giaTtopt.cpp:80
std::bitset< 64 > bsw
Definition giaTtopt.cpp:43
virtual void SaveIndices(unsigned i)
Definition giaTtopt.cpp:95
std::vector< std::vector< int > > vvIndices
Definition giaTtopt.cpp:51
virtual void Load(unsigned i)
Definition giaTtopt.cpp:89
int BDDFind(int index, int lev)
Definition giaTtopt.cpp:165
virtual int BDDRebuild(int lev)
Definition giaTtopt.cpp:251
static const int ww
Definition giaTtopt.cpp:41
std::vector< std::vector< word > > savedt
Definition giaTtopt.cpp:55
int IsEq(int index1, int index2, int lev, bool fCompl=false)
Definition giaTtopt.cpp:118
bool pos
Definition globals.c:30
Cube * p
Definition exorList.c:222
Gia_Man_t * Gia_ManTtopt(Gia_Man_t *p, int nIns, int nOuts, int nRounds)
Gia_Man_t * Gia_ManTtoptCare(Gia_Man_t *p, int nIns, int nOuts, int nRounds, char *pFileName, int nRarity)
word * Gia_ObjComputeTruthTableCut(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vLeaves)
Definition giaTruth.c:628
void Gia_ManHashStart(Gia_Man_t *p)
Definition giaHash.c:125
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
Definition giaMan.c:764
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
int Gia_ManHashOr(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:621
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
int Gia_ManHashMux(Gia_Man_t *p, int iCtrl, int iData1, int iData0)
Definition giaHash.c:692
void Gia_ObjComputeTruthTableStart(Gia_Man_t *p, int nVarsMax)
Definition giaTruth.c:552
Vec_Int_t * Gia_ManCollectSuppNew(Gia_Man_t *p, int iOut, int nOuts)
Definition giaMinLut.c:632
void Gia_ObjComputeTruthTableStop(Gia_Man_t *p)
Definition giaTruth.c:568
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:576
word * Gia_ManCountFraction(Gia_Man_t *p, Vec_Wrd_t *vSimI, Vec_Int_t *vSupp, int Thresh, int fVerbose, int *pCare)
Definition giaMinLut.c:531
#define Gia_ManForEachCi(p, pObj, i)
Definition gia.h:1228
void Gia_ManHashStop(Gia_Man_t *p)
Definition giaHash.c:149
int Gia_ManLevelNum(Gia_Man_t *p)
Definition giaUtil.c:546
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
char * pSpec
Definition gia.h:100
char * pName
Definition gia.h:99
#define assert(ex)
Definition util_old.h:213
VOID_HACK abort()
struct Hash_IntMan_t_ Hash_IntMan_t
Definition vecHash.h:51
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition vecWrd.h:42