/**Function************************************************************* Synopsis [Computes one-node dominators.] Description [For each node, computes the closest one-node dominator, which can be the node itself if the node has no other dominators.] SideEffects [] SeeAlso [] ***********************************************************************/ static inline void Gia_ManAddDom( Gia_Man_t * p, Gia_Obj_t * pObj, int iDom0 ) { int iDom1, iDomNext; if ( Gia_ObjDom(p, pObj) == -1 ) { Gia_ObjSetDom( p, pObj, iDom0 ); return; } iDom1 = Gia_ObjDom( p, pObj ); while ( 1 ) { if ( iDom0 > iDom1 ) { iDomNext = Gia_ObjDom( p, Gia_ManObj(p, iDom1) ); if ( iDomNext == iDom1 ) break; iDom1 = iDomNext; continue; } if ( iDom1 > iDom0 ) { iDomNext = Gia_ObjDom( p, Gia_ManObj(p, iDom0) ); if ( iDomNext == iDom0 ) break; iDom0 = iDomNext; continue; } assert( iDom0 == iDom1 ); Gia_ObjSetDom( p, pObj, iDom0 ); return; } Gia_ObjSetDom( p, pObj, Gia_ObjId(p, pObj) ); }
void Gia_ManPrintTents( Gia_Man_t * p ) { Vec_Int_t * vObjs; Gia_Obj_t * pObj; int t, i, iObjId, nSizePrev, nSizeCurr; assert( Gia_ManPoNum(p) > 0 ); vObjs = Vec_IntAlloc( 100 ); // save constant class Gia_ManIncrementTravId( p ); Gia_ObjSetTravIdCurrent( p, Gia_ManConst0(p) ); Vec_IntPush( vObjs, 0 ); // create starting root nSizePrev = Vec_IntSize(vObjs); Gia_ManForEachPo( p, pObj, i ) Gia_ManPrintTents_rec( p, pObj, vObjs ); // build tents printf( "Tents: " ); for ( t = 1; nSizePrev < Vec_IntSize(vObjs); t++ ) { nSizeCurr = Vec_IntSize(vObjs); Vec_IntForEachEntryStartStop( vObjs, iObjId, i, nSizePrev, nSizeCurr ) if ( Gia_ObjIsRo(p, Gia_ManObj(p, iObjId)) ) Gia_ManPrintTents_rec( p, Gia_ObjRoToRi(p, Gia_ManObj(p, iObjId)), vObjs ); printf( "%d=%d ", t, nSizeCurr - nSizePrev ); nSizePrev = nSizeCurr; } printf( " Unused=%d\n", Gia_ManObjNum(p) - Vec_IntSize(vObjs) ); Vec_IntFree( vObjs ); // the remaining objects are PIs without fanout // Gia_ManForEachObj( p, pObj, i ) // if ( !Gia_ObjIsTravIdCurrent(p, pObj) ) // Gia_ObjPrint( p, pObj ); }
/**Function************************************************************* Synopsis [Makes sure the manager is normalized.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Gia_ManIsNormalized( Gia_Man_t * p ) { int i, nOffset; nOffset = 1; for ( i = 0; i < Gia_ManCiNum(p); i++ ) if ( !Gia_ObjIsCi( Gia_ManObj(p, nOffset+i) ) ) return 0; nOffset = 1 + Gia_ManCiNum(p) + Gia_ManAndNum(p); for ( i = 0; i < Gia_ManCoNum(p); i++ ) if ( !Gia_ObjIsCo( Gia_ManObj(p, nOffset+i) ) ) return 0; return 1; }
static inline int Gia_ObjCheckMffc( Gia_Man_t * p, Gia_Obj_t * pRoot, int Limit, Vec_Int_t * vNodes, Vec_Int_t * vLeaves, Vec_Int_t * vInners ) { int RetValue, iObj, i; Vec_IntClear( vNodes ); RetValue = Gia_ObjCheckMffc_rec( p, pRoot, Limit, vNodes ); if ( RetValue ) { Vec_IntClear( vLeaves ); Vec_IntClear( vInners ); Vec_IntSort( vNodes, 0 ); Vec_IntForEachEntry( vNodes, iObj, i ) if ( Gia_ObjRefNumId(p, iObj) > 0 || Gia_ObjIsCi(Gia_ManObj(p, iObj)) ) { if ( !Vec_IntSize(vLeaves) || Vec_IntEntryLast(vLeaves) != iObj ) Vec_IntPush( vLeaves, iObj ); } else { if ( !Vec_IntSize(vInners) || Vec_IntEntryLast(vInners) != iObj ) Vec_IntPush( vInners, iObj ); } Vec_IntPush( vInners, Gia_ObjId(p, pRoot) ); } Vec_IntForEachEntry( vNodes, iObj, i ) Gia_ObjRefIncId( p, iObj ); return RetValue; }
/**Function************************************************************* Synopsis [Returns the number of words used.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Gia_ManSatPartCreate_rec( Gia_Man_t * p, Gia_Obj_t * pObj, int * pObjPlace, int * pStore ) { Gia_Obj_t * pFanin; int i, nWordsUsed, nSuperSize = 0, Super[2*GIA_LIMIT]; // make sure this is a valid node assert( Gia_ObjIsAnd(pObj) ); assert( pObj->fMark0 == 0 ); // collect inputs to the supergate Gia_ManSatPartCollectSuper( p, pObj, Super, &nSuperSize ); assert( nSuperSize <= 2*GIA_LIMIT ); // create the root entry *pObjPlace = 0; ((Gia_ObjSat1_t *)pObjPlace)->nFans = Gia_Var2Lit( nSuperSize, 0 ); ((Gia_ObjSat1_t *)pObjPlace)->nOffset = pStore - pObjPlace; nWordsUsed = nSuperSize; for ( i = 0; i < nSuperSize; i++ ) { pFanin = Gia_ManObj( p, Gia_Lit2Var(Super[i]) ); if ( pFanin->fMark0 ) { ((Gia_ObjSat2_t *)(pStore + i))->fTerm = 1; ((Gia_ObjSat2_t *)(pStore + i))->iLit = Super[i]; } else { assert( Gia_LitIsCompl(Super[i]) ); nWordsUsed += Gia_ManSatPartCreate_rec( p, pFanin, pStore + i, pStore + nWordsUsed ); } } return nWordsUsed; }
int Bmc_LoadAddCnf( void * pMan, int iLit ) { Bmc_Load_t * p = (Bmc_Load_t *)pMan; int Lits[3], iVar = Abc_Lit2Var(iLit); Gia_Obj_t * pObj = Gia_ManObj( p->pGia, Vec_IntEntry(p->vSat2Id, iVar) ); p->nCallBacks1++; if ( Gia_ObjIsCi(pObj) || Gia_ObjIsConst0(pObj) ) return 0; assert( Gia_ObjIsAnd(pObj) ); if ( (Abc_LitIsCompl(iLit) ? pObj->fMark1 : pObj->fMark0) ) return 0; Lits[0] = Abc_LitNot(iLit); if ( Abc_LitIsCompl(iLit) ) { Lits[1] = Abc_Var2Lit( Bmc_LoadGetSatVar(p, Gia_ObjFaninId0p(p->pGia, pObj)), !Gia_ObjFaninC0(pObj) ); Lits[2] = Abc_Var2Lit( Bmc_LoadGetSatVar(p, Gia_ObjFaninId1p(p->pGia, pObj)), !Gia_ObjFaninC1(pObj) ); sat_solver_clause_new( p->pSat, Lits, Lits + 3, 0 ); pObj->fMark1 = 1; } else { Lits[1] = Abc_Var2Lit( Bmc_LoadGetSatVar(p, Gia_ObjFaninId0p(p->pGia, pObj)), Gia_ObjFaninC0(pObj) ); sat_solver_clause_new( p->pSat, Lits, Lits + 2, 0 ); Lits[1] = Abc_Var2Lit( Bmc_LoadGetSatVar(p, Gia_ObjFaninId1p(p->pGia, pObj)), Gia_ObjFaninC1(pObj) ); sat_solver_clause_new( p->pSat, Lits, Lits + 2, 0 ); pObj->fMark0 = 1; } p->nCallBacks2++; return 1; }
int Dau_DsdBalance( Gia_Man_t * pGia, int * pFans, int nFans, int fAnd ) { Gia_Obj_t * pObj; int iFan0, iFan1, iFan; if ( nFans == 1 ) return pFans[0]; assert( nFans > 1 ); iFan0 = pFans[--nFans]; iFan1 = pFans[--nFans]; if ( fAnd ) iFan = Gia_ManHashAnd( pGia, iFan0, iFan1 ); else if ( pGia->pMuxes ) iFan = Gia_ManHashXorReal( pGia, iFan0, iFan1 ); else iFan = Gia_ManHashXor( pGia, iFan0, iFan1 ); pObj = Gia_ManObj(pGia, Abc_Lit2Var(iFan)); if ( Gia_ObjIsAnd(pObj) ) { if ( fAnd ) Gia_ObjSetAndLevel( pGia, pObj ); else if ( pGia->pMuxes ) Gia_ObjSetXorLevel( pGia, pObj ); else { if ( Gia_ObjIsAnd(Gia_ObjFanin0(pObj)) ) Gia_ObjSetAndLevel( pGia, Gia_ObjFanin0(pObj) ); if ( Gia_ObjIsAnd(Gia_ObjFanin1(pObj)) ) Gia_ObjSetAndLevel( pGia, Gia_ObjFanin1(pObj) ); Gia_ObjSetAndLevel( pGia, pObj ); } } Dau_DsdAddToArray( pGia, pFans, nFans++, iFan ); return Dau_DsdBalance( pGia, pFans, nFans, fAnd ); }
ABC_NAMESPACE_IMPL_START //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// /**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Gia_ManHighlight_rec( Gia_Man_t * p, int iObj ) { Gia_Obj_t * pObj; if ( Gia_ObjIsTravIdCurrentId(p, iObj) ) return; Gia_ObjSetTravIdCurrentId(p, iObj); pObj = Gia_ManObj( p, iObj ); if ( Gia_ObjIsAnd(pObj) ) Gia_ManHighlight_rec( p, Gia_ObjFaninId0(pObj, iObj) ); if ( Gia_ObjIsAnd(pObj) ) Gia_ManHighlight_rec( p, Gia_ObjFaninId1(pObj, iObj) ); }
int Gia_MuxDeref( Gia_Man_t * p, int iObj ) { Gia_Obj_t * pObj = Gia_ManObj( p, iObj ); assert( Gia_ObjIsMuxId(p, iObj) ); return Gia_MuxDeref_rec( p, Gia_ObjFaninId0p(p, pObj) ) + Gia_MuxDeref_rec( p, Gia_ObjFaninId1p(p, pObj) ) + Gia_MuxDeref_rec( p, Gia_ObjFaninId2p(p, pObj) ) + 1; }
/**Function************************************************************* Synopsis [Load CNF for the cone.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Bmc_LoadGetSatVar( Bmc_Load_t * p, int Id ) { Gia_Obj_t * pObj = Gia_ManObj( p->pGia, Id ); if ( pObj->Value == 0 ) { pObj->Value = Vec_IntSize( p->vSat2Id ); Vec_IntPush( p->vSat2Id, Id ); sat_solver_setnvars( p->pSat, Vec_IntSize(p->vSat2Id) ); } return pObj->Value; }
int Gia_MuxDeref_rec( Gia_Man_t * p, int iObj ) { Gia_Obj_t * pObj; if ( !Gia_ObjIsMuxId(p, iObj) ) return 0; pObj = Gia_ManObj( p, iObj ); if ( Gia_ObjRefDec(p, pObj) ) return 0; return Gia_MuxDeref_rec( p, Gia_ObjFaninId0p(p, pObj) ) + Gia_MuxDeref_rec( p, Gia_ObjFaninId1p(p, pObj) ) + Gia_MuxDeref_rec( p, Gia_ObjFaninId2p(p, pObj) ) + 1; }
/**Function************************************************************* Synopsis [Refine one class by resimulating one pattern.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Ssc_GiaSimulatePatternFraig_rec( Ssc_Man_t * p, int iFraigObj ) { Gia_Obj_t * pObj; int Res0, Res1; if ( Ssc_ObjSatVar(p, iFraigObj) ) return sat_solver_var_value( p->pSat, Ssc_ObjSatVar(p, iFraigObj) ); pObj = Gia_ManObj( p->pFraig, iFraigObj ); assert( Gia_ObjIsAnd(pObj) ); Res0 = Ssc_GiaSimulatePatternFraig_rec( p, Gia_ObjFaninId0(pObj, iFraigObj) ); Res1 = Ssc_GiaSimulatePatternFraig_rec( p, Gia_ObjFaninId1(pObj, iFraigObj) ); pObj->fMark0 = (Res0 ^ Gia_ObjFaninC0(pObj)) & (Res1 ^ Gia_ObjFaninC1(pObj)); return pObj->fMark0; }
void Gia_ManTisCollectMffc( Gia_Man_t * p, int Id, Vec_Int_t * vMffc, Vec_Int_t * vLeaves ) { Gia_Obj_t * pObj = Gia_ManObj( p, Id ); assert( Gia_ObjIsAnd(pObj) ); Vec_IntClear( vMffc ); Vec_IntClear( vLeaves ); Gia_ManIncrementTravId( p ); Gia_ManTisCollectMffc_rec( p, Gia_ObjFaninId0(pObj, Id), vMffc, vLeaves ); Gia_ManTisCollectMffc_rec( p, Gia_ObjFaninId1(pObj, Id), vMffc, vLeaves ); if ( Gia_ObjIsMuxId(p, Id) ) Gia_ManTisCollectMffc_rec( p, Gia_ObjFaninId2(p, Id), vMffc, vLeaves ); Vec_IntPush( vMffc, Id ); }
int Bmc_LoadAddCnf_rec( Bmc_Load_t * p, int Id ) { int iVar = Bmc_LoadGetSatVar( p, Id ); Gia_Obj_t * pObj = Gia_ManObj( p->pGia, Id ); if ( Gia_ObjIsAnd(pObj) && !(pObj->fMark0 && pObj->fMark1) ) { Bmc_LoadAddCnf( p, Abc_Var2Lit(iVar, 0) ); Bmc_LoadAddCnf( p, Abc_Var2Lit(iVar, 1) ); Bmc_LoadAddCnf_rec( p, Gia_ObjFaninId0(pObj, Id) ); Bmc_LoadAddCnf_rec( p, Gia_ObjFaninId1(pObj, Id) ); } return iVar; }
static inline void Wlc_ObjSimCo( Gia_Man_t * p, int iObj ) { int w; Gia_Obj_t * pObj = Gia_ManObj( p, iObj ); word * pSimCo = Wlc_ObjSim( p, iObj ); word * pSimDri = Wlc_ObjSim( p, Gia_ObjFaninId0(pObj, iObj) ); if ( Gia_ObjFaninC0(pObj) ) for ( w = 0; w < p->iPatsPi; w++ ) pSimCo[w] = ~pSimDri[w]; else for ( w = 0; w < p->iPatsPi; w++ ) pSimCo[w] = pSimDri[w]; }
Gia_Man_t * Gia_ManInsertWin( Gia_Man_t * p, Vec_Int_t * vOuts, Gia_Man_t * pWin ) { Vec_Int_t * vPos, * vPis, * vAnds; Gia_Man_t * pNew, * pTemp; Gia_Obj_t * pObj; int i; Gia_ManPrepareWin( p, vOuts, &vPis, &vPos, &vAnds ); // create AIG pNew = Gia_ManStart( Gia_ManObjNum(p) - Vec_IntSize(vAnds) + Gia_ManAndNum(pWin) ); pNew->pName = Abc_UtilStrsav( p->pName ); pNew->pSpec = Abc_UtilStrsav( p->pSpec ); // inputs Gia_ManConst0(p)->Value = 0; Gia_ManForEachCi( p, pObj, i ) pObj->Value = Gia_ManAppendCi( pNew ); Gia_ManConst0(pWin)->Value = 0; Gia_ManForEachCi( pWin, pObj, i ) pObj->Value = Gia_ManObj(p, Vec_IntEntry(vPis, i))->Value; // internal nodes Gia_ManHashAlloc( pNew ); Gia_ManForEachAnd( pWin, pObj, i ) pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) ); Gia_ManForEachCo( pWin, pObj, i ) Gia_ManObj( p, Vec_IntEntry(vPos, i) )->Value = Gia_ObjFanin0Copy(pObj); Gia_ManForEachAnd( p, pObj, i ) if ( !Gia_ObjIsTravIdCurrentId(p, i) ) pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) ); Gia_ManForEachCo( p, pObj, i ) Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) ); Gia_ManHashStop( pNew ); // cleanup Vec_IntFree( vPis ); Vec_IntFree( vPos ); Vec_IntFree( vAnds ); pNew = Gia_ManCleanup( pTemp = pNew ); Gia_ManStop( pTemp ); return pNew; }
/**Function************************************************************* Synopsis [Computes truth table of a 6-LUT.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Gia_ObjComputeTruthTable6Lut_rec( Gia_Man_t * p, int iObj, Vec_Wrd_t * vTemp ) { word uTruth0, uTruth1; Gia_Obj_t * pObj = Gia_ManObj( p, iObj ); if ( !Gia_ObjIsAnd(pObj) ) return; Gia_ObjComputeTruthTable6Lut_rec( p, Gia_ObjFaninId0p(p, pObj), vTemp ); Gia_ObjComputeTruthTable6Lut_rec( p, Gia_ObjFaninId1p(p, pObj), vTemp ); uTruth0 = Vec_WrdEntry( vTemp, Gia_ObjFanin0(pObj)->Value ); uTruth0 = Gia_ObjFaninC0(pObj) ? ~uTruth0 : uTruth0; uTruth1 = Vec_WrdEntry( vTemp, Gia_ObjFanin1(pObj)->Value ); uTruth1 = Gia_ObjFaninC1(pObj) ? ~uTruth1 : uTruth1; Vec_WrdWriteEntry( vTemp, iObj, uTruth0 & uTruth1 ); }
int Ssc_GiaResimulateOneClass( Ssc_Man_t * p, int iRepr, int iObj ) { int Ent, RetValue; assert( iRepr == Gia_ObjRepr(p->pAig, iObj) ); assert( Gia_ObjIsHead( p->pAig, iRepr ) ); // set bit-values at the nodes according to the counter-example Gia_ManIncrementTravId( p->pAig ); Gia_ClassForEachObj( p->pAig, iRepr, Ent ) Ssc_GiaSimulatePattern_rec( p, Gia_ManObj(p->pAig, Ent) ); // refine one class using these bit-values RetValue = Ssc_GiaSimClassRefineOneBit( p->pAig, iRepr ); // check that the candidate equivalence is indeed refined assert( iRepr != Gia_ObjRepr(p->pAig, iObj) ); return RetValue; }
/**Function************************************************************* Synopsis [Remaps the AIG from the old manager into the new manager.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Gia_ManCleanupRemap( Gia_Man_t * p, Gia_Man_t * pGia ) { Gia_Obj_t * pObj, * pObjGia; int i, iPrev; Gia_ManForEachObj1( p, pObj, i ) { iPrev = Gia_ObjValue(pObj); if ( iPrev == ~0 ) continue; pObjGia = Gia_ManObj( pGia, Abc_Lit2Var(iPrev) ); if ( pObjGia->Value == ~0 ) Gia_ObjSetValue( pObj, pObjGia->Value ); else Gia_ObjSetValue( pObj, Abc_LitNotCond(pObjGia->Value, Abc_LitIsCompl(iPrev)) ); }
/**Function************************************************************* Synopsis [Collects support nodes.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Gia_ManCollectCis( Gia_Man_t * p, int * pNodes, int nNodes, Vec_Int_t * vSupp ) { Gia_Obj_t * pObj; int i; Vec_IntClear( vSupp ); Gia_ManIncrementTravId( p ); Gia_ObjSetTravIdCurrent( p, Gia_ManConst0(p) ); for ( i = 0; i < nNodes; i++ ) { pObj = Gia_ManObj( p, pNodes[i] ); if ( Gia_ObjIsCo(pObj) ) Gia_ManCollectCis_rec( p, Gia_ObjFanin0(pObj), vSupp ); else Gia_ManCollectCis_rec( p, pObj, vSupp ); } }
/**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Gia_MuxStructPrint_rec( Gia_Man_t * p, int iObj, int fFirst ) { Gia_Obj_t * pObj = Gia_ManObj( p, iObj ); if ( !fFirst && (!Gia_ObjIsMuxId(p, iObj) || Gia_ObjRefNumId(p, iObj) > 0) ) return; printf( " [(%s", Gia_ObjFaninC2(p, pObj)? "!": "" ); if ( !Gia_ObjIsMuxId(p, Gia_ObjFaninId2p(p, pObj)) ) printf( "%d", Gia_ObjFaninId2p(p, pObj) ); else Gia_MuxStructPrint_rec( p, Gia_ObjFaninId2p(p, pObj), 0 ); printf( ")" ); Gia_MuxStructPrint_rec( p, Gia_ObjFaninId0p(p, pObj), 0 ); printf( "|" ); Gia_MuxStructPrint_rec( p, Gia_ObjFaninId1p(p, pObj), 0 ); printf( "] " ); }
/**Function************************************************************* Synopsis [Collects support nodes.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Vec_Int_t * Gia_ManCollectNodesCis( Gia_Man_t * p, int * pNodes, int nNodes ) { Vec_Int_t * vNodes; Gia_Obj_t * pObj; int i; vNodes = Vec_IntAlloc( 10000 ); Gia_ManIncrementTravId( p ); Gia_ObjSetTravIdCurrent( p, Gia_ManConst0(p) ); for ( i = 0; i < nNodes; i++ ) { pObj = Gia_ManObj( p, pNodes[i] ); if ( Gia_ObjIsCo(pObj) ) Gia_ManCollectNodesCis_rec( p, Gia_ObjFanin0(pObj), vNodes ); else Gia_ManCollectNodesCis_rec( p, pObj, vNodes ); } return vNodes; }
/**Function************************************************************* Synopsis [Duplicates AIG in the DFS order.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Gia_ManFromAigChoices_rec( Gia_Man_t * pNew, Aig_Man_t * p, Aig_Obj_t * pObj ) { if ( pObj == NULL || pObj->iData ) return; assert( Aig_ObjIsNode(pObj) ); Gia_ManFromAigChoices_rec( pNew, p, Aig_ObjFanin0(pObj) ); Gia_ManFromAigChoices_rec( pNew, p, Aig_ObjFanin1(pObj) ); Gia_ManFromAigChoices_rec( pNew, p, Aig_ObjEquiv(p, pObj) ); pObj->iData = Gia_ManAppendAnd( pNew, Gia_ObjChild0Copy(pObj), Gia_ObjChild1Copy(pObj) ); if ( Aig_ObjEquiv(p, pObj) ) { int iObjNew, iNextNew; iObjNew = Abc_Lit2Var(pObj->iData); iNextNew = Abc_Lit2Var(Aig_ObjEquiv(p, pObj)->iData); assert( iObjNew > iNextNew ); assert( Gia_ObjIsAnd(Gia_ManObj(pNew, iNextNew)) ); pNew->pSibls[iObjNew] = iNextNew; } }
static inline void Wlc_ObjSimAnd( Gia_Man_t * p, int iObj ) { int w; Gia_Obj_t * pObj = Gia_ManObj( p, iObj ); word * pSim = Wlc_ObjSim( p, iObj ); word * pSim0 = Wlc_ObjSim( p, Gia_ObjFaninId0(pObj, iObj) ); word * pSim1 = Wlc_ObjSim( p, Gia_ObjFaninId1(pObj, iObj) ); if ( Gia_ObjFaninC0(pObj) && Gia_ObjFaninC1(pObj) ) for ( w = 0; w < p->iPatsPi; w++ ) pSim[w] = ~pSim0[w] & ~pSim1[w]; else if ( Gia_ObjFaninC0(pObj) && !Gia_ObjFaninC1(pObj) ) for ( w = 0; w < p->iPatsPi; w++ ) pSim[w] = ~pSim0[w] & pSim1[w]; else if ( !Gia_ObjFaninC0(pObj) && Gia_ObjFaninC1(pObj) ) for ( w = 0; w < p->iPatsPi; w++ ) pSim[w] = pSim0[w] & ~pSim1[w]; else for ( w = 0; w < p->iPatsPi; w++ ) pSim[w] = pSim0[w] & pSim1[w]; }
/**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Gia_ManPrintSignals( Gia_Man_t * p, int * pFreq, char * pStr ) { Vec_Int_t * vObjs; int i, Counter = 0, nTotal = 0; vObjs = Vec_IntAlloc( 100 ); for ( i = 0; i < Gia_ManObjNum(p); i++ ) if ( pFreq[i] > 1 ) { nTotal += pFreq[i]; Counter++; } printf( "%s (total = %d driven = %d)\n", pStr, Counter, nTotal ); Counter = 0; for ( i = 0; i < Gia_ManObjNum(p); i++ ) if ( pFreq[i] > 10 ) { printf( "%3d : Obj = %6d Refs = %6d Freq = %6d\n", ++Counter, i, Gia_ObjRefs(p, Gia_ManObj(p,i)), pFreq[i] ); Vec_IntPush( vObjs, i ); } Vec_IntFree( vObjs ); }
/**Function************************************************************* Synopsis [Count the number of edges between internal nodes.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Vec_Int_t * Seg_ManCountIntEdges( Gia_Man_t * p, Vec_Int_t * vPolars, Vec_Int_t * vToSkip, int nFanouts ) { int i, iLut, iFanin; Vec_Int_t * vEdges = Vec_IntAlloc( 1000 ); assert( Gia_ManHasMapping(p) ); Vec_IntClear( vPolars ); Vec_IntClear( vToSkip ); if ( nFanouts ) Gia_ManSetLutRefs( p ); Gia_ManForEachLut( p, iLut ) Gia_LutForEachFanin( p, iLut, iFanin, i ) if ( Gia_ObjIsAnd(Gia_ManObj(p, iFanin)) ) { if ( p->vEdge1 && Gia_ObjCheckEdge(p, iFanin, iLut) ) Vec_IntPush( vPolars, Vec_IntSize(vEdges)/2 ); if ( nFanouts && Gia_ObjLutRefNumId(p, iFanin) >= nFanouts ) Vec_IntPush( vToSkip, Vec_IntSize(vEdges)/2 ); Vec_IntPushTwo( vEdges, iFanin, iLut ); } if ( nFanouts ) ABC_FREE( p->pLutRefs ); return vEdges; }
/**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Gia_ManTisCollectMffc_rec( Gia_Man_t * p, int Id, Vec_Int_t * vMffc, Vec_Int_t * vLeaves ) { Gia_Obj_t * pObj; if ( Gia_ObjIsTravIdCurrentId(p, Id) ) return; Gia_ObjSetTravIdCurrentId(p, Id); if ( Gia_ObjRefNumId(p, Id) > 1 ) { Vec_IntPush( vLeaves, Id ); return; } pObj = Gia_ManObj( p, Id ); if ( Gia_ObjIsCi(pObj) ) { Vec_IntPush( vLeaves, Id ); return; } assert( Gia_ObjIsAnd(pObj) ); Gia_ManTisCollectMffc_rec( p, Gia_ObjFaninId0(pObj, Id), vMffc, vLeaves ); Gia_ManTisCollectMffc_rec( p, Gia_ObjFaninId1(pObj, Id), vMffc, vLeaves ); if ( Gia_ObjIsMuxId(p, Id) ) Gia_ManTisCollectMffc_rec( p, Gia_ObjFaninId2(p, Id), vMffc, vLeaves ); Vec_IntPush( vMffc, Id ); }
static inline int Cof_ObjLevel( Cof_Man_t * p, Cof_Obj_t * pObj ) { return Gia_ObjLevel(p->pGia, Gia_ManObj(p->pGia,pObj->Id)); }
/**Function************************************************************* Synopsis [Performs structural hashing on the LUT functions.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void * Dsm_ManDeriveGia( void * pGia, int fUseMuxes ) { Gia_Man_t * p = (Gia_Man_t *)pGia; Gia_Man_t * pNew, * pTemp; Vec_Int_t * vCover, * vLeaves; Gia_Obj_t * pObj; int k, i, iLut, iVar; word * pTruth; assert( Gia_ManHasMapping(p) ); // create new manager pNew = Gia_ManStart( 6*Gia_ManObjNum(p)/5 + 100 ); pNew->pName = Abc_UtilStrsav( p->pName ); pNew->pSpec = Abc_UtilStrsav( p->pSpec ); pNew->vLevels = Vec_IntStart( 6*Gia_ManObjNum(p)/5 + 100 ); if ( fUseMuxes ) pNew->pMuxes = ABC_CALLOC( unsigned, pNew->nObjsAlloc ); // map primary inputs Gia_ManFillValue(p); Gia_ManConst0(p)->Value = 0; Gia_ManForEachCi( p, pObj, i ) pObj->Value = Gia_ManAppendCi(pNew); // iterate through nodes used in the mapping vLeaves = Vec_IntAlloc( 16 ); vCover = Vec_IntAlloc( 1 << 16 ); Gia_ManHashStart( pNew ); Gia_ObjComputeTruthTableStart( p, Gia_ManLutSizeMax(p) ); Gia_ManForEachAnd( p, pObj, iLut ) { if ( Gia_ObjIsBuf(pObj) ) { pObj->Value = Gia_ManAppendBuf( pNew, Gia_ObjFanin0Copy(pObj) ); continue; } if ( !Gia_ObjIsLut(p, iLut) ) continue; // collect leaves Vec_IntClear( vLeaves ); Gia_LutForEachFanin( p, iLut, iVar, k ) Vec_IntPush( vLeaves, iVar ); pTruth = Gia_ObjComputeTruthTableCut( p, Gia_ManObj(p, iLut), vLeaves ); // collect incoming literals Vec_IntClear( vLeaves ); Gia_LutForEachFanin( p, iLut, iVar, k ) Vec_IntPush( vLeaves, Gia_ManObj(p, iVar)->Value ); Gia_ManObj(p, iLut)->Value = Dsm_ManTruthToGia( pNew, pTruth, vLeaves, vCover ); } Gia_ObjComputeTruthTableStop( p ); Gia_ManForEachCo( p, pObj, i ) pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) ); Gia_ManHashStop( pNew ); Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) ); Vec_IntFree( vLeaves ); Vec_IntFree( vCover ); /* Gia_ManForEachAnd( pNew, pObj, i ) { int iLev = Gia_ObjLevelId(pNew, i); int iLev0 = Gia_ObjLevelId(pNew, Gia_ObjFaninId0(pObj, i)); int iLev1 = Gia_ObjLevelId(pNew, Gia_ObjFaninId1(pObj, i)); assert( iLev == 1 + Abc_MaxInt(iLev0, iLev1) ); } */ // perform cleanup pNew = Gia_ManCleanup( pTemp = pNew ); Gia_ManStop( pTemp ); return pNew; }
int Dau_DsdToGia_rec( Gia_Man_t * pGia, char * pStr, char ** p, int * pMatches, int * pLits, Vec_Int_t * vCover ) { int fCompl = 0; if ( **p == '!' ) (*p)++, fCompl = 1; if ( **p >= 'a' && **p < 'a' + DAU_DSD_MAX_VAR ) // var return Abc_LitNotCond( pLits[**p - 'a'], fCompl ); if ( **p == '(' ) // and/or { char * q = pStr + pMatches[ *p - pStr ]; int pFans[DAU_DSD_MAX_VAR], nFans = 0, Fan; assert( **p == '(' && *q == ')' ); for ( (*p)++; *p < q; (*p)++ ) { Fan = Dau_DsdToGia_rec( pGia, pStr, p, pMatches, pLits, vCover ); Dau_DsdAddToArray( pGia, pFans, nFans++, Fan ); } Fan = Dau_DsdBalance( pGia, pFans, nFans, 1 ); assert( *p == q ); return Abc_LitNotCond( Fan, fCompl ); } if ( **p == '[' ) // xor { char * q = pStr + pMatches[ *p - pStr ]; int pFans[DAU_DSD_MAX_VAR], nFans = 0, Fan; assert( **p == '[' && *q == ']' ); for ( (*p)++; *p < q; (*p)++ ) { Fan = Dau_DsdToGia_rec( pGia, pStr, p, pMatches, pLits, vCover ); Dau_DsdAddToArray( pGia, pFans, nFans++, Fan ); } Fan = Dau_DsdBalance( pGia, pFans, nFans, 0 ); assert( *p == q ); return Abc_LitNotCond( Fan, fCompl ); } if ( **p == '<' ) // mux { Gia_Obj_t * pObj; int nVars = 0; int Temp[3], * pTemp = Temp, Res; int Fanins[DAU_DSD_MAX_VAR], * pLits2; char * pOld = *p; char * q = pStr + pMatches[ *p - pStr ]; // read fanins if ( *(q+1) == '{' ) { char * q2; *p = q+1; q2 = pStr + pMatches[ *p - pStr ]; assert( **p == '{' && *q2 == '}' ); for ( nVars = 0, (*p)++; *p < q2; (*p)++, nVars++ ) Fanins[nVars] = Dau_DsdToGia_rec( pGia, pStr, p, pMatches, pLits, vCover ); assert( *p == q2 ); pLits2 = Fanins; } else pLits2 = pLits; // read MUX *p = pOld; q = pStr + pMatches[ *p - pStr ]; assert( **p == '<' && *q == '>' ); // verify internal variables if ( nVars ) for ( ; pOld < q; pOld++ ) if ( *pOld >= 'a' && *pOld <= 'z' ) assert( *pOld - 'a' < nVars ); // derive MUX components for ( (*p)++; *p < q; (*p)++ ) *pTemp++ = Dau_DsdToGia_rec( pGia, pStr, p, pMatches, pLits2, vCover ); assert( pTemp == Temp + 3 ); assert( *p == q ); if ( *(q+1) == '{' ) // and/or { char * q = pStr + pMatches[ ++(*p) - pStr ]; assert( **p == '{' && *q == '}' ); *p = q; } if ( pGia->pMuxes ) Res = Gia_ManHashMuxReal( pGia, Temp[0], Temp[1], Temp[2] ); else Res = Gia_ManHashMux( pGia, Temp[0], Temp[1], Temp[2] ); pObj = Gia_ManObj(pGia, Abc_Lit2Var(Res)); if ( Gia_ObjIsAnd(pObj) ) { if ( pGia->pMuxes ) Gia_ObjSetMuxLevel( pGia, pObj ); else { if ( Gia_ObjIsAnd(Gia_ObjFanin0(pObj)) ) Gia_ObjSetAndLevel( pGia, Gia_ObjFanin0(pObj) ); if ( Gia_ObjIsAnd(Gia_ObjFanin1(pObj)) ) Gia_ObjSetAndLevel( pGia, Gia_ObjFanin1(pObj) ); Gia_ObjSetAndLevel( pGia, pObj ); } } return Abc_LitNotCond( Res, fCompl ); } if ( (**p >= 'A' && **p <= 'F') || (**p >= '0' && **p <= '9') ) { Vec_Int_t vLeaves; char * q; word pFunc[DAU_DSD_MAX_VAR > 6 ? (1 << (DAU_DSD_MAX_VAR-6)) : 1]; int Fanins[DAU_DSD_MAX_VAR], Res, nObjOld; int i, nVars = Abc_TtReadHex( pFunc, *p ); *p += Abc_TtHexDigitNum( nVars ); q = pStr + pMatches[ *p - pStr ]; assert( **p == '{' && *q == '}' ); for ( i = 0, (*p)++; *p < q; (*p)++, i++ ) Fanins[i] = Dau_DsdToGia_rec( pGia, pStr, p, pMatches, pLits, vCover ); assert( i == nVars ); assert( *p == q ); vLeaves.nCap = nVars; vLeaves.nSize = nVars; vLeaves.pArray = Fanins; nObjOld = Gia_ManObjNum(pGia); Res = Kit_TruthToGia( pGia, (unsigned *)pFunc, nVars, vCover, &vLeaves, 1 ); // assert( nVars <= 6 ); // Res = Dau_DsdToGiaCompose_rec( pGia, pFunc[0], Fanins, nVars ); for ( i = nObjOld; i < Gia_ManObjNum(pGia); i++ ) Gia_ObjSetGateLevel( pGia, Gia_ManObj(pGia, i) ); m_Non1Step++; return Abc_LitNotCond( Res, fCompl ); } assert( 0 ); return 0; }