abc/src/map/if/ifDsd.c
// checks if there is a way to package some fanins 
checks if there is a way to package some fanins
checks if there is a way to package some fanins
unsigned If_DsdManCheckAndXor( If_DsdMan_t * p, int iFirst, unsigned uMaskNot, If_DsdObj_t * pObj, int nSuppAll, int LutSize, int fDerive, int fVerbose )
{
    int i[6], LimitOut, SizeIn, SizeOut, pSSizes[DAU_MAX_VAR];
    int nFans = If_DsdObjFaninNum(pObj), pFirsts[DAU_MAX_VAR];
    unsigned uRes;
    assert( pObj->nFans > 2 );
    assert( If_DsdObjSuppSize(pObj) > LutSize );
    If_DsdManGetSuppSizes( p, pObj, pSSizes );
    LimitOut = LutSize - (nSuppAll - pObj->nSupp + 1);
    assert( LimitOut < LutSize );
    for ( i[0] = 0;      i[0] < nFans; i[0]++ )
    for ( i[1] = i[0]+1; i[1] < nFans; i[1]++ )
    {
        SizeIn = pSSizes[i[0]] + pSSizes[i[1]];
        SizeOut = pObj->nSupp - SizeIn;
        if ( SizeIn > LutSize || SizeOut > LimitOut )
            continue;
        if ( !fDerive )
            return ~0;
        If_DsdManComputeFirst( p, pObj, pFirsts );
        uRes = If_DsdSign(p, pObj, i[0], iFirst + pFirsts[i[0]], 0) | 
               If_DsdSign(p, pObj, i[1], iFirst + pFirsts[i[1]], 0);
        if ( uRes & uMaskNot )
            continue;
        return uRes;
    }
    if ( pObj->nFans == 3 )
        return 0;
    for ( i[0] = 0;      i[0] < nFans; i[0]++ )
    for ( i[1] = i[0]+1; i[1] < nFans; i[1]++ )
    for ( i[2] = i[1]+1; i[2] < nFans; i[2]++ )
    {
        SizeIn = pSSizes[i[0]] + pSSizes[i[1]] + pSSizes[i[2]];
        SizeOut = pObj->nSupp - SizeIn;
        if ( SizeIn > LutSize || SizeOut > LimitOut )
            continue;
        if ( !fDerive )
            return ~0;
        If_DsdManComputeFirst( p, pObj, pFirsts );
        uRes = If_DsdSign(p, pObj, i[0], iFirst + pFirsts[i[0]], 0) | 
               If_DsdSign(p, pObj, i[1], iFirst + pFirsts[i[1]], 0) | 
               If_DsdSign(p, pObj, i[2], iFirst + pFirsts[i[2]], 0);
        if ( uRes & uMaskNot )
            continue;
        return uRes;
    }
    if ( pObj->nFans == 4 )
        return 0;
    for ( i[0] = 0;      i[0] < nFans; i[0]++ )
    for ( i[1] = i[0]+1; i[1] < nFans; i[1]++ )
    for ( i[2] = i[1]+1; i[2] < nFans; i[2]++ )
    for ( i[3] = i[2]+1; i[3] < nFans; i[3]++ )
    {
        SizeIn = pSSizes[i[0]] + pSSizes[i[1]] + pSSizes[i[2]] + pSSizes[i[3]];
        SizeOut = pObj->nSupp - SizeIn;
        if ( SizeIn > LutSize || SizeOut > LimitOut )
            continue;
        if ( !fDerive )
            return ~0;
        If_DsdManComputeFirst( p, pObj, pFirsts );
        uRes = If_DsdSign(p, pObj, i[0], iFirst + pFirsts[i[0]], 0) | 
               If_DsdSign(p, pObj, i[1], iFirst + pFirsts[i[1]], 0) | 
               If_DsdSign(p, pObj, i[2], iFirst + pFirsts[i[2]], 0) | 
               If_DsdSign(p, pObj, i[3], iFirst + pFirsts[i[3]], 0);
        if ( uRes & uMaskNot )
            continue;
        return uRes;
    }
    return 0;
}
unsigned If_DsdManCheckAndXor ( If_DsdMan_t * p , int iFirst , unsigned uMaskNot , If_DsdObj_t * pObj , int nSuppAll , int LutSize , int fDerive , int fVerbose ) { int i [ 6 ] , LimitOut , SizeIn , SizeOut , pSSizes [ DAU_MAX_VAR ] ; int nFans = If_DsdObjFaninNum ( pObj ) , pFirsts [ DAU_MAX_VAR ] ; unsigned uRes ; assert ( pObj -> nFans > 2 ) ; assert ( If_DsdObjSuppSize ( pObj ) > LutSize ) ; If_DsdManGetSuppSizes ( p , pObj , pSSizes ) ; LimitOut = LutSize - ( nSuppAll - pObj -> nSupp + 1 ) ; assert ( LimitOut < LutSize ) ; for ( i [ 0 ] = 0 ; i [ 0 ] < nFans ; i [ 0 ] ++ ) for ( i [ 1 ] = i [ 0 ] + 1 ; i [ 1 ] < nFans ; i [ 1 ] ++ ) { SizeIn = pSSizes [ i [ 0 ] ] + pSSizes [ i [ 1 ] ] ; SizeOut = pObj -> nSupp - SizeIn ; if ( SizeIn > LutSize || SizeOut > LimitOut ) continue ; if ( ! fDerive ) return ~ 0 ; If_DsdManComputeFirst ( p , pObj , pFirsts ) ; uRes = If_DsdSign ( p , pObj , i [ 0 ] , iFirst + pFirsts [ i [ 0 ] ] , 0 ) | If_DsdSign ( p , pObj , i [ 1 ] , iFirst + pFirsts [ i [ 1 ] ] , 0 ) ; if ( uRes & uMaskNot ) continue ; return uRes ; } if ( pObj -> nFans == 3 ) return 0 ; for ( i [ 0 ] = 0 ; i [ 0 ] < nFans ; i [ 0 ] ++ ) for ( i [ 1 ] = i [ 0 ] + 1 ; i [ 1 ] < nFans ; i [ 1 ] ++ ) for ( i [ 2 ] = i [ 1 ] + 1 ; i [ 2 ] < nFans ; i [ 2 ] ++ ) { SizeIn = pSSizes [ i [ 0 ] ] + pSSizes [ i [ 1 ] ] + pSSizes [ i [ 2 ] ] ; SizeOut = pObj -> nSupp - SizeIn ; if ( SizeIn > LutSize || SizeOut > LimitOut ) continue ; if ( ! fDerive ) return ~ 0 ; If_DsdManComputeFirst ( p , pObj , pFirsts ) ; uRes = If_DsdSign ( p , pObj , i [ 0 ] , iFirst + pFirsts [ i [ 0 ] ] , 0 ) | If_DsdSign ( p , pObj , i [ 1 ] , iFirst + pFirsts [ i [ 1 ] ] , 0 ) | If_DsdSign ( p , pObj , i [ 2 ] , iFirst + pFirsts [ i [ 2 ] ] , 0 ) ; if ( uRes & uMaskNot ) continue ; return uRes ; } if ( pObj -> nFans == 4 ) return 0 ; for ( i [ 0 ] = 0 ; i [ 0 ] < nFans ; i [ 0 ] ++ ) for ( i [ 1 ] = i [ 0 ] + 1 ; i [ 1 ] < nFans ; i [ 1 ] ++ ) for ( i [ 2 ] = i [ 1 ] + 1 ; i [ 2 ] < nFans ; i [ 2 ] ++ ) for ( i [ 3 ] = i [ 2 ] + 1 ; i [ 3 ] < nFans ; i [ 3 ] ++ ) { SizeIn = pSSizes [ i [ 0 ] ] + pSSizes [ i [ 1 ] ] + pSSizes [ i [ 2 ] ] + pSSizes [ i [ 3 ] ] ; SizeOut = pObj -> nSupp - SizeIn ; if ( SizeIn > LutSize || SizeOut > LimitOut ) continue ; if ( ! fDerive ) return ~ 0 ; If_DsdManComputeFirst ( p , pObj , pFirsts ) ; uRes = If_DsdSign ( p , pObj , i [ 0 ] , iFirst + pFirsts [ i [ 0 ] ] , 0 ) | If_DsdSign ( p , pObj , i [ 1 ] , iFirst + pFirsts [ i [ 1 ] ] , 0 ) | If_DsdSign ( p , pObj , i [ 2 ] , iFirst + pFirsts [ i [ 2 ] ] , 0 ) | If_DsdSign ( p , pObj , i [ 3 ] , iFirst + pFirsts [ i [ 3 ] ] , 0 ) ; if ( uRes & uMaskNot ) continue ; return uRes ; } return 0 ; }
checks if there is a way to package some fanins
checks if there is a way to package some fanins