52 for(i = 0; i < Abc_NtkPoNum(pNtk); i++) {
53 char * seg = (
char *)vSuppFun->pArray[i];
55 for(j = 0; j < Abc_NtkPiNum(pNtk); j+=8) {
56 if(((*seg) & 0x01) == 0x01)
57 Vec_IntPushOrder(oDep[i], j);
58 if(((*seg) & 0x02) == 0x02)
59 Vec_IntPushOrder(oDep[i], j+1);
60 if(((*seg) & 0x04) == 0x04)
61 Vec_IntPushOrder(oDep[i], j+2);
62 if(((*seg) & 0x08) == 0x08)
63 Vec_IntPushOrder(oDep[i], j+3);
64 if(((*seg) & 0x10) == 0x10)
65 Vec_IntPushOrder(oDep[i], j+4);
66 if(((*seg) & 0x20) == 0x20)
67 Vec_IntPushOrder(oDep[i], j+5);
68 if(((*seg) & 0x40) == 0x40)
69 Vec_IntPushOrder(oDep[i], j+6);
70 if(((*seg) & 0x80) == 0x80)
71 Vec_IntPushOrder(oDep[i], j+7);
77 for(i = 0; i < Abc_NtkPoNum(pNtk); i++)
78 for(j = 0; j < Vec_IntSize(oDep[i]); j++)
79 Vec_IntPush(iDep[Vec_IntEntry(oDep[i], j)], i);
111 for(i = 0; i < Abc_NtkPiNum(pNtk)+1; i++)
112 temp[i] = Vec_IntAlloc( 0 );
114 for(i = 0; i < Abc_NtkPoNum(pNtk); i++)
115 Vec_IntPush(temp[Vec_IntSize(oDep[i])], i);
118 for(i = 0; i < Abc_NtkPiNum(pNtk)+1; i++)
120 if(Vec_IntSize(temp[i]) == 0)
121 Vec_IntFree( temp[i] );
125 oMatch[curr] = temp[i];
127 for(j = 0; j < Vec_IntSize(temp[i]); j++)
128 oGroup[Vec_IntEntry(oMatch[curr], j)] = curr;
140 for(i = 0; i < Abc_NtkPoNum(pNtk); i++)
142 Vec_IntPush(oMatch[i], i);
144 (*oLastItem) = Abc_NtkPoNum(pNtk);
163 for(i = 0; i < Abc_NtkPoNum(pNtk)+1; i++)
164 temp[i] = Vec_IntAlloc( 0 );
166 for(i = 0; i < Abc_NtkPiNum(pNtk); i++)
167 Vec_IntPush(temp[Vec_IntSize(iDep[i])], i);
170 for(i = 0; i < Abc_NtkPoNum(pNtk)+1; i++)
172 if(Vec_IntSize(temp[i]) == 0)
173 Vec_IntFree( temp[i] );
176 iMatch[curr] = temp[i];
177 for(j = 0; j < Vec_IntSize(iMatch[curr]); j++)
178 iGroup[Vec_IntEntry(iMatch[curr], j)] = curr;
207 oGroupList = Vec_IntAlloc( 10 );
209 for(i = 0; i < Abc_NtkPiNum(pNtk); i++)
211 if(Vec_IntSize(iDep[i]) == 1)
214 temp = Vec_IntAlloc( Vec_IntSize(iDep[i]) );
216 for(j = 0; j < Vec_IntSize(iDep[i]); j++)
217 Vec_IntPushUniqueOrder(oGroupList, oGroup[Vec_IntEntry(iDep[i], j)]);
219 for(j = 0; j < Vec_IntSize(oGroupList); j++)
221 for(k = 0; k < Vec_IntSize(iDep[i]); k++)
222 if(oGroup[Vec_IntEntry(iDep[i], k)] == Vec_IntEntry(oGroupList, j))
224 Vec_IntPush( temp, Vec_IntEntry(iDep[i], k) );
225 Vec_IntRemove( iDep[i], Vec_IntEntry(iDep[i], k) );
230 Vec_IntFree( iDep[i] );
232 Vec_IntClear( oGroupList );
240 Vec_IntFree( oGroupList );
249 iGroupList = Vec_IntAlloc( 10 );
251 for(i = 0; i < Abc_NtkPoNum(pNtk); i++)
253 if(Vec_IntSize(oDep[i]) == 1)
256 temp = Vec_IntAlloc( Vec_IntSize(oDep[i]) );
258 for(j = 0; j < Vec_IntSize(oDep[i]); j++)
259 Vec_IntPushUniqueOrder(iGroupList, iGroup[Vec_IntEntry(oDep[i], j)]);
261 for(j = 0; j < Vec_IntSize(iGroupList); j++)
263 for(k = 0; k < Vec_IntSize(oDep[i]); k++)
264 if(iGroup[Vec_IntEntry(oDep[i], k)] == Vec_IntEntry(iGroupList, j))
266 Vec_IntPush( temp, Vec_IntEntry(oDep[i], k) );
267 Vec_IntRemove( oDep[i], Vec_IntEntry(oDep[i], k) );
272 Vec_IntFree( oDep[i] );
274 Vec_IntClear( iGroupList );
282 Vec_IntFree( iGroupList );
293 for(i = 0; i < *oLastItem; i++)
295 if(Vec_IntSize(oMatch[i]) == 1)
298 array = Vec_IntAlloc( Vec_IntSize(oMatch[i]) );
299 sortedArray = Vec_IntAlloc( Vec_IntSize(oMatch[i]) );
301 for(j = 0; j < Vec_IntSize(oMatch[i]); j++)
308 for(k = 0; k < Vec_IntSize(oDep[Vec_IntEntry(oMatch[i], j)]); k++)
309 encode += iGroup[Vec_IntEntry(oDep[Vec_IntEntry(oMatch[i], j)], k)] * factor;
311 Vec_IntPush(array, encode);
312 Vec_IntPushUniqueOrder(sortedArray, encode);
315 printf(
"WARNING! Integer overflow!");
320 while( Vec_IntSize(sortedArray) > 1 )
322 for(k = 0; k < Vec_IntSize(oMatch[i]); k++)
324 if(Vec_IntEntry(array, k) == Vec_IntEntryLast(sortedArray))
326 Vec_IntPush(oMatch[*oLastItem+numOfItemsAdded], Vec_IntEntry(oMatch[i], k));
327 oGroup[Vec_IntEntry(oMatch[i], k)] = *oLastItem+numOfItemsAdded;
328 Vec_IntRemove( oMatch[i], Vec_IntEntry(oMatch[i], k) );
329 Vec_IntRemove( array, Vec_IntEntry(array, k) );
334 Vec_IntPop(sortedArray);
337 Vec_IntFree( array );
338 Vec_IntFree( sortedArray );
342 *oLastItem += numOfItemsAdded;
353 return numOfItemsAdded;
359 int numOfItemsAdded = 0;
362 for(i = 0; i < *iLastItem; i++)
364 if(Vec_IntSize(iMatch[i]) == 1)
367 array = Vec_IntAlloc( Vec_IntSize(iMatch[i]) );
368 sortedArray = Vec_IntAlloc( Vec_IntSize(iMatch[i]) );
370 for(j = 0; j < Vec_IntSize(iMatch[i]); j++)
377 for(k = 0; k < Vec_IntSize(iDep[Vec_IntEntry(iMatch[i], j)]); k++)
378 encode += oGroup[Vec_IntEntry(iDep[Vec_IntEntry(iMatch[i], j)], k)] * factor;
380 Vec_IntPush(array, encode);
381 Vec_IntPushUniqueOrder(sortedArray, encode);
386 while( Vec_IntSize(sortedArray) > 1 )
388 for(k = 0; k < Vec_IntSize(iMatch[i]); k++)
390 if(Vec_IntEntry(array, k) == Vec_IntEntryLast(sortedArray))
392 Vec_IntPush(iMatch[*iLastItem+numOfItemsAdded], Vec_IntEntry(iMatch[i], k));
393 iGroup[Vec_IntEntry(iMatch[i], k)] = *iLastItem+numOfItemsAdded;
394 Vec_IntRemove( iMatch[i], Vec_IntEntry(iMatch[i], k) );
395 Vec_IntRemove( array, Vec_IntEntry(array, k) );
400 Vec_IntPop(sortedArray);
403 Vec_IntFree( array );
404 Vec_IntFree( sortedArray );
408 *iLastItem += numOfItemsAdded;
419 return numOfItemsAdded;
432 for(i = 0; i < Abc_NtkPiNum(pNtk); i++)
433 vNodes[i] = Vec_PtrAlloc(50);
438 Abc_NtkIncrementTravId( pNtk );
439 Abc_NodeSetTravIdCurrent( pObj );
440 pObj = Abc_ObjFanout0Ntk(pObj);
453 int * pValues, Value0, Value1, i;
455 vNodes = Vec_PtrAlloc( 50 );
463 Abc_NtkIncrementTravId( pNtk );
466 pNode = Abc_NtkCi(pNtk, input);
467 pNode->
iTemp = pModel[input];
470 for(i = Vec_PtrSize(topOrder[input])-1; i >= 0; i--)
472 pNode = (
Abc_Obj_t *)Vec_PtrEntry(topOrder[input], i);
474 Value0 = ((int)(ABC_PTRUINT_T)Abc_ObjFanin0(pNode)->pCopy) ^ Abc_ObjFaninC0(pNode);
475 Value1 = ((int)(ABC_PTRUINT_T)Abc_ObjFanin1(pNode)->pCopy) ^ Abc_ObjFaninC1(pNode);
477 if( pNode->
iTemp != (Value0 & Value1))
479 pNode->
iTemp = (Value0 & Value1);
480 Vec_PtrPush(vNodes, pNode);
485 pValues =
ABC_ALLOC(
int, Abc_NtkCoNum(pNtk) );
487 pValues[i] = ((int)(ABC_PTRUINT_T)Abc_ObjFanin0(pNode)->pCopy) ^ Abc_ObjFaninC0(pNode);
489 pNode = Abc_NtkCi(pNtk, input);
495 for(i = 0; i < Vec_PtrSize(vNodes); i++)
497 pNode = (
Abc_Obj_t *)Vec_PtrEntry(vNodes, i);
505 Vec_PtrFree( vNodes );
510int refineIOBySimulation(
Abc_Ntk_t *pNtk,
Vec_Int_t** iMatch,
int* iLastItem,
int * iGroup,
Vec_Int_t** iDep,
Vec_Int_t** oMatch,
int* oLastItem,
int * oGroup,
Vec_Int_t** oDep,
char * vPiValues,
int * observability,
Vec_Ptr_t ** topOrder)
514 int * output, * output2;
517 Vec_Int_t * iComputedNum, * iComputedNumSorted;
520 int isRefined =
FALSE;
522 pModel =
ABC_ALLOC(
int, Abc_NtkCiNum(pNtk) );
525 pModel[i] = vPiValues[i] -
'0';
527 pModel[Abc_NtkPiNum(pNtk)+i] = pObj->
iData - 1;
531 oComputedNum = Vec_IntAlloc( Abc_NtkPoNum(pNtk) );
532 for(i = 0; i < Abc_NtkPoNum(pNtk); i++)
533 Vec_IntPush(oComputedNum, 0);
538 lastItem = *oLastItem;
539 for(i = 0; i < lastItem && (*oLastItem) != Abc_NtkPoNum(pNtk); i++)
543 if(Vec_IntSize(oMatch[i]) == 1)
546 for(j = 1; j < Vec_IntSize(oMatch[i]); j++)
547 if(output[Vec_IntEntry(oMatch[i], 0)] != output[Vec_IntEntry(oMatch[i], j)])
555 for(j = 0; j < Vec_IntSize(oMatch[i]); j++)
556 if(output[Vec_IntEntry(oMatch[i], j)])
558 Vec_IntPush(oMatch[*oLastItem], Vec_IntEntry(oMatch[i], j));
559 oGroup[Vec_IntEntry(oMatch[i], j)] = *oLastItem;
560 Vec_IntRemove(oMatch[i], Vec_IntEntry(oMatch[i], j));
568 if( (*oLastItem) > lastItem )
577 lastItem = *iLastItem;
578 for(i = 0; i < lastItem && (*iLastItem) != Abc_NtkPiNum(pNtk); i++)
582 if(Vec_IntSize(iMatch[i]) == 1)
585 iComputedNum = Vec_IntAlloc( Vec_IntSize(iMatch[i]) );
586 iComputedNumSorted = Vec_IntAlloc( Vec_IntSize(iMatch[i]) );
588 for(j = 0; j < Vec_IntSize(iMatch[i]); j++)
590 if( vPiValues[Vec_IntEntry(iMatch[i], j)] ==
'0' )
591 pModel[Vec_IntEntry(iMatch[i], j)] = 1;
593 pModel[Vec_IntEntry(iMatch[i], j)] = 0;
600 for(k = 0; k < Vec_IntSize(iDep[Vec_IntEntry(iMatch[i], j)]); k++)
602 int outputIndex = Vec_IntEntry(iDep[Vec_IntEntry(iMatch[i], j)], k);
604 if(output2[outputIndex])
605 num += (oGroup[outputIndex] + 1) * factor;
607 if(output[outputIndex] != output2[outputIndex])
609 int temp = Vec_IntEntry(oComputedNum, outputIndex) + i + 1;
610 Vec_IntWriteEntry(oComputedNum, outputIndex, temp);
611 observability[Vec_IntEntry(iMatch[i], j)]++;
615 Vec_IntPush(iComputedNum, num);
616 Vec_IntPushUniqueOrder(iComputedNumSorted, num);
618 pModel[Vec_IntEntry(iMatch[i], j)] = vPiValues[Vec_IntEntry(iMatch[i], j)] -
'0';
622 while( Vec_IntSize( iComputedNumSorted ) > 1 )
624 for(k = 0; k < Vec_IntSize(iMatch[i]); k++)
626 if(Vec_IntEntry(iComputedNum, k) == Vec_IntEntryLast(iComputedNumSorted) )
628 Vec_IntPush(iMatch[*iLastItem], Vec_IntEntry(iMatch[i], k));
629 iGroup[Vec_IntEntry(iMatch[i], k)] = *iLastItem;
630 Vec_IntRemove( iMatch[i], Vec_IntEntry(iMatch[i], k) );
631 Vec_IntRemove( iComputedNum, Vec_IntEntry(iComputedNum, k) );
636 Vec_IntPop( iComputedNumSorted );
639 Vec_IntFree( iComputedNum );
640 Vec_IntFree( iComputedNumSorted );
643 if( (*iLastItem) > lastItem )
653 lastItem = *oLastItem;
654 for(i = 0; i < lastItem && (*oLastItem) != Abc_NtkPoNum(pNtk); i++)
658 if(Vec_IntSize(oMatch[i]) == 1)
661 encode = Vec_IntAlloc( Vec_IntSize(oMatch[i]) );
662 sortedEncode = Vec_IntAlloc( Vec_IntSize(oMatch[i]) );
664 for(j = 0; j < Vec_IntSize(oMatch[i]); j++)
666 Vec_IntPush(encode, Vec_IntEntry(oComputedNum, Vec_IntEntry(oMatch[i], j)) );
667 Vec_IntPushUniqueOrder( sortedEncode, Vec_IntEntry(encode, j) );
670 while( Vec_IntSize(sortedEncode) > 1 )
672 for(j = 0; j < Vec_IntSize(oMatch[i]); j++)
673 if(Vec_IntEntry(encode, j) == Vec_IntEntryLast(sortedEncode))
675 Vec_IntPush(oMatch[*oLastItem], Vec_IntEntry(oMatch[i], j));
676 oGroup[Vec_IntEntry(oMatch[i], j)] = *oLastItem;
677 Vec_IntRemove( oMatch[i], Vec_IntEntry(oMatch[i], j) );
678 Vec_IntRemove( encode, Vec_IntEntry(encode, j) );
683 Vec_IntPop( sortedEncode );
686 Vec_IntFree( encode );
687 Vec_IntFree( sortedEncode );
690 if( (*oLastItem) > lastItem )
695 Vec_IntFree( oComputedNum );
718 if(iCurrMatch == NULL)
722 pObjNew = Abc_NtkCreatePi( pNtkMiter );
724 pObj->
pCopy = pObjNew;
725 pObj = Abc_NtkCi(pNtk2, i);
726 pObj->
pCopy = pObjNew;
733 for(i = 0; i < Vec_PtrSize( iCurrMatch ); i += 2)
735 pObjNew = Abc_NtkCreatePi( pNtkMiter );
736 pObj = (
Abc_Obj_t *)Vec_PtrEntry(iCurrMatch, i);
737 pObj->
pCopy = pObjNew;
738 pObj = (
Abc_Obj_t *)Vec_PtrEntry(iCurrMatch, i+1);
739 pObj->
pCopy = pObjNew;
746 pObjNew = Abc_NtkCreatePo( pNtkMiter );
775 vPairs = Vec_PtrAlloc( 100 );
778 if(oCurrMatch != NULL)
780 for(i = 0; i < Vec_PtrSize( oCurrMatch ); i += 2)
782 Vec_PtrPush( vPairs, Abc_ObjChild0Copy((
Abc_Obj_t *)Vec_PtrEntry(oCurrMatch, i)) );
783 Vec_PtrPush( vPairs, Abc_ObjChild0Copy((
Abc_Obj_t *)Vec_PtrEntry(oCurrMatch, i+1)) );
792 Vec_PtrPush( vPairs, Abc_ObjChild0Copy(pNode) );
793 pNode = Abc_NtkCo( pNtk2, i );
794 Vec_PtrPush( vPairs, Abc_ObjChild0Copy(pNode) );
814 int nErrors, nPrinted, i, iNode = -1;
816 assert( Abc_NtkCiNum(pNtk1) == Abc_NtkCiNum(pNtk2) );
817 assert( Abc_NtkCoNum(pNtk1) == Abc_NtkCoNum(pNtk2) );
823 for ( i = 0; i < Abc_NtkCoNum(pNtk1); i++ )
828 for ( i = 0; i < Abc_NtkCoNum(pNtk1); i++ )
834 if ( ++nPrinted == 3 )
847 pNode = Abc_NtkCo(pNtk1,iNode);
853 pNode = (
Abc_Obj_t *)Vec_PtrEntry( vNodes, 0 );
854 if ( Abc_ObjIsCi(pNode) )
858 assert( Abc_ObjIsCi(pNode) );
860 Vec_IntPush(mismatch, Abc_ObjId(pNode)-1);
861 Vec_IntPush(mismatch, pModel[(
int)(
size_t)pNode->
pCopy]);
865 Vec_PtrFree( vNodes );
871int Abc_NtkMiterSatBm(
Abc_Ntk_t * pNtk, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit,
int fVerbose, ABC_INT64_T * pNumConfs, ABC_INT64_T * pNumInspects)
886 assert( Abc_NtkLatchNum(pNtk) == 0 );
923 status =
sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)nInsLimit, (ABC_INT64_T)0, (ABC_INT64_T)0 );
929 else if ( status ==
l_True )
950 Vec_IntFree( vCiIds );
979 pMiter =
Abc_NtkMiterBm( pNtk1, pNtk2, iMatchPairs, oMatchPairs );
988 vPairs = Vec_PtrAlloc( 100 );
993 for(i = 0; i < Vec_PtrSize( oMatchPairs ); i += 2)
995 Vec_PtrPush( vPairs, Abc_ObjChild0Copy((
Abc_Obj_t *)Vec_PtrEntry(oMatchPairs, i)) );
996 Vec_PtrPush( vPairs, Abc_ObjChild0Copy((
Abc_Obj_t *)Vec_PtrEntry(oMatchPairs, i+1)) );
1000 Vec_PtrFree( vPairs);
1002 else if(
mode == 2 )
1010 if ( pMiter == NULL )
1012 printf(
"Miter computation has failed.");
1020 if(mismatch != NULL)
1042 printf(
"Renoding for CNF has failed.");
1047 RetValue =
Abc_NtkMiterSat( pCnf, (ABC_INT64_T)10000, (ABC_INT64_T)0, 0, NULL, NULL);
1054 if ( mismatch != NULL && pCnf->
pModel )
1070 iMatchPairs = Vec_PtrAlloc( Abc_NtkPiNum( pNtk1 ) * 2);
1071 oMatchPairs = Vec_PtrAlloc( Abc_NtkPoNum( pNtk1 ) * 2);
1073 for(i = 0; i < Abc_NtkPiNum(pNtk1); i++)
1075 Vec_PtrPush(iMatchPairs, Abc_NtkPi(pNtk2, Vec_IntEntry(matchedInputs2, i)));
1076 Vec_PtrPush(iMatchPairs, Abc_NtkPi(pNtk1, Vec_IntEntry(matchedInputs1, i)));
1080 for(i = 0; i < Abc_NtkPoNum(pNtk1); i++)
1082 Vec_PtrPush(oMatchPairs, Abc_NtkPo(pNtk2, Vec_IntEntry(matchedOutputs2, i)));
1083 Vec_PtrPush(oMatchPairs, Abc_NtkPo(pNtk1, Vec_IntEntry(matchedOutputs1, i)));
1086 result =
Abc_NtkBmSat(pNtk1, pNtk2, iMatchPairs, oMatchPairs, NULL, 0);
1089 printf(
"*** Circuits are equivalent ***\n");
1091 printf(
"*** Circuits are NOT equivalent ***\n");
1093 Vec_PtrFree( iMatchPairs );
1094 Vec_PtrFree( oMatchPairs );
1103 int i, j, numOfLevels;
1116 if(bitVector != NULL)
1118 for(i = 0; i < Abc_NtkPiNum(pNtk); i++)
1121 pObj = Abc_NtkPi(pNtk, i);
1126 for(i = 0; i < Vec_IntSize(currInputs); i++)
1128 pObj = Abc_NtkPi(pNtk, Vec_IntEntry(currInputs, i));
1130 pObj->
pCopy = pObjNew;
1135 for( i = 0; i <= numOfLevels; i++ )
1136 for( j = 0; j < Vec_PtrSize( nodesInLevel[i] ); j++)
1138 pObj = (
Abc_Obj_t *)Vec_PtrEntry( nodesInLevel[i], j );
1140 if(Abc_ObjChild0Copy(pObj) == NULL && Abc_ObjChild1Copy(pObj) == NULL)
1142 else if(Abc_ObjChild0Copy(pObj) == NULL && Abc_ObjChild1Copy(pObj) == (
void*)(1))
1144 else if(Abc_ObjChild0Copy(pObj) == NULL && (Abc_ObjChild1Copy(pObj) != (NULL) && Abc_ObjChild1Copy(pObj) != (
void*)(1)) )
1146 else if(Abc_ObjChild0Copy(pObj) == (
void*)(1) && Abc_ObjChild1Copy(pObj) == NULL)
1148 else if(Abc_ObjChild0Copy(pObj) == (
void*)(1) && Abc_ObjChild1Copy(pObj) == (
void*)(1))
1150 else if(Abc_ObjChild0Copy(pObj) == (
void*)(1) && (Abc_ObjChild1Copy(pObj) != (NULL) && Abc_ObjChild1Copy(pObj) != (
void*)(1)) )
1151 pObj->
pCopy = Abc_ObjChild1Copy(pObj);
1152 else if( (Abc_ObjChild0Copy(pObj) != (NULL) && Abc_ObjChild0Copy(pObj) != (
void*)(1)) && Abc_ObjChild1Copy(pObj) == NULL )
1154 else if( (Abc_ObjChild0Copy(pObj) != (NULL) && Abc_ObjChild0Copy(pObj) != (
void*)(1)) && Abc_ObjChild1Copy(pObj) == (
void*)(1) )
1155 pObj->
pCopy = Abc_ObjChild0Copy(pObj);
1156 else if( (Abc_ObjChild0Copy(pObj) != (NULL) && Abc_ObjChild0Copy(pObj) != (
void*)(1)) &&
1157 (Abc_ObjChild1Copy(pObj) != (NULL) && Abc_ObjChild1Copy(pObj) != (
void*)(1)) )
1161 for(i = 0; i < Abc_NtkPoNum(pNtk); i++)
1163 pObj = Abc_NtkPo(pNtk, i);
1166 if( Abc_ObjChild0Copy(pObj) == NULL)
1171 else if( Abc_ObjChild0Copy(pObj) == (
void*)(1) )
1189 Vec_Int_t * oNonSingleton,
int oI,
int idx,
int ii,
int iidx)
1191 static int MATCH_FOUND;
1198 MATCH_FOUND =
FALSE;
1200 if( oI == Vec_IntSize( oNonSingleton ) )
1202 if( iNonSingleton != NULL)
1203 if(
match1by1(pNtk1, nodesInLevel1, iMatch1, iDep1, matchedInputs1, iGroup1, oMatch1, oGroup1,
1204 pNtk2, nodesInLevel2, iMatch2, iDep2, matchedInputs2, iGroup2, oMatch2, oGroup2,
1205 matchedOutputs1, matchedOutputs2, oMatchedGroups, iNonSingleton, ii, iidx) )
1208 if( iNonSingleton == NULL)
1214 i = Vec_IntEntry(oNonSingleton, oI);
1216 mismatch = Vec_IntAlloc(10);
1218 skipList =
ABC_ALLOC(
int, Vec_IntSize(oMatch1[i]));
1220 for(j = 0; j < Vec_IntSize(oMatch1[i]); j++)
1221 skipList[j] =
FALSE;
1223 Vec_PtrPush(oMatchPairs, Abc_NtkPo(subNtk1, Vec_IntEntry(oMatch1[i], idx)) );
1224 Vec_IntPush(matchedOutputs1, Vec_IntEntry(oMatch1[i], idx));
1226 for(j = 0; j < Vec_IntSize( oMatch2[i] ) && MATCH_FOUND ==
FALSE; j++)
1228 if( Vec_IntEntry(oMatch2[i], j) == -1 || skipList[j] ==
TRUE)
1231 Vec_PtrPush(oMatchPairs, Abc_NtkPo(subNtk2, Vec_IntEntry(oMatch2[i], j)));
1232 Vec_IntPush(matchedOutputs2, Vec_IntEntry(oMatch2[i], j));
1235 if(
Abc_NtkBmSat( subNtk1, subNtk2, NULL, oMatchPairs, mismatch, 0) )
1240 temp = Vec_IntEntry(oMatch2[i], j);
1241 Vec_IntWriteEntry(oMatch2[i], j, -1);
1243 if(idx != Vec_IntSize( oMatch1[i] ) - 1)
1246 pNtk2, nodesInLevel2, iMatch2, iDep2, matchedInputs2, iGroup2, oMatch2, oGroup2,
1247 matchedOutputs1, matchedOutputs2, oMatchedGroups, iNonSingleton,
1248 subNtk1, subNtk2, oMatchPairs,
1249 oNonSingleton, oI, idx+1, ii, iidx);
1253 pNtk2, nodesInLevel2, iMatch2, iDep2, matchedInputs2, iGroup2, oMatch2, oGroup2,
1254 matchedOutputs1, matchedOutputs2, oMatchedGroups, iNonSingleton,
1255 subNtk1, subNtk2, oMatchPairs,
1256 oNonSingleton, oI+1, 0, ii, iidx);
1258 Vec_IntWriteEntry(oMatch2[i], j, temp);
1262 int * output1, * output2;
1269 vPiValues =
ABC_ALLOC(
char, Abc_NtkPiNum(subNtk1) + 1);
1270 vPiValues[Abc_NtkPiNum(subNtk1)] =
'\0';
1272 for(k = 0; k < Abc_NtkPiNum(subNtk1); k++)
1275 for(k = 0; k < Vec_IntSize(mismatch); k += 2)
1276 vPiValues[Vec_IntEntry(mismatch, k)] = Vec_IntEntry(mismatch, k+1);
1278 pModel =
ABC_ALLOC(
int, Abc_NtkCiNum(subNtk1) );
1281 pModel[k] = vPiValues[k] -
'0';
1283 pModel[Abc_NtkPiNum(subNtk1)+k] = pObj->
iData - 1;
1288 pModel[Abc_NtkPiNum(subNtk2)+k] = pObj->
iData - 1;
1293 for(k = 0; k < Vec_IntSize( oMatch1[i] ); k++)
1294 if(output1[Vec_IntEntry(oMatch1[i], idx)] != output2[Vec_IntEntry(oMatch2[i], k)])
1306 if(MATCH_FOUND ==
FALSE )
1308 Vec_PtrPop(oMatchPairs);
1309 Vec_IntPop(matchedOutputs2);
1313 if(MATCH_FOUND ==
FALSE )
1315 Vec_PtrPop(oMatchPairs);
1316 Vec_IntPop(matchedOutputs1);
1319 if(MATCH_FOUND &&
counter != 0)
1335 static int MATCH_FOUND =
FALSE;
1344 MATCH_FOUND =
FALSE;
1346 if( ii == Vec_IntSize(iNonSingleton) )
1352 i = Vec_IntEntry(iNonSingleton, ii);
1354 if( idx == Vec_IntSize(iMatch1[i]) )
1357 return match1by1(pNtk1, nodesInLevel1, iMatch1, iDep1, matchedInputs1, iGroup1, oMatch1, oGroup1,
1358 pNtk2, nodesInLevel2, iMatch2, iDep2, matchedInputs2, iGroup2, oMatch2, oGroup2,
1359 matchedOutputs1, matchedOutputs2, oMatchedGroups, iNonSingleton, ii+1, 0);
1363 oNonSingleton = Vec_IntAlloc(10);
1364 oMatchPairs = Vec_PtrAlloc(100);
1365 skipList =
ABC_ALLOC(
int, Vec_IntSize(iMatch1[i]));
1367 for(j = 0; j < Vec_IntSize(iMatch1[i]); j++)
1368 skipList[j] =
FALSE;
1370 Vec_IntPush(matchedInputs1, Vec_IntEntry(iMatch1[i], idx));
1375 for(j = 0; j < Vec_IntSize(iDep1[Vec_IntEntryLast(iMatch1[i])]); j++)
1377 if( Vec_IntSize(oMatch1[oGroup1[Vec_IntEntry(iDep1[Vec_IntEntryLast(iMatch1[i])], j)]]) == 1 )
1379 if( Vec_IntFind( oMatchedGroups, oGroup1[Vec_IntEntry(iDep1[Vec_IntEntryLast(iMatch1[i])], j)]) != -1)
1382 Vec_IntPushUnique(oNonSingleton, oGroup1[Vec_IntEntry(iDep1[Vec_IntEntryLast(iMatch1[i])], j)]);
1383 Vec_IntPushUnique(oMatchedGroups, oGroup1[Vec_IntEntry(iDep1[Vec_IntEntryLast(iMatch1[i])], j)]);
1387 subNtk1 =
computeCofactor(pNtk1, nodesInLevel1, NULL, matchedInputs1);
1389 for(j = idx-1; j < Vec_IntSize(iMatch2[i]) && MATCH_FOUND ==
FALSE; j++)
1397 mismatch = Vec_IntAlloc(10);
1399 Vec_IntPush(matchedInputs2, Vec_IntEntry(iMatch2[i], j));
1401 subNtk2 =
computeCofactor(pNtk2, nodesInLevel2, NULL, matchedInputs2);
1403 for(m = 0; m < Vec_IntSize(matchedOutputs1); m++)
1405 Vec_PtrPush(oMatchPairs, Abc_NtkPo(subNtk1, Vec_IntEntry(matchedOutputs1, m)));
1406 Vec_PtrPush(oMatchPairs, Abc_NtkPo(subNtk2, Vec_IntEntry(matchedOutputs2, m)));
1411 if(
Abc_NtkBmSat( subNtk2, subNtk1, NULL, oMatchPairs, mismatch, 0) )
1415 tempJ = Vec_IntEntry(iMatch2[i], idx-1);
1416 Vec_IntWriteEntry(iMatch2[i], idx-1, Vec_IntEntry(iMatch2[i], j));
1417 Vec_IntWriteEntry(iMatch2[i], j, tempJ);
1425 pNtk2, nodesInLevel2, iMatch2, iDep2, matchedInputs2, iGroup2, oMatch2, oGroup2,
1426 matchedOutputs1, matchedOutputs2, oMatchedGroups, iNonSingleton,
1427 subNtk1, subNtk2, oMatchPairs, oNonSingleton, 0, 0, ii, idx);
1432 tempJ = Vec_IntEntry(iMatch2[i], idx-1);
1433 Vec_IntWriteEntry(iMatch2[i], idx-1, Vec_IntEntry(iMatch2[i], j));
1434 Vec_IntWriteEntry(iMatch2[i], j, tempJ);
1440 int * bitVector1, * bitVector2;
1447 bitVector1 =
ABC_ALLOC(
int, Abc_NtkPiNum(pNtk1) );
1448 bitVector2 =
ABC_ALLOC(
int, Abc_NtkPiNum(pNtk2) );
1450 currInputs1 = Vec_IntAlloc(10);
1451 currInputs2 = Vec_IntAlloc(10);
1453 suppNum2 =
ABC_ALLOC(
int, Vec_IntSize(iMatch2[i])-idx+1);
1455 for(m = 0; m < Abc_NtkPiNum(pNtk1); m++)
1461 for(m = 0; m < Vec_IntSize(iMatch2[i])-idx+1; m++)
1465 for(m = 0; m < Vec_IntSize(mismatch); m += 2)
1467 int n = Vec_IntEntry(mismatch, m);
1469 bitVector1[Vec_IntEntry(matchedInputs1, n)] = Vec_IntEntry(mismatch, m+1);
1470 bitVector2[Vec_IntEntry(matchedInputs2, n)] = Vec_IntEntry(mismatch, m+1);
1474 for(m = idx-1; m < Vec_IntSize(iMatch1[i]); m++)
1476 Vec_IntPush(currInputs1, Vec_IntEntry(iMatch1[i], m));
1477 Vec_IntPush(currInputs2, Vec_IntEntry(iMatch2[i], m));
1481 for(m = 0; m < Abc_NtkPiNum(pNtk1); m++)
1483 if(Vec_IntFind( matchedInputs1, m ) == -1)
1484 Vec_IntPushUnique(currInputs1, m);
1486 if(Vec_IntFind( matchedInputs2, m ) == -1)
1487 Vec_IntPushUnique(currInputs2, m);
1490 FpNtk1 =
computeCofactor(pNtk1, nodesInLevel1, bitVector1, currInputs1);
1491 FpNtk2 =
computeCofactor(pNtk2, nodesInLevel2, bitVector2, currInputs2);
1498 for(n = 0; n < vSupp->nSize; n++)
1499 if( Abc_ObjId((
Abc_Obj_t *)vSupp->pArray[n]) == 1 )
1500 suppNum1 += Vec_IntFind( matchedOutputs1, m) + 1;
1502 Vec_PtrFree( vSupp );
1510 for(n = 0; n < vSupp->nSize; n++)
1511 if( (
int)Abc_ObjId((
Abc_Obj_t *)vSupp->pArray[n])-1 < (Vec_IntSize(iMatch2[i]))-idx+1 &&
1512 (
int)Abc_ObjId((
Abc_Obj_t *)vSupp->pArray[n])-1 >= 0)
1513 suppNum2[Abc_ObjId((
Abc_Obj_t *)vSupp->pArray[n])-1] += Vec_IntFind( matchedOutputs2, m) + 1;
1515 Vec_PtrFree( vSupp );
1524 for(m = 0; m < Vec_IntSize(iMatch2[i])-idx+1; m++)
1525 if(suppNum2[m] != suppNum1)
1527 skipList[m+idx-1] =
TRUE;
1535 Vec_IntFree( currInputs1 );
1536 Vec_IntFree( currInputs2 );
1540 Vec_PtrClear(oMatchPairs);
1542 Vec_IntFree(mismatch);
1546 if( MATCH_FOUND ==
FALSE )
1547 Vec_IntPop(matchedInputs2);
1550 if( MATCH_FOUND ==
FALSE )
1552 Vec_IntPop(matchedInputs1);
1556 for(m = 0; m < Vec_IntSize(oNonSingleton); m++)
1557 Vec_IntPop( oMatchedGroups );
1561 Vec_IntFree( oNonSingleton );
1562 Vec_PtrFree( oMatchPairs );
1566 if(MATCH_FOUND &&
counter != 0)
1576float refineBySAT(
Abc_Ntk_t * pNtk1,
Vec_Int_t ** iMatch1,
int * iGroup1,
Vec_Int_t ** iDep1,
int* iLastItem1,
Vec_Int_t ** oMatch1,
int * oGroup1,
Vec_Int_t ** oDep1,
int* oLastItem1,
int * observability1,
1582 Vec_Int_t * matchedInputs1, * matchedInputs2;
1583 Vec_Int_t * matchedOutputs1, * matchedOutputs2;
1584 Vec_Ptr_t ** nodesInLevel1, ** nodesInLevel2;
1589 float satTime = 0.0;
1593 iNonSingleton = Vec_IntAlloc(10);
1595 matchedInputs1 = Vec_IntAlloc( Abc_NtkPiNum(pNtk1) );
1596 matchedInputs2 = Vec_IntAlloc( Abc_NtkPiNum(pNtk2) );
1598 matchedOutputs1 = Vec_IntAlloc( Abc_NtkPoNum(pNtk1) );
1599 matchedOutputs2 = Vec_IntAlloc( Abc_NtkPoNum(pNtk2) );
1603 nodesInLevel1[i] = Vec_PtrAlloc( 20 );
1607 Vec_PtrPush(nodesInLevel1[Abc_ObjLevel(pObj)], pObj);
1611 nodesInLevel2[i] = Vec_PtrAlloc( 20 );
1615 Vec_PtrPush(nodesInLevel2[Abc_ObjLevel(pObj)], pObj);
1617 oMatchedGroups = Vec_IntAlloc( 10 );
1619 for(i = 0; i < *iLastItem1; i++)
1621 if(Vec_IntSize(iMatch1[i]) == 1)
1623 Vec_IntPush(matchedInputs1, Vec_IntEntryLast(iMatch1[i]));
1624 Vec_IntPush(matchedInputs2, Vec_IntEntryLast(iMatch2[i]));
1627 Vec_IntPush(iNonSingleton, i);
1630 for(i = 0; i < *oLastItem1; i++)
1632 if(Vec_IntSize(oMatch1[i]) == 1)
1634 Vec_IntPush(matchedOutputs1, Vec_IntEntryLast(oMatch1[i]));
1635 Vec_IntPush(matchedOutputs2, Vec_IntEntryLast(oMatch2[i]));
1639 for(i = 0; i < Vec_IntSize(iNonSingleton) - 1; i++)
1641 for(j = i + 1; j < Vec_IntSize(iNonSingleton); j++)
1642 if( observability2[Vec_IntEntry(iMatch2[Vec_IntEntry(iNonSingleton, j)], 0)] >
1643 observability2[Vec_IntEntry(iMatch2[Vec_IntEntry(iNonSingleton, i)], 0)] )
1645 int temp = Vec_IntEntry(iNonSingleton, i);
1646 Vec_IntWriteEntry( iNonSingleton, i, Vec_IntEntry(iNonSingleton, j) );
1647 Vec_IntWriteEntry( iNonSingleton, j, temp );
1649 else if( observability2[Vec_IntEntry(iMatch2[Vec_IntEntry(iNonSingleton, j)], 0)] ==
1650 observability2[Vec_IntEntry(iMatch2[Vec_IntEntry(iNonSingleton, i)], 0)] )
1652 if( Vec_IntSize(iMatch2[Vec_IntEntry(iNonSingleton, j)]) < Vec_IntSize(iMatch2[Vec_IntEntry(iNonSingleton, i)]) )
1654 int temp = Vec_IntEntry(iNonSingleton, i);
1655 Vec_IntWriteEntry( iNonSingleton, i, Vec_IntEntry(iNonSingleton, j) );
1656 Vec_IntWriteEntry( iNonSingleton, j, temp );
1684 matchFound =
match1by1(pNtk1, nodesInLevel1, iMatch1, iDep1, matchedInputs1, iGroup1, oMatch1, oGroup1,
1685 pNtk2, nodesInLevel2, iMatch2, iDep2, matchedInputs2, iGroup2, oMatch2, oGroup2,
1686 matchedOutputs1, matchedOutputs2, oMatchedGroups, iNonSingleton, 0, 0);
1688 if( matchFound && Vec_IntSize(matchedOutputs1) != Abc_NtkPoNum(pNtk1) )
1694 oNonSingleton = Vec_IntAlloc( 10 );
1696 oMatchPairs = Vec_PtrAlloc(Abc_NtkPoNum(pNtk1) * 2);
1698 for(i = 0; i < *oLastItem1; i++)
1699 if( Vec_IntSize(oMatch1[i]) > 1 && Vec_IntFind( oMatchedGroups, i) == -1 )
1700 Vec_IntPush(oNonSingleton, i);
1702 subNtk1 =
computeCofactor(pNtk1, nodesInLevel1, NULL, matchedInputs1);
1703 subNtk2 =
computeCofactor(pNtk2, nodesInLevel2, NULL, matchedInputs2);
1705 matchFound =
matchNonSingletonOutputs(pNtk1, nodesInLevel1, iMatch1, iDep1, matchedInputs1, iGroup1, oMatch1, oGroup1,
1706 pNtk2, nodesInLevel2, iMatch2, iDep2, matchedInputs2, iGroup1, oMatch2, oGroup2,
1707 matchedOutputs1, matchedOutputs2, oMatchedGroups, NULL,
1708 subNtk1, subNtk2, oMatchPairs, oNonSingleton, 0, 0, 0, 0);
1710 Vec_IntFree( oNonSingleton );
1711 Vec_PtrFree( oMatchPairs );
1717 satTime = (float)(Abc_Clock() - clk)/(float)(CLOCKS_PER_SEC);
1721 checkEquivalence( pNtk1, matchedInputs1, matchedOutputs1, pNtk2, matchedInputs2, matchedOutputs2);
1723 result = fopen(
"IOmatch.txt",
"w");
1725 fprintf(result,
"I/O = %d / %d \n\n", Abc_NtkPiNum(pNtk1), Abc_NtkPoNum(pNtk1));
1727 for(i = 0; i < Vec_IntSize(matchedInputs1) ; i++)
1728 fprintf(result,
"{%s}\t{%s}\n",
Abc_ObjName(Abc_NtkPi(pNtk1, Vec_IntEntry(matchedInputs1, i))),
Abc_ObjName(Abc_NtkPi(pNtk2, Vec_IntEntry(matchedInputs2, i))) );
1730 fprintf(result,
"\n-----------------------------------------\n");
1732 for(i = 0; i < Vec_IntSize(matchedOutputs1) ; i++)
1733 fprintf(result,
"{%s}\t{%s}\n",
Abc_ObjName(Abc_NtkPo(pNtk1, Vec_IntEntry(matchedOutputs1, i))),
Abc_ObjName(Abc_NtkPo(pNtk2, Vec_IntEntry(matchedOutputs2, i))) );
1738 Vec_IntFree( matchedInputs1 );
1739 Vec_IntFree( matchedInputs2 );
1740 Vec_IntFree( matchedOutputs1 );
1741 Vec_IntFree( matchedOutputs2 );
1742 Vec_IntFree( iNonSingleton );
1743 Vec_IntFree( oMatchedGroups );
1746 Vec_PtrFree( nodesInLevel1[i] );
1748 Vec_PtrFree( nodesInLevel2[i] );
1762 if(iLastItem1 != iLastItem2 || oLastItem1 != oLastItem2)
1785 int * iGroup1, * oGroup1;
1786 int * iGroup2, * oGroup2;
1787 int iLastItem1, oLastItem1;
1788 int iLastItem2, oLastItem2;
1791 char * vPiValues1, * vPiValues2;
1792 int * observability1, * observability2;
1797 Vec_Ptr_t ** topOrder1 = NULL, ** topOrder2 = NULL;
1806 extern int refineIOBySimulation(
Abc_Ntk_t *pNtk,
Vec_Int_t** iMatch,
int* iLastItem,
int * iGroup,
Vec_Int_t** iDep,
Vec_Int_t** oMatch,
int* oLastItem,
int * oGroup,
Vec_Int_t** oDep,
char * vPiValues,
int * observability,
Vec_Ptr_t ** topOrder);
1807 extern float refineBySAT(
Abc_Ntk_t * pNtk1,
Vec_Int_t ** iMatch1,
int * iGroup1,
Vec_Int_t ** iDep1,
int* iLastItem1,
Vec_Int_t ** oMatch1,
int * oGroup1,
Vec_Int_t ** oDep1,
int* oLastItem1,
int * observability1,
1823 iGroup1 =
ABC_ALLOC(
int, Abc_NtkPiNum(pNtk1) );
1824 oGroup1 =
ABC_ALLOC(
int, Abc_NtkPoNum(pNtk1) );
1826 iGroup2 =
ABC_ALLOC(
int, Abc_NtkPiNum(pNtk2) );
1827 oGroup2 =
ABC_ALLOC(
int, Abc_NtkPoNum(pNtk2) );
1829 vPiValues1 =
ABC_ALLOC(
char, Abc_NtkPiNum(pNtk1) + 1);
1830 vPiValues1[Abc_NtkPiNum(pNtk1)] =
'\0';
1832 vPiValues2 =
ABC_ALLOC(
char, Abc_NtkPiNum(pNtk2) + 1);
1833 vPiValues2[Abc_NtkPiNum(pNtk2)] =
'\0';
1835 observability1 =
ABC_ALLOC(
int, (
unsigned)Abc_NtkPiNum(pNtk1));
1836 observability2 =
ABC_ALLOC(
int, (
unsigned)Abc_NtkPiNum(pNtk2));
1838 for(i = 0; i < Abc_NtkPiNum(pNtk1); i++)
1840 iDep1[i] = Vec_IntAlloc( 1 );
1841 iMatch1[i] = Vec_IntAlloc( 1 );
1843 iDep2[i] = Vec_IntAlloc( 1 );
1844 iMatch2[i] = Vec_IntAlloc( 1 );
1846 vPiValues1[i] =
'0';
1847 vPiValues2[i] =
'0';
1849 observability1[i] = 0;
1850 observability2[i] = 0;
1853 for(i = 0; i < Abc_NtkPoNum(pNtk1); i++)
1855 oDep1[i] = Vec_IntAlloc( 1 );
1856 oMatch1[i] = Vec_IntAlloc( 1 );
1858 oDep2[i] = Vec_IntAlloc( 1 );
1859 oMatch2[i] = Vec_IntAlloc( 1 );
1865 printf(
"Network strashing is done!\n");
1871 printf(
"Getting dependencies is done!\n");
1875 initMatchList(pNtk1, iDep1, oDep1, iMatch1, &iLastItem1, oMatch1, &oLastItem1, iGroup1, oGroup1, p_equivalence);
1876 initMatchList(pNtk2, iDep2, oDep2, iMatch2, &iLastItem2, oMatch2, &oLastItem2, iGroup2, oGroup2, p_equivalence);
1877 printf(
"Initializing match lists is done!\n");
1880 if( !
checkListConsistency(iMatch1, oMatch1, iMatch2, oMatch2, iLastItem1, oLastItem1, iLastItem2, oLastItem2) )
1882 fprintf( stdout,
"I/O dependencies of two circuits are different.\n");
1886 printf(
"Refining IOs by dependencies ...");
1890 int iNumOfItemsAdded = 1, oNumOfItemsAdded = 1;
1894 if( oNumOfItemsAdded )
1900 if( iNumOfItemsAdded )
1906 if( iLastItem1 < Abc_NtkPiNum(pNtk1) )
1908 iSplitByDep(pNtk1, iDep1, iMatch1, iGroup1, &iLastItem1, oGroup1);
1909 if( oLastItem1 < Abc_NtkPoNum(pNtk1) )
1910 oSplitByDep(pNtk1, oDep1, oMatch1, oGroup1, &oLastItem1, iGroup1);
1913 if( iLastItem2 < Abc_NtkPiNum(pNtk2) )
1914 iNumOfItemsAdded =
iSplitByDep(pNtk2, iDep2, iMatch2, iGroup2, &iLastItem2, oGroup2);
1916 iNumOfItemsAdded = 0;
1918 if( oLastItem2 < Abc_NtkPoNum(pNtk2) )
1919 oNumOfItemsAdded =
oSplitByDep(pNtk2, oDep2, oMatch2, oGroup2, &oLastItem2, iGroup2);
1921 oNumOfItemsAdded = 0;
1923 if(!
checkListConsistency(iMatch1, oMatch1, iMatch2, oMatch2, iLastItem1, oLastItem1, iLastItem2, oLastItem2))
1925 fprintf( stdout,
"I/O dependencies of two circuits are different.\n");
1928 }
while(iNumOfItemsAdded != 0 || oNumOfItemsAdded != 0);
1934 initTime = ((float)(Abc_Clock() - clk)/(float)(CLOCKS_PER_SEC));
1940 printf(
"Refining IOs by simulation ...");
1945 int ioSuccess1, ioSuccess2;
1949 for(i = 0; i < iLastItem1; i++)
1953 if(Vec_IntSize(iMatch1[i]) != Vec_IntSize(iMatch2[i]))
1955 fprintf( stdout,
"Input refinement by simulation finds two circuits different.\n");
1959 for(j = 0; j < Vec_IntSize(iMatch1[i]); j++)
1961 vPiValues1[Vec_IntEntry(iMatch1[i], j)] = temp +
'0';
1962 vPiValues2[Vec_IntEntry(iMatch2[i], j)] = temp +
'0';
1966 ioSuccess1 =
refineIOBySimulation(pNtk1, iMatch1, &iLastItem1, iGroup1, iDep1, oMatch1, &oLastItem1, oGroup1, oDep1, vPiValues1, observability1, topOrder1);
1967 ioSuccess2 =
refineIOBySimulation(pNtk2, iMatch2, &iLastItem2, iGroup2, iDep2, oMatch2, &oLastItem2, oGroup2, oDep2, vPiValues2, observability2, topOrder2);
1969 if(ioSuccess1 && ioSuccess2)
1974 if(ioSuccess1 != ioSuccess2 ||
1975 !
checkListConsistency(iMatch1, oMatch1, iMatch2, oMatch2, iLastItem1, oLastItem1, iLastItem2, oLastItem2))
1977 fprintf( stdout,
"Input refinement by simulation finds two circuits different.\n");
1986 simulTime = (float)(Abc_Clock() - clk)/(float)(CLOCKS_PER_SEC);
1987 printf(
"SAT-based search started ...\n");
1989 satTime =
refineBySAT(pNtk1, iMatch1, iGroup1, iDep1, &iLastItem1, oMatch1, oGroup1, oDep1, &oLastItem1, observability1,
1990 pNtk2, iMatch2, iGroup2, iDep2, &iLastItem2, oMatch2, oGroup2, oDep2, &oLastItem2, observability2);
1992 printf(
"Init Time = %4.2f\n", initTime );
1993 printf(
"Simulation Time = %4.2f\n", simulTime );
1994 printf(
"SAT Time = %4.2f\n", satTime );
1995 printf(
"Overall Time = %4.2f\n", initTime + simulTime + satTime );
1999 for(i = 0; i < iLastItem1 ; i++)
2002 Vec_IntFree( iMatch1[i] );
2003 Vec_IntFree( iMatch2[i] );
2006 for(i = 0; i < oLastItem1 ; i++)
2009 Vec_IntFree( oMatch1[i] );
2010 Vec_IntFree( oMatch2[i] );
2013 for(i = 0; i < Abc_NtkPiNum(pNtk1); i++)
2015 Vec_IntFree( iDep1[i] );
2016 Vec_IntFree( iDep2[i] );
2017 if(topOrder1 != NULL) {
2018 Vec_PtrFree( topOrder1[i] );
2019 Vec_PtrFree( topOrder2[i] );
2023 for(i = 0; i < Abc_NtkPoNum(pNtk1); i++)
2025 Vec_IntFree( oDep1[i] );
2026 Vec_IntFree( oDep2[i] );
2045 if(topOrder1 != NULL) {
void bmGateWay(Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2, int p_equivalence)
int match1by1(Abc_Ntk_t *pNtk1, Vec_Ptr_t **nodesInLevel1, Vec_Int_t **iMatch1, Vec_Int_t **iDep1, Vec_Int_t *matchedInputs1, int *iGroup1, Vec_Int_t **oMatch1, int *oGroup1, Abc_Ntk_t *pNtk2, Vec_Ptr_t **nodesInLevel2, Vec_Int_t **iMatch2, Vec_Int_t **iDep2, Vec_Int_t *matchedInputs2, int *iGroup2, Vec_Int_t **oMatch2, int *oGroup2, Vec_Int_t *matchedOutputs1, Vec_Int_t *matchedOutputs2, Vec_Int_t *oMatchedGroups, Vec_Int_t *iNonSingleton, int ii, int idx)
void initMatchList(Abc_Ntk_t *pNtk, Vec_Int_t **iDep, Vec_Int_t **oDep, Vec_Int_t **iMatch, int *iLastItem, Vec_Int_t **oMatch, int *oLastItem, int *iGroup, int *oGroup, int p_equivalence)
void iSortDependencies(Abc_Ntk_t *pNtk, Vec_Int_t **iDep, int *oGroup)
int Abc_NtkBmSat(Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2, Vec_Ptr_t *iMatchPairs, Vec_Ptr_t *oMatchPairs, Vec_Int_t *mismatch, int mode)
Abc_Ntk_t * computeCofactor(Abc_Ntk_t *pNtk, Vec_Ptr_t **nodesInLevel, int *bitVector, Vec_Int_t *currInputs)
Abc_Ntk_t * Abc_NtkMiterBm(Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2, Vec_Ptr_t *iCurrMatch, Vec_Ptr_t *oCurrMatch)
int refineIOBySimulation(Abc_Ntk_t *pNtk, Vec_Int_t **iMatch, int *iLastItem, int *iGroup, Vec_Int_t **iDep, Vec_Int_t **oMatch, int *oLastItem, int *oGroup, Vec_Int_t **oDep, char *vPiValues, int *observability, Vec_Ptr_t **topOrder)
void oSortDependencies(Abc_Ntk_t *pNtk, Vec_Int_t **oDep, int *iGroup)
int * Abc_NtkSimulateOneNode(Abc_Ntk_t *pNtk, int *pModel, int input, Vec_Ptr_t **topOrder)
float refineBySAT(Abc_Ntk_t *pNtk1, Vec_Int_t **iMatch1, int *iGroup1, Vec_Int_t **iDep1, int *iLastItem1, Vec_Int_t **oMatch1, int *oGroup1, Vec_Int_t **oDep1, int *oLastItem1, int *observability1, Abc_Ntk_t *pNtk2, Vec_Int_t **iMatch2, int *iGroup2, Vec_Int_t **iDep2, int *iLastItem2, Vec_Int_t **oMatch2, int *oGroup2, Vec_Int_t **oDep2, int *oLastItem2, int *observability2)
int iSplitByDep(Abc_Ntk_t *pNtk, Vec_Int_t **iDep, Vec_Int_t **iMatch, int *iGroup, int *iLastItem, int *oGroup)
void Abc_NtkVerifyReportError(Abc_Ntk_t *pNtk1, Abc_Ntk_t *pNtk2, int *pModel, Vec_Int_t *mismatch)
int checkListConsistency(Vec_Int_t **iMatch1, Vec_Int_t **oMatch1, Vec_Int_t **iMatch2, Vec_Int_t **oMatch2, int iLastItem1, int oLastItem1, int iLastItem2, int oLastItem2)
int checkEquivalence(Abc_Ntk_t *pNtk1, Vec_Int_t *matchedInputs1, Vec_Int_t *matchedOutputs1, Abc_Ntk_t *pNtk2, Vec_Int_t *matchedInputs2, Vec_Int_t *matchedOutputs2)
int Abc_NtkMiterSatBm(Abc_Ntk_t *pNtk, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int fVerbose, ABC_INT64_T *pNumConfs, ABC_INT64_T *pNumInspects)
void getDependencies(Abc_Ntk_t *pNtk, Vec_Int_t **iDep, Vec_Int_t **oDep)
Vec_Ptr_t ** findTopologicalOrder(Abc_Ntk_t *pNtk)
int matchNonSingletonOutputs(Abc_Ntk_t *pNtk1, Vec_Ptr_t **nodesInLevel1, Vec_Int_t **iMatch1, Vec_Int_t **iDep1, Vec_Int_t *matchedInputs1, int *iGroup1, Vec_Int_t **oMatch1, int *oGroup1, Abc_Ntk_t *pNtk2, Vec_Ptr_t **nodesInLevel2, Vec_Int_t **iMatch2, Vec_Int_t **iDep2, Vec_Int_t *matchedInputs2, int *iGroup2, Vec_Int_t **oMatch2, int *oGroup2, Vec_Int_t *matchedOutputs1, Vec_Int_t *matchedOutputs2, Vec_Int_t *oMatchedGroups, Vec_Int_t *iNonSingleton, Abc_Ntk_t *subNtk1, Abc_Ntk_t *subNtk2, Vec_Ptr_t *oMatchPairs, Vec_Int_t *oNonSingleton, int oI, int idx, int ii, int iidx)
int oSplitByDep(Abc_Ntk_t *pNtk, Vec_Int_t **oDep, Vec_Int_t **oMatch, int *oGroup, int *oLastItem, int *iGroup)
void Abc_NtkDfsReverse_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
ABC_NAMESPACE_IMPL_START Abc_Ntk_t * Abc_NtkMulti(Abc_Ntk_t *pNtk, int nThresh, int nFaninMax, int fCnf, int fMulti, int fSimple, int fFactor)
DECLARATIONS ///.
Vec_Int_t * Abc_NtkGetCiSatVarNums(Abc_Ntk_t *pNtk)
struct Abc_Obj_t_ Abc_Obj_t
#define Abc_NtkForEachCo(pNtk, pCo, i)
ABC_DLL int Abc_NtkIsDfsOrdered(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Ntk_t * Abc_NtkAlloc(Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan)
DECLARATIONS ///.
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
#define Abc_AigForEachAnd(pNtk, pNode, i)
ABC_DLL void * Abc_NtkMiterSatCreate(Abc_Ntk_t *pNtk, int fAllPrimes)
#define Abc_NtkForEachPo(pNtk, pPo, i)
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
#define Abc_NtkForEachLatch(pNtk, pObj, i)
#define Abc_ObjForEachFanout(pObj, pFanout, i)
struct Abc_Aig_t_ Abc_Aig_t
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
struct Abc_Ntk_t_ Abc_Ntk_t
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
ABC_DLL Vec_Ptr_t * Abc_NtkNodeSupport(Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
ABC_DLL int Abc_NtkMiterSat(Abc_Ntk_t *pNtk, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int fVerbose, ABC_INT64_T *pNumConfs, ABC_INT64_T *pNumInspects)
FUNCTION DEFINITIONS ///.
ABC_DLL int * Abc_NtkVerifySimulatePattern(Abc_Ntk_t *pNtk, int *pModel)
ABC_DLL int * Abc_NtkVerifyGetCleanModel(Abc_Ntk_t *pNtk, int nFrames)
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
#define Abc_NtkForEachPi(pNtk, pPi, i)
ABC_DLL Abc_Ntk_t * Abc_NtkStrash(Abc_Ntk_t *pNtk, int fAllNodes, int fCleanup, int fRecord)
ABC_DLL int Abc_AigLevel(Abc_Ntk_t *pNtk)
ABC_DLL void Abc_ObjRemoveFanins(Abc_Obj_t *pObj)
#define Abc_NtkForEachCi(pNtk, pCi, i)
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Obj_t * Abc_AigMiter(Abc_Aig_t *pMan, Vec_Ptr_t *vPairs, int fImplic)
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
ABC_DLL int Abc_NtkMiterIsConstant(Abc_Ntk_t *pMiter)
#define ABC_ALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
int sat_solver_simplify(sat_solver *s)
void sat_solver_store_free(sat_solver *s)
void sat_solver_delete(sat_solver *s)
int * Sat_SolverGetModel(sat_solver *p, int *pVars, int nVars)
void Sat_SolverPrintStats(FILE *pFile, sat_solver *p)
#define SIM_RANDOM_UNSIGNED
Vec_Ptr_t * Sim_ComputeFunSupp(Abc_Ntk_t *pNtk, int fVerbose)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.