/**Function******************************************************************** Synopsis [] Description [] SideEffects [] SeeAlso [] ******************************************************************************/ int Cba_CommandClp( Abc_Frame_t * pAbc, int argc, char ** argv ) { Cba_Man_t * pNew = NULL, * p = Cba_AbcGetMan(pAbc); int c, fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) { switch ( c ) { case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( p == NULL ) { Abc_Print( 1, "Cba_CommandGet(): There is no current design.\n" ); return 0; } pNew = Cba_ManCollapse( p ); Cba_AbcUpdateMan( pAbc, pNew ); return 0; usage: Abc_Print( -2, "usage: @clp [-vh]\n" ); Abc_Print( -2, "\t collapses the current hierarchical design\n" ); Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; }
/**Function******************************************************************** Synopsis [] Description [] SideEffects [] SeeAlso [] ******************************************************************************/ int Cba_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) { Cba_Man_t * p = Cba_AbcGetMan(pAbc); int c, fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) { switch ( c ) { case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( p == NULL ) { Abc_Print( 1, "Cba_CommandTest(): There is no current design.\n" ); return 0; } return 0; usage: Abc_Print( -2, "usage: @test [-vh]\n" ); Abc_Print( -2, "\t experiments with word-level networks\n" ); Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; }
/**Function************************************************************* Synopsis [Prints one cut.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void If_CutPrint( If_Cut_t * pCut ) { unsigned i; Abc_Print( 1, "{" ); for ( i = 0; i < pCut->nLeaves; i++ ) Abc_Print( 1, " %d", pCut->pLeaves[i] ); Abc_Print( 1, " }\n" ); }
/**Function************************************************************* Synopsis [Prints one cut.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void If_CutPrintTiming( If_Man_t * p, If_Cut_t * pCut ) { If_Obj_t * pLeaf; unsigned i; Abc_Print( 1, "{" ); If_CutForEachLeaf( p, pCut, pLeaf, i ) Abc_Print( 1, " %d(%.2f/%.2f)", pLeaf->Id, If_ObjCutBest(pLeaf)->Delay, pLeaf->Required ); Abc_Print( 1, " }\n" ); }
/**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Aig_Man_t * Saig_ManTempor( Aig_Man_t * pAig, int nFrames, int TimeOut, int nConfLimit, int fUseBmc, int fUseTransSigs, int fVerbose, int fVeryVerbose ) { extern int Saig_ManPhasePrefixLength( Aig_Man_t * p, int fVerbose, int fVeryVerbose, Vec_Int_t ** pvTrans ); Vec_Int_t * vTransSigs = NULL; int RetValue, nFramesFinished = -1; assert( nFrames >= 0 ); if ( nFrames == 0 ) { nFrames = Saig_ManPhasePrefixLength( pAig, fVerbose, fVeryVerbose, &vTransSigs ); if ( nFrames == 1 ) { Vec_IntFreeP( &vTransSigs ); printf( "The leading sequence has length 1. Temporal decomposition is not performed.\n" ); return NULL; } if ( fUseTransSigs ) { int Entry, i, iLast = -1; Vec_IntForEachEntry( vTransSigs, Entry, i ) iLast = Entry ? i :iLast; if ( iLast > 0 && iLast < nFrames ) { Abc_Print( 1, "Reducing frame count from %d to %d to fit the last transient.\n", nFrames, iLast ); nFrames = iLast; } } Abc_Print( 1, "Using computed frame number (%d).\n", nFrames ); } else Abc_Print( 1, "Using user-given frame number (%d).\n", nFrames ); // run BMC2 if ( fUseBmc ) { RetValue = Saig_BmcPerform( pAig, 0, nFrames, 2000, TimeOut, nConfLimit, 0, fVerbose, 0, &nFramesFinished ); if ( RetValue == 0 ) { Vec_IntFreeP( &vTransSigs ); printf( "A cex found in the first %d frames.\n", nFrames ); return NULL; } if ( nFramesFinished < nFrames ) { int iLastBefore = Vec_IntLastNonZeroBeforeLimit( vTransSigs, nFramesFinished ); if ( iLastBefore < 1 || !fUseTransSigs ) { Vec_IntFreeP( &vTransSigs ); printf( "BMC for %d frames could not be completed. A cex may exist!\n", nFrames ); return NULL; } assert( iLastBefore < nFramesFinished ); printf( "BMC succeeded to frame %d. Adjusting frame count to be (%d) based on the last transient signal.\n", nFramesFinished, iLastBefore ); } } Vec_IntFreeP( &vTransSigs ); return Saig_ManTemporDecompose( pAig, nFrames ); }
/**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; } }
/**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 [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 ); }
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 ); }
/**Function************************************************************* Synopsis [Performs computation of AIGs with choices.] Description [Takes several AIGs and performs choicing.] SideEffects [] SeeAlso [] ***********************************************************************/ Aig_Man_t * Dch_ComputeChoices( Aig_Man_t * pAig, Dch_Pars_t * pPars ) { Dch_Man_t * p; Aig_Man_t * pResult; int clk, clkTotal = clock(); // reset random numbers Aig_ManRandom(1); // start the choicing manager p = Dch_ManCreate( pAig, pPars ); // compute candidate equivalence classes clk = clock(); p->ppClasses = Dch_CreateCandEquivClasses( pAig, pPars->nWords, pPars->fVerbose ); p->timeSimInit = clock() - clk; // Dch_ClassesPrint( p->ppClasses, 0 ); p->nLits = Dch_ClassesLitNum( p->ppClasses ); // perform SAT sweeping Dch_ManSweep( p ); // free memory ahead of time p->timeTotal = clock() - clkTotal; Dch_ManStop( p ); // create choices ABC_FREE( pAig->pTable ); pResult = Dch_DeriveChoiceAig( pAig ); // count the number of representatives if ( pPars->fVerbose ) Abc_Print( 1, "STATS: Reprs = %6d. Equivs = %6d. Choices = %6d.\n", Dch_DeriveChoiceCountReprs( pAig ), Dch_DeriveChoiceCountEquivs( pResult ), Aig_ManChoiceNum( pResult ) ); return pResult; }
/**Function******************************************************************** Synopsis [] Description [] SideEffects [] SeeAlso [] ******************************************************************************/ int Cba_CommandGet( Abc_Frame_t * pAbc, int argc, char ** argv ) { Cba_Man_t * pNew = NULL, * p = Cba_AbcGetMan(pAbc); int c, fMapped = 0, fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "mvh" ) ) != EOF ) { switch ( c ) { case 'm': fMapped ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( p == NULL ) { Abc_Print( 1, "Cba_CommandGet(): There is no current design.\n" ); return 0; } if ( fMapped ) { if ( pAbc->pNtkCur == NULL ) { Abc_Print( 1, "Cba_CommandGet(): There is no current mapped design.\n" ); return 0; } pNew = Cba_ManInsertAbc( p, pAbc->pNtkCur ); } else { if ( pAbc->pGia == NULL ) { Abc_Print( 1, "Cba_CommandGet(): There is no current AIG.\n" ); return 0; } pNew = Cba_ManInsertGia( p, pAbc->pGia ); } Cba_AbcUpdateMan( pAbc, pNew ); return 0; usage: Abc_Print( -2, "usage: @get [-mvh]\n" ); Abc_Print( -2, "\t extracts AIG or mapped network into the hierarchical design\n" ); Abc_Print( -2, "\t-m : toggle using mapped network from main-space [default = %s]\n", fMapped? "yes": "no" ); Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; }
void Ssc_ManPrintStats( Ssc_Man_t * p ) { Abc_Print( 1, "Parameters: SimWords = %d. SatConfs = %d. SatVarMax = %d. CallsRec = %d. Verbose = %d.\n", p->pPars->nWords, p->pPars->nBTLimit, p->pPars->nSatVarMax, p->pPars->nCallsRecycle, p->pPars->fVerbose ); Abc_Print( 1, "SAT calls : Total = %d. Proof = %d. Cex = %d. Undec = %d.\n", p->nSatCalls, p->nSatCallsUnsat, p->nSatCallsSat, p->nSatCallsUndec ); Abc_Print( 1, "SAT solver: Vars = %d. Clauses = %d. Recycles = %d. Sim rounds = %d.\n", sat_solver_nvars(p->pSat), sat_solver_nclauses(p->pSat), p->nRecycles, p->nSimRounds ); p->timeOther = p->timeTotal - p->timeSimInit - p->timeSimSat - p->timeCnfGen - p->timeSatSat - p->timeSatUnsat - p->timeSatUndec; ABC_PRTP( "Initialization ", p->timeSimInit, p->timeTotal ); ABC_PRTP( "SAT simulation ", p->timeSimSat, p->timeTotal ); ABC_PRTP( "CNF generation ", p->timeSimSat, p->timeTotal ); ABC_PRTP( "SAT solving ", p->timeSat-p->timeCnfGen, p->timeTotal ); ABC_PRTP( " unsat ", p->timeSatUnsat, p->timeTotal ); ABC_PRTP( " sat ", p->timeSatSat, p->timeTotal ); ABC_PRTP( " undecided ", p->timeSatUndec, p->timeTotal ); ABC_PRTP( "Other ", p->timeOther, p->timeTotal ); ABC_PRTP( "TOTAL ", p->timeTotal, p->timeTotal ); }
/**Function************************************************************* Synopsis [Core procedure for simulation.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Cec_ManSimulation( Gia_Man_t * pAig, Cec_ParSim_t * pPars ) { int r, nLitsOld, nLitsNew, nCountNoRef = 0, fStop = 0; Gia_ManRandom( 1 ); if ( pPars->fSeqSimulate ) Abc_Print( 1, "Performing rounds of random simulation of %d frames with %d words.\n", pPars->nRounds, pPars->nFrames, pPars->nWords ); nLitsOld = Gia_ManEquivCountLits( pAig ); for ( r = 0; r < pPars->nRounds; r++ ) { if ( Cec_ManSimulationOne( pAig, pPars ) ) { fStop = 1; break; } // decide when to stop nLitsNew = Gia_ManEquivCountLits( pAig ); if ( nLitsOld == 0 || nLitsOld > nLitsNew ) { nLitsOld = nLitsNew; nCountNoRef = 0; } else if ( ++nCountNoRef == pPars->nNonRefines ) { r++; break; } assert( nLitsOld == nLitsNew ); } // if ( pPars->fVerbose ) if ( r == pPars->nRounds || fStop ) Abc_Print( 1, "Random simulation is stopped after %d rounds.\n", r ); else Abc_Print( 1, "Random simulation saturated after %d rounds.\n", r ); if ( pPars->fCheckMiter ) { int nNonConsts = Cec_ManCountNonConstOutputs( pAig ); if ( nNonConsts ) Abc_Print( 1, "The number of POs that are not const-0 candidates = %d.\n", nNonConsts ); } }
/**Function************************************************************* Synopsis [Derive a new counter-example.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Abc_Cex_t * Saig_ManCexRemap( Aig_Man_t * p, Aig_Man_t * pAbs, Abc_Cex_t * pCexAbs ) { Abc_Cex_t * pCex; Aig_Obj_t * pObj; int i, f; if ( !Saig_ManVerifyCex( pAbs, pCexAbs ) ) printf( "Saig_ManCexRemap(): The initial counter-example is invalid.\n" ); // else // printf( "Saig_ManCexRemap(): The initial counter-example is correct.\n" ); // start the counter-example pCex = Abc_CexAlloc( Aig_ManRegNum(p), Saig_ManPiNum(p), pCexAbs->iFrame+1 ); pCex->iFrame = pCexAbs->iFrame; pCex->iPo = pCexAbs->iPo; // copy the bit data for ( f = 0; f <= pCexAbs->iFrame; f++ ) { Saig_ManForEachPi( pAbs, pObj, i ) { if ( i == Saig_ManPiNum(p) ) break; if ( Abc_InfoHasBit( pCexAbs->pData, pCexAbs->nRegs + pCexAbs->nPis * f + i ) ) Abc_InfoSetBit( pCex->pData, pCex->nRegs + pCex->nPis * f + i ); } } // verify the counter example if ( !Saig_ManVerifyCex( p, pCex ) ) { printf( "Saig_ManCexRemap(): Counter-example is invalid.\n" ); Abc_CexFree( pCex ); pCex = NULL; } else { Abc_Print( 1, "Counter-example verification is successful.\n" ); Abc_Print( 1, "Output %d of miter \"%s\" was asserted in frame %d. \n", pCex->iPo, p->pName, pCex->iFrame ); } return pCex; }
/**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 [] Description [] SideEffects [] SeeAlso [] ******************************************************************************/ int Cba_CommandPut( Abc_Frame_t * pAbc, int argc, char ** argv ) { Cba_Man_t * p = Cba_AbcGetMan(pAbc); Gia_Man_t * pGia = NULL; int c, fBarBufs = 1, fSeq = 0, fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "bsvh" ) ) != EOF ) { switch ( c ) { case 'b': fBarBufs ^= 1; break; case 's': fSeq ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( p == NULL ) { Abc_Print( 1, "Cba_CommandPut(): There is no current design.\n" ); return 0; } pGia = Cba_ManBlast( p, fBarBufs, fSeq, fVerbose ); if ( pGia == NULL ) { Abc_Print( 1, "Cba_CommandPut(): Conversion to AIG has failed.\n" ); return 0; } Abc_FrameUpdateGia( pAbc, pGia ); return 0; usage: Abc_Print( -2, "usage: @put [-bsvh]\n" ); Abc_Print( -2, "\t extracts AIG from the hierarchical design\n" ); Abc_Print( -2, "\t-b : toggle using barrier buffers [default = %s]\n", fBarBufs? "yes": "no" ); Abc_Print( -2, "\t-s : toggle blasting sequential elements [default = %s]\n", fSeq? "yes": "no" ); Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; }
/**Function************************************************************* Synopsis [Checks correctness of the cut.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int If_CutCheck( If_Cut_t * pCut ) { int i; assert( pCut->nLeaves <= pCut->nLimit ); for ( i = 1; i < (int)pCut->nLeaves; i++ ) { if ( pCut->pLeaves[i-1] >= pCut->pLeaves[i] ) { Abc_Print( -1, "If_CutCheck(): Cut has wrong ordering of inputs.\n" ); return 0; } assert( pCut->pLeaves[i-1] < pCut->pLeaves[i] ); } return 1; }
/**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 ); }
ABC_NAMESPACE_IMPL_START //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// /**Function************************************************************* Synopsis [Returns the wireload model for the given area.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ SC_WireLoad * Abc_SclFindWireLoadModel( SC_Lib * p, float Area ) { SC_WireLoad * pWL = NULL; char * pWLoadUsed = NULL; int i; if ( p->default_wire_load_sel && strlen(p->default_wire_load_sel) ) { SC_WireLoadSel * pWLS = NULL; SC_LibForEachWireLoadSel( p, pWLS, i ) if ( !strcmp(pWLS->pName, p->default_wire_load_sel) ) break; if ( i == Vec_PtrSize(p->vWireLoadSels) ) { Abc_Print( -1, "Cannot find wire load selection model \"%s\".\n", p->default_wire_load_sel ); exit(1); } for ( i = 0; i < Vec_FltSize(pWLS->vAreaFrom); i++) if ( Area >= Vec_FltEntry(pWLS->vAreaFrom, i) && Area < Vec_FltEntry(pWLS->vAreaTo, i) ) { pWLoadUsed = (char *)Vec_PtrEntry(pWLS->vWireLoadModel, i); break; } if ( i == Vec_FltSize(pWLS->vAreaFrom) ) pWLoadUsed = (char *)Vec_PtrEntryLast(pWLS->vWireLoadModel); }
/**Function************************************************************* Synopsis [Returns the max delay of the POs.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ float If_ManDelayMax( If_Man_t * p, int fSeq ) { If_Obj_t * pObj; float DelayBest; int i; if ( p->pPars->fLatchPaths && p->pPars->nLatches == 0 ) { Abc_Print( 0, "Delay optimization of latch path is not performed because there is no latches.\n" ); p->pPars->fLatchPaths = 0; } DelayBest = -IF_FLOAT_LARGE; if ( fSeq ) { assert( p->pPars->nLatches > 0 ); If_ManForEachPo( p, pObj, i ) if ( DelayBest < If_ObjArrTime(If_ObjFanin0(pObj)) ) DelayBest = If_ObjArrTime(If_ObjFanin0(pObj)); } else if ( p->pPars->fLatchPaths )
Gia_Man_t * Ssc_PerformSweepingConstr( Gia_Man_t * p, Ssc_Pars_t * pPars ) { Gia_Man_t * pAig, * pCare, * pResult; int i; if ( pPars->fVerbose ) Abc_Print( 0, "SAT sweeping AIG with %d constraints.\n", p->nConstrs ); if ( p->nConstrs == 0 ) { pAig = Gia_ManDup( p ); pCare = Gia_ManStart( Gia_ManCiNum(p) + 2 ); pCare->pName = Abc_UtilStrsav( "care" ); for ( i = 0; i < Gia_ManCiNum(p); i++ ) Gia_ManAppendCi( pCare ); Gia_ManAppendCo( pCare, 0 ); } else { Vec_Int_t * vOuts = Vec_IntStartNatural( Gia_ManPoNum(p) ); pAig = Gia_ManDupCones( p, Vec_IntArray(vOuts), Gia_ManPoNum(p) - p->nConstrs, 0 ); pCare = Gia_ManDupCones( p, Vec_IntArray(vOuts) + Gia_ManPoNum(p) - p->nConstrs, p->nConstrs, 0 ); Vec_IntFree( vOuts ); } if ( pPars->fVerbose ) { printf( "User AIG: " ); Gia_ManPrintStats( pAig, NULL ); printf( "Care AIG: " ); Gia_ManPrintStats( pCare, NULL ); } pAig = Gia_ManDupLevelized( pResult = pAig ); Gia_ManStop( pResult ); pResult = Ssc_PerformSweeping( pAig, pCare, pPars ); if ( pPars->fAppend ) { Gia_ManDupAppendShare( pResult, pCare ); pResult->nConstrs = Gia_ManPoNum(pCare); } Gia_ManStop( pAig ); Gia_ManStop( pCare ); return pResult; }
/**Function******************************************************************** Synopsis [] Description [] SideEffects [] SeeAlso [] ******************************************************************************/ int Cba_CommandBlast( Abc_Frame_t * pAbc, int argc, char ** argv ) { Gia_Man_t * pNew = NULL; Cba_Man_t * p = Cba_AbcGetMan(pAbc); int c, fSeq = 0, fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "svh" ) ) != EOF ) { switch ( c ) { case 's': fSeq ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( p == NULL ) { Abc_Print( 1, "Cba_CommandBlast(): There is no current design.\n" ); return 0; } pNew = Cba_ManBlast( p, 0, fSeq, fVerbose ); if ( pNew == NULL ) { Abc_Print( 1, "Cba_CommandBlast(): Bit-blasting has failed.\n" ); return 0; } Abc_FrameUpdateGia( pAbc, pNew ); return 0; usage: Abc_Print( -2, "usage: %%blast [-svh]\n" ); Abc_Print( -2, "\t performs bit-blasting of the word-level design\n" ); Abc_Print( -2, "\t-s : toggle blasting sequential elements [default = %s]\n", fSeq? "yes": "no" ); Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; }
/**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 [The main() procedure.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_RealMain( int argc, char * argv[] ) { Abc_Frame_t * pAbc; char sCommandUsr[500] = {0}, sCommandTmp[100], sReadCmd[20], sWriteCmd[20]; const char * sOutFile, * sInFile; char * sCommand; int fStatus = 0; int c, fBatch, fInitSource, fInitRead, fFinalWrite; // added to detect memory leaks // watch for {,,msvcrtd.dll}*__p__crtBreakAlloc() // (http://support.microsoft.com/kb/151585) #if defined(_DEBUG) && defined(_MSC_VER) _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif // get global frame (singleton pattern) // will be initialized on first call pAbc = Abc_FrameGetGlobalFrame(); pAbc->sBinary = argv[0]; #ifdef ABC_PYTHON_EMBED { PyObject* pModule; void init_pyabc(void); Py_SetProgramName(argv[0]); Py_NoSiteFlag = 1; Py_Initialize(); init_pyabc(); pModule = PyImport_ImportModule("pyabc"); if (pModule) { Py_DECREF(pModule); } else { fprintf( pAbc->Err, "error: pyabc.py not found. PYTHONPATH may not be set properly.\n"); } } #endif /* ABC_PYTHON_EMBED */ // default options fBatch = 0; fInitSource = 1; fInitRead = 0; fFinalWrite = 0; sInFile = sOutFile = NULL; sprintf( sReadCmd, "read" ); sprintf( sWriteCmd, "write" ); Extra_UtilGetoptReset(); while ((c = Extra_UtilGetopt(argc, argv, "c:C:hf:F:o:st:T:xb")) != EOF) { switch(c) { case 'c': strcpy( sCommandUsr, globalUtilOptarg ); fBatch = 1; break; case 'C': strcpy( sCommandUsr, globalUtilOptarg ); fBatch = 2; break; case 'f': sprintf(sCommandUsr, "source %s", globalUtilOptarg); fBatch = 1; break; case 'F': sprintf(sCommandUsr, "source -x %s", globalUtilOptarg); fBatch = 1; break; case 'h': goto usage; break; case 'o': sOutFile = globalUtilOptarg; fFinalWrite = 1; break; case 's': fInitSource = 0; break; case 't': if ( TypeCheck( pAbc, globalUtilOptarg ) ) { if ( !strcmp(globalUtilOptarg, "none") == 0 ) { fInitRead = 1; sprintf( sReadCmd, "read_%s", globalUtilOptarg ); } } else { goto usage; } fBatch = 1; break; case 'T': if ( TypeCheck( pAbc, globalUtilOptarg ) ) { if (!strcmp(globalUtilOptarg, "none") == 0) { fFinalWrite = 1; sprintf( sWriteCmd, "write_%s", globalUtilOptarg); } } else { goto usage; } fBatch = 1; break; case 'x': fFinalWrite = 0; fInitRead = 0; fBatch = 1; break; case 'b': Abc_FrameSetBridgeMode(); break; default: goto usage; } } if ( Abc_FrameIsBridgeMode() ) { extern Gia_Man_t * Gia_ManFromBridge( FILE * pFile, Vec_Int_t ** pvInit ); pAbc->pGia = Gia_ManFromBridge( stdin, NULL ); } else if ( fBatch && sCommandUsr[0] ) Abc_Print( 1, "ABC command line: \"%s\".\n\n", sCommandUsr ); if ( fBatch ) { pAbc->fBatchMode = 1; if (argc - globalUtilOptind == 0) { sInFile = NULL; } else if (argc - globalUtilOptind == 1) { fInitRead = 1; sInFile = argv[globalUtilOptind]; } else { Abc_UtilsPrintUsage( pAbc, argv[0] ); } // source the resource file if ( fInitSource ) { Abc_UtilsSource( pAbc ); } fStatus = 0; if ( fInitRead && sInFile ) { sprintf( sCommandTmp, "%s %s", sReadCmd, sInFile ); fStatus = Cmd_CommandExecute( pAbc, sCommandTmp ); } if ( fStatus == 0 ) { /* cmd line contains `source <file>' */ fStatus = Cmd_CommandExecute( pAbc, sCommandUsr ); if ( (fStatus == 0 || fStatus == -1) && fFinalWrite && sOutFile ) { sprintf( sCommandTmp, "%s %s", sWriteCmd, sOutFile ); fStatus = Cmd_CommandExecute( pAbc, sCommandTmp ); } } if (fBatch == 2){ fBatch = 0; pAbc->fBatchMode = 0; } } if ( !fBatch ) { // start interactive mode // print the hello line Abc_UtilsPrintHello( pAbc ); // print history of the recent commands Cmd_HistoryPrint( pAbc, 10 ); // source the resource file if ( fInitSource ) { Abc_UtilsSource( pAbc ); } // execute commands given by the user while ( !feof(stdin) ) { // print command line prompt and // get the command from the user sCommand = Abc_UtilsGetUsersInput( pAbc ); // execute the user's command fStatus = Cmd_CommandExecute( pAbc, sCommand ); // stop if the user quitted or an error occurred if ( fStatus == -1 || fStatus == -2 ) break; } } #ifdef ABC_PYTHON_EMBED { Py_Finalize(); } #endif /* ABC_PYTHON_EMBED */ // if the memory should be freed, quit packages // if ( fStatus < 0 ) { Abc_Stop(); } return 0; usage: Abc_UtilsPrintHello( pAbc ); Abc_UtilsPrintUsage( pAbc, argv[0] ); return 1; }
/**Function******************************************************************** Synopsis [] Description [] SideEffects [] SeeAlso [] ******************************************************************************/ int Cba_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv ) { Cba_Man_t * p = Cba_AbcGetMan(pAbc), * pTemp; Gia_Man_t * pFirst, * pSecond, * pMiter; Cec_ParCec_t ParsCec, * pPars = &ParsCec; char * pFileName, * pStr, ** pArgvNew; int c, nArgcNew, fDumpMiter = 0; FILE * pFile; Cec_ManCecSetDefaultParams( pPars ); Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) { switch ( c ) { case 'v': pPars->fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( p == NULL ) { Abc_Print( 1, "Cba_CommandCec(): There is no current design.\n" ); return 0; } pArgvNew = argv + globalUtilOptind; nArgcNew = argc - globalUtilOptind; if ( nArgcNew != 1 ) { if ( p->pSpec == NULL ) { Abc_Print( -1, "File name is not given on the command line.\n" ); return 1; } pFileName = p->pSpec; } else pFileName = pArgvNew[0]; // fix the wrong symbol for ( pStr = pFileName; *pStr; pStr++ ) if ( *pStr == '>' ) *pStr = '\\'; if ( (pFile = fopen( pFileName, "r" )) == NULL ) { Abc_Print( -1, "Cannot open input file \"%s\". ", pFileName ); if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".v", ".blif", NULL, NULL, NULL )) ) Abc_Print( 1, "Did you mean \"%s\"?", pFileName ); Abc_Print( 1, "\n" ); return 1; } fclose( pFile ); // extract AIG from the current design pFirst = Cba_ManBlast( p, 0, 0, 0 ); if ( pFirst == NULL ) { Abc_Print( -1, "Extracting AIG from the current design has failed.\n" ); return 0; } // extract AIG from the second design if ( !strcmp( Extra_FileNameExtension(pFileName), "blif" ) ) pTemp = Cba_ManReadBlif( pFileName ); else if ( !strcmp( Extra_FileNameExtension(pFileName), "v" ) ) pTemp = Cba_ManReadVerilog( pFileName ); else if ( !strcmp( Extra_FileNameExtension(pFileName), "cba" ) ) pTemp = Cba_ManReadCba( pFileName ); else assert( 0 ); pSecond = Cba_ManBlast( pTemp, 0, 0, 0 ); Cba_ManFree( pTemp ); if ( pSecond == NULL ) { Gia_ManStop( pFirst ); Abc_Print( -1, "Extracting AIG from the original design has failed.\n" ); return 0; } // compute the miter pMiter = Gia_ManMiter( pFirst, pSecond, 0, 1, 0, 0, pPars->fVerbose ); if ( pMiter ) { if ( fDumpMiter ) { Abc_Print( 0, "The verification miter is written into file \"%s\".\n", "cec_miter.aig" ); Gia_AigerWrite( pMiter, "cec_miter.aig", 0, 0 ); } pAbc->Status = Cec_ManVerify( pMiter, pPars ); //Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexComb ); Gia_ManStop( pMiter ); } Gia_ManStop( pFirst ); Gia_ManStop( pSecond ); return 0; usage: Abc_Print( -2, "usage: @cec [-vh]\n" ); Abc_Print( -2, "\t combinational equivalence checking\n" ); Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; }
static int Abc_SclReadLibrary( Vec_Str_t * vOut, int * pPos, SC_Lib * p ) { int i, j, k, n; int version = Vec_StrGetI( vOut, pPos ); if ( version != ABC_SCL_CUR_VERSION ) { Abc_Print( -1, "Wrong version of the SCL file.\n" ); return 0; } assert( version == ABC_SCL_CUR_VERSION ); // wrong version of the file // Read non-composite fields: p->pName = Vec_StrGetS(vOut, pPos); p->default_wire_load = Vec_StrGetS(vOut, pPos); p->default_wire_load_sel = Vec_StrGetS(vOut, pPos); p->default_max_out_slew = Vec_StrGetF(vOut, pPos); p->unit_time = Vec_StrGetI(vOut, pPos); p->unit_cap_fst = Vec_StrGetF(vOut, pPos); p->unit_cap_snd = Vec_StrGetI(vOut, pPos); // Read 'wire_load' vector: for ( i = Vec_StrGetI(vOut, pPos); i != 0; i-- ) { SC_WireLoad * pWL = Abc_SclWireLoadAlloc(); Vec_PtrPush( p->vWireLoads, pWL ); pWL->pName = Vec_StrGetS(vOut, pPos); pWL->cap = Vec_StrGetF(vOut, pPos); pWL->slope = Vec_StrGetF(vOut, pPos); for ( j = Vec_StrGetI(vOut, pPos); j != 0; j-- ) { Vec_IntPush( pWL->vFanout, Vec_StrGetI(vOut, pPos) ); Vec_FltPush( pWL->vLen, Vec_StrGetF(vOut, pPos) ); } } // Read 'wire_load_sel' vector: for ( i = Vec_StrGetI(vOut, pPos); i != 0; i-- ) { SC_WireLoadSel * pWLS = Abc_SclWireLoadSelAlloc(); Vec_PtrPush( p->vWireLoadSels, pWLS ); pWLS->pName = Vec_StrGetS(vOut, pPos); for ( j = Vec_StrGetI(vOut, pPos); j != 0; j-- ) { Vec_FltPush( pWLS->vAreaFrom, Vec_StrGetF(vOut, pPos) ); Vec_FltPush( pWLS->vAreaTo, Vec_StrGetF(vOut, pPos) ); Vec_PtrPush( pWLS->vWireLoadModel, Vec_StrGetS(vOut, pPos) ); } } for ( i = Vec_StrGetI(vOut, pPos); i != 0; i-- ) { SC_Cell * pCell = Abc_SclCellAlloc(); pCell->Id = SC_LibCellNum(p); Vec_PtrPush( p->vCells, pCell ); pCell->pName = Vec_StrGetS(vOut, pPos); pCell->area = Vec_StrGetF(vOut, pPos); pCell->drive_strength = Vec_StrGetI(vOut, pPos); pCell->n_inputs = Vec_StrGetI(vOut, pPos); pCell->n_outputs = Vec_StrGetI(vOut, pPos); /* printf( "%s\n", pCell->pName ); if ( !strcmp( "XOR3_X4M_A9TL", pCell->pName ) ) { int s = 0; } */ for ( j = 0; j < pCell->n_inputs; j++ ) { SC_Pin * pPin = Abc_SclPinAlloc(); Vec_PtrPush( pCell->vPins, pPin ); pPin->dir = sc_dir_Input; pPin->pName = Vec_StrGetS(vOut, pPos); pPin->rise_cap = Vec_StrGetF(vOut, pPos); pPin->fall_cap = Vec_StrGetF(vOut, pPos); } for ( j = 0; j < pCell->n_outputs; j++ ) { SC_Pin * pPin = Abc_SclPinAlloc(); Vec_PtrPush( pCell->vPins, pPin ); pPin->dir = sc_dir_Output; pPin->pName = Vec_StrGetS(vOut, pPos); pPin->max_out_cap = Vec_StrGetF(vOut, pPos); pPin->max_out_slew = Vec_StrGetF(vOut, pPos); k = Vec_StrGetI(vOut, pPos); assert( k == pCell->n_inputs ); // read function // (possibly empty) formula is always given assert( version == ABC_SCL_CUR_VERSION ); assert( pPin->func_text == NULL ); pPin->func_text = Vec_StrGetS(vOut, pPos); if ( pPin->func_text[0] == 0 ) { // formula is not given - read truth table ABC_FREE( pPin->func_text ); assert( Vec_WrdSize(pPin->vFunc) == 0 ); Vec_WrdGrow( pPin->vFunc, Abc_Truth6WordNum(pCell->n_inputs) ); for ( k = 0; k < Vec_WrdCap(pPin->vFunc); k++ ) Vec_WrdPush( pPin->vFunc, Vec_StrGetW(vOut, pPos) ); } else { // formula is given - derive truth table SC_Pin * pPin2; Vec_Ptr_t * vNames; // collect input names vNames = Vec_PtrAlloc( pCell->n_inputs ); SC_CellForEachPinIn( pCell, pPin2, n ) Vec_PtrPush( vNames, pPin2->pName ); // derive truth table assert( Vec_WrdSize(pPin->vFunc) == 0 ); Vec_WrdFree( pPin->vFunc ); pPin->vFunc = Mio_ParseFormulaTruth( pPin->func_text, (char **)Vec_PtrArray(vNames), pCell->n_inputs ); Vec_PtrFree( vNames ); // skip truth table assert( Vec_WrdSize(pPin->vFunc) == Abc_Truth6WordNum(pCell->n_inputs) ); for ( k = 0; k < Vec_WrdSize(pPin->vFunc); k++ ) { word Value = Vec_StrGetW(vOut, pPos); assert( Value == Vec_WrdEntry(pPin->vFunc, k) ); } } // Read 'rtiming': (pin-to-pin timing tables for this particular output) for ( k = 0; k < pCell->n_inputs; k++ ) { SC_Timings * pRTime = Abc_SclTimingsAlloc(); Vec_PtrPush( pPin->vRTimings, pRTime ); pRTime->pName = Vec_StrGetS(vOut, pPos); n = Vec_StrGetI(vOut, pPos); assert( n <= 1 ); if ( n == 1 ) { SC_Timing * pTime = Abc_SclTimingAlloc(); Vec_PtrPush( pRTime->vTimings, pTime ); pTime->tsense = (SC_TSense)Vec_StrGetI(vOut, pPos); Abc_SclReadSurface( vOut, pPos, pTime->pCellRise ); Abc_SclReadSurface( vOut, pPos, pTime->pCellFall ); Abc_SclReadSurface( vOut, pPos, pTime->pRiseTrans ); Abc_SclReadSurface( vOut, pPos, pTime->pFallTrans ); } else assert( Vec_PtrSize(pRTime->vTimings) == 0 ); } } } return 1; }
/**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 [] ******************************************************************************/ int Cba_CommandPs( Abc_Frame_t * pAbc, int argc, char ** argv ) { Cba_Man_t * p = Cba_AbcGetMan(pAbc); int nModules = 0; int fShowMulti = 0; int fShowAdder = 0; int fDistrib = 0; int c, fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "Mmadvh" ) ) != EOF ) { switch ( c ) { case 'M': if ( globalUtilOptind >= argc ) { Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" ); goto usage; } nModules = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nModules < 0 ) goto usage; break; case 'm': fShowMulti ^= 1; break; case 'a': fShowAdder ^= 1; break; case 'd': fDistrib ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( p == NULL ) { Abc_Print( 1, "Cba_CommandPs(): There is no current design.\n" ); return 0; } if ( nModules ) { Cba_ManPrintStats( p, nModules, fVerbose ); return 0; } Cba_NtkPrintStatsFull( Cba_ManRoot(p), fDistrib, fVerbose ); if ( fShowMulti ) Cba_NtkPrintNodes( Cba_ManRoot(p), CBA_BOX_MUL ); if ( fShowAdder ) Cba_NtkPrintNodes( Cba_ManRoot(p), CBA_BOX_ADD ); return 0; usage: Abc_Print( -2, "usage: @ps [-M num] [-madvh]\n" ); Abc_Print( -2, "\t prints statistics\n" ); Abc_Print( -2, "\t-M num : the number of first modules to report [default = %d]\n", nModules ); Abc_Print( -2, "\t-m : toggle printing multipliers [default = %s]\n", fShowMulti? "yes": "no" ); Abc_Print( -2, "\t-a : toggle printing adders [default = %s]\n", fShowAdder? "yes": "no" ); Abc_Print( -2, "\t-d : toggle printing distrubition [default = %s]\n", fDistrib? "yes": "no" ); Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; }
/**Function******************************************************************** Synopsis [] Description [] SideEffects [] SeeAlso [] ******************************************************************************/ int Cba_CommandWrite( Abc_Frame_t * pAbc, int argc, char ** argv ) { Cba_Man_t * p = Cba_AbcGetMan(pAbc); char * pFileName = NULL; int fInclineCats = 0; int c, fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "cvh" ) ) != EOF ) { switch ( c ) { case 'c': fInclineCats ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( p == NULL ) { Abc_Print( 1, "Cba_CommandWrite(): There is no current design.\n" ); return 0; } if ( argc == globalUtilOptind + 1 ) pFileName = argv[globalUtilOptind]; else if ( argc == globalUtilOptind && p ) { pFileName = Extra_FileNameGenericAppend( Cba_ManSpec(p) ? Cba_ManSpec(p) : Cba_ManName(p), "_out.v" ); printf( "Generated output file name \"%s\".\n", pFileName ); } else { printf( "Output file name should be given on the command line.\n" ); return 0; } // perform writing if ( !strcmp( Extra_FileNameExtension(pFileName), "blif" ) ) Cba_ManWriteBlif( pFileName, p ); else if ( !strcmp( Extra_FileNameExtension(pFileName), "v" ) ) Cba_ManWriteVerilog( pFileName, p, fInclineCats ); else if ( !strcmp( Extra_FileNameExtension(pFileName), "cba" ) ) Cba_ManWriteCba( pFileName, p ); else { printf( "Unrecognized output file extension.\n" ); return 0; } return 0; usage: Abc_Print( -2, "usage: @write [-cvh]\n" ); Abc_Print( -2, "\t writes the design into a file in BLIF or Verilog\n" ); Abc_Print( -2, "\t-c : toggle inlining input concatenations [default = %s]\n", fInclineCats? "yes": "no" ); Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; }
/**Function******************************************************************** Synopsis [] Description [] SideEffects [] SeeAlso [] ******************************************************************************/ int Cba_CommandRead( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pFile; Cba_Man_t * p = NULL; char * pFileName = NULL; int c, fTest = 0, fDfs = 0, fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "tdvh" ) ) != EOF ) { switch ( c ) { case 't': fTest ^= 1; break; case 'd': fDfs ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( argc != globalUtilOptind + 1 ) { printf( "Cba_CommandRead(): Input file name should be given on the command line.\n" ); return 0; } // get the file name pFileName = argv[globalUtilOptind]; if ( (pFile = fopen( pFileName, "r" )) == NULL ) { Abc_Print( 1, "Cannot open input file \"%s\". ", pFileName ); if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".v", ".blif", ".smt", ".cba", NULL )) ) Abc_Print( 1, "Did you mean \"%s\"?", pFileName ); Abc_Print( 1, "\n" ); return 0; } fclose( pFile ); if ( fTest ) { if ( !strcmp( Extra_FileNameExtension(pFileName), "blif" ) ) Prs_ManReadBlifTest( pFileName ); else if ( !strcmp( Extra_FileNameExtension(pFileName), "v" ) ) Prs_ManReadVerilogTest( pFileName ); else { printf( "Unrecognized input file extension.\n" ); return 0; } return 0; } if ( !strcmp( Extra_FileNameExtension(pFileName), "blif" ) ) p = Cba_ManReadBlif( pFileName ); else if ( !strcmp( Extra_FileNameExtension(pFileName), "v" ) ) p = Cba_ManReadVerilog( pFileName ); else if ( !strcmp( Extra_FileNameExtension(pFileName), "cba" ) ) p = Cba_ManReadCba( pFileName ); else { printf( "Unrecognized input file extension.\n" ); return 0; } if ( fDfs ) { Cba_Man_t * pTemp; p = Cba_ManDup( pTemp = p, Cba_NtkCollectDfs ); Cba_ManFree( pTemp ); } Cba_AbcUpdateMan( pAbc, p ); return 0; usage: Abc_Print( -2, "usage: @read [-tdvh] <file_name>\n" ); Abc_Print( -2, "\t reads hierarchical design\n" ); Abc_Print( -2, "\t-t : toggle testing the parser [default = %s]\n", fTest? "yes": "no" ); Abc_Print( -2, "\t-d : toggle computing DFS ordering [default = %s]\n", fDfs? "yes": "no" ); Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; }