Exemplo n.º 1
0
/**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;
}
Exemplo n.º 2
0
/**Function*************************************************************

  Synopsis    [Performs one step of bi-decomposition.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Bdc_Fun_t * Bdc_ManDecompose_rec( Bdc_Man_t * p, Bdc_Isf_t * pIsf )
{
    Bdc_Fun_t * pFunc;
    Bdc_Isf_t IsfL, * pIsfL = &IsfL;
    Bdc_Isf_t IsfB, * pIsfR = &IsfB;
    // check computed results
    if ( pFunc = Bdc_TableLookup( p, pIsf ) )
        return pFunc;
    // decide on the decomposition type
    pFunc = Bdc_FunNew( p );
    if ( pFunc == NULL )
        return NULL;
    pFunc->Type = Bdc_DecomposeStep( p, pIsf, pIsfL, pIsfR );
    // decompose the left branch
    pFunc->pFan0 = Bdc_ManDecompose_rec( p, pIsfL );
    if ( pFunc->pFan0 == NULL )
        return NULL;
    // decompose the right branch
    if ( Bdc_DecomposeUpdateRight( p, pIsf, pIsfL, pIsfR, pFunc->pFan0->puFunc, pFunc->Type ) )
    {
        p->nNodes--;
        return pFunc->pFan0;
    }
    pFunc->pFan1 = Bdc_ManDecompose_rec( p, pIsfL );
    if ( pFunc->pFan1 == NULL )
        return NULL;
    // compute the function of node
    pFunc->puFunc = (unsigned *)Vec_IntFetch(p->vMemory, p->nWords); 
    if ( pFunc->Type == BDC_TYPE_AND )
        Kit_TruthAnd( pFunc->puFunc, pFunc->pFan0->puFunc, pFunc->pFan1->puFunc, p->nVars );
    else if ( pFunc->Type == BDC_TYPE_OR )
        Kit_TruthOr( pFunc->puFunc, pFunc->pFan0->puFunc, pFunc->pFan1->puFunc, p->nVars );
    else 
        assert( 0 );
    // verify correctness
    assert( Bdc_TableCheckContainment(p, pIsf, pFunc->puFunc) );
    // convert from OR to AND
    if ( pFunc->Type == BDC_TYPE_OR )
    {
        pFunc->Type = BDC_TYPE_AND;
        pFunc->pFan0 = Bdc_Not(pFunc->pFan0);
        pFunc->pFan1 = Bdc_Not(pFunc->pFan1);
        Kit_TruthNot( pFunc->puFunc, pFunc->puFunc, p->nVars );
        pFunc = Bdc_Not(pFunc);
    }
    Bdc_TableAdd( p, Bdc_Regular(pFunc) );
    return pFunc;
}