55 return (*a)->second < (*b)->second;
67 Abc_Print( 1,
"PIs:");
70 Abc_Print( 1,
"\n\n");
72 Abc_Print( 1,
"POs:");
75 Abc_Print( 1,
"\n\n");
77 Abc_Print( 1,
"FO(Fi)s:");
79 if ( !Wlc_ObjIsPi( pObj ) )
81 Abc_Print( 1,
"\n\n");
83 Abc_Print( 1,
"Objs:\n");
86 if ( !Wlc_ObjIsCi(pObj) )
97 iObj = Wlc_ObjId(
p, pObj );
98 if ( Vec_BitEntry( vCiMarks, iObj ) )
101 Vec_IntAddToEntry( vSuppRefs, iObj, 1 );
103 Vec_IntPush( vSuppList, iObj );
112 assert( vSuppRefs || vSuppList );
124 num += Wlc_ObjRange(pObj);
138 vCurCis = Vec_BitStart( Wlc_NtkObjNumMax(
p ) );
139 vCandCis = Vec_BitStart( Wlc_NtkObjNumMax(
p ) );
140 vDeltaB = Vec_IntAlloc( Vec_IntSize(vBlacks) );
141 vSuppList = Vec_IntAlloc( Wlc_NtkCiNum(
p) + Vec_IntSize(vBlacks) );
142 vSuppRefs = Vec_IntAlloc( Wlc_NtkObjNumMax(
p ) );
145 Vec_IntFill( vSuppRefs, Wlc_NtkObjNumMax(
p ), 0 );
149 Vec_BitWriteEntry( vCurCis, Wlc_ObjId(
p, pObj), 1 ) ;
150 Vec_BitWriteEntry( vCandCis, Wlc_ObjId(
p, pObj), 1 ) ;
155 Vec_BitWriteEntry( vCurCis, Entry, 1 );
156 if ( !Vec_BitEntry( vUnmark, Entry ) )
157 Vec_BitWriteEntry( vCandCis, Entry, 1 );
159 Vec_IntPush( vDeltaB, Entry );
161 assert( Vec_IntSize( vDeltaB ) );
182 Vec_IntClear( vSuppList );
189 if ( Vec_IntEntry( vSuppRefs, iSupp ) >= 2 )
209 Vec_BitFree( vCurCis );
210 Vec_BitFree( vCandCis );
211 Vec_IntFree( vDeltaB );
212 Vec_IntFree( vSuppList );
213 Vec_IntFree( vSuppRefs );
216static Vec_Int_t * Wlc_NtkGetCoreSels(
Gia_Man_t * pFrames,
int nFrames,
int first_sel_pi,
int num_sel_pis,
Vec_Bit_t * vMark,
int nConfLimit,
Wlc_Par_t * pPars,
int fSetPO,
int RunId )
227 sat_solver_set_runid( pSat, RunId );
231 for (i = 0; i < pCnf->
nClauses; i++)
244 Vec_IntPush(vLits, toLitCond(pCnf->
pVarNums[pObj->
Id], 0));
248 ret =
sat_solver_addclause(pSat, Vec_IntArray(vLits), Vec_IntArray(vLits) + Vec_IntSize(vLits));
250 Abc_Print( 1,
"UNSAT after adding PO clauses.\n" );
255 for ( i = 0; i < Vec_IntSize(vLits); ++i )
257 if ( i == Vec_IntSize(vLits) - 1 )
258 Lit = Vec_IntEntry( vLits, i );
260 Lit = lit_neg(Vec_IntEntry( vLits, i ));
263 Abc_Print( 1,
"UNSAT after adding PO clauses.\n" );
275 for ( i = 0; i < num_sel_pis; ++i )
277 int cur_pi = first_sel_pi + i;
278 int var = pCnf->
pVarNums[Aig_ManCi(pAigFrames, cur_pi)->Id];
281 Vec_IntWriteEntry( vMapVar2Sel, var, i );
282 Lit = toLitCond( var, 0 );
283 if ( Vec_BitEntry( vMark, i ) )
284 Vec_IntPush(vLits, Lit);
295 status =
sat_solver_solve(pSat, Vec_IntArray(vLits), Vec_IntArray(vLits) + Vec_IntSize(vLits), (ABC_INT64_T)(nConfLimit), (ABC_INT64_T)(0), (ABC_INT64_T)(0), (ABC_INT64_T)(0));
297 int nCoreLits, *pCoreLits;
298 Abc_Print( 1,
"UNSAT.\n" );
299 nCoreLits = sat_solver_final(pSat, &pCoreLits);
300 vCores = Vec_IntAlloc( nCoreLits );
301 for (i = 0; i < nCoreLits; i++)
303 Vec_IntPush( vCores, Vec_IntEntry( vMapVar2Sel, lit_var( pCoreLits[i] ) ) );
305 }
else if (status ==
l_True) {
306 Abc_Print( 1,
"SAT.\n" );
308 Abc_Print( 1,
"UNKNOWN.\n" );
312 Vec_IntFree(vMapVar2Sel);
321static Gia_Man_t * Wlc_NtkUnrollWoCex(
Wlc_Ntk_t * pChoice,
int nFrames,
int first_sel_pi,
int num_sel_pis)
329 pFrames->
pName = Abc_UtilStrsav( pGiaChoice->
pName );
331 Gia_ManConst0(pGiaChoice)->Value = 0;
335 for ( f = 0; f < nFrames; f++ )
337 for( i = 0; i < Gia_ManPiNum(pGiaChoice); i++ )
339 if ( i >= first_sel_pi && i < first_sel_pi + num_sel_pis )
342 Gia_ManPi(pGiaChoice, i)->Value = Gia_ManAppendCi(pFrames);
346 Gia_ManPi(pGiaChoice, i)->Value = Gia_ManAppendCi(pFrames);
354 pObj->
Value = Gia_ObjFanin0Copy(pObj);
356 Gia_ManAppendCo(pFrames, pObj->
Value);
367static Gia_Man_t * Wlc_NtkUnrollWithCex(
Wlc_Ntk_t * pChoice,
Abc_Cex_t * pCex,
int nbits_old_pis,
int num_sel_pis,
int * p_num_ppis,
int sel_pi_first,
int fUsePPI)
371 int num_ppis = nbits_new_pis - nbits_old_pis - num_sel_pis;
372 int num_undc_pis = Gia_ManPiNum(pGiaChoice) - nbits_new_pis;
378 *p_num_ppis = num_ppis;
380 Abc_Print( 1,
"#orig_pis = %d, #ppis = %d, #sel_pis = %d, #undc_pis = %d\n", nbits_old_pis, num_ppis, num_sel_pis, num_undc_pis );
381 assert(Gia_ManPiNum(pGiaChoice)==nbits_old_pis+num_ppis+num_sel_pis+num_undc_pis);
382 assert(Gia_ManPiNum(pGiaChoice)==pCex->nPis+num_sel_pis);
385 pFrames->
pName = Abc_UtilStrsav( pGiaChoice->
pName );
387 Gia_ManConst0(pGiaChoice)->Value = 0;
391 for ( f = 0; f <= pCex->iFrame; f++ )
393 for( i = 0; i < Gia_ManPiNum(pGiaChoice); i++ )
395 if ( i >= nbits_old_pis && i < nbits_old_pis + num_ppis + num_sel_pis )
397 is_sel_pi = sel_pi_first ? (i < nbits_old_pis + num_sel_pis) : (i >= nbits_old_pis + num_ppis);
398 if( f == 0 && is_sel_pi )
399 Gia_ManPi(pGiaChoice, i)->Value = Gia_ManAppendCi(pFrames);
403 Gia_ManPi(pGiaChoice, i)->Value = Gia_ManAppendCi(pFrames);
405 Gia_ManPi(pGiaChoice, i)->Value = Abc_InfoHasBit(pCex->pData, pCex->nRegs+pCex->nPis*f + i + num_undc_pis);
408 else if (i < nbits_old_pis)
410 Gia_ManPi(pGiaChoice, i)->Value = Abc_InfoHasBit(pCex->pData, pCex->nRegs+pCex->nPis*f + i);
412 else if (i >= nbits_old_pis + num_ppis + num_sel_pis)
414 Gia_ManPi(pGiaChoice, i)->Value = Abc_InfoHasBit(pCex->pData, pCex->nRegs+pCex->nPis*f + i - num_sel_pis - num_ppis);
422 pObj->
Value = Gia_ObjFanin0Copy(pObj);
424 Gia_ManAppendCo(pFrames, pObj->
Value);
438 Vec_Int_t * vNodes = Vec_IntDup( vBlacks );
441 int i, k, iObj, iFanin;
443 Vec_Int_t * vMapNode2Pi = Vec_IntStart( Wlc_NtkObjNumMax(pNtk) );
444 Vec_Int_t * vMapNode2Sel = Vec_IntStart( Wlc_NtkObjNumMax(pNtk) );
445 int nOrigObjNum = Wlc_NtkObjNumMax( pNtk );
452 Vec_IntWriteEntry(vNodes, i, Wlc_ObjCopy(pNtk, Wlc_ObjId(pNtk, pObj)));
457 vPPIMark = Vec_BitStart( Wlc_NtkObjNumMax(pNtk) );
460 Vec_IntWriteEntry(vPPIs, i, Wlc_ObjCopy(pNtk, Wlc_ObjId(pNtk, pObj)));
461 Vec_BitWriteEntry( vPPIMark, Vec_IntEntry(vPPIs, i), 1 );
466 Wlc_NtkCleanCopy(
p );
471 iObj = Wlc_ObjId(
p, pObj);
474 Vec_IntWriteEntry( vMapNode2Pi, iObj,
Wlc_ObjAlloc(
p,
WLC_OBJ_PI, Wlc_ObjIsSigned(pObj), Wlc_ObjRange(pObj) - 1, 0 ) );
481 iObj = Wlc_ObjId(
p, pObj);
484 Vec_IntWriteEntry( vMapNode2Pi, iObj,
Wlc_ObjAlloc(
p,
WLC_OBJ_PI, Wlc_ObjIsSigned(pObj), Wlc_ObjRange(pObj) - 1, 0 ) );
491 iObj = Wlc_ObjId(
p, pObj );
499 if ( i == nOrigObjNum )
507 Wlc_ObjFanins(pObj)[k] = Wlc_ObjCopy(
p, iFanin);
516 if ( vPPIMark && Vec_BitEntry(vPPIMark, i) )
517 iObj = Vec_IntEntry( vMapNode2Pi, i );
520 isSigned = Wlc_ObjIsSigned(pObj);
521 range = Wlc_ObjRange(pObj);
522 Vec_IntClear(vFanins);
523 Vec_IntPush(vFanins, Vec_IntEntry( vMapNode2Sel, i) );
524 Vec_IntPush(vFanins, Vec_IntEntry( vMapNode2Pi, i ) );
525 Vec_IntPush(vFanins, i);
530 Wlc_ObjSetCopy(
p, i, iObj );
535 iObj = Wlc_ObjId(
p, pObj);
536 if (iObj != Wlc_ObjCopy(
p, iObj))
539 Wlc_NtkObj(
p, Wlc_ObjCopy(
p, iObj))->fIsFi = 1;
541 Wlc_NtkObj(
p, Wlc_ObjCopy(
p, iObj))->fIsPo = 1;
543 Vec_IntWriteEntry(&
p->vCos, i, Wlc_ObjCopy(
p, iObj));
551 Vec_BitFree( vPPIMark );
552 Vec_IntFree( vFanins );
553 Vec_IntFree( vMapNode2Pi );
554 Vec_IntFree( vMapNode2Sel );
555 Vec_IntFree( vNodes );
566 Abc_Cex_t * pCexReal =
Abc_CexAlloc( Gia_ManRegNum(pGiaOrig), Gia_ManPiNum(pGiaOrig), pCex->iFrame + 1 );
568 Gia_ManConst0(pGiaOrig)->Value = 0;
571 for ( f = 0; f <= pCex->iFrame; f++ )
573 for( i = 0; i < Gia_ManPiNum( pGiaOrig ); i++ )
575 Gia_ManPi(pGiaOrig, i)->Value = Abc_InfoHasBit(pCex->pData, pCex->nRegs+pCex->nPis*f + i);
576 if ( Gia_ManPi(pGiaOrig, i)->Value )
577 Abc_InfoSetBit(pCexReal->pData, pCexReal->nRegs + pCexReal->nPis*f + i);
582 pObj->
Value = Gia_ObjFanin0Copy(pObj) & Gia_ObjFanin1Copy(pObj);
584 pObj->
Value = Gia_ObjFanin0Copy(pObj);
587 if (pObj->
Value==1) {
588 Abc_Print( 1,
"CEX is real on the original model.\n" );
590 pCexReal->iFrame = f;
605 Vec_Int_t * vFlops = Vec_IntAlloc( 100 );
606 Vec_Int_t * vNodes = Vec_IntDup( vBlacks );
609 int i, k, iObj, iFanin;
610 Vec_Int_t * vMapNode2Pi = Vec_IntStart( Wlc_NtkObjNumMax(pNtk) );
611 int nOrigObjNum = Wlc_NtkObjNumMax( pNtk );
616 if ( !Wlc_ObjIsPi( pObj ) )
617 Vec_IntPush( vFlops, Wlc_ObjId( pNtk, pObj ) );
621 Vec_IntWriteEntry(vNodes, i, Wlc_ObjCopy(pNtk, Wlc_ObjId(pNtk, pObj)));
626 iObj = Wlc_ObjId(
p, pObj);
629 Vec_IntWriteEntry( vMapNode2Pi, iObj,
Wlc_ObjAlloc(
p,
WLC_OBJ_PI, Wlc_ObjIsSigned(pObj), Wlc_ObjRange(pObj) - 1, 0 ) );
632 Wlc_NtkCleanCopy(
p );
636 if ( i == nOrigObjNum )
642 iObj = Vec_IntEntry( vMapNode2Pi, i );
647 Wlc_ObjFanins(pObj)[k] = Wlc_ObjCopy(
p, iFanin);
651 Wlc_ObjSetCopy(
p, i, iObj );
656 iObj = Wlc_ObjId(
p, pObj);
657 if (iObj != Wlc_ObjCopy(
p, iObj))
660 Wlc_NtkObj(
p, Wlc_ObjCopy(
p, iObj))->fIsFi = 1;
662 Wlc_NtkObj(
p, Wlc_ObjCopy(
p, iObj))->fIsPo = 1;
665 Vec_IntWriteEntry(&
p->vCos, i, Wlc_ObjCopy(
p, iObj));
670 Vec_IntFree( vMapNode2Pi );
671 Vec_IntFree( vNodes );
677 Vec_IntFree( vFlops );
692 assert( vWhites && Vec_IntSize(vWhites) );
695 first_sel_pi =
Wlc_NtkNumPiBits( pNtkWithChoices ) - Vec_IntSize( vWhites );
696 pGiaFrames = Wlc_NtkUnrollWoCex( pNtkWithChoices, nFrames, first_sel_pi, Vec_IntSize( vWhites ) );
698 vChoiceMark = Vec_BitStartFull( Vec_IntSize( vWhites ) );
699 vCoreSels = Wlc_NtkGetCoreSels( pGiaFrames, nFrames, first_sel_pi, Vec_IntSize( vWhites ), vChoiceMark, 0, pPars, 0, RunId );
704 if ( vCoreSels == NULL )
707 Vec_BitReset( vChoiceMark );
709 Vec_BitWriteEntry( vChoiceMark, Entry, 1 );
711 Abc_Print( 1,
"ProofReduce: remove %d out of %d white boxes.", Vec_IntSize(vWhites) - Vec_BitCount(vChoiceMark), Vec_IntSize(vWhites) );
712 Abc_PrintTime( 1,
" Time", Abc_Clock() - clk );
714 Vec_IntFree( vCoreSels );
729 if ( *pvRefine == NULL )
732 vUnmark = Vec_BitStart( Wlc_NtkObjNumMax(
p ) );
733 vChoiceMark = Vec_BitStart( Vec_IntSize( vBlacks ) );
736 Vec_BitWriteEntry( vUnmark, Entry, 1 );
740 if ( Vec_BitEntry( vUnmark, Entry ) )
741 Vec_BitWriteEntry( vChoiceMark, i, 1 );
745 pGiaFrames = Wlc_NtkUnrollWithCex( pNtkWithChoices, pCex,
Wlc_NtkNumPiBits(
p ), Vec_IntSize( vBlacks ), &num_ppis, 0, pPars->
fProofUsePPI );
748 vCoreSels = Wlc_NtkGetCoreSels( pGiaFrames, pCex->iFrame+1, num_ppis, Vec_IntSize( vBlacks ), vChoiceMark, 0, pPars, 0, -1 );
750 vCoreSels = Wlc_NtkGetCoreSels( pGiaFrames, pCex->iFrame+1, 0, Vec_IntSize( vBlacks ), vChoiceMark, 0, pPars, 0, -1 );
754 Vec_BitFree( vUnmark );
755 Vec_BitFree( vChoiceMark );
757 assert( Vec_IntSize( vCoreSels ) );
759 vRefine = Vec_IntAlloc( 100 );
761 Vec_IntPush( vRefine, Vec_IntEntry( vBlacks, Entry ) );
763 Vec_IntFree( vCoreSels );
766 Abc_Print( 1,
"Proof-based refinement reduces %d (out of %d) white boxes\n", Vec_IntSize( *pvRefine ) - Vec_IntSize( vRefine ), Vec_IntSize( *pvRefine ) );
768 Vec_IntFree( *pvRefine );
778 Vec_Int_t * vBlacks = Vec_IntAlloc( 100 );
783 vVec = vSignals ? vSignals : *pvBlacks;
787 if ( Vec_BitEntry( vUnmark, Entry) )
789 Vec_IntPush( vBlacks, Entry );
791 pObj = Wlc_NtkObj(
p, Entry );
798 else if ( Wlc_ObjIsCi(pObj) && !Wlc_ObjIsPi(pObj) )
802 Vec_IntFree( *pvBlacks );
806 printf(
"Abstraction engine marked %d adds/subs, %d muls/divs, %d muxes, and %d flops to be abstracted away.\n", Count[0], Count[1], Count[2], Vec_IntSize( vBlacks ) - Count[0] - Count[1] - Count[2] );
814 Vec_Ptr_t * vAdds = Vec_PtrAlloc( 1000 );
815 Vec_Ptr_t * vMuxes = Vec_PtrAlloc( 1000 );
816 Vec_Ptr_t * vMults = Vec_PtrAlloc( 1000 );
817 Vec_Ptr_t * vFlops = Vec_PtrAlloc( 1000 );
824 vMarks = Vec_BitStart( Wlc_NtkObjNumMax(
p ) );
830 if ( Wlc_ObjRange(pObj) >= pPars->
nBitsAdd )
834 pPair->
second = Wlc_ObjRange( pObj );
835 Vec_PtrPush( vAdds, pPair );
840 if ( Wlc_ObjRange(pObj) >= pPars->
nBitsMul )
844 pPair->
second = Wlc_ObjRange( pObj );
845 Vec_PtrPush( vMults, pPair );
850 if ( Wlc_ObjRange(pObj) >= pPars->
nBitsMux )
854 pPair->
second = Wlc_ObjRange( pObj );
855 Vec_PtrPush( vMuxes, pPair );
858 else if ( Wlc_ObjIsCi(pObj) && !Wlc_ObjIsPi(pObj) )
860 if ( Wlc_ObjRange(pObj) >= pPars->
nBitsFlop )
864 pPair->
second = Wlc_ObjRange( pObj );
865 Vec_PtrPush( vFlops, pPair );
877 if ( i >= pPars->
nLimit )
break;
878 Vec_BitWriteEntry( vMarks, pPair->
first, 1 );
880 if ( i && pPars->
fVerbose ) Abc_Print( 1,
"%%PDRA: %d-th ADD has width = %d\n", i, pPair->
second );
884 if ( i >= pPars->
nLimit )
break;
885 Vec_BitWriteEntry( vMarks, pPair->
first, 1 );
887 if ( i && pPars->
fVerbose ) Abc_Print( 1,
"%%PDRA: %d-th MUL has width = %d\n", i, pPair->
second );
891 if ( i >= pPars->
nLimit )
break;
892 Vec_BitWriteEntry( vMarks, pPair->
first, 1 );
894 if ( i && pPars->
fVerbose ) Abc_Print( 1,
"%%PDRA: %d-th MUX has width = %d\n", i, pPair->
second );
898 if ( i >= pPars->
nLimit )
break;
899 Vec_BitWriteEntry( vMarks, pPair->
first, 1 );
901 if ( i && pPars->
fVerbose ) Abc_Print( 1,
"%%PDRA: %d-th FF has width = %d\n", i, pPair->
second );
908 Vec_PtrFree( vAdds );
909 Vec_PtrFree( vMults );
910 Vec_PtrFree( vMuxes );
911 Vec_PtrFree( vFlops );
919 Vec_Bit_t * vMarks = Wlc_NtkMarkLimit(
p, pPars );
922 Vec_BitWriteEntry( vUnmark, i, Entry^1 );
924 Vec_BitFree( vMarks );
929 Vec_Int_t * vBlacks = Vec_IntAlloc( 100 ) ;
934 vMarks = Wlc_NtkMarkLimit(
p, pPars ) ;
940 if ( Wlc_ObjRange(pObj) >= pPars->
nBitsAdd )
943 if ( vMarks == NULL )
944 Vec_IntPushUniqueOrder( vBlacks, Wlc_ObjId(
p, pObj) ), Count[0]++;
945 else if ( Vec_BitEntry( vMarks, i ) )
946 Vec_IntPushUniqueOrder( vBlacks, Wlc_ObjId(
p, pObj) ), Count[0]++;
952 if ( Wlc_ObjRange(pObj) >= pPars->
nBitsMul )
955 if ( vMarks == NULL )
956 Vec_IntPushUniqueOrder( vBlacks, Wlc_ObjId(
p, pObj) ), Count[1]++;
957 else if ( Vec_BitEntry( vMarks, i ) )
958 Vec_IntPushUniqueOrder( vBlacks, Wlc_ObjId(
p, pObj) ), Count[1]++;
964 if ( Wlc_ObjRange(pObj) >= pPars->
nBitsMux )
967 if ( vMarks == NULL )
968 Vec_IntPushUniqueOrder( vBlacks, Wlc_ObjId(
p, pObj) ), Count[2]++;
969 else if ( Vec_BitEntry( vMarks, i ) )
970 Vec_IntPushUniqueOrder( vBlacks, Wlc_ObjId(
p, pObj) ), Count[2]++;
974 if ( Wlc_ObjIsCi(pObj) && !Wlc_ObjIsPi(pObj) )
976 if ( Wlc_ObjRange(pObj) >= pPars->
nBitsFlop )
979 if ( vMarks == NULL )
980 Vec_IntPushUniqueOrder( vBlacks, Wlc_ObjId(
p, Wlc_ObjFo2Fi(
p, pObj ) ) ), Count[3]++;
981 else if ( Vec_BitEntry( vMarks, i ) )
982 Vec_IntPushUniqueOrder( vBlacks, Wlc_ObjId(
p, Wlc_ObjFo2Fi(
p, pObj ) ) ), Count[3]++;
988 Vec_BitFree( vMarks );
990 printf(
"Abstraction engine marked %d adds/subs, %d muls/divs, %d muxes, and %d flops to be abstracted away (out of %d signals).\n", Count[0], Count[1], Count[2], Count[3],
nTotal );
1010 Vec_Bit_t * vLeaves = Vec_BitStart( Wlc_NtkObjNumMax(
p) );
1011 Wlc_Obj_t * pObj;
int i, Count[4] = {0};
1014 if ( vUnmark && Vec_BitEntry(vUnmark, i) )
1018 if ( Wlc_ObjRange(pObj) >= pPars->
nBitsAdd )
1019 Vec_BitWriteEntry( vLeaves, Wlc_ObjId(
p, pObj), 1 ), Count[0]++;
1024 if ( Wlc_ObjRange(pObj) >= pPars->
nBitsMul )
1025 Vec_BitWriteEntry( vLeaves, Wlc_ObjId(
p, pObj), 1 ), Count[1]++;
1030 if ( Wlc_ObjRange(pObj) >= pPars->
nBitsMux )
1031 Vec_BitWriteEntry( vLeaves, Wlc_ObjId(
p, pObj), 1 ), Count[2]++;
1034 if ( Wlc_ObjIsCi(pObj) && !Wlc_ObjIsPi(pObj) )
1036 if ( Wlc_ObjRange(pObj) >= pPars->
nBitsFlop )
1037 Vec_BitWriteEntry( vLeaves, Wlc_ObjId(
p, pObj), 1 ), Count[3]++;
1042 printf(
"Abstraction engine marked %d adds/subs, %d muls/divs, %d muxes, and %d flops to be abstracted away.\n", Count[0], Count[1], Count[2], Count[3] );
1066 if ( Vec_BitEntry(vLeaves, Wlc_ObjId(
p, pObj)) )
1068 assert( !Wlc_ObjIsPi(pObj) );
1069 Vec_IntPush( vPisNew, Wlc_ObjId(
p, pObj) );
1072 if ( Wlc_ObjIsCi(pObj) )
1074 if ( Wlc_ObjIsPi(pObj) )
1075 Vec_IntPush( vPisOld, Wlc_ObjId(
p, pObj) );
1077 Vec_IntPush( vFlops, Wlc_ObjId(
p, pObj) );
1081 Wlc_NtkAbsMarkNodes_rec(
p, Wlc_NtkObj(
p, iFanin), vLeaves, vPisOld, vPisNew, vFlops );
1089 Wlc_NtkAbsMarkNodes_rec(
p, pObj, vLeaves, vPisOld, vPisNew, vFlops );
1102 Wlc_NtkAbsMarkNodes_rec(
p, Wlc_ObjFo2Fi(
p, pObj), vLeaves, vPisOld, vPisNew, vFlops );
1104 Count += pObj->
Mark;
1108 Vec_IntSort( vPisOld, 0 );
1109 Vec_IntSort( vPisNew, 0 );
1110 Vec_IntSort( vFlops, 0 );
1132 Vec_Int_t * vPisOld = Vec_IntAlloc( 100 );
1133 Vec_Int_t * vPisNew = Vec_IntAlloc( 100 );
1134 Vec_Int_t * vFlops = Vec_IntAlloc( 100 );
1135 Vec_Bit_t * vLeaves = Wlc_NtkAbsMarkOpers(
p, pPars, vUnmark, fVerbose );
1136 Wlc_NtkAbsMarkNodes(
p, vLeaves, vPisOld, vPisNew, vFlops );
1137 Vec_BitFree( vLeaves );
1139 Vec_IntFree( vPisOld );
1143 Vec_IntFree( vFlops );
1145 *pvPisNew = vPisNew;
1147 Vec_IntFree( vPisNew );
1167 Vec_Int_t * vRefine = Vec_IntAlloc( 100 );
1171 int f, i, b, nRealPis, nPpiBits = 0;
1172 Vec_Int_t * vMap = Vec_IntStartFull( pCex->nPis );
1174 for ( b = 0; b < Wlc_ObjRange(pObj); b++ )
1175 Vec_IntWriteEntry( vMap, nPpiBits++, Wlc_ObjId(
p, pObj) );
1177 nRealPis = pCex->nPis - nPpiBits;
1180 assert( pCexCare->nPis == pCex->nPis );
1182 for ( f = 0; f <= pCexCare->iFrame; f++ )
1183 for ( i = nRealPis; i < pCexCare->nPis; i++ )
1184 if ( Abc_InfoHasBit(pCexCare->pData, pCexCare->nRegs + pCexCare->nPis * f + i) )
1185 Vec_IntPushUniqueOrder( vRefine, Vec_IntEntry(vMap, i-nRealPis) );
1187 Vec_IntFree( vMap );
1188 if ( Vec_IntSize(vRefine) == 0 )
1189 Vec_IntFreeP( &vRefine );
1207 int i, Fanin, Counter = 1;
1208 if ( Wlc_ObjIsCi(pNode) )
1210 Vec_BitWriteEntry( vUnmark, Wlc_ObjId(
p, pNode), 1 );
1213 Vec_IntAddToEntry( &
p->vRefs, Fanin, -1 );
1214 if ( Vec_IntEntry(&
p->vRefs, Fanin) == 0 )
1215 Counter += Wlc_NtkNodeDeref_rec(
p, Wlc_NtkObj(
p, Fanin), vUnmark );
1221 int i, Fanin, Counter = 1;
1222 if ( Wlc_ObjIsCi(pNode) )
1226 if ( Vec_IntEntry(&
p->vRefs, Fanin) == 0 )
1227 Counter += Wlc_NtkNodeRef_rec(
p, Wlc_NtkObj(
p, Fanin) );
1228 Vec_IntAddToEntry( &
p->vRefs, Fanin, 1 );
1236 while ( Wlc_ObjIsCi(pNode) )
1238 Vec_BitWriteEntry( vUnmark, Wlc_ObjId(
p, pNode), 1 );
1239 pNode = Wlc_ObjFo2Fi(
p, pNode);
1241 assert( !Wlc_ObjIsCi(pNode) );
1243 Count1 = Wlc_NtkNodeDeref_rec(
p, pNode, vUnmark );
1245 Count2 = Wlc_NtkNodeRef_rec(
p, pNode );
1246 assert( Count1 == Count2 );
1252 if ( Vec_IntSize(&
p->vRefs) == 0 )
1255 nNodes += Wlc_NtkMarkMffc(
p, pObj, vUnmark );
1264 Vec_BitWriteEntry( vUnmark, Wlc_ObjId(
p, pObj), 1 );
1286 Vec_Int_t * vMap = Vec_IntAlloc( 1000 );
1287 Vec_Int_t * vMapFfNew2Bit1 = Vec_IntAlloc( 1000 );
1288 int i, b, iFfOld, iFfNew, iBit1New, nBits = 0;
1290 Vec_Int_t * vMapFfObj2FfId = Vec_IntStartFull( Wlc_NtkObjNumMax(
p) );
1292 Vec_IntWriteEntry( vMapFfObj2FfId, iFfNew, i );
1297 int nRange = Wlc_ObjRange( pObj );
1298 Vec_IntPush( vMapFfNew2Bit1, nBits );
1301 assert( Vec_IntSize(vMapFfNew2Bit1) == Vec_IntSize(vFfNew) );
1306 int nRange = Wlc_ObjRange( pObj );
1307 iFfNew = Vec_IntEntry( vMapFfObj2FfId, iFfOld );
1310 iBit1New = Vec_IntEntry( vMapFfNew2Bit1, iFfNew );
1311 for ( b = 0; b < nRange; b++ )
1312 Vec_IntPush( vMap, iBit1New + b );
1314 Vec_IntFree( vMapFfNew2Bit1 );
1315 Vec_IntFree( vMapFfObj2FfId );
1337 vNodes = Vec_IntAlloc( 100 );
1340 if ( !fBlack && Vec_BitEntry(pWla->
vUnmark, Entry) )
1341 Vec_IntPush( vNodes, Entry );
1343 if ( fBlack && !Vec_BitEntry(pWla->
vUnmark, Entry) )
1344 Vec_IntPush( vNodes, Entry );
1357 Vec_Bit_t * vCoreMarks = Wlc_NtkProofReduce( pWla->
p, pWla->
pPars, nFrames, vWhites, vBlacks, RunId );
1359 if ( vCoreMarks == NULL )
1361 Vec_IntFree( vWhites );
1362 Vec_IntFree( vBlacks );
1366 RetValue = Vec_IntSize( vWhites ) != Vec_BitCount( vCoreMarks );
1369 if ( !Vec_BitEntry( vCoreMarks, i ) )
1370 Vec_BitWriteEntry( pWla->
vUnmark, Entry, 0 );
1372 Vec_IntFree( vWhites );
1373 Vec_IntFree( vBlacks );
1374 Vec_BitFree( vCoreMarks );
1393 pAbs = Wlc_NtkAbs2( pWla->
p, pWla->
vBlacks, NULL );
1424 printf(
"Derived abstraction with %d objects and %d PPIs. Bit-blasted AIG stats are:\n", Wlc_NtkObjNum(pAbs), Vec_IntSize(pWla->
vBlacks) );
1441 if ( Aig_ManAndNum( pAig ) <= 20000 )
1444 Ssw_Pars_t ScorrPars, * pScorrPars = &ScorrPars;
1450 pScorrPars->fStopWhenGone = 1;
1451 pScorrPars->nFramesK = 1;
1454 nAnds = Aig_ManAndNum( pAigScorr);
1460 Abc_PrintTime( 1,
"SCORR proved UNSAT. Time", Abc_Clock() - clk );
1465 Abc_Print( 1,
"SCORR failed with %d ANDs. ", nAnds);
1466 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
1472 pPdrPars->fVerbose = 0;
1478 pWla->
tPdr += Abc_Clock() - clk;
1498 if ( RetValue == 1 )
1501 Abc_PrintTime( 1,
"ABS becomes combinationally UNSAT. Time", Abc_Clock() - clk );
1506 Abc_PrintTime( 1,
"Check comb. unsat failed. Time", Abc_Clock() - clk );
1511 pPdrPars->RunId = RunId;
1531 pPdr->
tTotal += Abc_Clock() - clk;
1543 pWla->
pCex = pBmcCex ;
1547 pWla->
pCex = pAig->pSeqModel;
1548 pAig->pSeqModel = NULL;
1552 if ( pWla->
pCex == NULL )
1559 pCexReal = Wlc_NtkCexIsReal( pWla->
p, pWla->
pCex );
1563 pWla->
pCex = pCexReal;
1589 vRefine = Wlc_NtkAbsRefinement( pWla->
p, pWla->
pGia, pWla->
pCex, pWla->
vBlacks );
1590 pWla->
tCbr += Abc_Clock() - clk;
1594 vRefine = Vec_IntDup( pWla->
vBlacks );
1599 Wlc_NtkProofRefine( pWla->
p, pWla->
pPars, pWla->
pCex, pWla->
vBlacks, &vRefine );
1600 pWla->
tPbr += Abc_Clock() - clk;
1615 nNodes = Wlc_NtkRemoveFromAbstraction( pWla->
p, vRefine, pWla->
vUnmark );
1617 printf(
"Refinement of CEX in frame %d came up with %d un-abstacted PPIs, whose MFFCs include %d objects.\n", pWla->
pCex->iFrame, Vec_IntSize(vRefine), nNodes );
1621 nNodes = Wlc_NtkUnmarkRefinement( pWla->
p, vRefine, pWla->
vUnmark );
1623 printf(
"Refinement of CEX in frame %d came up with %d un-abstacted PPIs.\n", pWla->
pCex->iFrame, Vec_IntSize(vRefine) );
1633 pWla->
tCbr += Abc_Clock() - clk;
1648 Vec_IntFree( vRefine );
1659 p->vUnmark = Vec_BitStart( Wlc_NtkObjNumMax(pNtk) );
1664 pPdrPars->fVeryVerbose = 0;
1666 pPdrPars->RunId = pPars->
RunId;
1669 pPdrPars->fUseAbs = 1;
1670 pPdrPars->fCtgs = 1;
1671 pPdrPars->fSkipDown = 0;
1672 pPdrPars->nRestLimit = 500;
1674 p->pPdrPars = (
void *)pPdrPars;
1689 if (
p->vBlacks ) Vec_IntFree(
p->vBlacks );
1690 if (
p->vSignals ) Vec_IntFree(
p->vSignals );
1693 Vec_BitFree(
p->vUnmark );
1711 printf(
"\nIteration %d:\n", pWla->
nIters );
1730 printf(
"Abstraction " );
1731 if ( RetValue == 0 )
1732 printf(
"resulted in a real CEX" );
1733 else if ( RetValue == 1 )
1734 printf(
"is successfully proved" );
1736 printf(
"timed out" );
1737 printf(
" after %d iterations. ", pWla->
nIters );
1738 tTotal = Abc_Clock() - clk;
1739 Abc_PrintTime( 1,
"Time", tTotal );
1742 Abc_Print( 1,
"PDRA reused %d clauses.\n", pWla->
nTotalCla );
1749 ABC_PRTP(
"Total ", tTotal, tTotal );
1790 int nIters, nNodes, nDcFlops, RetValue = -1;
1793 Vec_Bit_t * vUnmark = Vec_BitStart( Wlc_NtkObjNumMax(
p) );
1795 Pdr_Par_t PdrPars, * pPdrPars = &PdrPars;
1802 pPdrPars->fVeryVerbose = 0;
1804 for ( nIters = 1; nIters < pPars->
nIterMax; nIters++ )
1813 printf(
"\nIteration %d:\n", nIters );
1818 if ( vBlacks == NULL )
1819 vBlacks = Wlc_NtkGetBlacks(
p, pPars );
1821 Wlc_NtkUpdateBlacks(
p, pPars, &vBlacks, vUnmark, NULL );
1822 pAbs = Wlc_NtkAbs2(
p, vBlacks, NULL );
1823 vPisNew = Vec_IntDup( vBlacks );
1828 Wlc_NtkSetUnmark(
p, pPars, vUnmark );
1830 pAbs = Wlc_NtkAbs(
p, pPars, vUnmark, &vPisNew, NULL, pPars->
fVerbose );
1852 printf(
"Derived abstraction with %d objects and %d PPIs. Bit-blasted AIG stats are:\n", Wlc_NtkObjNum(pAbs), Vec_IntSize(vPisNew) );
1860 pCex = pAig->pSeqModel; pAig->pSeqModel = NULL;
1868 Vec_IntFree( vPisNew );
1873 vRefine = Wlc_NtkAbsRefinement(
p, pGia, pCex, vPisNew );
1875 Vec_IntFree( vPisNew );
1876 if ( vRefine == NULL )
1883 nNodes = Wlc_NtkRemoveFromAbstraction(
p, vRefine, vUnmark );
1885 printf(
"Refinement of CEX in frame %d came up with %d un-abstacted PPIs, whose MFFCs include %d objects.\n", pCex->iFrame, Vec_IntSize(vRefine), nNodes );
1886 Vec_IntFree( vRefine );
1889 Vec_IntFreeP( &vBlacks );
1890 Vec_BitFreeP( &vUnmark );
1894 printf(
"Abstraction " );
1895 if ( RetValue == 0 )
1896 printf(
"resulted in a real CEX" );
1897 else if ( RetValue == 1 )
1898 printf(
"is successfully proved" );
1900 printf(
"timed out" );
1901 printf(
" after %d iterations. ", nIters );
1902 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
#define ABC_ALLOC(type, num)
#define ABC_PRTP(a, t, T)
#define ABC_INFINITY
MACRO DEFINITIONS ///.
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Aig_Man_t * Aig_ManDupSimple(Aig_Man_t *p)
DECLARATIONS ///.
void Aig_ManStop(Aig_Man_t *p)
struct Aig_Obj_t_ Aig_Obj_t
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
#define Aig_ManForEachCo(p, pObj, i)
int nTotal
DECLARATIONS ///.
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Abc_Cex_t * Bmc_CexCareMinimizeAig(Gia_Man_t *p, int nRealPis, Abc_Cex_t *pCex, int nTryCexes, int fCheck, int fVerbose)
#define sat_solver_addclause
Cnf_Dat_t * Cnf_Derive(Aig_Man_t *pAig, int nOutputs)
struct Cnf_Dat_t_ Cnf_Dat_t
Aig_Man_t * Gia_ManToAigSimple(Gia_Man_t *p)
void Gia_ManStop(Gia_Man_t *p)
Gia_Man_t * Gia_ManPermuteInputs(Gia_Man_t *p, int nPpis, int nExtra)
#define Gia_ManForEachPo(p, pObj, i)
#define Gia_ManForEachAnd(p, pObj, i)
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
void Gia_ManHashAlloc(Gia_Man_t *p)
Gia_Man_t * Gia_ManStart(int nObjsMax)
FUNCTION DEFINITIONS ///.
struct Gia_Obj_t_ Gia_Obj_t
struct Gia_Man_t_ Gia_Man_t
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Gia_Man_t * Gia_ManTransformMiter2(Gia_Man_t *p)
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
#define Gia_ManForEachCo(p, pObj, i)
#define Gia_ManForEachRiRo(p, pObjRi, pObjRo, i)
void Gia_ManHashStop(Gia_Man_t *p)
void Gia_ManPrintStats(Gia_Man_t *p, Gps_Par_t *pPars)
#define Gia_ManForEachRi(p, pObj, i)
Pdr_Man_t * Pdr_ManStart(Aig_Man_t *pAig, Pdr_Par_t *pPars, Vec_Int_t *vPrioInit)
void Pdr_ManStop(Pdr_Man_t *p)
struct Pdr_Man_t_ Pdr_Man_t
void Pdr_ManSetDefaultParams(Pdr_Par_t *pPars)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Pdr_Par_t_ Pdr_Par_t
INCLUDES ///.
int Pdr_ManSolve(Aig_Man_t *p, Pdr_Par_t *pPars)
sat_solver * sat_solver_new(void)
void sat_solver_setnvars(sat_solver *s, int n)
void sat_solver_delete(sat_solver *s)
void Ssw_ManSetDefaultParams(Ssw_Pars_t *p)
DECLARATIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Ssw_Pars_t_ Ssw_Pars_t
INCLUDES ///.
Aig_Man_t * Ssw_SignalCorrespondence(Aig_Man_t *pAig, Ssw_Pars_t *pPars)
void Abc_CexFree(Abc_Cex_t *p)
ABC_NAMESPACE_IMPL_START Abc_Cex_t * Abc_CexAlloc(int nRegs, int nRealPis, int nFrames)
DECLARATIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.
#define Vec_BitForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Bit_t_ Vec_Bit_t
INCLUDES ///.
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
#define Vec_VecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
void Wla_ManStop(Wla_Man_t *p)
void Wla_ManJoinThread(Wla_Man_t *pWla, int RunId)
Aig_Man_t * Wla_ManBitBlast(Wla_Man_t *pWla, Wlc_Ntk_t *pAbs)
int IPdr_ManSolveInt(Pdr_Man_t *p, int fCheckClauses, int fPushClauses)
int Wlc_NtkNumPiBits(Wlc_Ntk_t *pNtk)
int IPdr_ManReduceClauses(Pdr_Man_t *p, Vec_Vec_t *vClauses)
int IPdr_ManCheckCombUnsat(Pdr_Man_t *p)
int IPdr_ManRebuildClauses(Pdr_Man_t *p, Vec_Vec_t *vClauses)
int Wla_CallBackToStop(int RunId)
void Wla_ManRefine(Wla_Man_t *pWla)
int IPdr_ManRestoreClauses(Pdr_Man_t *p, Vec_Vec_t *vClauses, Vec_Int_t *vMap)
int Wlc_NtkPdrAbs(Wlc_Ntk_t *p, Wlc_Par_t *pPars)
int IntPairPtrCompare(Int_Pair_t **a, Int_Pair_t **b)
int Wlc_NtkAbsCore(Wlc_Ntk_t *p, Wlc_Par_t *pPars)
FUNCTION DECLARATIONS ///.
void Wlc_NtkPrintNtk(Wlc_Ntk_t *p)
FUNCTION DEFINITIONS ///.
Vec_Int_t * Wlc_NtkFlopsRemap(Wlc_Ntk_t *p, Vec_Int_t *vFfOld, Vec_Int_t *vFfNew)
Wla_Man_t * Wla_ManStart(Wlc_Ntk_t *pNtk, Wlc_Par_t *pPars)
int Wla_ManSolveInt(Wla_Man_t *pWla, Aig_Man_t *pAig)
int Wla_ManSolve(Wla_Man_t *pWla, Wlc_Par_t *pPars)
void Wlc_NtkAbsGetSupp(Wlc_Ntk_t *p, Wlc_Obj_t *pObj, Vec_Bit_t *vCiMarks, Vec_Int_t *vSuppRefs, Vec_Int_t *vSuppList)
struct Int_Pair_t_ Int_Pair_t
Wlc_Ntk_t * Wlc_NtkIntroduceChoices(Wlc_Ntk_t *pNtk, Vec_Int_t *vBlacks, Vec_Int_t *vPPIs)
void IPdr_ManPrintClauses(Vec_Vec_t *vClauses, int kStart, int nRegs)
void Wla_ManConcurrentBmc3(Wla_Man_t *pWla, Aig_Man_t *pAig, Abc_Cex_t **ppCex)
int Wla_ManShrinkAbs(Wla_Man_t *pWla, int nFrames, int RunId)
int Wla_ManCheckCombUnsat(Wla_Man_t *pWla, Aig_Man_t *pAig)
void Wlc_NtkAbsGetSupp_rec(Wlc_Ntk_t *p, Wlc_Obj_t *pObj, Vec_Bit_t *vCiMarks, Vec_Int_t *vSuppRefs, Vec_Int_t *vSuppList)
Wlc_Ntk_t * Wla_ManCreateAbs(Wla_Man_t *pWla)
Vec_Int_t * Wla_ManCollectNodes(Wla_Man_t *pWla, int fBlack)
void Wlc_NtkAbsAnalyzeRefine(Wlc_Ntk_t *p, Vec_Int_t *vBlacks, Vec_Bit_t *vUnmark, int *nDisj, int *nNDisj)
ABC_NAMESPACE_IMPL_START Vec_Vec_t * IPdr_ManSaveClauses(Pdr_Man_t *p, int fDropLast)
DECLARATIONS ///.
struct Wlc_Par_t_ Wlc_Par_t
Wlc_Ntk_t * Wlc_NtkDupDfsAbs(Wlc_Ntk_t *p, Vec_Int_t *vPisOld, Vec_Int_t *vPisNew, Vec_Int_t *vFlops)
#define Wlc_NtkForEachPo(p, pPo, i)
#define Wlc_NtkForEachCi(p, pCi, i)
Gia_Man_t * Wlc_NtkBitBlast(Wlc_Ntk_t *p, Wlc_BstPar_t *pPars)
void Wlc_NtkPrintNode(Wlc_Ntk_t *p, Wlc_Obj_t *pObj)
int Wlc_ObjAlloc(Wlc_Ntk_t *p, int Type, int Signed, int End, int Beg)
void Wlc_NtkCleanMarks(Wlc_Ntk_t *p)
#define Wlc_NtkForEachObjVec(vVec, p, pObj, i)
void Wlc_NtkFree(Wlc_Ntk_t *p)
void Wlc_NtkSetRefs(Wlc_Ntk_t *p)
#define Wlc_NtkForEachPi(p, pPi, i)
struct Wlc_Ntk_t_ Wlc_Ntk_t
#define Wlc_NtkForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
#define Wlc_ObjForEachFanin(pObj, iFanin, i)
int Wlc_ObjCreate(Wlc_Ntk_t *p, int Type, int Signed, int End, int Beg, Vec_Int_t *vFanins)
char * Wlc_ObjName(Wlc_Ntk_t *p, int iObj)
Wlc_Ntk_t * Wlc_NtkDupDfsSimple(Wlc_Ntk_t *p)
int Wlc_NtkCountObjBits(Wlc_Ntk_t *p, Vec_Int_t *vPisNew)
struct Wlc_Obj_t_ Wlc_Obj_t
BASIC TYPES ///.
#define Wlc_NtkForEachCo(p, pCo, i)
int Wlc_NtkDcFlopNum(Wlc_Ntk_t *p)
struct Wla_Man_t_ Wla_Man_t