/**Function************************************************************* Synopsis [Deallocates sequential AIG manager.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Seq_Resize( Abc_Seq_t * p, int nMaxId ) { if ( p->nSize > nMaxId ) return; p->nSize = nMaxId + 1; Vec_IntFill( p->vNums, 2 * p->nSize, 0 ); Vec_PtrFill( p->vInits, 2 * p->nSize, NULL ); Vec_IntFill( p->vLValues, p->nSize, 0 ); Vec_StrFill( p->vLags, p->nSize, 0 ); Vec_IntFill( p->vLValuesN, p->nSize, 0 ); Vec_IntFill( p->vAFlows, p->nSize, 0 ); Vec_StrFill( p->vLagsN, p->nSize, 0 ); Vec_StrFill( p->vUses, p->nSize, 0 ); }
/**Function************************************************************* Synopsis [Expands cubes against the offset given as an AIG.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_ObjExpandCubesTry( Vec_Str_t * vSop, sat_solver * pSat, Vec_Int_t * vVars ) { extern int Bmc_CollapseExpandRound( sat_solver * pSat, sat_solver * pSatOn, Vec_Int_t * vLits, Vec_Int_t * vNums, Vec_Int_t * vTemp, int nBTLimit, int fCanon, int fOnOffSetLit ); char * pCube, * pSop = Vec_StrArray(vSop); int nCubes = Abc_SopGetCubeNum(pSop); int nVars = Abc_SopGetVarNum(pSop); Vec_Int_t * vLits = Vec_IntAlloc( nVars ); Vec_Int_t * vTemp = Vec_IntAlloc( nVars ); assert( nVars == Vec_IntSize(vVars) ); assert( Vec_StrSize(vSop) == nCubes * (nVars + 3) + 1 ); Bmc_SopForEachCube( pSop, nVars, pCube ) { int k, Entry; // collect literals and clean cube Vec_IntFill( vLits, nVars, -1 ); for ( k = 0; k < nVars; k++ ) { if ( pCube[k] == '-' ) continue; Vec_IntWriteEntry( vLits, k, Abc_Var2Lit(Vec_IntEntry(vVars, k), pCube[k] == '0') ); pCube[k] = '-'; } // expand cube Bmc_CollapseExpandRound( pSat, NULL, vLits, NULL, vTemp, 0, 0, -1 ); // insert literals Vec_IntForEachEntry( vLits, Entry, k ) if ( Entry != -1 ) pCube[k] = '1' - Abc_LitIsCompl(Entry); }
/**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Mig_ManSetRefs( Mig_Man_t * p ) { Mig_Obj_t * pObj; int i, iFanin; // increment references Vec_IntFill( &p->vRefs, Mig_ManObjNum(p), 0 ); Mig_ManForEachObj( p, pObj ) { Mig_ObjForEachFaninId( pObj, iFanin, i ) Vec_IntAddToEntry( &p->vRefs, iFanin, 1 ); if ( Mig_ObjSiblId(pObj) ) Vec_IntAddToEntry( &p->vRefs, Mig_ObjSiblId(pObj), 1 ); }
/**Function************************************************************* Synopsis [Computes equivalence classes of objects in pNtk1 and pNtk2.] Description [Internal procedure.] SideEffects [] SeeAlso [] ***********************************************************************/ Vec_Ptr_t * Abc_NtkDressMapIds( Aig_Man_t * pMiter, Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2 ) { Vec_Ptr_t * vRes; Vec_Int_t * vId2Lit1, * vId2Lit2, * vCounts0, * vCounts1, * vClassC, * vClass2Num; int i, Class; // start the classes vRes = Vec_PtrAlloc( 1000 ); // set polarity of the nodes Abc_NtkDressMapSetPolarity( pNtk1 ); Abc_NtkDressMapSetPolarity( pNtk2 ); // create mapping of node IDs of pNtk1/pNtk2 into the IDs of equiv classes of pMiter vId2Lit1 = Abc_NtkDressMapClasses( pMiter, pNtk1 ); vId2Lit2 = Abc_NtkDressMapClasses( pMiter, pNtk2 ); // count the number of nodes in each equivalence class vCounts0 = Vec_IntStart( Aig_ManObjNumMax(pMiter) ); Vec_IntForEachEntry( vId2Lit1, Class, i ) if ( Class >= 0 ) Vec_IntAddToEntry( vCounts0, Class, 1 ); vCounts1 = Vec_IntStart( Aig_ManObjNumMax(pMiter) ); Vec_IntForEachEntry( vId2Lit2, Class, i ) if ( Class >= 0 ) Vec_IntAddToEntry( vCounts1, Class, 1 ); // get the costant class vClassC = Vec_IntAlloc( 100 ); Vec_IntForEachEntry( vId2Lit1, Class, i ) if ( Class == 0 ) Vec_IntPush( vClassC, Abc_ObjDressMakeId(pNtk1, i, 0) ); Vec_IntForEachEntry( vId2Lit2, Class, i ) if ( Class == 0 ) Vec_IntPush( vClassC, Abc_ObjDressMakeId(pNtk2, i, 1) ); Vec_PtrPush( vRes, vClassC ); // map repr node IDs into class numbers vClass2Num = Vec_IntAlloc( 0 ); Vec_IntFill( vClass2Num, Aig_ManObjNumMax(pMiter), -1 ); // keep classes having at least one element from pNtk1 and one from pNtk2 Vec_IntForEachEntry( vId2Lit1, Class, i ) if ( Class > 0 && Vec_IntEntry(vCounts0, Class) && Vec_IntEntry(vCounts1, Class) ) Vec_IntPush( Abc_ObjDressClass(vRes, vClass2Num, Class), Abc_ObjDressMakeId(pNtk1, i, 0) ); Vec_IntForEachEntry( vId2Lit2, Class, i ) if ( Class > 0 && Vec_IntEntry(vCounts0, Class) && Vec_IntEntry(vCounts1, Class) ) Vec_IntPush( Abc_ObjDressClass(vRes, vClass2Num, Class), Abc_ObjDressMakeId(pNtk2, i, 1) ); // package them accordingly Vec_IntFree( vClass2Num ); Vec_IntFree( vCounts0 ); Vec_IntFree( vCounts1 ); Vec_IntFree( vId2Lit1 ); Vec_IntFree( vId2Lit2 ); return vRes; }
/**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Bal_Man_t * Bal_ManAlloc( Gia_Man_t * pGia, Gia_Man_t * pNew, int nLutSize, int nCutNum, int fVerbose ) { Bal_Man_t * p; p = ABC_CALLOC( Bal_Man_t, 1 ); p->clkStart = Abc_Clock(); p->pGia = pGia; p->pNew = pNew; p->nLutSize = nLutSize; p->nCutNum = nCutNum; p->fVerbose = fVerbose; p->vCosts = Vec_IntAlloc( 3 * Gia_ManObjNum(pGia) / 2 ); p->vCutSets = Vec_PtrAlloc( 3 * Gia_ManObjNum(pGia) / 2 ); Vec_IntFill( p->vCosts, Gia_ManObjNum(pNew), 0 ); Vec_PtrFill( p->vCutSets, Gia_ManObjNum(pNew), NULL ); pNew->pData = p; return p; }
static inline void Gia_ManComputeDoms( Gia_Man_t * p ) { Gia_Obj_t * pObj; int i; if ( p->vDoms == NULL ) p->vDoms = Vec_IntAlloc( 0 ); Vec_IntFill( p->vDoms, Gia_ManObjNum(p), -1 ); Gia_ManForEachObjReverse( p, pObj, i ) { if ( i == 0 || Gia_ObjIsCi(pObj) ) continue; if ( Gia_ObjIsCo(pObj) ) { Gia_ObjSetDom( p, pObj, i ); Gia_ManAddDom( p, Gia_ObjFanin0(pObj), i ); continue; } assert( Gia_ObjIsAnd(pObj) ); Gia_ManAddDom( p, Gia_ObjFanin0(pObj), i ); Gia_ManAddDom( p, Gia_ObjFanin1(pObj), i ); } }
/**Function************************************************************* Synopsis [Create mapping of node IDs of pNtk into equiv classes of pMiter.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Vec_Int_t * Abc_NtkDressMapClasses( Aig_Man_t * pMiter, Abc_Ntk_t * pNtk ) { Vec_Int_t * vId2Lit; Abc_Obj_t * pObj, * pAnd; Aig_Obj_t * pObjMan, * pObjMiter, * pObjRepr; int i; vId2Lit = Vec_IntAlloc( 0 ); Vec_IntFill( vId2Lit, Abc_NtkObjNumMax(pNtk), -1 ); Abc_NtkForEachNode( pNtk, pObj, i ) { // get the pointer to the miter node corresponding to pObj if ( (pAnd = Abc_ObjRegular(pObj->pCopy)) && Abc_ObjType(pAnd) != ABC_OBJ_NONE && // strashed node is present and legal (pObjMan = Aig_Regular((Aig_Obj_t *)pAnd->pCopy)) && Aig_ObjType(pObjMan) != AIG_OBJ_NONE && // AIG node is present and legal (pObjMiter = Aig_Regular((Aig_Obj_t *)pObjMan->pData)) && Aig_ObjType(pObjMiter) != AIG_OBJ_NONE ) // miter node is present and legal { // get the representative of the miter node pObjRepr = Aig_ObjRepr( pMiter, pObjMiter ); pObjRepr = pObjRepr? pObjRepr : pObjMiter; // map pObj (whose ID is i) into the repr node ID (i.e. equiv class) Vec_IntWriteEntry( vId2Lit, i, Aig_ObjId(pObjRepr) ); } } return vId2Lit; }
ABC_NAMESPACE_IMPL_START //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Mpm_Man_t * Mpm_ManStart( Mig_Man_t * pMig, Mpm_Par_t * pPars ) { Mpm_Man_t * p; int i; assert( sizeof(Mpm_Uni_t) % sizeof(word) == 0 ); // aligned info to word boundary assert( pPars->nNumCuts <= MPM_CUT_MAX ); assert( !pPars->fUseTruth || pPars->pLib->LutMax <= 16 ); assert( !pPars->fUseDsd || pPars->pLib->LutMax <= 6 ); Mig_ManSetRefs( pMig ); // alloc p = ABC_CALLOC( Mpm_Man_t, 1 ); p->pMig = pMig; p->pPars = pPars; p->pLibLut = pPars->pLib; p->nLutSize = pPars->pLib->LutMax; p->nTruWords = pPars->fUseTruth ? Abc_Truth6WordNum(p->nLutSize) : 0; p->nNumCuts = pPars->nNumCuts; // cuts assert( Mpm_CutWordNum(32) < 32 ); // using 5 bits for word count p->pManCuts = Mmr_StepStart( 13, Abc_Base2Log(Mpm_CutWordNum(p->nLutSize) + 1) ); Vec_PtrGrow( &p->vFreeUnits, p->nNumCuts + 1 ); for ( i = p->nNumCuts; i >= 0; i-- ) Vec_PtrPush( &p->vFreeUnits, p->pCutUnits + i ); p->vTemp = Vec_PtrAlloc( 1000 ); // mapping attributes Vec_IntFill( &p->vCutBests, Mig_ManObjNum(pMig), 0 ); Vec_IntFill( &p->vCutLists, Mig_ManObjNum(pMig), 0 ); Vec_IntFill( &p->vMigRefs, Mig_ManObjNum(pMig), 0 ); Vec_IntFill( &p->vMapRefs, Mig_ManObjNum(pMig), 0 ); Vec_IntFill( &p->vEstRefs, Mig_ManObjNum(pMig), 0 ); Vec_IntFill( &p->vRequireds, Mig_ManObjNum(pMig), ABC_INFINITY ); Vec_IntFill( &p->vTimes, Mig_ManObjNum(pMig), 0 ); Vec_IntFill( &p->vAreas, Mig_ManObjNum(pMig), 0 ); Vec_IntFill( &p->vEdges, Mig_ManObjNum(pMig), 0 ); // start DSD manager assert( !p->pPars->fUseTruth || !p->pPars->fUseDsd ); if ( p->pPars->fUseTruth ) { p->vTtMem = Vec_MemAlloc( p->nTruWords, 12 ); // 32 KB/page for 6-var functions Vec_MemHashAlloc( p->vTtMem, 10000 ); p->funcCst0 = Vec_MemHashInsert( p->vTtMem, p->Truth ); Abc_TtUnit( p->Truth, p->nTruWords, 0 ); p->funcVar0 = Vec_MemHashInsert( p->vTtMem, p->Truth ); } else if ( p->pPars->fUseDsd ) { Mpm_ManPrecomputePerms( p ); p->funcVar0 = 1; } // finish p->timeTotal = Abc_Clock(); pMig->pMan = p; return p; }