ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
giaBound.c
Go to the documentation of this file.
1#include "gia.h"
2#include "misc/tim/tim.h"
3#include "misc/vec/vecWec.h"
4#include "proof/cec/cec.h"
5
6
8
12
13typedef struct Bnd_Man_t_ Bnd_Man_t;
14
60
62
66
67void Bnd_ManSetEqOut( int eq ) { pBnd -> eq_out = eq;}
68void Bnd_ManSetEqRes( int eq ) { pBnd -> eq_res = eq;}
69
70Vec_Int_t* Bnd_ManSpec2Impl( int id ) { return (Vec_Int_t*)Vec_PtrEntry( pBnd -> vBmiter2Impl, Vec_IntEntry( pBnd->vSpec2Bmiter, id ) ); }
71int Bnd_ManSpec2ImplNum( int id ) { return Vec_IntSize( (Vec_Int_t*)Vec_PtrEntry( pBnd -> vBmiter2Impl, Vec_IntEntry( pBnd->vSpec2Bmiter, id ) ) ); }
72
73Vec_Int_t* Bnd_ManImpl2Spec( int id ) { return (Vec_Int_t*)Vec_PtrEntry( pBnd -> vBmiter2Spec, Vec_IntEntry( pBnd->vImpl2Bmiter, id ) ); }
74int Bnd_ManImpl2SpecNum( int id ) { return Vec_IntSize( (Vec_Int_t*)Vec_PtrEntry( pBnd -> vBmiter2Spec, Vec_IntEntry( pBnd->vImpl2Bmiter, id ) ) ); }
75
87
88Bnd_Man_t* Bnd_ManStart( Gia_Man_t *pSpec, Gia_Man_t *pImpl, int fVerbose )
89{
90 int i;
92
93 p -> maxNumClass = Gia_ManCiNum( pSpec ) + Gia_ManAndNotBufNum(pSpec) + Gia_ManAndNum(pImpl) + 2 + Gia_ManCoNum(pSpec) * 2;
94 // one for constant node and one for dummy
95
96 p -> vBmiter2Spec = Vec_PtrAlloc( p -> maxNumClass );
97 p -> vBmiter2Impl = Vec_PtrAlloc( p -> maxNumClass );
98 Vec_PtrFill( p -> vBmiter2Spec, p -> maxNumClass, 0 );
99 Vec_PtrFill( p -> vBmiter2Impl, p -> maxNumClass, 0 );
100 for( i = 0; i < Vec_PtrSize( p -> vBmiter2Impl ); i ++ )
101 {
102 Vec_PtrSetEntry( p -> vBmiter2Spec, i, Vec_IntAlloc(1) );
103 Vec_PtrSetEntry( p -> vBmiter2Impl, i, Vec_IntAlloc(1) );
104 }
105
106 p -> vSpec2Impl_phase = Vec_BitAlloc( Gia_ManObjNum(pSpec) );
107 Vec_BitFill( p -> vSpec2Impl_phase, Gia_ManObjNum(pSpec), 0 );
108
109 p -> vImpl2Bmiter = Vec_IntAlloc( Gia_ManObjNum(pImpl) );
110 Vec_IntFill( p -> vImpl2Bmiter, Gia_ManObjNum(pImpl), p -> maxNumClass - 1 );
111 p -> vSpec2Bmiter = Vec_IntAlloc( Gia_ManObjNum(pSpec) );
112 Vec_IntFill( p -> vSpec2Bmiter, Gia_ManObjNum(pSpec), p -> maxNumClass - 1);
113
114 p -> vBI = Vec_IntAlloc(16);
115 p -> vBO = Vec_IntAlloc(16);
116 p -> vEI_spec = Vec_IntAlloc(16);
117 p -> vEO_spec = Vec_IntAlloc(16);
118 p -> vEI_impl = Vec_IntAlloc(16);
119 p -> vEO_impl = Vec_IntAlloc(16);
120 p -> vEI_phase = Vec_BitAlloc(16);
121 p -> vEO_phase = Vec_BitAlloc(16);
122
123 p -> nNode_spec = Gia_ManAndNum(pSpec) - Gia_ManBufNum(pSpec);
124 p -> nNode_impl = Gia_ManAndNum(pImpl);
125 p -> nNode_patch = 0;
126 p -> nNode_patched = 0;
127
128 p -> fVerbose = fVerbose;
129
130 p -> combLoop_spec = 0;
131 p -> combLoop_impl = 0;
132 p -> eq_out = 0;
133 p -> eq_res = 0;
134
135 p -> nChoice_spec = 0;
136 p -> nChoice_impl = 0;
137 p -> feedthrough = 0;
138
139 return p;
140}
141
154{
155 assert(pBnd);
156
157 Vec_PtrFree( pBnd-> vBmiter2Spec );
158 Vec_PtrFree( pBnd-> vBmiter2Impl );
159 Vec_BitFree( pBnd-> vSpec2Impl_phase );
160 Vec_IntFree( pBnd-> vImpl2Bmiter );
161 Vec_IntFree( pBnd-> vSpec2Bmiter );
162
163 Vec_IntFree( pBnd->vBI );
164 Vec_IntFree( pBnd->vBO );
165 Vec_IntFree( pBnd->vEI_spec );
166 Vec_IntFree( pBnd->vEO_spec );
167 Vec_IntFree( pBnd->vEI_impl );
168 Vec_IntFree( pBnd->vEO_impl );
169 Vec_BitFree( pBnd->vEI_phase );
170 Vec_BitFree( pBnd->vEO_phase );
171
172 ABC_FREE( pBnd );
173}
174
175int Bnd_ManGetNInternal() { assert(pBnd); return pBnd -> nInternal; }
176int Bnd_ManGetNExtra() { assert(pBnd); return pBnd -> nExtra; }
177
178void Bnd_ManMap( int iLit, int id, int spec )
179{
180
181 if ( spec )
182 {
183 Vec_IntPush( (Vec_Int_t *)Vec_PtrEntry( pBnd -> vBmiter2Spec, iLit >> 1), id );
184 Vec_BitSetEntry( pBnd -> vSpec2Impl_phase, id, iLit & 1 );
185 }
186 else
187 {
188 assert( (iLit & 1) == 0 );
189 Vec_IntPush( (Vec_Int_t *)Vec_PtrEntry( pBnd -> vBmiter2Impl, iLit >> 1), id );
190 }
191}
192
193void Bnd_ManMerge( int id_repr, int id_obj, int phaseDiff )
194{
195
196
197 Vec_Ptr_t* vBmiter2Spec = pBnd -> vBmiter2Spec;
198 Vec_Ptr_t* vBmiter2Impl = pBnd -> vBmiter2Impl;
199 Vec_Bit_t* vSpec2Impl_phase = pBnd -> vSpec2Impl_phase;
200 int id, i;
201
202 Vec_Int_t *vIds_spec_repr, *vIds_impl_repr, *vIds_spec_obj, *vIds_impl_obj;
203
204 vIds_spec_repr = (Vec_Int_t *)Vec_PtrEntry( vBmiter2Spec, id_repr );
205 vIds_impl_repr = (Vec_Int_t *)Vec_PtrEntry( vBmiter2Impl, id_repr );
206 vIds_spec_obj = (Vec_Int_t *)Vec_PtrEntry( vBmiter2Spec, id_obj );
207 vIds_impl_obj = (Vec_Int_t *)Vec_PtrEntry( vBmiter2Impl, id_obj );
208
209 Vec_IntForEachEntry( vIds_spec_obj, id, i )
210 {
211 Vec_IntPush(vIds_spec_repr, id);
212 }
213 Vec_IntForEachEntry( vIds_impl_obj, id, i )
214 {
215 Vec_IntPush(vIds_impl_repr, id);
216 }
217
218 // handle spec2impl phase
219 if ( phaseDiff )
220 {
221 Vec_IntForEachEntry( vIds_spec_obj, id, i )
222 {
223 Vec_BitSetEntry( vSpec2Impl_phase, id, !Vec_BitEntry(vSpec2Impl_phase, id) );
224 // printf( "spec id %d's phase set to %d\n", id, Vec_BitEntry(vSpec2Impl_phase, id) );
225 }
226 }
227
228 Vec_IntClear(vIds_spec_obj);
229 Vec_IntClear(vIds_impl_obj);
230
231}
233{
234
235 Vec_Ptr_t* vBmiter2Spec = pBnd -> vBmiter2Spec;
236 Vec_Ptr_t* vBmiter2Impl = pBnd -> vBmiter2Impl;
237
238 Vec_Int_t *vSpec, *vImpl;
239 int i, j, id;
240
241 pBnd -> nMerged_impl = 0;
242 pBnd -> nMerged_spec = 0;
243
244
245 for( i = 0; i < Vec_PtrSize(vBmiter2Spec); i++ )
246 {
247 vSpec = (Vec_Int_t *)Vec_PtrEntry( vBmiter2Spec, i );
248 vImpl = (Vec_Int_t *)Vec_PtrEntry( vBmiter2Impl, i );
249
250 Vec_IntForEachEntry( vSpec, id, j )
251 {
252 // vSpec2Bmiter
253 Vec_IntSetEntry( pBnd->vSpec2Bmiter, id, i );
254 }
255
256 Vec_IntForEachEntry( vImpl, id, j )
257 {
258 // vImpl2Bmiter
259 Vec_IntSetEntry( pBnd->vImpl2Bmiter, id, i );
260 }
261
262 // count number of nodes merged into the same circuit
263 if ( Vec_IntSize(vSpec) != 0 )
264 {
265 pBnd->nMerged_spec += Vec_IntSize(vSpec) - 1;
266 }
267 if ( Vec_IntSize(vImpl) != 0 )
268 {
269 pBnd->nMerged_impl += Vec_IntSize(vImpl) - 1;
270 }
271 }
272
273}
275{
276 Vec_Ptr_t* vBmiter2Spec = pBnd -> vBmiter2Spec;
277 Vec_Ptr_t* vBmiter2Impl = pBnd -> vBmiter2Impl;
278 Vec_Int_t* vIds_spec, *vIds_impl;
279 int k, id;
280 for( int j=0; j < Vec_PtrSize(vBmiter2Spec); j++ )
281 {
282 printf("node %d: ", j);
283 vIds_spec = (Vec_Int_t *)Vec_PtrEntry( vBmiter2Spec, j);
284 vIds_impl = (Vec_Int_t *)Vec_PtrEntry( vBmiter2Impl, j);
285 Vec_IntForEachEntry(vIds_spec, id, k)
286 printf("%d ", id);
287 printf("| ");
288 Vec_IntForEachEntry(vIds_impl, id, k)
289 printf("%d ", id);
290 printf("\n");
291 }
292
293}
294
296{
297
298 // printf("%d nodes merged in spec\n", pBnd ->nMerged_spec - Vec_IntSize(pBnd->vBI) - Vec_IntSize(pBnd->vBO) );
299 // printf("%d nodes merged in impl\n", pBnd ->nMerged_impl );
300 printf("BI spec:\t"); Vec_IntPrint(pBnd -> vBI);
301 printf("BO spec:\t"); Vec_IntPrint(pBnd -> vBO);
302 printf("EI spec:\t"); Vec_IntPrint(pBnd -> vEI_spec);
303 printf("EI impl:\t"); Vec_IntPrint(pBnd -> vEI_impl);
304 printf("EI phase:\t"); Vec_BitPrint(pBnd -> vEI_phase);
305 printf("EO spec:\t"); Vec_IntPrint(pBnd -> vEO_spec);
306 printf("EO impl:\t"); Vec_IntPrint(pBnd -> vEO_impl);
307 printf("EO phase:\t"); Vec_BitPrint(pBnd -> vEO_phase);
308}
309
311{
312 Bnd_Man_t* p = pBnd;
313
314
315 printf("\nSTATS\n");
316
317 int warning = 0;
318 if ( p->nChoice_spec > 0 )
319 {
320 warning = 1;
321 printf("WARNING: multiple equiv nodes on the boundary of spec\n");
322 }
323 if ( p->nChoice_impl > 0 )
324 {
325 warning = 1;
326 printf("WARNING: multiple equiv nodes on the boundary of impl\n");
327 }
328
329 printf("The outsides of spec and impl are %sEQ.\n", p->eq_out ? "" : "NOT " );
330 printf("The patched impl is %sEQ. to spec (and impl)\n", p->eq_res ? "" : "NOT " );
331
332 // #internal
333 // nBI, nBO
334 // nBI_miss, nBO_miss
335 // nEI, nEO, nExtra
336 // #spec, #impl, #patched
337 // combLoop_spec, combLoop_impl
338 // #choice_impl
339 // #choice_spec
340 // #feedthrough
341 // warning (may be neq)
342 // eq_out, eq_res
343
344 printf("\nRESULT\n");
345 printf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
346 p->nInternal,
347 p->nBI, p->nBO,
348 p->nBI_miss, p->nBO_miss,
349 Vec_IntSize(p->vEI_spec), Vec_IntSize(p->vEO_spec), p->nExtra,
350 p->nNode_spec, p->nNode_impl, p->nNode_patched,
351 p->combLoop_spec, p->combLoop_impl,
352 p->nChoice_impl,
353 p->nChoice_spec,
354 warning,
355 p->eq_out, p->eq_res
356 );
357
358 printf("#Choice Spec\t%d\n", p->nChoice_spec);
359 printf("#Choice Impl\t%d\n", p->nChoice_impl);
360
361
362
363}
364
379int Bnd_ManCheckBound( Gia_Man_t * p, int fVerbose )
380{
381 int i;
382 Gia_Obj_t *pObj;
383 int valid = 1;
384 int nBI = 0, nBO = 0, nInternal = 0;
385
386 if ( fVerbose ) printf( "Checking boundary... \n");
387
388 Vec_Int_t *vPath;
389 vPath = Vec_IntAlloc( Gia_ManObjNum(p) );
390 Vec_IntFill( vPath, Gia_ManObjNum(p), 0 );
391 int path;
392
393 Gia_ManForEachObjReverse1( p , pObj, i )
394 {
395 if ( Gia_ObjIsCo( pObj ) )
396 {
397 Vec_IntSetEntry( vPath, Gia_ObjId( p, pObj ), 1 );
398 }
399
400 path = Vec_IntEntry( vPath, Gia_ObjId(p, pObj) );
401 // printf("path = %d\n", path);
402
403 if ( path >= 8 )
404 {
405 valid = 0;
406 printf("there're more than 2 bufs in a path\n");
407 break;
408 }
409
410
411 if( Gia_ObjIsBuf( pObj ) )
412 {
413 Vec_IntSetEntry( vPath, Gia_ObjId( p, Gia_ObjFanin0( pObj ) ), Vec_IntEntry( vPath, Gia_ObjId(p, Gia_ObjFanin0( pObj ) ) ) | path << 1 );
414 if ( path == 1 ) // boundary input
415 {
416 // TODO: record BIs here since they may not be in the first n buffers
417 nBO ++;
418 }
419 }
420 else if ( Gia_ObjFaninNum( p, pObj ) >= 1 )
421 {
422 Vec_IntSetEntry( vPath, Gia_ObjId( p, Gia_ObjFanin0( pObj ) ), Vec_IntEntry( vPath, Gia_ObjId(p, Gia_ObjFanin0( pObj ) ) ) | path );
423 if ( Gia_ObjFaninNum( p, pObj ) >= 2 )
424 {
425 assert( Gia_ObjFaninNum( p, pObj ) <= 2 );
426 Vec_IntSetEntry( vPath, Gia_ObjId( p, Gia_ObjFanin1( pObj ) ), Vec_IntEntry( vPath, Gia_ObjId(p, Gia_ObjFanin1( pObj ) ) ) | path );
427 }
428 if ( path == 2 ) // inside boundary
429 {
430 // TODO: record BIs here since they may not be in the first n buffers
431 nInternal ++;
432 }
433 }
434 else // PI or const, check validity
435 {
436 if ( (Vec_IntEntry( vPath, Gia_ObjId(p, pObj) ) | 5) != 5 )
437 {
438 valid = 0;
439 printf("incorrect buf number at pi %d\n", Vec_IntEntry(vPath, Gia_ObjId(p, pObj)) );
440 break;
441 }
442 }
443 }
444
445 nBI = Gia_ManBufNum(p) - nBO;
446
447 if ( !valid )
448 {
449 printf("invalid boundary\n");
450 return 0;
451 }
452 else if ( nBI == 0 )
453 {
454 printf("no boundary\n");
455 return 0;
456 }
457 else
458 {
459 if ( fVerbose )
460 {
461 printf("valid boundary (");
462 printf("#BI = %d\t#BO = %d\t", nBI, Gia_ManBufNum(p)- nBI);
463 printf("#Internal = %d)\n", nInternal );
464 }
465 if ( pBnd )
466 {
467 pBnd -> nBI = nBI;
468 pBnd -> nBO = nBO;
469 pBnd -> nInternal = nInternal;
470 }
471 return nBI;
472 }
473}
474
475
477{
478 int id = Gia_ObjId(p, pObj);
479 if ( Vec_IntEntry(vFlag, id) == 1 ) return 1;
480 if ( Vec_IntEntry(vFlag, id) == 2 ) return 0;
481
482 Vec_IntSetEntry(vFlag, id, 1);
483
484 int ret = 1;
485 for( int i = 0; i < Gia_ObjFaninNum(p, pObj); i++ )
486 {
487 if ( !Bnd_CheckFlagRec( p, Gia_ObjFanin(pObj, i), vFlag ) )
488 {
489 ret = 0;
490 break;
491 }
492 }
493 return ret;
494
495}
496
509{
510 Vec_Int_t *vFlag = Vec_IntAlloc( Gia_ManObjNum(p) );
511 Vec_IntFill( vFlag, Gia_ManObjNum(p), 0 );
512 int success = 1;
513 int i, id;
514
515 Vec_IntForEachEntry( vEO, id, i )
516 {
517 Vec_IntSetEntry( vFlag, id, 2 );
518 }
519
520 Vec_IntForEachEntry( vEI, id, i )
521 {
522 if ( Vec_IntEntry(vFlag, id) == 2 ) continue; // BI connected to BO directly
523
524 if ( !Bnd_CheckFlagRec( p, Gia_ManObj(p, id), vFlag ) )
525 {
526 success = 0;
527 break;
528 }
529 }
530
531
532 Vec_IntFree(vFlag);
533 return success;
534}
535
536
550{
551 Vec_Int_t *vFlag;
552 Vec_Ptr_t *vQ;
553 Gia_Obj_t *pObj;
554 int i, j, id, cnt;
555
556 Vec_Int_t *vAI = Vec_IntAlloc(16);
557 Vec_Int_t *vAO = Vec_IntAlloc(16);
558
559 Vec_Bit_t *vSpec2Impl_phase = pBnd -> vSpec2Impl_phase;
560 Vec_Int_t *vBI = pBnd -> vBI;
561 Vec_Int_t *vBO = pBnd -> vBO;
562 Vec_Int_t *vEI_spec = pBnd -> vEI_spec;
563 Vec_Int_t *vEO_spec = pBnd -> vEO_spec;
564 Vec_Int_t *vEI_impl = pBnd -> vEI_impl;
565 Vec_Int_t *vEO_impl = pBnd -> vEO_impl;
566 Vec_Bit_t *vEI_phase = pBnd -> vEI_phase;
567 Vec_Bit_t *vEO_phase = pBnd -> vEO_phase;
568
569
570 // prepare to compute extended boundary
571 vQ = Vec_PtrAlloc(16);
572 vFlag = Vec_IntAlloc( Gia_ManObjNum(p) );
573 Vec_IntFill( vFlag, Gia_ManObjNum(p), 0 );
574
576
577 // save bo, bi
578 cnt = 0;
579 Gia_ManForEachBuf(p, pObj, i)
580 {
581 if ( cnt < pBnd -> nBI )
582 {
583 Vec_IntPush( vBI, Gia_ObjId(p, Gia_ObjFanin0(pObj) ) );
584 }
585 else
586 {
587 Vec_IntPush( vBO, Gia_ObjId(p, pObj) );
588 }
589 cnt++;
590 }
591
592 // compute EO, travse with flag 1
593 Vec_IntForEachEntry( vBO, id, i )
594 {
595 if ( Bnd_ManSpec2ImplNum(id) == 0 ) // BO not matched
596 {
597 Vec_PtrPush( vQ, Gia_ManObj(p, id) );
598 }
599 else
600 {
601 Vec_IntPush(vEO_spec, id);
602 }
603 }
604 if ( pBnd -> fVerbose ) printf("%d BO doesn't match. ", Vec_PtrSize(vQ) );
605 pBnd -> nBO_miss = Vec_PtrSize(vQ);
606
607 int cnt_extra = - Vec_PtrSize(vQ);
608 while( Vec_PtrSize(vQ) > 0 )
609 {
610 pObj = (Gia_Obj_t *)Vec_PtrPop(vQ);
611 id = Gia_ObjId( p, pObj );
612
613 if ( Vec_IntEntry( vFlag, id ) == 1 ) continue;
614 Vec_IntSetEntry( vFlag, id, 1 );
615
616 // printf("%d\n", id);
617
618 if ( Bnd_ManSpec2ImplNum(id) != 0 ) // matched
619 {
620 Vec_IntPush( vEO_spec, id );
621 Vec_IntPush( vAO, id );
622 }
623 else
624 {
625 for( j = 0; j < Gia_ObjFanoutNum(p, pObj); j++ )
626 {
627 Vec_PtrPush( vQ, Gia_ObjFanout(p, pObj, j) );
628 // printf("\t%d\n", Gia_ObjId( p1, Gia_ObjFanout(p1, pObj, j) ) );
629 }
630 }
631 }
632 // printf("%d AO found with %d extra nodes\n", Vec_IntSize(vAO) , cnt_extra );
633 if ( pBnd -> fVerbose ) printf("%d AO found\n", Vec_IntSize(vAO) );
634
635
636 // mark TFOC of BO with flag 1 to prevent them from being selected into EI
637 // stop at CO
638 Vec_IntForEachEntry( pBnd -> vBO, id, i )
639 {
640 Vec_PtrPush( vQ, Gia_ManObj(p, id) );
641 }
642 Vec_IntForEachEntry( vFlag, id, i )
643 {
644 Vec_IntSetEntry( vFlag, id, 0 );
645 }
646 while( Vec_PtrSize(vQ) > 0 )
647 {
648 pObj = (Gia_Obj_t *)Vec_PtrPop(vQ);
649 id = Gia_ObjId( p, pObj );
650
651 if ( Vec_IntEntry( vFlag, id ) == 1 ) continue;
652 Vec_IntSetEntry( vFlag, id, 1 );
653
654 for( j = 0; j < Gia_ObjFanoutNum(p, pObj); j++ )
655 {
656 Vec_PtrPush( vQ, Gia_ObjFanout(p, pObj, j) );
657 }
658 }
659
660
661
662 // compute EI, traverse with flag 2
663
664 // add unmatched BI to queue
665 Vec_IntForEachEntry( vBI, id, i )
666 {
667 if ( Bnd_ManSpec2ImplNum(id) == 0 ) // BO not matched
668 {
669 Vec_PtrPush( vQ, Gia_ManObj(p, id) );
670 }
671 else
672 {
673 Vec_IntPush(vEI_spec, id);
674 }
675 }
676 if ( pBnd -> fVerbose ) printf("%d BI doesn't match. ", Vec_PtrSize(vQ) );
677 pBnd -> nBI_miss = Vec_PtrSize(vQ);
678 cnt_extra -= Vec_PtrSize(vQ);
679
680 // add AO to queue
681 Vec_IntForEachEntry( vAO, id, i )
682 {
683 Vec_PtrPush( vQ, Gia_ManObj(p, id) );
684 }
685
686 // set flag 2 for BO
687 Vec_IntForEachEntry( vBO, id, i )
688 {
689 Vec_IntSetEntry( vFlag, id, 2 );
690 }
691
692 // traverse down from AI and unmatched BI
693 while( Vec_PtrSize(vQ) > 0 )
694 {
695 pObj = (Gia_Obj_t *)Vec_PtrPop(vQ);
696 id = Gia_ObjId( p, pObj );
697
698 if ( Vec_IntEntry( vFlag, id ) == 2 ) continue;
699 cnt_extra ++;
700
701 // printf("%d\n", id);
702
703 if ( Vec_IntEntry(vFlag, id) != 1 && Bnd_ManSpec2ImplNum(id) != 0 ) // matched
704 {
705 Vec_IntPush( vEI_spec, id );
706 Vec_IntPush( vAI, id );
707 }
708 else
709 {
710 for( j = 0; j < Gia_ObjFaninNum(p, pObj); j++ )
711 {
712 Vec_PtrPush( vQ, Gia_ObjFanin(pObj, j) );
713 // printf("\t%d\n", Gia_ObjId( p1, Gia_ObjFanout(p1, pObj, j) ) );
714 }
715 }
716
717 Vec_IntSetEntry( vFlag, id, 2 );
718 }
719 if ( pBnd -> fVerbose ) printf("%d AI found with %d extra nodes in total\n", Vec_IntSize(vAI) , cnt_extra );
720 pBnd -> nExtra = cnt_extra;
721
722
723 // gen vEI_impl, vEO_impl, vEI_phase, vEO_phase
724 Vec_IntForEachEntry( vEI_spec, id, i )
725 {
726 Vec_IntPush( vEI_impl, Vec_IntEntry( Bnd_ManSpec2Impl(id) , 0 ) );
727 Vec_BitPush( vEI_phase, Vec_BitEntry( vSpec2Impl_phase, id ) );
728 }
729 Vec_IntForEachEntry( vEO_spec, id, i )
730 {
731 Vec_IntPush( vEO_impl, Vec_IntEntry( Bnd_ManSpec2Impl(id), 0 ) );
732 Vec_BitPush( vEO_phase, Vec_BitEntry( vSpec2Impl_phase, id ) );
733 }
734
735
736 // count number of choice of boundary
737 Vec_IntForEachEntry( vEO_spec, id, i )
738 {
739 pBnd -> nChoice_impl += Bnd_ManSpec2ImplNum( id ) - 1;
740 }
741 Vec_IntForEachEntry( vEO_impl, id, i )
742 {
743 pBnd -> nChoice_spec += Bnd_ManImpl2SpecNum( id ) - 1;
744 }
745
746 // print
747 if ( pBnd -> fVerbose )
748 {
749 printf("#EI = %d\t#EO = %d\t#Extra Node = %d\n", Vec_IntSize(vEI_spec) , Vec_IntSize(vEO_spec), cnt_extra );
751 }
752
753 // check boundary has comb loop
754 if ( !Bnd_ManCheckExtBound( p, vEI_spec, vEO_spec ) )
755 {
756
757 printf("Combinational loop exist\n");
758 pBnd -> combLoop_spec = 1;
759
760 }
761
762
763 // clean up
764 Vec_IntFree(vAI);
765 Vec_IntFree(vAO);
766}
767
768
781{
782 Gia_Man_t * pNew, * pTemp;
783 Gia_Obj_t * pObj;
784 Vec_Int_t * vValue;
785 int i, id, lit;
786
787 // check if the boundary has loop (EO cannot be in the TFC of EI )
788 if ( !Bnd_ManCheckExtBound( p, vEI, vEO ) )
789 {
790 printf("Combinational loop exist\n");
791 pBnd -> combLoop_impl = 1;
792 return 0;
793 }
794
795 // initialize
796 pNew = Gia_ManStart( Gia_ManObjNum(p) );
797 pNew -> pName = ABC_ALLOC( char, strlen(p->pName)+10);
798 sprintf( pNew -> pName, "%s_out", p -> pName );
799 Gia_ManHashStart( pNew );
801 Gia_ManConst0(p) -> Value = 0;
802
803
804 // record the original value for eo
805 vValue = Vec_IntAlloc( Gia_ManObjNum(p) );
806 Vec_IntFill( vValue, Gia_ManObjNum(p), -1 );
807
808 // create ci for ci and eo
809 Gia_ManForEachCi( p, pObj, i )
810 {
811 pObj -> Value = Gia_ManAppendCi( pNew );
812 }
813 Vec_IntForEachEntry( vEO, id, i )
814 {
815 if( Gia_ManObj(p, id) -> Value != ~0 )
816 {
817 Vec_IntSetEntry( vValue, id, Gia_ManObj(p, id) -> Value );
818 }
819 Gia_ManObj( p, id ) -> Value = Gia_ManAppendCi(pNew);
820 if ( vEO_phase && Vec_BitEntry( vEO_phase, i ) )
821 {
822 Gia_ManObj( p, id ) -> Value ^= 1;
823 }
824 }
825
826 // add aig nodes
827 Gia_ManForEachAnd(p, pObj, i)
828 {
829 if ( pObj -> Value != ~0 ) continue;
830 pObj -> Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
831 }
832
833 // create co for co and ei
834 Gia_ManForEachCo(p, pObj, i)
835 {
836 Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
837 }
838 Vec_IntForEachEntry( vEI, id, i )
839 {
840 pObj = Gia_ManObj(p, id);
841 // lit = Gia_ManObj(p, id)->Value;
842 if ( Gia_ObjIsAnd(pObj) ) lit = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
843 else
844 {
845 assert(Gia_ObjIsCi(pObj) || Gia_ObjIsConst0(pObj));
846 if ( Vec_IntEntry(vValue, id) != -1 )
847 {
848 lit = Vec_IntEntry( vValue, id ); // EI at PI and EI merged with EO
849 }
850 else {
851 lit = pObj -> Value; // EI at PI
852 }
853 }
854 if ( vEI_phase && Vec_BitEntry( vEI_phase, i ) ) lit ^= 1;
855 Gia_ManAppendCo( pNew, lit );
856 }
857
858 // clean up
859 Vec_IntFree( vValue );
860 Gia_ManHashStop( pNew );
861 pNew = Gia_ManCleanup( pTemp = pNew );
862 Gia_ManStop( pTemp );
863 return pNew;
864
865}
866
868{
869 if ( pBnd -> fVerbose ) printf("Generating spec_out with given boundary.\n");
870 Gia_Man_t *pNew = Bnd_ManCutBoundary( p, pBnd->vEI_spec, pBnd->vEO_spec, 0, 0 );
871 return pNew;
872}
874{
875 if ( pBnd -> fVerbose ) printf("Generating impl_out with given boundary.\n");
876 Gia_Man_t *pNew = Bnd_ManCutBoundary( p, pBnd->vEI_impl, pBnd->vEO_impl, pBnd->vEI_phase, pBnd->vEO_phase );
877 if (!pNew) pBnd -> combLoop_impl = 1;
878 return pNew;
879}
880
881void Bnd_AddNodeRec( Gia_Man_t *p, Gia_Man_t *pNew, Gia_Obj_t *pObj, int fSkipStrash )
882{
883 // TODO does this mean constant zero node?
884 if ( pObj -> Value != ~0 ) return;
885
886 for( int i = 0; i < Gia_ObjFaninNum(p, pObj); i++ )
887 {
888 Bnd_AddNodeRec( p, pNew, Gia_ObjFanin(pObj, i), fSkipStrash );
889 }
890
891 if ( Gia_ObjIsAnd(pObj) )
892 {
893 if ( fSkipStrash )
894 {
895 if ( Gia_ObjIsBuf(pObj) ) pObj -> Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) );
896 else pObj -> Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
897 }
898 else
899 {
900 pObj -> Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
901 }
902 }
903 else
904 {
905 assert( Gia_ObjIsCo(pObj) );
906 // if ( Gia_ObjIsCi(pObj) ) printf("Ci with value ~0 encountered (id = %d)\n", Gia_ObjId(p, pObj) );
907 pObj -> Value = Gia_ObjFanin0Copy(pObj);
908 }
909}
910
923{
924
925 Gia_Man_t * pNew, * pTemp;
926 Gia_Obj_t * pObj;
927 int i, id, cnt;
928 Vec_Int_t *vBI_patch, *vBO_patch;
929
930 pBnd -> nNode_patch = Gia_ManAndNotBufNum( pPatch );
931
932 pNew = Gia_ManStart( Gia_ManObjNum(pOut) + Gia_ManObjNum( pSpec ) + Gia_ManObjNum(pPatch) );
933 pNew -> pName = ABC_ALLOC( char, strlen(pOut->pName)+3);
934 sprintf( pNew -> pName, "%s_p", pOut -> pName );
935 Gia_ManHashStart( pNew );
936 Gia_ManFillValue(pOut);
937 Gia_ManFillValue(pSpec);
938 Gia_ManFillValue(pPatch);
939 Gia_ManConst0(pOut)->Value = 0;
940 Gia_ManConst0(pSpec)->Value = 0;
941 Gia_ManConst0(pPatch)->Value = 0;
942
943 // get bi and bo in patch
944 cnt = 0;
945 vBI_patch = Vec_IntAlloc(16);
946 vBO_patch = Vec_IntAlloc(16);
947 Gia_ManForEachBuf( pPatch, pObj, i )
948 {
949 if ( cnt < pBnd -> nBI )
950 {
951 Vec_IntPush( vBI_patch, Gia_ObjId( pPatch, pObj ) );
952 }
953 else
954 {
955
956 Vec_IntPush( vBO_patch, Gia_ObjId( pPatch, pObj ) );
957 }
958 cnt ++;
959 }
960 assert( Vec_IntSize( vBI_patch ) == Vec_IntSize(pBnd->vBI) );
961 assert( Vec_IntSize( vBO_patch ) == Vec_IntSize(pBnd->vBO) );
962
963
964 // add Impl (real) PI
965 for ( i = 0; i < Gia_ManCiNum(pSpec); i++ )
966 {
967 pObj = Gia_ManCi(pOut, i);
968 pObj -> Value = Gia_ManAppendCi( pNew );
969 }
970
971 // add Impl EI to CI
972 // printf("adding EI to CI in Impl\n");
973 for ( i = 0; i < Vec_IntSize( pBnd -> vEI_spec ); i++ )
974 {
975 pObj = Gia_ManCo(pOut, i + Gia_ManCoNum(pSpec) );
976 Bnd_AddNodeRec( pOut, pNew, pObj, 0 );
977
978 // set Spec EI
979 Gia_ManObj( pSpec, Vec_IntEntry(pBnd -> vEI_spec, i) ) -> Value = pObj -> Value;
980 // printf(" %d",pObj -> Value);
981 }
982 // printf("\n");
983
984 // add Spec BI to EI
985 // printf("adding BI to EI in Spec\n");
986 Vec_IntForEachEntry( pBnd -> vBI, id, i )
987 {
988 pObj = Gia_ManObj( pSpec, id );
989 Bnd_AddNodeRec( pSpec, pNew, pObj, 0 );
990
991 // set patch bi
992 Gia_ManObj( pPatch, Vec_IntEntry( vBI_patch, i) ) -> Value = pObj -> Value;
993 // printf(" %d",pObj -> Value);
994 }
995 // printf("\n");
996
997 // add Patch BO to BI
998 // printf("adding BO to BI in Patch\n");
999 Vec_IntForEachEntry( vBO_patch, id, i )
1000 {
1001 pObj = Gia_ManObj( pPatch, id );
1002 Bnd_AddNodeRec( pPatch, pNew, pObj, 0 );
1003
1004 // set spec bo
1005 Gia_ManObj( pSpec, Vec_IntEntry( pBnd -> vBO, i) ) -> Value = pObj -> Value;
1006 // printf(" %d",pObj -> Value);
1007 }
1008 // printf("\n");
1009
1010 // add Spec EO to BO
1011 // printf("adding EO to BO in Spec\n");
1012 Vec_IntForEachEntry( pBnd -> vEO_spec, id, i )
1013 {
1014 pObj = Gia_ManObj( pSpec, id );
1015 Bnd_AddNodeRec( pSpec, pNew, pObj, 0 );
1016
1017 // set impl EO (PI)
1018 Gia_ManCi( pOut, i + Gia_ManCiNum(pSpec) ) -> Value = pObj -> Value;
1019 // printf(" %d",pObj -> Value);
1020 }
1021 // printf("\n");
1022
1023 // add Impl (real) PO to EO
1024 // printf("adding CO to EO in Impl\n");
1025 for ( i = 0; i < Gia_ManCoNum(pSpec); i++ )
1026 {
1027 pObj = Gia_ManCo( pOut, i );
1028 Bnd_AddNodeRec( pOut, pNew, pObj, 0 );
1029 Gia_ManAppendCo( pNew, pObj->Value );
1030 // printf(" %d",pObj -> Value);
1031 }
1032 // printf("\n");
1033
1034
1035 // clean up
1036 Vec_IntFree( vBI_patch );
1037 Vec_IntFree( vBO_patch );
1038 Gia_ManHashStop( pNew );
1039
1040 pNew = Gia_ManCleanup( pTemp = pNew );
1041 Gia_ManStop( pTemp );
1042
1043 pBnd -> nNode_patched = Gia_ManAndNum( pNew );
1044
1045 return pNew;
1046}
1047
1060{
1061
1062 Gia_Man_t * pNew, * pTemp;
1063 Gia_Obj_t * pObj;
1064 int i, id;
1065
1066 pNew = Gia_ManStart( Gia_ManObjNum(pOut) + Gia_ManObjNum( pSpec ) );
1067 pNew -> pName = ABC_ALLOC( char, strlen(pOut->pName)+3);
1068 sprintf( pNew -> pName, "%s_p", pOut -> pName );
1069
1070 Gia_ManFillValue(pOut);
1071 Gia_ManFillValue(pSpec);
1072 Gia_ManConst0(pOut)->Value = 0;
1073 Gia_ManConst0(pSpec)->Value = 0;
1074
1075
1076 // add Impl (real) PI
1077 for ( i = 0; i < Gia_ManCiNum(pSpec); i++ )
1078 {
1079 pObj = Gia_ManCi(pOut, i);
1080 pObj -> Value = Gia_ManAppendCi( pNew );
1081 }
1082
1083 // add Impl EI to CI
1084 // printf("adding EI to CI in Impl\n");
1085 for ( i = 0; i < Vec_IntSize( pBnd -> vEI_spec ); i++ )
1086 {
1087 pObj = Gia_ManCo(pOut, i + Gia_ManCoNum(pSpec) );
1088 Bnd_AddNodeRec( pOut, pNew, pObj, 1 );
1089
1090 // set Spec EI
1091 Gia_ManObj( pSpec, Vec_IntEntry(pBnd -> vEI_spec, i) ) -> Value = pObj -> Value;
1092 // printf(" %d",pObj -> Value);
1093 }
1094 // printf("\n");
1095
1096 // add Spec EO to EI
1097 // add BI -> BO -> EO to maintain the order of bufs
1098 // Vec_IntForEachEntry( pBnd -> vBI, id, i )
1099 // {
1100 // pObj = Gia_ManObj( pSpec, id );
1101 // Bnd_AddNodeRec( pSpec, pNew, pObj, 1 );
1102 // }
1103 // Vec_IntForEachEntry( pBnd -> vBO, id, i )
1104 // {
1105 // pObj = Gia_ManObj( pSpec, id );
1106 // Bnd_AddNodeRec( pSpec, pNew, pObj, 1 );
1107 // }
1108 Gia_ManForEachBuf( pSpec, pObj, i )
1109 {
1110 Bnd_AddNodeRec( pSpec, pNew, pObj, 1 );
1111 }
1112 Vec_IntForEachEntry( pBnd -> vEO_spec, id, i )
1113 {
1114 pObj = Gia_ManObj( pSpec, id );
1115 Bnd_AddNodeRec( pSpec, pNew, pObj, 1 );
1116
1117 // set impl EO (PI)
1118 Gia_ManCi( pOut, i + Gia_ManCiNum(pSpec) ) -> Value = pObj -> Value;
1119 // printf(" %d",pObj -> Value);
1120 }
1121 // printf("\n");
1122
1123 // add Impl (real) PO to EO
1124 // printf("adding CO to EO in Impl\n");
1125 for ( i = 0; i < Gia_ManCoNum(pSpec); i++ )
1126 {
1127 pObj = Gia_ManCo( pOut, i );
1128 Bnd_AddNodeRec( pOut, pNew, pObj, 1 );
1129 Gia_ManAppendCo( pNew, pObj->Value );
1130 // printf(" %d",pObj -> Value);
1131 }
1132 // printf("\n");
1133
1134
1135 // clean up
1136 pNew = Gia_ManCleanup( pTemp = pNew );
1137 Gia_ManStop( pTemp );
1138
1139 pBnd -> nNode_patched = Gia_ManAndNum( pNew );
1140
1141 return pNew;
1142}
1143
1156Gia_Man_t* Bnd_ManGenPatched2( Gia_Man_t *pImpl, Gia_Man_t *pPatch, int fSkipStrash, int fVerbose )
1157{
1158
1159 Gia_Man_t * pNew, * pTemp;
1160 Gia_Obj_t * pObj;
1161 int i, nBI, nBI_patch, cnt;
1162 Vec_Int_t* vLit;
1163
1164
1165 // check boundary first
1166 nBI = Bnd_ManCheckBound( pImpl, fVerbose );
1167 nBI_patch = Bnd_ManCheckBound( pPatch, fVerbose );
1168 if ( 0 == nBI_patch || Gia_ManBufNum(pImpl) != Gia_ManBufNum(pPatch) || nBI != nBI_patch )
1169 {
1170 Abc_Print( -1, "Abc_CommandAbc9StrEco(): The given boundary is invalid.\n" );
1171 return 0;
1172 }
1173
1174 // prepare new network
1175 pNew = Gia_ManStart( Gia_ManObjNum(pImpl) + Gia_ManObjNum( pPatch ) );
1176 pNew -> pName = ABC_ALLOC( char, strlen(pImpl->pName)+3);
1177 sprintf( pNew -> pName, "%s_p", pImpl -> pName );
1178 if ( !fSkipStrash )
1179 {
1180 Gia_ManHashAlloc( pNew );
1181 }
1182 Gia_ManFillValue(pImpl);
1183 Gia_ManFillValue(pPatch);
1184 Gia_ManConst0(pImpl)->Value = 0;
1185 Gia_ManConst0(pPatch)->Value = 0;
1186
1187 vLit = Vec_IntAlloc( Gia_ManBufNum(pImpl) );
1188
1189 // add Impl (real) CI
1190 Gia_ManForEachCi( pImpl, pObj, i )
1191 {
1192 pObj -> Value = Gia_ManAppendCi( pNew );
1193 }
1194
1195 // add Impl BI to CI
1196 cnt = 0;
1197 Gia_ManForEachBuf( pImpl, pObj, i )
1198 {
1199 Bnd_AddNodeRec( pImpl, pNew, pObj, fSkipStrash );
1200 Vec_IntPush( vLit, pObj -> Value );
1201 cnt ++;
1202 if ( cnt >= nBI ) break;
1203 }
1204
1205 // set BI in patch
1206 // add patch BO to BI
1207 cnt = 0;
1208 Gia_ManForEachBuf( pPatch, pObj, i )
1209 {
1210 if ( cnt < nBI )
1211 {
1212 pObj -> Value = Vec_IntEntry( vLit, cnt );
1213 }
1214 else
1215 {
1216 Bnd_AddNodeRec( pPatch, pNew, pObj, fSkipStrash );
1217 Vec_IntPush( vLit, pObj -> Value );
1218 }
1219 cnt ++;
1220 if ( cnt == nBI ) Vec_IntClear( vLit );
1221 }
1222
1223 // set BO in impl
1224 cnt = 0;
1225 Gia_ManForEachBuf( pImpl, pObj, i )
1226 {
1227 cnt ++;
1228 if ( cnt <= nBI) continue;
1229 pObj -> Value = Vec_IntEntry( vLit, cnt-nBI-1 );
1230 }
1231
1232 // add impl CO to BO
1233 Gia_ManForEachCo( pImpl, pObj, i )
1234 {
1235 Bnd_AddNodeRec( pImpl, pNew, pObj, fSkipStrash );
1236 Gia_ManAppendCo( pNew, pObj -> Value );
1237 }
1238
1239 // clean up
1240 if ( !fSkipStrash )
1241 {
1242 Gia_ManHashStop( pNew );
1243 }
1244 Vec_IntFree( vLit );
1245 pNew = Gia_ManCleanup( pTemp = pNew );
1246 Gia_ManStop( pTemp );
1247
1248 return pNew;
1249}
1250
1251
1253{
1254 Gia_Man_t * pNew, * pTemp;
1255 Gia_Obj_t * pObj;
1256
1257 int i, iLit;
1258 if ( Gia_ManBufNum(pSpec) == 0 ) {
1259 printf( "The spec AIG should have a boundary.\n" );
1260 return NULL;
1261 }
1262 if ( Gia_ManBufNum(pImpl) != 0 ) {
1263 printf( "The impl AIG should have no boundary.\n" );
1264 return NULL;
1265 }
1266
1267 assert( Gia_ManBufNum(pSpec) > 0 );
1268 assert( Gia_ManBufNum(pImpl) == 0 );
1269 assert( Gia_ManRegNum(pSpec) == 0 );
1270 assert( Gia_ManRegNum(pImpl) == 0 );
1271 assert( Gia_ManCiNum(pSpec) == Gia_ManCiNum(pImpl) );
1272 assert( Gia_ManCoNum(pSpec) == Gia_ManCoNum(pImpl) );
1273
1274 pNew = Gia_ManStart( Gia_ManObjNum(pSpec) + Gia_ManObjNum(pImpl) );
1275 pNew->pName = ABC_ALLOC( char, strlen(pSpec->pName) + 10 );
1276 sprintf( pNew->pName, "%s_stack", pSpec->pName );
1277
1278 Gia_ManHashStart( pNew );
1279 Gia_ManConst0(pSpec)->Value = 0;
1280 Gia_ManConst0(pImpl)->Value = 0;
1281
1282 for( int i = 0; i < Gia_ManCiNum(pSpec); i++ )
1283 {
1284 int iLit = Gia_ManCi(pSpec, i)->Value = Gia_ManCi(pImpl, i) -> Value = Gia_ManAppendCi(pNew);
1285
1286 pObj = Gia_ManCi(pSpec, i);
1287 Bnd_ManMap( iLit, Gia_ObjId( pSpec, pObj ), 1 );
1288
1289 pObj = Gia_ManCi(pImpl, i);
1290 Bnd_ManMap( iLit, Gia_ObjId( pImpl, pObj) , 0 );
1291 }
1292
1293 // record the corresponding impl node of each lit
1294 Gia_ManForEachAnd( pImpl, pObj, i )
1295 {
1296 pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1297 if ( pBnd ) Bnd_ManMap( pObj -> Value, Gia_ObjId(pImpl, pObj), 0 );
1298 }
1299
1300 Vec_Int_t* vFlag = Vec_IntAlloc( Gia_ManObjNum( pSpec ) );
1301 Vec_IntFill( vFlag, Gia_ManObjNum(pSpec), 0 );
1302 int count = 0;
1303 Gia_ManForEachBuf( pSpec, pObj, i )
1304 {
1305 if ( count < pBnd -> nBI )
1306 {
1307 // it's BI, don't record buf
1308 Vec_IntSetEntry( vFlag, Gia_ObjId( pSpec, pObj ), 1 );
1309 }
1310 else
1311 {
1312 // it's BO, don't record buf's fanin
1313 Vec_IntSetEntry( vFlag, Gia_ObjId( pSpec, Gia_ObjFanin0( pObj ) ), 1 );
1314 }
1315 count++;
1316 }
1317
1318 // record hashed equivalent nodes
1319 Gia_ManForEachAnd( pSpec, pObj, i )
1320 {
1321 pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
1322 if ( Vec_IntEntry( vFlag, Gia_ObjId( pSpec, pObj ) ) == 0 )
1323 {
1324 Bnd_ManMap( pObj -> Value, Gia_ObjId(pSpec, pObj), 1 );
1325 }
1326 }
1327 Vec_IntFree( vFlag );
1328
1329 Gia_ManForEachCo( pImpl, pObj, i )
1330 {
1331 iLit = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
1332 }
1333 Gia_ManForEachCo( pSpec, pObj, i )
1334 {
1335 iLit = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
1336 }
1337
1338 // miter
1339 // Gia_ManForEachCo( pImpl, pObj, i )
1340 // {
1341 // iLit = Gia_ManHashXor( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin0Copy(Gia_ManCo(pSpec,i)) );
1342 // Gia_ManAppendCo( pNew, iLit );
1343 // }
1344
1345
1346 Gia_ManHashStop( pNew );
1347 pNew = Gia_ManCleanup( pTemp = pNew );
1348 Gia_ManStop( pTemp );
1349 return pNew;
1350}
1351
1353{
1354 int nCO = Gia_ManCoNum(p)/2;
1355
1356 Gia_Obj_t* pObj1;
1357 Gia_Obj_t* pObj2;
1358
1359 for ( int i = 0; i < nCO; i++ )
1360 {
1361 pObj1 = Gia_ManCo(p, i);
1362 pObj2 = Gia_ManCo(p, i + nCO);
1363 if ( Gia_ObjFaninLit0p(p, pObj1) != Gia_ObjFaninLit0p(p, pObj2) ) return 0;
1364 }
1365 return 1;
1366}
1367
1368
1372
1373
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
#define ABC_FREE(obj)
Definition abc_global.h:267
#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
Cube * p
Definition exorList.c:222
void Bnd_ManStop()
Definition giaBound.c:153
void Bnd_ManPrintBound()
Definition giaBound.c:295
void Bnd_ManSetEqRes(int eq)
Definition giaBound.c:68
int Bnd_CheckFlagRec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vFlag)
Definition giaBound.c:476
Gia_Man_t * Bnd_ManGenPatched1(Gia_Man_t *pOut, Gia_Man_t *pSpec)
Definition giaBound.c:1059
Bnd_Man_t * Bnd_ManStart(Gia_Man_t *pSpec, Gia_Man_t *pImpl, int fVerbose)
Definition giaBound.c:88
int Bnd_ManCheckExtBound(Gia_Man_t *p, Vec_Int_t *vEI, Vec_Int_t *vEO)
Definition giaBound.c:508
void Bnd_ManMap(int iLit, int id, int spec)
Definition giaBound.c:178
Gia_Man_t * Bnd_ManGenImplOut(Gia_Man_t *p)
Definition giaBound.c:873
Vec_Int_t * Bnd_ManSpec2Impl(int id)
Definition giaBound.c:70
Bnd_Man_t * pBnd
DECLARATIONS ///.
Definition giaBound.c:61
void Bnd_ManMerge(int id_repr, int id_obj, int phaseDiff)
Definition giaBound.c:193
int Bnd_ManGetNExtra()
Definition giaBound.c:176
void Bnd_AddNodeRec(Gia_Man_t *p, Gia_Man_t *pNew, Gia_Obj_t *pObj, int fSkipStrash)
Definition giaBound.c:881
Gia_Man_t * Bnd_ManGenPatched(Gia_Man_t *pOut, Gia_Man_t *pSpec, Gia_Man_t *pPatch)
Definition giaBound.c:922
void Bnd_ManSetEqOut(int eq)
FUNCTION DEFINITIONS ///.
Definition giaBound.c:67
int Bnd_ManCheckCoMerged(Gia_Man_t *p)
Definition giaBound.c:1352
void Bnd_ManPrintStats()
Definition giaBound.c:310
Gia_Man_t * Bnd_ManGenPatched2(Gia_Man_t *pImpl, Gia_Man_t *pPatch, int fSkipStrash, int fVerbose)
Definition giaBound.c:1156
int Bnd_ManCheckBound(Gia_Man_t *p, int fVerbose)
Definition giaBound.c:379
Gia_Man_t * Bnd_ManCutBoundary(Gia_Man_t *p, Vec_Int_t *vEI, Vec_Int_t *vEO, Vec_Bit_t *vEI_phase, Vec_Bit_t *vEO_phase)
Definition giaBound.c:780
int Bnd_ManImpl2SpecNum(int id)
Definition giaBound.c:74
Vec_Int_t * Bnd_ManImpl2Spec(int id)
Definition giaBound.c:73
Gia_Man_t * Bnd_ManStackGias(Gia_Man_t *pSpec, Gia_Man_t *pImpl)
Definition giaBound.c:1252
void Bnd_ManFinalizeMappings()
Definition giaBound.c:232
int Bnd_ManSpec2ImplNum(int id)
Definition giaBound.c:71
void Bnd_ManPrintMappings()
Definition giaBound.c:274
Gia_Man_t * Bnd_ManGenSpecOut(Gia_Man_t *p)
Definition giaBound.c:867
void Bnd_ManFindBound(Gia_Man_t *p, Gia_Man_t *pImpl)
Definition giaBound.c:549
int Bnd_ManGetNInternal()
Definition giaBound.c:175
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
void Gia_ManStaticFanoutStart(Gia_Man_t *p)
Definition giaFanout.c:238
void Gia_ManHashStart(Gia_Man_t *p)
Definition giaHash.c:125
#define Gia_ManForEachBuf(p, pObj, i)
Definition gia.h:1210
#define Gia_ManForEachAnd(p, pObj, i)
Definition gia.h:1214
#define Gia_ManForEachObjReverse1(p, pObj, i)
Definition gia.h:1208
void Gia_ManHashAlloc(Gia_Man_t *p)
Definition giaHash.c:105
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
Definition giaMan.c:57
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
void Gia_ManFillValue(Gia_Man_t *p)
Definition giaUtil.c:369
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition giaScl.c:84
struct Bnd_Man_t_ Bnd_Man_t
Definition gia.h:1830
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition giaHash.c:576
#define Gia_ManForEachCo(p, pObj, i)
Definition gia.h:1236
#define Gia_ManForEachCi(p, pObj, i)
Definition gia.h:1228
void Gia_ManHashStop(Gia_Man_t *p)
Definition giaHash.c:149
int lit
Definition satVec.h:130
int nMerged_impl
Definition giaBound.c:24
Vec_Int_t * vEO_impl
Definition giaBound.c:55
int nMerged_spec
Definition giaBound.c:23
Vec_Bit_t * vSpec2Impl_phase
Definition giaBound.c:45
int nNode_patch
Definition giaBound.c:28
Vec_Ptr_t * vBmiter2Spec
Definition giaBound.c:43
Vec_Int_t * vEI_spec
Definition giaBound.c:52
int combLoop_impl
Definition giaBound.c:34
int nInternal
Definition giaBound.c:21
int nChoice_spec
Definition giaBound.c:37
int nChoice_impl
Definition giaBound.c:38
int nNode_patched
Definition giaBound.c:29
int nNode_spec
Definition giaBound.c:26
int eq_res
Definition giaBound.c:36
Vec_Bit_t * vEI_phase
Definition giaBound.c:56
int nExtra
Definition giaBound.c:22
int nNode_impl
Definition giaBound.c:27
Vec_Int_t * vBI
Definition giaBound.c:50
Vec_Int_t * vEO_spec
Definition giaBound.c:53
Vec_Ptr_t * vBmiter2Impl
Definition giaBound.c:44
int nBO_miss
Definition giaBound.c:20
int maxNumClass
Definition giaBound.c:41
Vec_Int_t * vBO
Definition giaBound.c:51
Vec_Int_t * vEI_impl
Definition giaBound.c:54
int eq_out
Definition giaBound.c:35
Vec_Int_t * vSpec2Bmiter
Definition giaBound.c:48
int feedthrough
Definition giaBound.c:39
int nBI_miss
Definition giaBound.c:19
int combLoop_spec
Definition giaBound.c:33
Vec_Int_t * vImpl2Bmiter
Definition giaBound.c:47
Vec_Bit_t * vEO_phase
Definition giaBound.c:57
int fVerbose
Definition giaBound.c:31
char * pName
Definition gia.h:99
unsigned Value
Definition gia.h:89
#define assert(ex)
Definition util_old.h:213
int strlen()
char * sprintf()
typedefABC_NAMESPACE_HEADER_START struct Vec_Bit_t_ Vec_Bit_t
INCLUDES ///.
Definition vecBit.h:42
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42