ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
saigStrSim.c
Go to the documentation of this file.
1
20
21#include "saig.h"
22#include "proof/ssw/ssw.h"
23
25
26
30
31#define SAIG_WORDS 16
32
33static inline Aig_Obj_t * Saig_ObjNext( Aig_Obj_t ** ppNexts, Aig_Obj_t * pObj ) { return ppNexts[pObj->Id]; }
34static inline void Saig_ObjSetNext( Aig_Obj_t ** ppNexts, Aig_Obj_t * pObj, Aig_Obj_t * pNext ) { ppNexts[pObj->Id] = pNext; }
35
39
51unsigned Saig_StrSimHash( Aig_Obj_t * pObj )
52{
53 static int s_SPrimes[128] = {
54 1009, 1049, 1093, 1151, 1201, 1249, 1297, 1361, 1427, 1459,
55 1499, 1559, 1607, 1657, 1709, 1759, 1823, 1877, 1933, 1997,
56 2039, 2089, 2141, 2213, 2269, 2311, 2371, 2411, 2467, 2543,
57 2609, 2663, 2699, 2741, 2797, 2851, 2909, 2969, 3037, 3089,
58 3169, 3221, 3299, 3331, 3389, 3461, 3517, 3557, 3613, 3671,
59 3719, 3779, 3847, 3907, 3943, 4013, 4073, 4129, 4201, 4243,
60 4289, 4363, 4441, 4493, 4549, 4621, 4663, 4729, 4793, 4871,
61 4933, 4973, 5021, 5087, 5153, 5227, 5281, 5351, 5417, 5471,
62 5519, 5573, 5651, 5693, 5749, 5821, 5861, 5923, 6011, 6073,
63 6131, 6199, 6257, 6301, 6353, 6397, 6481, 6563, 6619, 6689,
64 6737, 6803, 6863, 6917, 6977, 7027, 7109, 7187, 7237, 7309,
65 7393, 7477, 7523, 7561, 7607, 7681, 7727, 7817, 7877, 7933,
66 8011, 8039, 8059, 8081, 8093, 8111, 8123, 8147
67 };
68 unsigned * pSims;
69 unsigned uHash = 0;
70 int i;
71 assert( SAIG_WORDS <= 128 );
72 pSims = (unsigned *)pObj->pData;
73 for ( i = 0; i < SAIG_WORDS; i++ )
74 uHash ^= pSims[i] * s_SPrimes[i & 0x7F];
75 return uHash;
76}
77
89int Saig_StrSimIsEqual( Aig_Obj_t * pObj0, Aig_Obj_t * pObj1 )
90{
91 unsigned * pSims0 = (unsigned *)pObj0->pData;
92 unsigned * pSims1 = (unsigned *)pObj1->pData;
93 int i;
94 for ( i = 0; i < SAIG_WORDS; i++ )
95 if ( pSims0[i] != pSims1[i] )
96 return 0;
97 return 1;
98}
99
112{
113 unsigned * pSims = (unsigned *)pObj->pData;
114 int i;
115 for ( i = 0; i < SAIG_WORDS; i++ )
116 if ( pSims[i] != 0 )
117 return 0;
118 return 1;
119}
120
133{
134 unsigned * pSims = (unsigned *)pObj->pData;
135 int i;
136 for ( i = 0; i < SAIG_WORDS; i++ )
137 if ( pSims[i] != ~0 )
138 return 0;
139 return 1;
140}
141
154{
155 unsigned * pSims = (unsigned *)pObj->pData;
156 int i;
157 for ( i = 0; i < SAIG_WORDS; i++ )
158 pSims[i] = Aig_ManRandom(0);
159}
160
173{
174 unsigned * pSims = (unsigned *)pObj->pData;
175 int i;
176 for ( i = 0; i < SAIG_WORDS; i++ )
177 pSims[i] = ~0;
178}
179
192{
193 unsigned * pSims = (unsigned *)pObj->pData;
194 pSims[0] = 0;
195}
196
208void Saig_StrSimulateNode( Aig_Obj_t * pObj, int i )
209{
210 unsigned * pSims = (unsigned *)pObj->pData;
211 unsigned * pSims0 = (unsigned *)Aig_ObjFanin0(pObj)->pData;
212 unsigned * pSims1 = (unsigned *)Aig_ObjFanin1(pObj)->pData;
213 if ( Aig_ObjFaninC0(pObj) && Aig_ObjFaninC1(pObj) )
214 pSims[i] = ~(pSims0[i] | pSims1[i]);
215 else if ( Aig_ObjFaninC0(pObj) && !Aig_ObjFaninC1(pObj) )
216 pSims[i] = (~pSims0[i] & pSims1[i]);
217 else if ( !Aig_ObjFaninC0(pObj) && Aig_ObjFaninC1(pObj) )
218 pSims[i] = (pSims0[i] & ~pSims1[i]);
219 else // if ( !Aig_ObjFaninC0(pObj) && !Aig_ObjFaninC1(pObj) )
220 pSims[i] = (pSims0[i] & pSims1[i]);
221}
222
234void Saig_StrSimSaveOutput( Aig_Obj_t * pObj, int i )
235{
236 unsigned * pSims = (unsigned *)pObj->pData;
237 unsigned * pSims0 = (unsigned *)Aig_ObjFanin0(pObj)->pData;
238 if ( Aig_ObjFaninC0(pObj) )
239 pSims[i] = ~pSims0[i];
240 else
241 pSims[i] = pSims0[i];
242}
243
256{
257 unsigned * pSims0 = (unsigned *)pObj0->pData;
258 unsigned * pSims1 = (unsigned *)pObj1->pData;
259 int i;
260 for ( i = 0; i < SAIG_WORDS; i++ )
261 pSims1[i] = pSims0[i];
262}
263
275void Saig_StrSimTransferNext( Aig_Obj_t * pObj0, Aig_Obj_t * pObj1, int i )
276{
277 unsigned * pSims0 = (unsigned *)pObj0->pData;
278 unsigned * pSims1 = (unsigned *)pObj1->pData;
279 assert( i < SAIG_WORDS - 1 );
280 pSims1[i+1] = pSims0[i];
281}
282
295{
296 Aig_Obj_t * pObj0, * pObj1;
297 int f, i;
298 // simulate the nodes
299 Aig_ManForEachObj( p0, pObj0, i )
300 {
301 if ( !Aig_ObjIsCi(pObj0) && !Aig_ObjIsNode(pObj0) )
302 continue;
303 pObj1 = Aig_ObjRepr(p0, pObj0);
304 if ( pObj1 == NULL )
305 continue;
306 assert( Aig_ObjRepr(p1, pObj1) == pObj0 );
308 Saig_StrSimTransfer( pObj0, pObj1 );
309 }
310 // simulate the timeframes
311 for ( f = 0; f < SAIG_WORDS; f++ )
312 {
313 // simulate the first AIG
314 Aig_ManForEachNode( p0, pObj0, i )
315 if ( Aig_ObjRepr(p0, pObj0) == NULL )
316 Saig_StrSimulateNode( pObj0, f );
317 Saig_ManForEachLi( p0, pObj0, i )
318 Saig_StrSimSaveOutput( pObj0, f );
319 if ( f < SAIG_WORDS - 1 )
320 Saig_ManForEachLiLo( p0, pObj0, pObj1, i )
321 Saig_StrSimTransferNext( pObj0, pObj1, f );
322 // simulate the second AIG
323 Aig_ManForEachNode( p1, pObj1, i )
324 if ( Aig_ObjRepr(p1, pObj1) == NULL )
325 Saig_StrSimulateNode( pObj1, f );
326 Saig_ManForEachLi( p1, pObj1, i )
327 Saig_StrSimSaveOutput( pObj1, f );
328 if ( f < SAIG_WORDS - 1 )
329 Saig_ManForEachLiLo( p1, pObj1, pObj0, i )
330 Saig_StrSimTransferNext( pObj1, pObj0, f );
331 }
332}
333
345Aig_Obj_t * Saig_StrSimTableLookup( Aig_Obj_t ** ppTable, Aig_Obj_t ** ppNexts, int nTableSize, Aig_Obj_t * pObj )
346{
347 Aig_Obj_t * pEntry;
348 int iEntry;
349 // find the hash entry
350 iEntry = Saig_StrSimHash( pObj ) % nTableSize;
351 // check if there are nodes with this signatures
352 for ( pEntry = ppTable[iEntry]; pEntry; pEntry = Saig_ObjNext(ppNexts,pEntry) )
353 if ( Saig_StrSimIsEqual( pEntry, pObj ) )
354 return pEntry;
355 return NULL;
356}
357
369void Saig_StrSimTableInsert( Aig_Obj_t ** ppTable, Aig_Obj_t ** ppNexts, int nTableSize, Aig_Obj_t * pObj )
370{
371 // find the hash entry
372 int iEntry = Saig_StrSimHash( pObj ) % nTableSize;
373 // check if there are nodes with this signatures
374 if ( ppTable[iEntry] == NULL )
375 ppTable[iEntry] = pObj;
376 else
377 {
378 Saig_ObjSetNext( ppNexts, pObj, Saig_ObjNext(ppNexts, ppTable[iEntry]) );
379 Saig_ObjSetNext( ppNexts, ppTable[iEntry], pObj );
380 }
381}
382
395{
396 Aig_Obj_t ** ppTable, ** ppNexts, ** ppCands;
397 Aig_Obj_t * pObj, * pEntry;
398 int i, nTableSize, Counter;
399
400 // allocate the hash table hashing simulation info into nodes
401 nTableSize = Abc_PrimeCudd( Aig_ManObjNum(p0)/2 );
402 ppTable = ABC_CALLOC( Aig_Obj_t *, nTableSize );
403 ppNexts = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p0) );
404 ppCands = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p0) );
405
406 // hash nodes of the first AIG
407 Aig_ManForEachObj( p0, pObj, i )
408 {
409 if ( !Aig_ObjIsCi(pObj) && !Aig_ObjIsNode(pObj) )
410 continue;
411 if ( Aig_ObjRepr(p0, pObj) )
412 continue;
413 if ( Saig_StrSimIsZero(pObj) || Saig_StrSimIsOne(pObj) )
414 continue;
415 // check if the entry exists
416 pEntry = Saig_StrSimTableLookup( ppTable, ppNexts, nTableSize, pObj );
417 if ( pEntry == NULL ) // insert
418 Saig_StrSimTableInsert( ppTable, ppNexts, nTableSize, pObj );
419 else // mark the entry as not unique
420 pEntry->fMarkA = 1;
421 }
422
423 // hash nodes from the second AIG
424 Aig_ManForEachObj( p1, pObj, i )
425 {
426 if ( !Aig_ObjIsCi(pObj) && !Aig_ObjIsNode(pObj) )
427 continue;
428 if ( Aig_ObjRepr(p1, pObj) )
429 continue;
430 if ( Saig_StrSimIsZero(pObj) || Saig_StrSimIsOne(pObj) )
431 continue;
432 // check if the entry exists
433 pEntry = Saig_StrSimTableLookup( ppTable, ppNexts, nTableSize, pObj );
434 if ( pEntry == NULL ) // skip
435 continue;
436 // if there is no candidate, label it
437 if ( Saig_ObjNext( ppCands, pEntry ) == NULL )
438 Saig_ObjSetNext( ppCands, pEntry, pObj );
439 else // mark the entry as not unique
440 pEntry->fMarkA = 1;
441 }
442
443 // create representatives for the unique entries
444 Counter = 0;
445 for ( i = 0; i < nTableSize; i++ )
446 for ( pEntry = ppTable[i]; pEntry; pEntry = Saig_ObjNext(ppNexts,pEntry) )
447 if ( !pEntry->fMarkA && (pObj = Saig_ObjNext( ppCands, pEntry )) )
448 {
449// assert( Aig_ObjIsNode(pEntry) == Aig_ObjIsNode(pObj) );
450 if ( Aig_ObjType(pEntry) != Aig_ObjType(pObj) )
451 continue;
452 Aig_ObjSetRepr( p0, pEntry, pObj );
453 Aig_ObjSetRepr( p1, pObj, pEntry );
454 Counter++;
455 }
456
457 // cleanup
458 Aig_ManCleanMarkA( p0 );
459 ABC_FREE( ppTable );
460 ABC_FREE( ppNexts );
461 ABC_FREE( ppCands );
462 return Counter;
463}
464
477{
478 Aig_Obj_t * pObj;
479 int i, Counter = 0;
480 Saig_ManForEachLo( p, pObj, i )
481 if ( Aig_ObjRepr(p, pObj) )
482 Counter++;
483 return Counter;
484}
485
498{
499 Aig_Obj_t * pObj;
500 int i, Counter = 0;
501 Aig_ManForEachNode( p, pObj, i )
502 if ( Aig_ObjRepr(p, pObj) )
503 Counter++;
504 return Counter;
505}
506
519{
520 Aig_Obj_t * pObj;
521 int i;
522 Aig_ManReprStart( p, Aig_ManObjNumMax(p) );
523 // allocate simulation info
524 p->pData2 = Vec_PtrAllocSimInfo( Aig_ManObjNumMax(p), SAIG_WORDS );
525 Aig_ManForEachObj( p, pObj, i )
526 pObj->pData = Vec_PtrEntry( (Vec_Ptr_t *)p->pData2, i );
527 // set simulation info for constant1 and register outputs
528 Saig_StrSimAssignOne( Aig_ManConst1(p) );
529 Saig_ManForEachLo( p, pObj, i )
531}
532
545{
546 Aig_Obj_t * pObj0, * pObj1;
547 int i;
548 pObj0 = Aig_ManConst1( p0 );
549 pObj1 = Aig_ManConst1( p1 );
550 Aig_ObjSetRepr( p0, pObj0, pObj1 );
551 Aig_ObjSetRepr( p1, pObj1, pObj0 );
552 Saig_ManForEachPi( p0, pObj0, i )
553 {
554 pObj1 = Aig_ManCi( p1, i );
555 Aig_ObjSetRepr( p0, pObj0, pObj1 );
556 Aig_ObjSetRepr( p1, pObj1, pObj0 );
557 }
558}
559
572{
573 Aig_Obj_t * pObj0, * pObj1;
574 Aig_Obj_t * pFanin00, * pFanin01;
575 Aig_Obj_t * pFanin10, * pFanin11;
576 int i, CountAll = 0, CountNot = 0;
578 Aig_ManForEachObj( p0, pObj0, i )
579 {
580 pObj1 = Aig_ObjRepr( p0, pObj0 );
581 if ( pObj1 == NULL )
582 continue;
583 CountAll++;
584 assert( pObj0 == Aig_ObjRepr( p1, pObj1 ) );
585 if ( Aig_ObjIsNode(pObj0) )
586 {
587 assert( Aig_ObjIsNode(pObj1) );
588 pFanin00 = Aig_ObjFanin0(pObj0);
589 pFanin01 = Aig_ObjFanin1(pObj0);
590 pFanin10 = Aig_ObjFanin0(pObj1);
591 pFanin11 = Aig_ObjFanin1(pObj1);
592 if ( Aig_ObjRepr(p0, pFanin00) != pFanin10 ||
593 Aig_ObjRepr(p0, pFanin01) != pFanin11 )
594 {
595 Aig_ObjSetTravIdCurrent(p0, pObj0);
596 CountNot++;
597 }
598 }
599 else if ( Saig_ObjIsLo(p0, pObj0) )
600 {
601 assert( Saig_ObjIsLo(p1, pObj1) );
602 pFanin00 = Aig_ObjFanin0( Saig_ObjLoToLi(p0, pObj0) );
603 pFanin10 = Aig_ObjFanin0( Saig_ObjLoToLi(p1, pObj1) );
604 if ( Aig_ObjRepr(p0, pFanin00) != pFanin10 )
605 {
606 Aig_ObjSetTravIdCurrent(p0, pObj0);
607 CountNot++;
608 }
609 }
610 }
611 // remove irrelevant matches
612 Aig_ManForEachObj( p0, pObj0, i )
613 {
614 pObj1 = Aig_ObjRepr( p0, pObj0 );
615 if ( pObj1 == NULL )
616 continue;
617 assert( pObj0 == Aig_ObjRepr( p1, pObj1 ) );
618 if ( Aig_ObjIsTravIdCurrent( p0, pObj0 ) )
619 {
620 Aig_ObjSetRepr( p0, pObj0, NULL );
621 Aig_ObjSetRepr( p1, pObj1, NULL );
622 }
623 }
624 Abc_Print( 1, "Total matches = %6d. Wrong matches = %6d. Ratio = %5.2f %%\n",
625 CountAll, CountNot, 100.0*CountNot/CountAll );
626}
627
640{
641 Aig_Obj_t * pFanout;
642 int i, iFanout = -1;
643 if ( Aig_ObjIsTravIdCurrent(p, pObj) )
644 return;
645 Aig_ObjSetTravIdCurrent(p, pObj);
646 if ( Saig_ObjIsPo( p, pObj ) )
647 return;
648 if ( Saig_ObjIsLi( p, pObj ) )
649 {
650 Saig_StrSimSetContiguousMatching_rec( p, Saig_ObjLiToLo(p, pObj) );
651 return;
652 }
653 assert( Aig_ObjIsCi(pObj) || Aig_ObjIsNode(pObj) );
654 if ( Aig_ObjRepr(p, pObj) == NULL )
655 return;
656 // go through the fanouts
657 Aig_ObjForEachFanout( p, pObj, pFanout, iFanout, i )
659 // go through the fanins
660 if ( !Aig_ObjIsCi( pObj ) )
661 {
662 Saig_StrSimSetContiguousMatching_rec( p, Aig_ObjFanin0(pObj) );
663 Saig_StrSimSetContiguousMatching_rec( p, Aig_ObjFanin1(pObj) );
664 }
665}
666
679{
680 Aig_Obj_t * pObj0, * pObj1;
681 int i, CountAll = 0, CountNot = 0;
682 // mark nodes reachable through the PIs
684 Aig_ObjSetTravIdCurrent( p0, Aig_ManConst1(p0) );
685 Saig_ManForEachPi( p0, pObj0, i )
687 // remove irrelevant matches
688 Aig_ManForEachObj( p0, pObj0, i )
689 {
690 pObj1 = Aig_ObjRepr( p0, pObj0 );
691 if ( pObj1 == NULL )
692 continue;
693 CountAll++;
694 assert( pObj0 == Aig_ObjRepr( p1, pObj1 ) );
695 if ( !Aig_ObjIsTravIdCurrent( p0, pObj0 ) )
696 {
697 Aig_ObjSetRepr( p0, pObj0, NULL );
698 Aig_ObjSetRepr( p1, pObj1, NULL );
699 CountNot++;
700 }
701 }
702 Abc_Print( 1, "Total matches = %6d. Wrong matches = %6d. Ratio = %5.2f %%\n",
703 CountAll, CountNot, 100.0*CountNot/CountAll );
704}
705
706
707
720{
721 Aig_Obj_t * pNext, * pObj;
722 int i, k, iFan = -1;
723 Vec_PtrClear( vNodes );
725 Aig_ManForEachObj( p, pObj, i )
726 {
727 if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsCi(pObj) )
728 continue;
729 if ( Aig_ObjRepr( p, pObj ) != NULL )
730 continue;
731 if ( Saig_ObjIsLo(p, pObj) )
732 {
733 pNext = Saig_ObjLoToLi(p, pObj);
734 pNext = Aig_ObjFanin0(pNext);
735 if ( Aig_ObjRepr( p, pNext ) && !Aig_ObjIsTravIdCurrent(p, pNext) && !Aig_ObjIsConst1(pNext) )
736 {
737 Aig_ObjSetTravIdCurrent(p, pNext);
738 Vec_PtrPush( vNodes, pNext );
739 }
740 }
741 if ( Aig_ObjIsNode(pObj) )
742 {
743 pNext = Aig_ObjFanin0(pObj);
744 if ( Aig_ObjRepr( p, pNext )&& !Aig_ObjIsTravIdCurrent(p, pNext) )
745 {
746 Aig_ObjSetTravIdCurrent(p, pNext);
747 Vec_PtrPush( vNodes, pNext );
748 }
749 pNext = Aig_ObjFanin1(pObj);
750 if ( Aig_ObjRepr( p, pNext ) && !Aig_ObjIsTravIdCurrent(p, pNext) )
751 {
752 Aig_ObjSetTravIdCurrent(p, pNext);
753 Vec_PtrPush( vNodes, pNext );
754 }
755 }
756 Aig_ObjForEachFanout( p, pObj, pNext, iFan, k )
757 {
758 if ( Saig_ObjIsPo(p, pNext) )
759 continue;
760 if ( Saig_ObjIsLi(p, pNext) )
761 pNext = Saig_ObjLiToLo(p, pNext);
762 if ( Aig_ObjRepr( p, pNext ) && !Aig_ObjIsTravIdCurrent(p, pNext) )
763 {
764 Aig_ObjSetTravIdCurrent(p, pNext);
765 Vec_PtrPush( vNodes, pNext );
766 }
767 }
768 }
769}
770
783{
784 Aig_Obj_t * pObj;
785 int i, Counter = 0;
786 Aig_ManForEachObj( p, pObj, i )
787 {
788 if ( !Aig_ObjIsNode(pObj) && !Aig_ObjIsCi(pObj) )
789 continue;
790 if ( Aig_ObjRepr( p, pObj ) != NULL )
791 continue;
792 Counter++;
793 }
794 return Counter;
795}
796
808void Ssw_StrSimMatchingExtend( Aig_Man_t * p0, Aig_Man_t * p1, int nDist, int fVerbose )
809{
810 Vec_Ptr_t * vNodes0, * vNodes1;
811 Aig_Obj_t * pNext0, * pNext1;
812 int d, k;
813 vNodes0 = Vec_PtrAlloc( 1000 );
814 vNodes1 = Vec_PtrAlloc( 1000 );
815 if ( fVerbose )
816 {
817 int nUnmached = Ssw_StrSimMatchingCountUnmached(p0);
818 Abc_Print( 1, "Extending islands by %d steps:\n", nDist );
819 Abc_Print( 1, "%2d : Total = %6d. Unmatched = %6d. Ratio = %6.2f %%\n",
820 0, Aig_ManCiNum(p0) + Aig_ManNodeNum(p0),
821 nUnmached, 100.0 * nUnmached/(Aig_ManCiNum(p0) + Aig_ManNodeNum(p0)) );
822 }
823 for ( d = 0; d < nDist; d++ )
824 {
825 Ssw_StrSimMatchingExtendOne( p0, vNodes0 );
826 Ssw_StrSimMatchingExtendOne( p1, vNodes1 );
827 Vec_PtrForEachEntry( Aig_Obj_t *, vNodes0, pNext0, k )
828 {
829 pNext1 = Aig_ObjRepr( p0, pNext0 );
830 if ( pNext1 == NULL )
831 continue;
832 assert( pNext0 == Aig_ObjRepr( p1, pNext1 ) );
833 if ( Saig_ObjIsPi(p1, pNext1) )
834 continue;
835 Aig_ObjSetRepr( p0, pNext0, NULL );
836 Aig_ObjSetRepr( p1, pNext1, NULL );
837 }
838 Vec_PtrForEachEntry( Aig_Obj_t *, vNodes1, pNext1, k )
839 {
840 pNext0 = Aig_ObjRepr( p1, pNext1 );
841 if ( pNext0 == NULL )
842 continue;
843 assert( pNext1 == Aig_ObjRepr( p0, pNext0 ) );
844 if ( Saig_ObjIsPi(p0, pNext0) )
845 continue;
846 Aig_ObjSetRepr( p0, pNext0, NULL );
847 Aig_ObjSetRepr( p1, pNext1, NULL );
848 }
849 if ( fVerbose )
850 {
851 int nUnmached = Ssw_StrSimMatchingCountUnmached(p0);
852 Abc_Print( 1, "%2d : Total = %6d. Unmatched = %6d. Ratio = %6.2f %%\n",
853 d+1, Aig_ManCiNum(p0) + Aig_ManNodeNum(p0),
854 nUnmached, 100.0 * nUnmached/(Aig_ManCiNum(p0) + Aig_ManNodeNum(p0)) );
855 }
856 }
857 Vec_PtrFree( vNodes0 );
858 Vec_PtrFree( vNodes1 );
859}
860
861
873Vec_Int_t * Saig_StrSimPerformMatching( Aig_Man_t * p0, Aig_Man_t * p1, int nDist, int fVerbose, Aig_Man_t ** ppMiter )
874{
876
877 Vec_Int_t * vPairs;
878 Aig_Man_t * pPart0, * pPart1;
879 Aig_Obj_t * pObj0, * pObj1;
880 int i, nMatches;
881 abctime clk, clkTotal = Abc_Clock();
882 Aig_ManRandom( 1 );
883 // consider the case when a miter is given
884 if ( p1 == NULL )
885 {
886 if ( fVerbose )
887 {
888 Aig_ManPrintStats( p0 );
889 }
890 // demiter the miter
891 if ( !Saig_ManDemiterSimpleDiff( p0, &pPart0, &pPart1 ) )
892 {
893 Abc_Print( 1, "Demitering has failed.\n" );
894 return NULL;
895 }
896 }
897 else
898 {
899 pPart0 = Aig_ManDupSimple( p0 );
900 pPart1 = Aig_ManDupSimple( p1 );
901 }
902 if ( fVerbose )
903 {
904 Aig_ManPrintStats( pPart0 );
905 Aig_ManPrintStats( pPart1 );
906 }
907 // start simulation
908 Saig_StrSimPrepareAig( pPart0 );
909 Saig_StrSimPrepareAig( pPart1 );
910 Saig_StrSimSetInitMatching( pPart0, pPart1 );
911 if ( fVerbose )
912 {
913 Abc_Print( 1, "Allocated %6.2f MB to simulate the first AIG.\n",
914 1.0 * Aig_ManObjNumMax(pPart0) * SAIG_WORDS * sizeof(unsigned) / (1<<20) );
915 Abc_Print( 1, "Allocated %6.2f MB to simulate the second AIG.\n",
916 1.0 * Aig_ManObjNumMax(pPart1) * SAIG_WORDS * sizeof(unsigned) / (1<<20) );
917 }
918 // iterate matching
919 nMatches = 1;
920 for ( i = 0; nMatches > 0; i++ )
921 {
922 clk = Abc_Clock();
923 Saig_StrSimulateRound( pPart0, pPart1 );
924 nMatches = Saig_StrSimDetectUnique( pPart0, pPart1 );
925 if ( fVerbose )
926 {
927 int nFlops = Saig_StrSimCountMatchedFlops(pPart0);
928 int nNodes = Saig_StrSimCountMatchedNodes(pPart0);
929 Abc_Print( 1, "%3d : Match =%6d. FF =%6d. (%6.2f %%) Node =%6d. (%6.2f %%) ",
930 i, nMatches,
931 nFlops, 100.0*nFlops/Aig_ManRegNum(pPart0),
932 nNodes, 100.0*nNodes/Aig_ManNodeNum(pPart0) );
933 ABC_PRT( "Time", Abc_Clock() - clk );
934 }
935 if ( i == 20 )
936 break;
937 }
938 // cleanup
939 Vec_PtrFree( (Vec_Ptr_t *)pPart0->pData2 ); pPart0->pData2 = NULL;
940 Vec_PtrFree( (Vec_Ptr_t *)pPart1->pData2 ); pPart1->pData2 = NULL;
941 // extend the islands
942 Aig_ManFanoutStart( pPart0 );
943 Aig_ManFanoutStart( pPart1 );
944 if ( nDist )
945 Ssw_StrSimMatchingExtend( pPart0, pPart1, nDist, fVerbose );
946 Saig_StrSimSetFinalMatching( pPart0, pPart1 );
947// Saig_StrSimSetContiguousMatching( pPart0, pPart1 );
948 // copy the results into array
949 vPairs = Vec_IntAlloc( 2*Aig_ManObjNumMax(pPart0) );
950 Aig_ManForEachObj( pPart0, pObj0, i )
951 {
952 pObj1 = Aig_ObjRepr(pPart0, pObj0);
953 if ( pObj1 == NULL )
954 continue;
955 assert( pObj0 == Aig_ObjRepr(pPart1, pObj1) );
956 Vec_IntPush( vPairs, pObj0->Id );
957 Vec_IntPush( vPairs, pObj1->Id );
958 }
959 // this procedure adds matching of PO and LI
960 if ( ppMiter )
961 *ppMiter = Saig_ManWindowExtractMiter( pPart0, pPart1 );
962 Aig_ManFanoutStop( pPart0 );
963 Aig_ManFanoutStop( pPart1 );
964 Aig_ManStop( pPart0 );
965 Aig_ManStop( pPart1 );
966 ABC_PRT( "Total runtime", Abc_Clock() - clkTotal );
967 return vPairs;
968}
969
970
974
975
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
#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
void Aig_ManFanoutStart(Aig_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition aigFanout.c:56
Aig_Man_t * Aig_ManDupSimple(Aig_Man_t *p)
DECLARATIONS ///.
Definition aigDup.c:46
void Aig_ManReprStart(Aig_Man_t *p, int nIdMax)
DECLARATIONS ///.
Definition aigRepr.c:45
void Aig_ManCleanMarkA(Aig_Man_t *p)
Definition aigUtil.c:148
void Aig_ManFanoutStop(Aig_Man_t *p)
Definition aigFanout.c:89
#define Aig_ManForEachObj(p, pObj, i)
Definition aig.h:403
void Aig_ManStop(Aig_Man_t *p)
Definition aigMan.c:187
#define Aig_ObjForEachFanout(p, pObj, pFanout, iFan, i)
Definition aig.h:427
void Aig_ManIncrementTravId(Aig_Man_t *p)
DECLARATIONS ///.
Definition aigUtil.c:44
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
void Aig_ManPrintStats(Aig_Man_t *p)
Definition aigMan.c:379
#define Aig_ManForEachNode(p, pObj, i)
Definition aig.h:413
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
unsigned Aig_ManRandom(int fReset)
Definition aigUtil.c:1170
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Cube * p
Definition exorList.c:222
void Ssw_StrSimMatchingExtend(Aig_Man_t *p0, Aig_Man_t *p1, int nDist, int fVerbose)
Definition saigStrSim.c:808
void Saig_StrSimSetContiguousMatching_rec(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition saigStrSim.c:639
void Saig_StrSimulateNode(Aig_Obj_t *pObj, int i)
Definition saigStrSim.c:208
void Saig_StrSimPrepareAig(Aig_Man_t *p)
Definition saigStrSim.c:518
void Saig_StrSimAssignOne(Aig_Obj_t *pObj)
Definition saigStrSim.c:172
Vec_Int_t * Saig_StrSimPerformMatching(Aig_Man_t *p0, Aig_Man_t *p1, int nDist, int fVerbose, Aig_Man_t **ppMiter)
Definition saigStrSim.c:873
void Saig_StrSimTableInsert(Aig_Obj_t **ppTable, Aig_Obj_t **ppNexts, int nTableSize, Aig_Obj_t *pObj)
Definition saigStrSim.c:369
void Saig_StrSimTransfer(Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
Definition saigStrSim.c:255
#define SAIG_WORDS
DECLARATIONS ///.
Definition saigStrSim.c:31
void Saig_StrSimulateRound(Aig_Man_t *p0, Aig_Man_t *p1)
Definition saigStrSim.c:294
void Saig_StrSimTransferNext(Aig_Obj_t *pObj0, Aig_Obj_t *pObj1, int i)
Definition saigStrSim.c:275
void Saig_StrSimSetContiguousMatching(Aig_Man_t *p0, Aig_Man_t *p1)
Definition saigStrSim.c:678
int Saig_StrSimIsOne(Aig_Obj_t *pObj)
Definition saigStrSim.c:132
unsigned Saig_StrSimHash(Aig_Obj_t *pObj)
FUNCTION DEFINITIONS ///.
Definition saigStrSim.c:51
int Saig_StrSimDetectUnique(Aig_Man_t *p0, Aig_Man_t *p1)
Definition saigStrSim.c:394
void Saig_StrSimAssignRandom(Aig_Obj_t *pObj)
Definition saigStrSim.c:153
void Saig_StrSimSetInitMatching(Aig_Man_t *p0, Aig_Man_t *p1)
Definition saigStrSim.c:544
void Ssw_StrSimMatchingExtendOne(Aig_Man_t *p, Vec_Ptr_t *vNodes)
Definition saigStrSim.c:719
void Saig_StrSimSaveOutput(Aig_Obj_t *pObj, int i)
Definition saigStrSim.c:234
void Saig_StrSimAssignZeroInit(Aig_Obj_t *pObj)
Definition saigStrSim.c:191
Aig_Obj_t * Saig_StrSimTableLookup(Aig_Obj_t **ppTable, Aig_Obj_t **ppNexts, int nTableSize, Aig_Obj_t *pObj)
Definition saigStrSim.c:345
int Ssw_StrSimMatchingCountUnmached(Aig_Man_t *p)
Definition saigStrSim.c:782
int Saig_StrSimCountMatchedNodes(Aig_Man_t *p)
Definition saigStrSim.c:497
int Saig_StrSimIsZero(Aig_Obj_t *pObj)
Definition saigStrSim.c:111
void Saig_StrSimSetFinalMatching(Aig_Man_t *p0, Aig_Man_t *p1)
Definition saigStrSim.c:571
int Saig_StrSimIsEqual(Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
Definition saigStrSim.c:89
int Saig_StrSimCountMatchedFlops(Aig_Man_t *p)
Definition saigStrSim.c:476
Aig_Man_t * Saig_ManWindowExtractMiter(Aig_Man_t *p0, Aig_Man_t *p1)
Definition saigWnd.c:716
#define Saig_ManForEachLiLo(p, pObjLi, pObjLo, i)
Definition saig.h:101
#define Saig_ManForEachLi(p, pObj, i)
Definition saig.h:98
int Saig_ManDemiterSimpleDiff(Aig_Man_t *p, Aig_Man_t **ppAig0, Aig_Man_t **ppAig1)
Definition saigMiter.c:660
#define Saig_ManForEachLo(p, pObj, i)
Definition saig.h:96
#define Saig_ManForEachPi(p, pObj, i)
Definition saig.h:91
int Id
Definition aig.h:85
unsigned int fMarkA
Definition aig.h:79
void * pData
Definition aig.h:87
#define assert(ex)
Definition util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55