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

  Synopsis    [Collects the nodes in the cone delimited by fMarkA==1.]

  Description [Returns -1 if the AND-cone has the same node in both polarities.
  Returns 1 if the AND-cone has the same node in the same polarity. Returns 0
  if the AND-cone has no repeated nodes.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [Collects the nodes in the cone delimited by fMarkA==1.]

Description [Returns -1 if the AND-cone has the same node in both polarities.
Returns 1 if the AND-cone has the same node in the same polarity. Returns 0
if the AND-cone has no repeated nodes.]




Function Synopsis [ Collects the nodes in the cone delimited by fMarkA == 1 . ] Description [ Returns - 1 if the AND - cone has the same node in both polarities . Returns 1 if the AND - cone has the same node in the same polarity . Returns 0 if the AND - cone has no repeated nodes . ]
int Abc_NodeBalanceCone_rec( Abc_Obj_t * pNode, Vec_Ptr_t * vSuper, int fFirst, int fDuplicate, int fSelective )
{
    int RetValue1, RetValue2, i;
    if ( Abc_ObjRegular(pNode)->fMarkB )
    {
        for ( i = 0; i < vSuper->nSize; i++ )
            if ( vSuper->pArray[i] == pNode )
                return 1;
        for ( i = 0; i < vSuper->nSize; i++ )
            if ( vSuper->pArray[i] == Abc_ObjNot(pNode) )
                return -1;
        assert( 0 );
        return 0;
    }
    if ( !fFirst && (Abc_ObjIsComplement(pNode) || !Abc_ObjIsNode(pNode) || (!fDuplicate && !fSelective && (Abc_ObjFanoutNum(pNode) > 1)) || Vec_PtrSize(vSuper) > 10000) )
    {
        Vec_PtrPush( vSuper, pNode );
        Abc_ObjRegular(pNode)->fMarkB = 1;
        return 0;
    }
    assert( !Abc_ObjIsComplement(pNode) );
    assert( Abc_ObjIsNode(pNode) );
    RetValue1 = Abc_NodeBalanceCone_rec( Abc_ObjChild0(pNode), vSuper, 0, fDuplicate, fSelective );
    RetValue2 = Abc_NodeBalanceCone_rec( Abc_ObjChild1(pNode), vSuper, 0, fDuplicate, fSelective );
    if ( RetValue1 == -1 || RetValue2 == -1 )
        return -1;
    return RetValue1 || RetValue2;
}
int Abc_NodeBalanceCone_rec ( Abc_Obj_t * pNode , Vec_Ptr_t * vSuper , int fFirst , int fDuplicate , int fSelective ) { int RetValue1 , RetValue2 , i ; if ( Abc_ObjRegular ( pNode ) -> fMarkB ) { for ( i = 0 ; i < vSuper -> nSize ; i ++ ) if ( vSuper -> pArray [ i ] == pNode ) return 1 ; for ( i = 0 ; i < vSuper -> nSize ; i ++ ) if ( vSuper -> pArray [ i ] == Abc_ObjNot ( pNode ) ) return -1 ; assert ( 0 ) ; return 0 ; } if ( ! fFirst && ( Abc_ObjIsComplement ( pNode ) || ! Abc_ObjIsNode ( pNode ) || ( ! fDuplicate && ! fSelective && ( Abc_ObjFanoutNum ( pNode ) > 1 ) ) || Vec_PtrSize ( vSuper ) > 10000 ) ) { Vec_PtrPush ( vSuper , pNode ) ; Abc_ObjRegular ( pNode ) -> fMarkB = 1 ; return 0 ; } assert ( ! Abc_ObjIsComplement ( pNode ) ) ; assert ( Abc_ObjIsNode ( pNode ) ) ; RetValue1 = Abc_NodeBalanceCone_rec ( Abc_ObjChild0 ( pNode ) , vSuper , 0 , fDuplicate , fSelective ) ; RetValue2 = Abc_NodeBalanceCone_rec ( Abc_ObjChild1 ( pNode ) , vSuper , 0 , fDuplicate , fSelective ) ; if ( RetValue1 == -1 || RetValue2 == -1 ) return -1 ; return RetValue1 || RetValue2 ; }
Function
Synopsis    [Collects the nodes in the cone delimited by fMarkA==1.]
Function Synopsis [ Collects the nodes in the cone delimited by fMarkA == 1 . ]
// check if the node is visited // check if the node occurs in the same polarity // check if the node is present in the opposite polarity // if the new node is complemented or a PI, another gate begins // go through the branches // return 1 if at least one branch has a duplicate