abc/src/base/abci/abcReconv.c
/**Function*************************************************************

  Synopsis    [Evaluate the cost of removing the node from the set of leaves.]

  Description [Returns the number of new leaves that will be brought in.
  Returns large number if the node cannot be removed from the set of leaves.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [Evaluate the cost of removing the node from the set of leaves.]

Description [Returns the number of new leaves that will be brought in.
Returns large number if the node cannot be removed from the set of leaves.]




Function Synopsis [ Evaluate the cost of removing the node from the set of leaves . ] Description [ Returns the number of new leaves that will be brought in . Returns large number if the node cannot be removed from the set of leaves . ]
static inline int Abc_NodeGetLeafCostTwo( Abc_Obj_t * pNode, int nFaninLimit, 
    Abc_Obj_t ** ppLeafToAdd, Abc_Obj_t ** pNodeToMark1, Abc_Obj_t ** pNodeToMark2 )
{
    Abc_Obj_t * pFanin0, * pFanin1, * pTemp;
    Abc_Obj_t * pGrand, * pGrandToAdd;
    assert( pNode->fMarkB == 1 );  
    if ( Abc_ObjIsCi(pNode) )
        return 999;
    pFanin0 = Abc_ObjFanin0(pNode);
    pFanin1 = Abc_ObjFanin1(pNode);
    assert( !pFanin0->fMarkB && !pFanin1->fMarkB );
    if ( Abc_ObjIsCi(pFanin0) && Abc_ObjIsCi(pFanin1) )
        return 999;
    if ( !Abc_ObjIsCi(pFanin0) && Abc_ObjFanin0(pFanin0)->fMarkB && Abc_ObjFanin1(pFanin0)->fMarkB )
    {
        *ppLeafToAdd  = pFanin1;
        *pNodeToMark1 = pFanin0;
        *pNodeToMark2 = NULL;
        return 1;
    }
    if ( !Abc_ObjIsCi(pFanin1) && Abc_ObjFanin0(pFanin1)->fMarkB && Abc_ObjFanin1(pFanin1)->fMarkB )
    {
        *ppLeafToAdd  = pFanin0;
        *pNodeToMark1 = pFanin1;
        *pNodeToMark2 = NULL;
        return 1;
    }
    if ( Abc_ObjIsCi(pFanin1) )
        pTemp = pFanin0, pFanin0 = pFanin1, pFanin1 = pTemp;
    pGrandToAdd = NULL;
    if ( Abc_ObjIsCi(pFanin0) )
    {
        *pNodeToMark1 = NULL;
        pGrandToAdd = pFanin0;
    }
    else
    {
        *pNodeToMark1 = pFanin0;
        pGrand = Abc_ObjFanin0(pFanin0);
        if ( !pGrand->fMarkB )
        {
            if ( pGrandToAdd && pGrandToAdd != pGrand )
                return 999;
            pGrandToAdd = pGrand;
        }
        pGrand = Abc_ObjFanin1(pFanin0);
        if ( !pGrand->fMarkB )
        {
            if ( pGrandToAdd && pGrandToAdd != pGrand )
                return 999;
            pGrandToAdd = pGrand;
        }
    }
    *pNodeToMark2 = pFanin1;
    pGrand = Abc_ObjFanin0(pFanin1);
    if ( !pGrand->fMarkB )
    {
        if ( pGrandToAdd && pGrandToAdd != pGrand )
            return 999;
        pGrandToAdd = pGrand;
    }
    pGrand = Abc_ObjFanin1(pFanin1);
    if ( !pGrand->fMarkB )
    {
        if ( pGrandToAdd && pGrandToAdd != pGrand )
            return 999;
        pGrandToAdd = pGrand;
    }
    assert( pGrandToAdd != NULL );
    *ppLeafToAdd = pGrandToAdd;
    return 1;
}
static inline int Abc_NodeGetLeafCostTwo ( Abc_Obj_t * pNode , int nFaninLimit , Abc_Obj_t * * ppLeafToAdd , Abc_Obj_t * * pNodeToMark1 , Abc_Obj_t * * pNodeToMark2 ) { Abc_Obj_t * pFanin0 , * pFanin1 , * pTemp ; Abc_Obj_t * pGrand , * pGrandToAdd ; assert ( pNode -> fMarkB == 1 ) ; if ( Abc_ObjIsCi ( pNode ) ) return 999 ; pFanin0 = Abc_ObjFanin0 ( pNode ) ; pFanin1 = Abc_ObjFanin1 ( pNode ) ; assert ( ! pFanin0 -> fMarkB && ! pFanin1 -> fMarkB ) ; if ( Abc_ObjIsCi ( pFanin0 ) && Abc_ObjIsCi ( pFanin1 ) ) return 999 ; if ( ! Abc_ObjIsCi ( pFanin0 ) && Abc_ObjFanin0 ( pFanin0 ) -> fMarkB && Abc_ObjFanin1 ( pFanin0 ) -> fMarkB ) { * ppLeafToAdd = pFanin1 ; * pNodeToMark1 = pFanin0 ; * pNodeToMark2 = NULL ; return 1 ; } if ( ! Abc_ObjIsCi ( pFanin1 ) && Abc_ObjFanin0 ( pFanin1 ) -> fMarkB && Abc_ObjFanin1 ( pFanin1 ) -> fMarkB ) { * ppLeafToAdd = pFanin0 ; * pNodeToMark1 = pFanin1 ; * pNodeToMark2 = NULL ; return 1 ; } if ( Abc_ObjIsCi ( pFanin1 ) ) pTemp = pFanin0 , pFanin0 = pFanin1 , pFanin1 = pTemp ; pGrandToAdd = NULL ; if ( Abc_ObjIsCi ( pFanin0 ) ) { * pNodeToMark1 = NULL ; pGrandToAdd = pFanin0 ; } else { * pNodeToMark1 = pFanin0 ; pGrand = Abc_ObjFanin0 ( pFanin0 ) ; if ( ! pGrand -> fMarkB ) { if ( pGrandToAdd && pGrandToAdd != pGrand ) return 999 ; pGrandToAdd = pGrand ; } pGrand = Abc_ObjFanin1 ( pFanin0 ) ; if ( ! pGrand -> fMarkB ) { if ( pGrandToAdd && pGrandToAdd != pGrand ) return 999 ; pGrandToAdd = pGrand ; } } * pNodeToMark2 = pFanin1 ; pGrand = Abc_ObjFanin0 ( pFanin1 ) ; if ( ! pGrand -> fMarkB ) { if ( pGrandToAdd && pGrandToAdd != pGrand ) return 999 ; pGrandToAdd = pGrand ; } pGrand = Abc_ObjFanin1 ( pFanin1 ) ; if ( ! pGrand -> fMarkB ) { if ( pGrandToAdd && pGrandToAdd != pGrand ) return 999 ; pGrandToAdd = pGrand ; } assert ( pGrandToAdd != NULL ) ; * ppLeafToAdd = pGrandToAdd ; return 1 ; }
Function
Synopsis    [Evaluate the cost of removing the node from the set of leaves.]
Function Synopsis [ Evaluate the cost of removing the node from the set of leaves . ]
// make sure the node is in the construction zone // cannot expand over the PI node // skip nodes with many fanouts //    if ( Abc_ObjFanoutNum(pNode) > nFaninLimit ) //        return 999; // get the children // count the number of unique grandchildren that will be included // return infinite cost if this number if more than 1 // consider the special case when a non-CI fanin can be dropped // make the first node CI if any // consider the first node // consider the second node