/**Function************************************************************* Synopsis [Adds the new entry to the hash table.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Bdc_Fun_t * Bdc_TableLookup( Bdc_Man_t * p, Bdc_Isf_t * pIsf ) { int fDisableCache = 0; Bdc_Fun_t * pFunc; if ( fDisableCache && Kit_WordCountOnes(pIsf->uSupp) > 1 ) return NULL; if ( pIsf->uSupp == 0 ) { assert( p->pTable[pIsf->uSupp] == p->pNodes ); if ( Kit_TruthIsConst1( pIsf->puOn, p->nVars ) ) return p->pNodes; assert( Kit_TruthIsConst1( pIsf->puOff, p->nVars ) ); return Bdc_Not(p->pNodes); } for ( pFunc = p->pTable[pIsf->uSupp]; pFunc; pFunc = pFunc->pNext ) if ( Bdc_TableCheckContainment( p, pIsf, pFunc->puFunc ) ) return pFunc; Bdc_IsfNot( pIsf ); for ( pFunc = p->pTable[pIsf->uSupp]; pFunc; pFunc = pFunc->pNext ) if ( Bdc_TableCheckContainment( p, pIsf, pFunc->puFunc ) ) { Bdc_IsfNot( pIsf ); return Bdc_Not(pFunc); } Bdc_IsfNot( pIsf ); return NULL; }
/**Function************************************************************* Synopsis [Performs one step of bi-decomposition.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Bdc_Type_t Bdc_DecomposeStep( Bdc_Man_t * p, Bdc_Isf_t * pIsf, Bdc_Isf_t * pIsfL, Bdc_Isf_t * pIsfR ) { int CostOr, CostAnd, CostOrL, CostOrR, CostAndL, CostAndR; Bdc_IsfClean( p->pIsfOL ); Bdc_IsfClean( p->pIsfOR ); Bdc_IsfClean( p->pIsfAL ); Bdc_IsfClean( p->pIsfAR ); // perform OR decomposition CostOr = Bdc_DecomposeOr( p, pIsf, p->pIsfOL, p->pIsfOR ); // perform AND decomposition Bdc_IsfNot( pIsf ); CostAnd = Bdc_DecomposeOr( p, pIsf, p->pIsfAL, p->pIsfAR ); Bdc_IsfNot( pIsf ); Bdc_IsfNot( p->pIsfAL ); Bdc_IsfNot( p->pIsfAR ); // check the hash table Bdc_SuppMinimize( p, p->pIsfOL ); CostOrL = (Bdc_TableLookup(p, p->pIsfOL) != NULL); Bdc_SuppMinimize( p, p->pIsfOR ); CostOrR = (Bdc_TableLookup(p, p->pIsfOR) != NULL); Bdc_SuppMinimize( p, p->pIsfAL ); CostAndL = (Bdc_TableLookup(p, p->pIsfAL) != NULL); Bdc_SuppMinimize( p, p->pIsfAR ); CostAndR = (Bdc_TableLookup(p, p->pIsfAR) != NULL); // check if there is any reuse for the components if ( CostOrL + CostOrR < CostAndL + CostAndR ) { Bdc_IsfCopy( pIsfL, p->pIsfOL ); Bdc_IsfCopy( pIsfR, p->pIsfOR ); return BDC_TYPE_OR; } if ( CostOrL + CostOrR > CostAndL + CostAndR ) { Bdc_IsfCopy( pIsfL, p->pIsfAL ); Bdc_IsfCopy( pIsfR, p->pIsfAR ); return BDC_TYPE_AND; } // compare the two-component costs if ( CostOr < CostAnd ) { Bdc_IsfCopy( pIsfL, p->pIsfOL ); Bdc_IsfCopy( pIsfR, p->pIsfOR ); return BDC_TYPE_OR; } return BDC_TYPE_AND; }