abc/src/opt/fxch/FxchDiv.c
/**Function*************************************************************

  Synopsis    [ Creates a Divisor. ]

  Description [ This functions receive as input two sub-cubes and creates
                a divisor using their information. The divisor is stored 
                in vCubeFree vector of the pFxchMan structure.
                
                It returns the base value, which is the number of elements
                that the cubes pair used to generate the devisor have in
                common. ]

  SideEffects []

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [ Creates a Divisor.

Description [ This functions receive as input two sub-cubes and creates
a divisor using their information. The divisor is stored
in vCubeFree vector of the pFxchMan structure.

It returns the base value, which is the number of elements
that the cubes pair used to generate the devisor have in
common.




Function Synopsis [ Creates a Divisor . Description [ This functions receive as input two sub - cubes and creates a divisor using their information . The divisor is stored in vCubeFree vector of the pFxchMan structure . It returns the base value which is the number of elements that the cubes pair used to generate the devisor have in common .
int Fxch_DivCreate( Fxch_Man_t* pFxchMan,
                    Fxch_SubCube_t* pSubCube0,
                    Fxch_SubCube_t* pSubCube1 )
{
    int Base = 0;
    int SC0_Lit0,
        SC0_Lit1,
        SC1_Lit0,
        SC1_Lit1;
    int Cube0Size,
        Cube1Size;
    Vec_IntClear( pFxchMan->vCubeFree );
    SC0_Lit0 = Fxch_ManGetLit( pFxchMan, pSubCube0->iCube, pSubCube0->iLit0 );
    SC0_Lit1 = 0;
    SC1_Lit0 = Fxch_ManGetLit( pFxchMan, pSubCube1->iCube, pSubCube1->iLit0 );
    SC1_Lit1 = 0;
    if ( pSubCube0->iLit1 == 0 && pSubCube1->iLit1 == 0 )
    {
        Vec_IntPush( pFxchMan->vCubeFree, SC0_Lit0 );
        Vec_IntPush( pFxchMan->vCubeFree, SC1_Lit0 );
    }
    else if ( pSubCube0->iLit1 > 0 && pSubCube1->iLit1 > 0 )
    {
        int RetValue;
        SC0_Lit1 = Fxch_ManGetLit( pFxchMan, pSubCube0->iCube, pSubCube0->iLit1 );
        SC1_Lit1 = Fxch_ManGetLit( pFxchMan, pSubCube1->iCube, pSubCube1->iLit1 );
        if ( SC0_Lit0 < SC1_Lit0 )
        {
            Vec_IntPush( pFxchMan->vCubeFree, Abc_Var2Lit( SC0_Lit0, 0 ) );
            Vec_IntPush( pFxchMan->vCubeFree, Abc_Var2Lit( SC1_Lit0, 1 ) );
            Vec_IntPush( pFxchMan->vCubeFree, Abc_Var2Lit( SC0_Lit1, 0 ) );
            Vec_IntPush( pFxchMan->vCubeFree, Abc_Var2Lit( SC1_Lit1, 1 ) );
        }
        else
        {
            Vec_IntPush( pFxchMan->vCubeFree, Abc_Var2Lit( SC1_Lit0, 0 ) );
            Vec_IntPush( pFxchMan->vCubeFree, Abc_Var2Lit( SC0_Lit0, 1 ) );
            Vec_IntPush( pFxchMan->vCubeFree, Abc_Var2Lit( SC1_Lit1, 0 ) );
            Vec_IntPush( pFxchMan->vCubeFree, Abc_Var2Lit( SC0_Lit1, 1 ) );
        }
        RetValue = Fxch_DivNormalize( pFxchMan->vCubeFree );
        if ( RetValue == -1 )
            return -1;
    } 
    else
    {
        if ( pSubCube0->iLit1 > 0 )
        {
            SC0_Lit1 = Fxch_ManGetLit( pFxchMan, pSubCube0->iCube, pSubCube0->iLit1 );
            Vec_IntPush( pFxchMan->vCubeFree, SC1_Lit0 );
            if ( SC0_Lit0 == Abc_LitNot( SC1_Lit0 ) )
                Vec_IntPush( pFxchMan->vCubeFree, SC0_Lit1 );
            else if ( SC0_Lit1 == Abc_LitNot( SC1_Lit0 ) )
                Vec_IntPush( pFxchMan->vCubeFree, SC0_Lit0 );
        }
        else 
        {
            SC1_Lit1 = Fxch_ManGetLit( pFxchMan, pSubCube1->iCube, pSubCube1->iLit1 );
            Vec_IntPush( pFxchMan->vCubeFree, SC0_Lit0 );
            if ( SC1_Lit0 == Abc_LitNot( SC0_Lit0 ) )
                Vec_IntPush( pFxchMan->vCubeFree, SC1_Lit1 );
            else if ( SC1_Lit1 == Abc_LitNot( SC0_Lit0 ) )
                Vec_IntPush( pFxchMan->vCubeFree, SC1_Lit0 );
        }
    }
    if ( Vec_IntSize( pFxchMan->vCubeFree ) == 0 )
        return -1;
    if ( Vec_IntSize ( pFxchMan->vCubeFree ) == 2 )
    {
        Vec_IntSort( pFxchMan->vCubeFree, 0 );
        Vec_IntWriteEntry( pFxchMan->vCubeFree, 0, Abc_Var2Lit( Vec_IntEntry( pFxchMan->vCubeFree, 0 ), 0 ) );
        Vec_IntWriteEntry( pFxchMan->vCubeFree, 1, Abc_Var2Lit( Vec_IntEntry( pFxchMan->vCubeFree, 1 ), 1 ) );
    }
    Cube0Size = Vec_IntSize( Fxch_ManGetCube( pFxchMan, pSubCube0->iCube ) );
    Cube1Size = Vec_IntSize( Fxch_ManGetCube( pFxchMan, pSubCube1->iCube ) );
    if ( Vec_IntSize( pFxchMan->vCubeFree ) % 2 == 0 )
    {
        Base = Abc_MinInt( Cube0Size, Cube1Size )
               -( Vec_IntSize( pFxchMan->vCubeFree ) / 2)  - 1; 
    }
    else
        return -1;
    return Base;
}
int Fxch_DivCreate ( Fxch_Man_t * pFxchMan , Fxch_SubCube_t * pSubCube0 , Fxch_SubCube_t * pSubCube1 ) { int Base = 0 ; int SC0_Lit0 , SC0_Lit1 , SC1_Lit0 , SC1_Lit1 ; int Cube0Size , Cube1Size ; Vec_IntClear ( pFxchMan -> vCubeFree ) ; SC0_Lit0 = Fxch_ManGetLit ( pFxchMan , pSubCube0 -> iCube , pSubCube0 -> iLit0 ) ; SC0_Lit1 = 0 ; SC1_Lit0 = Fxch_ManGetLit ( pFxchMan , pSubCube1 -> iCube , pSubCube1 -> iLit0 ) ; SC1_Lit1 = 0 ; if ( pSubCube0 -> iLit1 == 0 && pSubCube1 -> iLit1 == 0 ) { Vec_IntPush ( pFxchMan -> vCubeFree , SC0_Lit0 ) ; Vec_IntPush ( pFxchMan -> vCubeFree , SC1_Lit0 ) ; } else if ( pSubCube0 -> iLit1 > 0 && pSubCube1 -> iLit1 > 0 ) { int RetValue ; SC0_Lit1 = Fxch_ManGetLit ( pFxchMan , pSubCube0 -> iCube , pSubCube0 -> iLit1 ) ; SC1_Lit1 = Fxch_ManGetLit ( pFxchMan , pSubCube1 -> iCube , pSubCube1 -> iLit1 ) ; if ( SC0_Lit0 < SC1_Lit0 ) { Vec_IntPush ( pFxchMan -> vCubeFree , Abc_Var2Lit ( SC0_Lit0 , 0 ) ) ; Vec_IntPush ( pFxchMan -> vCubeFree , Abc_Var2Lit ( SC1_Lit0 , 1 ) ) ; Vec_IntPush ( pFxchMan -> vCubeFree , Abc_Var2Lit ( SC0_Lit1 , 0 ) ) ; Vec_IntPush ( pFxchMan -> vCubeFree , Abc_Var2Lit ( SC1_Lit1 , 1 ) ) ; } else { Vec_IntPush ( pFxchMan -> vCubeFree , Abc_Var2Lit ( SC1_Lit0 , 0 ) ) ; Vec_IntPush ( pFxchMan -> vCubeFree , Abc_Var2Lit ( SC0_Lit0 , 1 ) ) ; Vec_IntPush ( pFxchMan -> vCubeFree , Abc_Var2Lit ( SC1_Lit1 , 0 ) ) ; Vec_IntPush ( pFxchMan -> vCubeFree , Abc_Var2Lit ( SC0_Lit1 , 1 ) ) ; } RetValue = Fxch_DivNormalize ( pFxchMan -> vCubeFree ) ; if ( RetValue == -1 ) return -1 ; } else { if ( pSubCube0 -> iLit1 > 0 ) { SC0_Lit1 = Fxch_ManGetLit ( pFxchMan , pSubCube0 -> iCube , pSubCube0 -> iLit1 ) ; Vec_IntPush ( pFxchMan -> vCubeFree , SC1_Lit0 ) ; if ( SC0_Lit0 == Abc_LitNot ( SC1_Lit0 ) ) Vec_IntPush ( pFxchMan -> vCubeFree , SC0_Lit1 ) ; else if ( SC0_Lit1 == Abc_LitNot ( SC1_Lit0 ) ) Vec_IntPush ( pFxchMan -> vCubeFree , SC0_Lit0 ) ; } else { SC1_Lit1 = Fxch_ManGetLit ( pFxchMan , pSubCube1 -> iCube , pSubCube1 -> iLit1 ) ; Vec_IntPush ( pFxchMan -> vCubeFree , SC0_Lit0 ) ; if ( SC1_Lit0 == Abc_LitNot ( SC0_Lit0 ) ) Vec_IntPush ( pFxchMan -> vCubeFree , SC1_Lit1 ) ; else if ( SC1_Lit1 == Abc_LitNot ( SC0_Lit0 ) ) Vec_IntPush ( pFxchMan -> vCubeFree , SC1_Lit0 ) ; } } if ( Vec_IntSize ( pFxchMan -> vCubeFree ) == 0 ) return -1 ; if ( Vec_IntSize ( pFxchMan -> vCubeFree ) == 2 ) { Vec_IntSort ( pFxchMan -> vCubeFree , 0 ) ; Vec_IntWriteEntry ( pFxchMan -> vCubeFree , 0 , Abc_Var2Lit ( Vec_IntEntry ( pFxchMan -> vCubeFree , 0 ) , 0 ) ) ; Vec_IntWriteEntry ( pFxchMan -> vCubeFree , 1 , Abc_Var2Lit ( Vec_IntEntry ( pFxchMan -> vCubeFree , 1 ) , 1 ) ) ; } Cube0Size = Vec_IntSize ( Fxch_ManGetCube ( pFxchMan , pSubCube0 -> iCube ) ) ; Cube1Size = Vec_IntSize ( Fxch_ManGetCube ( pFxchMan , pSubCube1 -> iCube ) ) ; if ( Vec_IntSize ( pFxchMan -> vCubeFree ) % 2 == 0 ) { Base = Abc_MinInt ( Cube0Size , Cube1Size ) - ( Vec_IntSize ( pFxchMan -> vCubeFree ) / 2 ) - 1 ; } else return -1 ; return Base ; }
Function
Synopsis    [ Creates a Divisor. ]
Function Synopsis [ Creates a Divisor . ]
/* 1 or 2 Lits, 1 SOP NodeID */