abc/src/aig/gia/giaHash.c
/**Function*************************************************************

  Synopsis    [Recognizes what nodes are control and data inputs of a MUX.]

  Description [If the node is a MUX, returns the control variable C.
  Assigns nodes T and E to be the then and else variables of the MUX. 
  Node C is never complemented. Nodes T and E can be complemented.
  This function also recognizes EXOR/NEXOR gates as MUXes.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [Recognizes what nodes are control and data inputs of a MUX.]

Description [If the node is a MUX, returns the control variable C.
Assigns nodes T and E to be the then and else variables of the MUX.
Node C is never complemented. Nodes T and E can be complemented.
This function also recognizes EXOR/NEXOR gates as MUXes.]




Function Synopsis [ Recognizes what nodes are control and data inputs of a MUX . ] Description [ If the node is a MUX returns the control variable C . Assigns nodes T and E to be the then and else variables of the MUX . Node C is never complemented . Nodes T and E can be complemented . This function also recognizes EXOR / NEXOR gates as MUXes . ]
static inline Gia_Obj_t * Gia_ObjRecognizeMuxTwo( Gia_Obj_t * pNode0, Gia_Obj_t * pNode1, Gia_Obj_t ** ppNodeT, Gia_Obj_t ** ppNodeE )
{
    assert( !Gia_IsComplement(pNode0) );
    assert( !Gia_IsComplement(pNode1) );
    if ( Gia_ObjFanin1(pNode0) == Gia_ObjFanin1(pNode1) && (Gia_ObjFaninC1(pNode0) ^ Gia_ObjFaninC1(pNode1)) )
    {
        if ( Gia_ObjFaninC1(pNode0) )
        { 
            *ppNodeT = Gia_Not(Gia_ObjChild0(pNode1));
            *ppNodeE = Gia_Not(Gia_ObjChild0(pNode0));
            return Gia_ObjChild1(pNode1);
        }
        else
        { 
            *ppNodeT = Gia_Not(Gia_ObjChild0(pNode0));
            *ppNodeE = Gia_Not(Gia_ObjChild0(pNode1));
            return Gia_ObjChild1(pNode0);
        }
    }
    else if ( Gia_ObjFanin0(pNode0) == Gia_ObjFanin0(pNode1) && (Gia_ObjFaninC0(pNode0) ^ Gia_ObjFaninC0(pNode1)) )
    {
        if ( Gia_ObjFaninC0(pNode0) )
        { 
            *ppNodeT = Gia_Not(Gia_ObjChild1(pNode1));
            *ppNodeE = Gia_Not(Gia_ObjChild1(pNode0));
            return Gia_ObjChild0(pNode1);
        }
        else
        { 
            *ppNodeT = Gia_Not(Gia_ObjChild1(pNode0));
            *ppNodeE = Gia_Not(Gia_ObjChild1(pNode1));
            return Gia_ObjChild0(pNode0);
        }
    }
    else if ( Gia_ObjFanin0(pNode0) == Gia_ObjFanin1(pNode1) && (Gia_ObjFaninC0(pNode0) ^ Gia_ObjFaninC1(pNode1)) )
    {
        if ( Gia_ObjFaninC0(pNode0) )
        { 
            *ppNodeT = Gia_Not(Gia_ObjChild0(pNode1));
            *ppNodeE = Gia_Not(Gia_ObjChild1(pNode0));
            return Gia_ObjChild1(pNode1);
        }
        else
        { 
            *ppNodeT = Gia_Not(Gia_ObjChild1(pNode0));
            *ppNodeE = Gia_Not(Gia_ObjChild0(pNode1));
            return Gia_ObjChild0(pNode0);
        }
    }
    else if ( Gia_ObjFanin1(pNode0) == Gia_ObjFanin0(pNode1) && (Gia_ObjFaninC1(pNode0) ^ Gia_ObjFaninC0(pNode1)) )
    {
        if ( Gia_ObjFaninC1(pNode0) )
        { 
            *ppNodeT = Gia_Not(Gia_ObjChild1(pNode1));
            *ppNodeE = Gia_Not(Gia_ObjChild0(pNode0));
            return Gia_ObjChild0(pNode1);
        }
        else
        { 
            *ppNodeT = Gia_Not(Gia_ObjChild0(pNode0));
            *ppNodeE = Gia_Not(Gia_ObjChild1(pNode1));
            return Gia_ObjChild1(pNode0);
        }
    }
    assert( 0 ); 
    return NULL;
}
static inline Gia_Obj_t * Gia_ObjRecognizeMuxTwo ( Gia_Obj_t * pNode0 , Gia_Obj_t * pNode1 , Gia_Obj_t * * ppNodeT , Gia_Obj_t * * ppNodeE ) { assert ( ! Gia_IsComplement ( pNode0 ) ) ; assert ( ! Gia_IsComplement ( pNode1 ) ) ; if ( Gia_ObjFanin1 ( pNode0 ) == Gia_ObjFanin1 ( pNode1 ) && ( Gia_ObjFaninC1 ( pNode0 ) ^ Gia_ObjFaninC1 ( pNode1 ) ) ) { if ( Gia_ObjFaninC1 ( pNode0 ) ) { * ppNodeT = Gia_Not ( Gia_ObjChild0 ( pNode1 ) ) ; * ppNodeE = Gia_Not ( Gia_ObjChild0 ( pNode0 ) ) ; return Gia_ObjChild1 ( pNode1 ) ; } else { * ppNodeT = Gia_Not ( Gia_ObjChild0 ( pNode0 ) ) ; * ppNodeE = Gia_Not ( Gia_ObjChild0 ( pNode1 ) ) ; return Gia_ObjChild1 ( pNode0 ) ; } } else if ( Gia_ObjFanin0 ( pNode0 ) == Gia_ObjFanin0 ( pNode1 ) && ( Gia_ObjFaninC0 ( pNode0 ) ^ Gia_ObjFaninC0 ( pNode1 ) ) ) { if ( Gia_ObjFaninC0 ( pNode0 ) ) { * ppNodeT = Gia_Not ( Gia_ObjChild1 ( pNode1 ) ) ; * ppNodeE = Gia_Not ( Gia_ObjChild1 ( pNode0 ) ) ; return Gia_ObjChild0 ( pNode1 ) ; } else { * ppNodeT = Gia_Not ( Gia_ObjChild1 ( pNode0 ) ) ; * ppNodeE = Gia_Not ( Gia_ObjChild1 ( pNode1 ) ) ; return Gia_ObjChild0 ( pNode0 ) ; } } else if ( Gia_ObjFanin0 ( pNode0 ) == Gia_ObjFanin1 ( pNode1 ) && ( Gia_ObjFaninC0 ( pNode0 ) ^ Gia_ObjFaninC1 ( pNode1 ) ) ) { if ( Gia_ObjFaninC0 ( pNode0 ) ) { * ppNodeT = Gia_Not ( Gia_ObjChild0 ( pNode1 ) ) ; * ppNodeE = Gia_Not ( Gia_ObjChild1 ( pNode0 ) ) ; return Gia_ObjChild1 ( pNode1 ) ; } else { * ppNodeT = Gia_Not ( Gia_ObjChild1 ( pNode0 ) ) ; * ppNodeE = Gia_Not ( Gia_ObjChild0 ( pNode1 ) ) ; return Gia_ObjChild0 ( pNode0 ) ; } } else if ( Gia_ObjFanin1 ( pNode0 ) == Gia_ObjFanin0 ( pNode1 ) && ( Gia_ObjFaninC1 ( pNode0 ) ^ Gia_ObjFaninC0 ( pNode1 ) ) ) { if ( Gia_ObjFaninC1 ( pNode0 ) ) { * ppNodeT = Gia_Not ( Gia_ObjChild1 ( pNode1 ) ) ; * ppNodeE = Gia_Not ( Gia_ObjChild0 ( pNode0 ) ) ; return Gia_ObjChild0 ( pNode1 ) ; } else { * ppNodeT = Gia_Not ( Gia_ObjChild0 ( pNode0 ) ) ; * ppNodeE = Gia_Not ( Gia_ObjChild1 ( pNode1 ) ) ; return Gia_ObjChild1 ( pNode0 ) ; } } assert ( 0 ) ; return NULL ; }
Function
Synopsis    [Recognizes what nodes are control and data inputs of a MUX.]
Function Synopsis [ Recognizes what nodes are control and data inputs of a MUX . ]
// find the control variable //        if ( FrGia_IsComplement(pNode1->p2) ) // pNode2->p2 is positive phase of C //pNode2->p1); //pNode1->p1); //pNode2->p2; // pNode1->p2 is positive phase of C //pNode1->p1); //pNode2->p1); //pNode1->p2; //        if ( FrGia_IsComplement(pNode1->p1) ) // pNode2->p1 is positive phase of C //pNode2->p2); //pNode1->p2); //pNode2->p1; // pNode1->p1 is positive phase of C //pNode1->p2); //pNode2->p2); //pNode1->p1; //        if ( FrGia_IsComplement(pNode1->p1) ) // pNode2->p2 is positive phase of C //pNode2->p1); //pNode1->p2); //pNode2->p2; // pNode1->p1 is positive phase of C //pNode1->p2); //pNode2->p1); //pNode1->p1; //        if ( FrGia_IsComplement(pNode1->p2) ) // pNode2->p1 is positive phase of C //pNode2->p2); //pNode1->p1); //pNode2->p1; // pNode1->p2 is positive phase of C //pNode1->p1); //pNode2->p2); //pNode1->p2; // this is not MUX