/**Function************************************************************* Synopsis [Interface to the old CEC engine] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Cec_ManVerifyOld( Gia_Man_t * pMiter, int fVerbose, int * piOutFail, abctime clkTotal, int fSilent ) { // extern int Fra_FraigCec( Aig_Man_t ** ppAig, int nConfLimit, int fVerbose ); extern int Ssw_SecCexResimulate( Aig_Man_t * p, int * pModel, int * pnOutputs ); Gia_Man_t * pTemp = Gia_ManTransformMiter( pMiter ); Aig_Man_t * pMiterCec = Gia_ManToAig( pTemp, 0 ); int RetValue, iOut, nOuts; if ( piOutFail ) *piOutFail = -1; Gia_ManStop( pTemp ); // run CEC on this miter RetValue = Fra_FraigCec( &pMiterCec, 10000000, fVerbose ); // report the miter if ( RetValue == 1 ) { if ( !fSilent ) { Abc_Print( 1, "Networks are equivalent. " ); Abc_PrintTime( 1, "Time", Abc_Clock() - clkTotal ); } } else if ( RetValue == 0 ) { if ( !fSilent ) { Abc_Print( 1, "Networks are NOT EQUIVALENT. " ); Abc_PrintTime( 1, "Time", Abc_Clock() - clkTotal ); } if ( pMiterCec->pData == NULL ) Abc_Print( 1, "Counter-example is not available.\n" ); else { iOut = Ssw_SecCexResimulate( pMiterCec, (int *)pMiterCec->pData, &nOuts ); if ( iOut == -1 ) Abc_Print( 1, "Counter-example verification has failed.\n" ); else { if ( !fSilent ) { Abc_Print( 1, "Primary output %d has failed", iOut ); if ( nOuts-1 >= 0 ) Abc_Print( 1, ", along with other %d incorrect outputs", nOuts-1 ); Abc_Print( 1, ".\n" ); } if ( piOutFail ) *piOutFail = iOut; } Cec_ManTransformPattern( pMiter, iOut, (int *)pMiterCec->pData ); } } else if ( !fSilent ) { Abc_Print( 1, "Networks are UNDECIDED. " ); Abc_PrintTime( 1, "Time", Abc_Clock() - clkTotal ); } fflush( stdout ); Aig_ManStop( pMiterCec ); return RetValue; }
/**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Cec_ManHandleSpecialCases( Gia_Man_t * p, Cec_ParCec_t * pPars ) { Gia_Obj_t * pObj1, * pObj2; Gia_Obj_t * pDri1, * pDri2; int i; abctime clk = Abc_Clock(); Gia_ManSetPhase( p ); Gia_ManForEachPo( p, pObj1, i ) { pObj2 = Gia_ManPo( p, ++i ); // check if they different on all-0 pattern // (for example, when they have the same driver but complemented) if ( Gia_ObjPhase(pObj1) != Gia_ObjPhase(pObj2) ) { Abc_Print( 1, "Networks are NOT EQUIVALENT. Output %d trivially differs (different phase). ", i/2 ); Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); pPars->iOutFail = i/2; Cec_ManTransformPattern( p, i/2, NULL ); return 0; } // get the drivers pDri1 = Gia_ObjFanin0(pObj1); pDri2 = Gia_ObjFanin0(pObj2); // drivers are different PIs if ( Gia_ObjIsPi(p, pDri1) && Gia_ObjIsPi(p, pDri2) && pDri1 != pDri2 ) { Abc_Print( 1, "Networks are NOT EQUIVALENT. Output %d trivially differs (different PIs). ", i/2 ); Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); pPars->iOutFail = i/2; Cec_ManTransformPattern( p, i/2, NULL ); // if their compl attributes are the same - one should be complemented assert( Gia_ObjFaninC0(pObj1) == Gia_ObjFaninC0(pObj2) ); Abc_InfoSetBit( p->pCexComb->pData, Gia_ObjCioId(pDri1) ); return 0; } // one of the drivers is a PI; another is a constant 0 if ( (Gia_ObjIsPi(p, pDri1) && Gia_ObjIsConst0(pDri2)) || (Gia_ObjIsPi(p, pDri2) && Gia_ObjIsConst0(pDri1)) ) { Abc_Print( 1, "Networks are NOT EQUIVALENT. Output %d trivially differs (PI vs. constant). ", i/2 ); Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); pPars->iOutFail = i/2; Cec_ManTransformPattern( p, i/2, NULL ); // the compl attributes are the same - the PI should be complemented assert( Gia_ObjFaninC0(pObj1) == Gia_ObjFaninC0(pObj2) ); if ( Gia_ObjIsPi(p, pDri1) ) Abc_InfoSetBit( p->pCexComb->pData, Gia_ObjCioId(pDri1) ); else Abc_InfoSetBit( p->pCexComb->pData, Gia_ObjCioId(pDri2) ); return 0; } }
void Mpm_ManPrintStats( Mpm_Man_t * p ) { printf( "Memory usage: Mig = %.2f MB Map = %.2f MB Cut = %.2f MB Total = %.2f MB. ", 1.0 * Mig_ManObjNum(p->pMig) * sizeof(Mig_Obj_t) / (1 << 20), 1.0 * Mig_ManObjNum(p->pMig) * 48 / (1 << 20), 1.0 * Mmr_StepMemory(p->pManCuts) / (1 << 17), 1.0 * Mig_ManObjNum(p->pMig) * sizeof(Mig_Obj_t) / (1 << 20) + 1.0 * Mig_ManObjNum(p->pMig) * 48 / (1 << 20) + 1.0 * Mmr_StepMemory(p->pManCuts) / (1 << 17) ); if ( p->timeDerive ) { printf( "\n" ); p->timeTotal = Abc_Clock() - p->timeTotal; p->timeOther = p->timeTotal - p->timeDerive; Abc_Print( 1, "Runtime breakdown:\n" ); ABC_PRTP( "Complete cut computation ", p->timeDerive , p->timeTotal ); ABC_PRTP( "- Merging cuts ", p->timeMerge , p->timeTotal ); ABC_PRTP( "- Evaluting cut parameters ", p->timeEval , p->timeTotal ); ABC_PRTP( "- Checking cut containment ", p->timeCompare, p->timeTotal ); ABC_PRTP( "- Adding cuts to storage ", p->timeStore , p->timeTotal ); ABC_PRTP( "Other ", p->timeOther , p->timeTotal ); ABC_PRTP( "TOTAL ", p->timeTotal , p->timeTotal ); } else Abc_PrintTime( 1, "Time", Abc_Clock() - p->timeTotal ); }
int Agi_ManSuppSizeTest( Agi_Man_t * p ) { abctime clk = Abc_Clock(); int i, Counter = 0; Agi_ManForEachNode( p, i ) Counter += (Agi_ManSuppSizeOne(p, i) <= 16); printf( "Nodes with small support %d (out of %d)\n", Counter, Agi_ManNodeNum(p) ); Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); return Counter; }
/**Function************************************************************* Synopsis [Core procedure for simulation.] Description [Returns 1 if refinement has happened.] SideEffects [] SeeAlso [] ***********************************************************************/ int Cec_ManSimulationOne( Gia_Man_t * pAig, Cec_ParSim_t * pPars ) { Cec_ManSim_t * pSim; int RetValue = 0, clkTotal = clock(); pSim = Cec_ManSimStart( pAig, pPars ); if ( (pAig->pReprs == NULL && (RetValue = Cec_ManSimClassesPrepare( pSim, -1 ))) || (RetValue == 0 && (RetValue = Cec_ManSimClassesRefine( pSim ))) ) Abc_Print( 1, "The number of failed outputs of the miter = %6d. (Words = %4d. Frames = %4d.)\n", pSim->nOuts, pPars->nWords, pPars->nFrames ); if ( pPars->fVerbose ) Abc_PrintTime( 1, "Time", clock() - clkTotal ); Cec_ManSimStop( pSim ); return RetValue; }
/**Function************************************************************* Synopsis [Creates AIG.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Cec_ManPatPrintStats( Cec_ManPat_t * p ) { Abc_Print( 1, "Latest: P = %8d. L = %10d. Lm = %10d. Ave = %6.1f. MEM =%6.2f MB\n", p->nPats, p->nPatLits, p->nPatLitsMin, 1.0 * p->nPatLitsMin/p->nPats, 1.0*(Vec_StrSize(p->vStorage)-p->iStart)/(1<<20) ); Abc_Print( 1, "Total: P = %8d. L = %10d. Lm = %10d. Ave = %6.1f. MEM =%6.2f MB\n", p->nPatsAll, p->nPatLitsAll, p->nPatLitsMinAll, 1.0 * p->nPatLitsMinAll/p->nPatsAll, 1.0*Vec_StrSize(p->vStorage)/(1<<20) ); Abc_PrintTimeP( 1, "Finding ", p->timeFind, p->timeTotal ); Abc_PrintTimeP( 1, "Shrinking", p->timeShrink, p->timeTotal ); Abc_PrintTimeP( 1, "Verifying", p->timeVerify, p->timeTotal ); Abc_PrintTimeP( 1, "Sorting ", p->timeSort, p->timeTotal ); Abc_PrintTimeP( 1, "Packing ", p->timePack, p->timeTotal ); Abc_PrintTime( 1, "TOTAL ", p->timeTotal ); }
/**Function************************************************************* Synopsis [Prints statistics of the manager.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Cec_ManSatPrintStats( Cec_ManSat_t * p ) { Abc_Print( 1, "CO = %8d ", Gia_ManCoNum(p->pAig) ); Abc_Print( 1, "AND = %8d ", Gia_ManAndNum(p->pAig) ); Abc_Print( 1, "Conf = %5d ", p->pPars->nBTLimit ); Abc_Print( 1, "MinVar = %5d ", p->pPars->nSatVarMax ); Abc_Print( 1, "MinCalls = %5d\n", p->pPars->nCallsRecycle ); Abc_Print( 1, "Unsat calls %6d (%6.2f %%) Ave conf = %8.1f ", p->nSatUnsat, p->nSatTotal? 100.0*p->nSatUnsat/p->nSatTotal : 0.0, p->nSatUnsat? 1.0*p->nConfUnsat/p->nSatUnsat :0.0 ); Abc_PrintTimeP( 1, "Time", p->timeSatUnsat, p->timeTotal ); Abc_Print( 1, "Sat calls %6d (%6.2f %%) Ave conf = %8.1f ", p->nSatSat, p->nSatTotal? 100.0*p->nSatSat/p->nSatTotal : 0.0, p->nSatSat? 1.0*p->nConfSat/p->nSatSat : 0.0 ); Abc_PrintTimeP( 1, "Time", p->timeSatSat, p->timeTotal ); Abc_Print( 1, "Undef calls %6d (%6.2f %%) Ave conf = %8.1f ", p->nSatUndec, p->nSatTotal? 100.0*p->nSatUndec/p->nSatTotal : 0.0, p->nSatUndec? 1.0*p->nConfUndec/p->nSatUndec : 0.0 ); Abc_PrintTimeP( 1, "Time", p->timeSatUndec, p->timeTotal ); Abc_PrintTime( 1, "Total time", p->timeTotal ); }
/**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Bmc_LoadTest( Gia_Man_t * pGia, int fLoadCnf, int fVerbose ) { int nConfLimit = 0; Bmc_Load_t * p; Gia_Obj_t * pObj; int i, status, Lit; abctime clk = Abc_Clock(); // create the loading manager p = Bmc_LoadStart( pGia ); // add callback for CNF loading if ( fLoadCnf ) { p->pSat->pCnfMan = p; p->pSat->pCnfFunc = Bmc_LoadAddCnf; } // solve SAT problem for each PO Gia_ManForEachPo( pGia, pObj, i ) { if ( fLoadCnf ) Lit = Abc_Var2Lit( Bmc_LoadGetSatVar(p, Gia_ObjFaninId0p(pGia, pObj)), Gia_ObjFaninC0(pObj) ); else Lit = Abc_Var2Lit( Bmc_LoadAddCnf_rec(p, Gia_ObjFaninId0p(pGia, pObj)), Gia_ObjFaninC0(pObj) ); if ( fVerbose ) { printf( "Frame%4d : ", i ); printf( "Vars = %6d ", Vec_IntSize(p->vSat2Id) ); printf( "Clas = %6d ", sat_solver_nclauses(p->pSat) ); } status = sat_solver_solve( p->pSat, &Lit, &Lit + 1, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); if ( fVerbose ) { printf( "Conf = %6d ", sat_solver_nconflicts(p->pSat) ); if ( status == l_False ) printf( "UNSAT " ); else if ( status == l_True ) printf( "SAT " ); else // if ( status == l_Undec ) printf( "UNDEC " ); Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); } } printf( "Callbacks = %d. Loadings = %d.\n", p->nCallBacks1, p->nCallBacks2 ); Bmc_LoadStop( p ); }
/**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Gia_Iso3Test( Gia_Man_t * p ) { int nIterMax = 500; int i, Prev = -1, This; abctime clk = Abc_Clock(); Vec_Int_t * vSign = NULL; Gia_Iso3Init( p ); for ( i = 0; i < nIterMax; i++ ) { vSign = Gia_Iso3Save( p ); // This = Gia_Iso3Unique( vSign ); This = Vec_IntUniqueCount( vSign, 1, NULL ); printf( "Iter %3d : %6d out of %6d ", i, This, Vec_IntSize(vSign) ); Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); if ( This == Prev ) break; Prev = This; Gia_Iso3Compute( p, vSign ); Vec_IntFreeP( &vSign ); } Vec_IntFreeP( &vSign ); }
/**Function************************************************************* Synopsis [Improves current mapping using expand/Expand of one cut.] Description [Assumes current mapping assigned and required times computed.] SideEffects [] SeeAlso [] ***********************************************************************/ void If_ManImproveMapping( If_Man_t * p ) { abctime clk; clk = Abc_Clock(); If_ManImproveExpand( p, p->pPars->nLutSize ); If_ManComputeRequired( p ); if ( p->pPars->fVerbose ) { Abc_Print( 1, "E: Del = %7.2f. Ar = %9.1f. Edge = %8d. Switch = %7.2f. Cut = %8d. ", p->RequiredGlo, p->AreaGlo, p->nNets, p->dPower, p->nCutsMerged ); Abc_PrintTime( 1, "T", Abc_Clock() - clk ); } /* clk = Abc_Clock(); If_ManImproveReduce( p, p->pPars->nLutSize ); If_ManComputeRequired( p, 0 ); if ( p->pPars->fVerbose ) { Abc_Print( 1, "R: Del = %6.2f. Area = %8.2f. Nets = %6d. Cuts = %8d. Lim = %2d. Ave = %5.2f. ", p->RequiredGlo, p->AreaGlo, p->nNets, p->nCutsMerged, p->nCutsUsed, 1.0 * p->nCutsMerged / If_ManAndNum(p) ); Abc_PrintTime( 1, "T", Abc_Clock() - clk ); } */ /* clk = Abc_Clock(); If_ManImproveExpand( p, p->pPars->nLutSize ); If_ManComputeRequired( p, 0 ); if ( p->pPars->fVerbose ) { Abc_Print( 1, "E: Del = %6.2f. Area = %8.2f. Nets = %6d. Cuts = %8d. Lim = %2d. Ave = %5.2f. ", p->RequiredGlo, p->AreaGlo, p->nNets, p->nCutsMerged, p->nCutsUsed, 1.0 * p->nCutsMerged / If_ManAndNum(p) ); Abc_PrintTime( 1, "T", Abc_Clock() - clk ); } */ }
/**Function************************************************************* Synopsis [Core procedure for SAT sweeping.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Gia_Man_t * Cec_ManSatSweeping( Gia_Man_t * pAig, Cec_ParFra_t * pPars, int fSilent ) { int fOutputResult = 0; Cec_ParSat_t ParsSat, * pParsSat = &ParsSat; Cec_ParSim_t ParsSim, * pParsSim = &ParsSim; Gia_Man_t * pIni, * pSrm, * pTemp; Cec_ManFra_t * p; Cec_ManSim_t * pSim; Cec_ManPat_t * pPat; int i, fTimeOut = 0, nMatches = 0; abctime clk, clk2, clkTotal = Abc_Clock(); // duplicate AIG and transfer equivalence classes Gia_ManRandom( 1 ); pIni = Gia_ManDup(pAig); pIni->pReprs = pAig->pReprs; pAig->pReprs = NULL; pIni->pNexts = pAig->pNexts; pAig->pNexts = NULL; // prepare the managers // SAT sweeping p = Cec_ManFraStart( pIni, pPars ); if ( pPars->fDualOut ) pPars->fColorDiff = 1; // simulation Cec_ManSimSetDefaultParams( pParsSim ); pParsSim->nWords = pPars->nWords; pParsSim->nFrames = pPars->nRounds; pParsSim->fCheckMiter = pPars->fCheckMiter; pParsSim->fDualOut = pPars->fDualOut; pParsSim->fVerbose = pPars->fVerbose; pSim = Cec_ManSimStart( p->pAig, pParsSim ); // SAT solving Cec_ManSatSetDefaultParams( pParsSat ); pParsSat->nBTLimit = pPars->nBTLimit; pParsSat->fVerbose = pPars->fVeryVerbose; // simulation patterns pPat = Cec_ManPatStart(); pPat->fVerbose = pPars->fVeryVerbose; // start equivalence classes clk = Abc_Clock(); if ( p->pAig->pReprs == NULL ) { if ( Cec_ManSimClassesPrepare(pSim, -1) || Cec_ManSimClassesRefine(pSim) ) { Gia_ManStop( p->pAig ); p->pAig = NULL; goto finalize; } } p->timeSim += Abc_Clock() - clk; // perform solving for ( i = 1; i <= pPars->nItersMax; i++ ) { clk2 = Abc_Clock(); nMatches = 0; if ( pPars->fDualOut ) { nMatches = Gia_ManEquivSetColors( p->pAig, pPars->fVeryVerbose ); // p->pAig->pIso = Cec_ManDetectIsomorphism( p->pAig ); // Gia_ManEquivTransform( p->pAig, 1 ); } pSrm = Cec_ManFraSpecReduction( p ); // Gia_AigerWrite( pSrm, "gia_srm.aig", 0, 0 ); if ( pPars->fVeryVerbose ) Gia_ManPrintStats( pSrm, NULL ); if ( Gia_ManCoNum(pSrm) == 0 ) { Gia_ManStop( pSrm ); if ( p->pPars->fVerbose ) Abc_Print( 1, "Considered all available candidate equivalences.\n" ); if ( pPars->fDualOut && Gia_ManAndNum(p->pAig) > 0 ) { if ( pPars->fColorDiff ) { if ( p->pPars->fVerbose ) Abc_Print( 1, "Switching into reduced mode.\n" ); pPars->fColorDiff = 0; } else { if ( p->pPars->fVerbose ) Abc_Print( 1, "Switching into normal mode.\n" ); pPars->fDualOut = 0; } continue; } break; } clk = Abc_Clock(); if ( pPars->fRunCSat ) Cec_ManSatSolveCSat( pPat, pSrm, pParsSat ); else Cec_ManSatSolve( pPat, pSrm, pParsSat ); p->timeSat += Abc_Clock() - clk; if ( Cec_ManFraClassesUpdate( p, pSim, pPat, pSrm ) ) { Gia_ManStop( pSrm ); Gia_ManStop( p->pAig ); p->pAig = NULL; goto finalize; } Gia_ManStop( pSrm ); // update the manager pSim->pAig = p->pAig = Gia_ManEquivReduceAndRemap( pTemp = p->pAig, 0, pParsSim->fDualOut ); if ( p->pAig == NULL ) { p->pAig = pTemp; break; } Gia_ManStop( pTemp ); if ( p->pPars->fVerbose ) { Abc_Print( 1, "%3d : P =%7d. D =%7d. F =%6d. M = %7d. And =%8d. ", i, p->nAllProved, p->nAllDisproved, p->nAllFailed, nMatches, Gia_ManAndNum(p->pAig) ); Abc_PrintTime( 1, "Time", Abc_Clock() - clk2 ); } if ( Gia_ManAndNum(p->pAig) == 0 ) { if ( p->pPars->fVerbose ) Abc_Print( 1, "Network after reduction is empty.\n" ); break; } // check resource limits if ( p->pPars->TimeLimit && (Abc_Clock() - clkTotal)/CLOCKS_PER_SEC >= p->pPars->TimeLimit ) { fTimeOut = 1; break; } // if ( p->nAllFailed && !p->nAllProved && !p->nAllDisproved ) if ( p->nAllFailed > p->nAllProved + p->nAllDisproved ) { if ( pParsSat->nBTLimit >= 10001 ) break; if ( pPars->fSatSweeping ) { if ( p->pPars->fVerbose ) Abc_Print( 1, "Exceeded the limit on the number of conflicts (%d).\n", pParsSat->nBTLimit ); break; } pParsSat->nBTLimit *= 10; if ( p->pPars->fVerbose ) { if ( p->pPars->fVerbose ) Abc_Print( 1, "Increasing conflict limit to %d.\n", pParsSat->nBTLimit ); if ( fOutputResult ) { Gia_AigerWrite( p->pAig, "gia_cec_temp.aig", 0, 0 ); Abc_Print( 1,"The result is written into file \"%s\".\n", "gia_cec_temp.aig" ); } } } if ( pPars->fDualOut && pPars->fColorDiff && (Gia_ManAndNum(p->pAig) < 100000 || p->nAllProved + p->nAllDisproved < 10) ) { if ( p->pPars->fVerbose ) Abc_Print( 1, "Switching into reduced mode.\n" ); pPars->fColorDiff = 0; } // if ( pPars->fDualOut && Gia_ManAndNum(p->pAig) < 20000 ) else if ( pPars->fDualOut && (Gia_ManAndNum(p->pAig) < 20000 || p->nAllProved + p->nAllDisproved < 10) ) { if ( p->pPars->fVerbose ) Abc_Print( 1, "Switching into normal mode.\n" ); pPars->fColorDiff = 0; pPars->fDualOut = 0; } } finalize: if ( p->pPars->fVerbose && p->pAig ) { Abc_Print( 1, "NBeg = %d. NEnd = %d. (Gain = %6.2f %%). RBeg = %d. REnd = %d. (Gain = %6.2f %%).\n", Gia_ManAndNum(pAig), Gia_ManAndNum(p->pAig), 100.0*(Gia_ManAndNum(pAig)-Gia_ManAndNum(p->pAig))/(Gia_ManAndNum(pAig)?Gia_ManAndNum(pAig):1), Gia_ManRegNum(pAig), Gia_ManRegNum(p->pAig), 100.0*(Gia_ManRegNum(pAig)-Gia_ManRegNum(p->pAig))/(Gia_ManRegNum(pAig)?Gia_ManRegNum(pAig):1) ); Abc_PrintTimeP( 1, "Sim ", p->timeSim, Abc_Clock() - (int)clkTotal ); Abc_PrintTimeP( 1, "Sat ", p->timeSat-pPat->timeTotalSave, Abc_Clock() - (int)clkTotal ); Abc_PrintTimeP( 1, "Pat ", p->timePat+pPat->timeTotalSave, Abc_Clock() - (int)clkTotal ); Abc_PrintTime( 1, "Time", (int)(Abc_Clock() - clkTotal) ); } pTemp = p->pAig; p->pAig = NULL; if ( pTemp == NULL && pSim->iOut >= 0 ) { if ( !fSilent ) Abc_Print( 1, "Disproved at least one output of the miter (zero-based number %d).\n", pSim->iOut ); pPars->iOutFail = pSim->iOut; } else if ( pSim->pCexes && !fSilent ) Abc_Print( 1, "Disproved %d outputs of the miter.\n", pSim->nOuts ); if ( fTimeOut && !fSilent ) Abc_Print( 1, "Timed out after %d seconds.\n", (int)((double)Abc_Clock() - clkTotal)/CLOCKS_PER_SEC ); pAig->pCexComb = pSim->pCexComb; pSim->pCexComb = NULL; Cec_ManSimStop( pSim ); Cec_ManPatStop( pPat ); Cec_ManFraStop( p ); return pTemp; }
/**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Gia_Man_t * Ssc_PerformSweeping( Gia_Man_t * pAig, Gia_Man_t * pCare, Ssc_Pars_t * pPars ) { Ssc_Man_t * p; Gia_Man_t * pResult, * pTemp; Gia_Obj_t * pObj, * pRepr; abctime clk, clkTotal = Abc_Clock(); int i, fCompl, nRefined, status; clk = Abc_Clock(); assert( Gia_ManRegNum(pCare) == 0 ); assert( Gia_ManCiNum(pAig) == Gia_ManCiNum(pCare) ); assert( Gia_ManIsNormalized(pAig) ); assert( Gia_ManIsNormalized(pCare) ); // reset random numbers Gia_ManRandom( 1 ); // sweeping manager p = Ssc_ManStart( pAig, pCare, pPars ); if ( p == NULL ) return Gia_ManDup( pAig ); if ( p->pPars->fVerbose ) printf( "Care set produced %d hits out of %d.\n", Ssc_GiaEstimateCare(p->pFraig, 5), 640 ); // perform simulation while ( 1 ) { // simulate care set Ssc_GiaRandomPiPattern( p->pFraig, 5, NULL ); Ssc_GiaSimRound( p->pFraig ); // transfer care patterns to user's AIG if ( !Ssc_GiaTransferPiPattern( pAig, p->pFraig, p->vPivot ) ) break; // simulate the main AIG Ssc_GiaSimRound( pAig ); nRefined = Ssc_GiaClassesRefine( pAig ); if ( pPars->fVerbose ) Gia_ManEquivPrintClasses( pAig, 0, 0 ); if ( nRefined <= Gia_ManCandNum(pAig) / 100 ) break; } p->timeSimInit += Abc_Clock() - clk; // prepare user's AIG Gia_ManFillValue(pAig); Gia_ManConst0(pAig)->Value = 0; Gia_ManForEachCi( pAig, pObj, i ) pObj->Value = Gia_Obj2Lit( p->pFraig, Gia_ManCi(p->pFraig, i) ); // Gia_ManLevelNum(pAig); // prepare swept AIG (should be done after starting SAT solver in Ssc_ManStart) Gia_ManHashStart( p->pFraig ); // perform sweeping Ssc_GiaResetPiPattern( pAig, pPars->nWords ); Ssc_GiaSavePiPattern( pAig, p->vPivot ); Gia_ManForEachCand( pAig, pObj, i ) { if ( pAig->iPatsPi == 64 * pPars->nWords ) { clk = Abc_Clock(); Ssc_GiaSimRound( pAig ); Ssc_GiaClassesRefine( pAig ); if ( pPars->fVerbose ) Gia_ManEquivPrintClasses( pAig, 0, 0 ); Ssc_GiaClassesCheckPairs( pAig, p->vDisPairs ); Vec_IntClear( p->vDisPairs ); // prepare next patterns Ssc_GiaResetPiPattern( pAig, pPars->nWords ); Ssc_GiaSavePiPattern( pAig, p->vPivot ); p->timeSimSat += Abc_Clock() - clk; //printf( "\n" ); } if ( Gia_ObjIsAnd(pObj) ) pObj->Value = Gia_ManHashAnd( p->pFraig, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) ); if ( !Gia_ObjHasRepr(pAig, i) ) continue; pRepr = Gia_ObjReprObj(pAig, i); if ( (int)pObj->Value == Abc_LitNotCond( pRepr->Value, pRepr->fPhase ^ pObj->fPhase ) ) { Gia_ObjSetProved( pAig, i ); continue; } assert( Abc_Lit2Var(pRepr->Value) != Abc_Lit2Var(pObj->Value) ); fCompl = pRepr->fPhase ^ pObj->fPhase ^ Abc_LitIsCompl(pRepr->Value) ^ Abc_LitIsCompl(pObj->Value); // perform SAT call clk = Abc_Clock(); p->nSatCalls++; status = Ssc_ManCheckEquivalence( p, Abc_Lit2Var(pRepr->Value), Abc_Lit2Var(pObj->Value), fCompl ); if ( status == l_False ) { p->nSatCallsUnsat++; pObj->Value = Abc_LitNotCond( pRepr->Value, pRepr->fPhase ^ pObj->fPhase ); Gia_ObjSetProved( pAig, i ); } else if ( status == l_True ) { p->nSatCallsSat++; Ssc_GiaSavePiPattern( pAig, p->vPattern ); Vec_IntPush( p->vDisPairs, Gia_ObjRepr(p->pAig, i) ); Vec_IntPush( p->vDisPairs, i ); // printf( "Try %2d and %2d: ", Gia_ObjRepr(p->pAig, i), i ); // Vec_IntPrint( p->vPattern ); if ( Gia_ObjRepr(p->pAig, i) > 0 ) Ssc_GiaResimulateOneClass( p, Gia_ObjRepr(p->pAig, i), i ); } else if ( status == l_Undef ) p->nSatCallsUndec++; else assert( 0 ); p->timeSat += Abc_Clock() - clk; } if ( pAig->iPatsPi > 1 ) { clk = Abc_Clock(); while ( pAig->iPatsPi < 64 * pPars->nWords ) Ssc_GiaSavePiPattern( pAig, p->vPivot ); Ssc_GiaSimRound( pAig ); Ssc_GiaClassesRefine( pAig ); if ( pPars->fVerbose ) Gia_ManEquivPrintClasses( pAig, 0, 0 ); Ssc_GiaClassesCheckPairs( pAig, p->vDisPairs ); Vec_IntClear( p->vDisPairs ); p->timeSimSat += Abc_Clock() - clk; } // Gia_ManEquivPrintClasses( pAig, 1, 0 ); // Gia_ManPrint( pAig ); // generate the resulting AIG pResult = Gia_ManEquivReduce( pAig, 0, 0, 1, 0 ); if ( pResult == NULL ) { printf( "There is no equivalences.\n" ); ABC_FREE( pAig->pReprs ); ABC_FREE( pAig->pNexts ); pResult = Gia_ManDup( pAig ); } pResult = Gia_ManCleanup( pTemp = pResult ); Gia_ManStop( pTemp ); p->timeTotal = Abc_Clock() - clkTotal; if ( pPars->fVerbose ) Ssc_ManPrintStats( p ); Ssc_ManStop( p ); // count the number of representatives if ( pPars->fVerbose ) { Abc_Print( 1, "Reduction in AIG nodes:%8d ->%8d (%6.2f %%). ", Gia_ManAndNum(pAig), Gia_ManAndNum(pResult), 100.0 - 100.0 * Gia_ManAndNum(pResult) / Gia_ManAndNum(pAig) ); Abc_PrintTime( 1, "Time", Abc_Clock() - clkTotal ); } return pResult; }