abc/src/misc/util/utilIsop.c
/**Function*************************************************************

  Synopsis    [Compute CNF assuming it does not exceed the limit.]

  Description [Please note that pCover should have at least 32 extra entries!]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [Compute CNF assuming it does not exceed the limit.]

Description [Please note that pCover should have at least 32 extra entries!]




Function Synopsis [ Compute CNF assuming it does not exceed the limit . ] Description [ Please note that pCover should have at least 32 extra entries! ]
int Abc_IsopCnf( word * pFunc, int nVars, int nCubeLim, int * pCover )
{
    word pRes[ABC_ISOP_MAX_WORD];
    word Cost0, Cost1, CostInit = Abc_Cube2Cost(nCubeLim);
    int c, nCubes0, nCubes1;
    assert( nVars <= ABC_ISOP_MAX_VAR );
    assert( Abc_TtHasVar( pFunc, nVars, nVars - 1 ) );
    if ( nVars > 6 )
        Cost0 = s_pFuncIsopCover[nVars]( pFunc, pFunc, pRes, CostInit, pCover );
    else
        Cost0 = Abc_Isop6Cover( *pFunc, *pFunc, pRes, nVars, CostInit, pCover );
    if ( Cost0 >= CostInit )
        return CostInit;
    Abc_TtNot( pFunc, Abc_TtWordNum(nVars) );
    if ( nVars > 6 )
        Cost1 = s_pFuncIsopCover[nVars]( pFunc, pFunc, pRes, CostInit, pCover ? pCover + Abc_CostCubes(Cost0) : NULL );
    else
        Cost1 = Abc_Isop6Cover( *pFunc, *pFunc, pRes, nVars, CostInit, pCover ? pCover + Abc_CostCubes(Cost0) : NULL );
    Abc_TtNot( pFunc, Abc_TtWordNum(nVars) );
    if ( Cost0 + Cost1 >= CostInit )
        return CostInit;
    nCubes0 = Abc_CostCubes(Cost0);
    nCubes1 = Abc_CostCubes(Cost1);
    if ( pCover )
    {
        for ( c = 0; c < nCubes0; c++ )
            pCover[c] |= (1 << Abc_Var2Lit(nVars, 0));
        for ( c = 0; c < nCubes1; c++ )
            pCover[c+nCubes0] |= (1 << Abc_Var2Lit(nVars, 1));
    }
    return nCubes0 + nCubes1;
}
int Abc_IsopCnf ( word * pFunc , int nVars , int nCubeLim , int * pCover ) { word pRes [ ABC_ISOP_MAX_WORD ] ; word Cost0 , Cost1 , CostInit = Abc_Cube2Cost ( nCubeLim ) ; int c , nCubes0 , nCubes1 ; assert ( nVars <= ABC_ISOP_MAX_VAR ) ; assert ( Abc_TtHasVar ( pFunc , nVars , nVars - 1 ) ) ; if ( nVars > 6 ) Cost0 = s_pFuncIsopCover [ nVars ] ( pFunc , pFunc , pRes , CostInit , pCover ) ; else Cost0 = Abc_Isop6Cover ( * pFunc , * pFunc , pRes , nVars , CostInit , pCover ) ; if ( Cost0 >= CostInit ) return CostInit ; Abc_TtNot ( pFunc , Abc_TtWordNum ( nVars ) ) ; if ( nVars > 6 ) Cost1 = s_pFuncIsopCover [ nVars ] ( pFunc , pFunc , pRes , CostInit , pCover ? pCover + Abc_CostCubes ( Cost0 ) : NULL ) ; else Cost1 = Abc_Isop6Cover ( * pFunc , * pFunc , pRes , nVars , CostInit , pCover ? pCover + Abc_CostCubes ( Cost0 ) : NULL ) ; Abc_TtNot ( pFunc , Abc_TtWordNum ( nVars ) ) ; if ( Cost0 + Cost1 >= CostInit ) return CostInit ; nCubes0 = Abc_CostCubes ( Cost0 ) ; nCubes1 = Abc_CostCubes ( Cost1 ) ; if ( pCover ) { for ( c = 0 ; c < nCubes0 ; c ++ ) pCover [ c ] |= ( 1 << Abc_Var2Lit ( nVars , 0 ) ) ; for ( c = 0 ; c < nCubes1 ; c ++ ) pCover [ c + nCubes0 ] |= ( 1 << Abc_Var2Lit ( nVars , 1 ) ) ; } return nCubes0 + nCubes1 ; }
Function
Synopsis    [Compute CNF assuming it does not exceed the limit.]
Function Synopsis [ Compute CNF assuming it does not exceed the limit . ]