abc/src/aig/ivy/ivyUtil.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 . ]
Ivy_Obj_t * Ivy_ObjRecognizeMux( Ivy_Obj_t * pNode, Ivy_Obj_t ** ppNodeT, Ivy_Obj_t ** ppNodeE )
{
    Ivy_Obj_t * pNode0, * pNode1;
    assert( !Ivy_IsComplement(pNode) );
    assert( Ivy_ObjIsMuxType(pNode) );
    pNode0 = Ivy_ObjFanin0(pNode);
    pNode1 = Ivy_ObjFanin1(pNode);
    if ( Ivy_ObjFaninId0(pNode0) == Ivy_ObjFaninId0(pNode1) && (Ivy_ObjFaninC0(pNode0) ^ Ivy_ObjFaninC0(pNode1)) )
    {
        if ( Ivy_ObjFaninC0(pNode0) )
        { 
            *ppNodeT = Ivy_Not(Ivy_ObjChild1(pNode1));
            *ppNodeE = Ivy_Not(Ivy_ObjChild1(pNode0));
            return Ivy_ObjChild0(pNode1);
        }
        else
        { 
            *ppNodeT = Ivy_Not(Ivy_ObjChild1(pNode0));
            *ppNodeE = Ivy_Not(Ivy_ObjChild1(pNode1));
            return Ivy_ObjChild0(pNode0);
        }
    }
    else if ( Ivy_ObjFaninId0(pNode0) == Ivy_ObjFaninId1(pNode1) && (Ivy_ObjFaninC0(pNode0) ^ Ivy_ObjFaninC1(pNode1)) )
    {
        if ( Ivy_ObjFaninC0(pNode0) )
        { 
            *ppNodeT = Ivy_Not(Ivy_ObjChild0(pNode1));
            *ppNodeE = Ivy_Not(Ivy_ObjChild1(pNode0));
            return Ivy_ObjChild1(pNode1);
        }
        else
        { 
            *ppNodeT = Ivy_Not(Ivy_ObjChild1(pNode0));
            *ppNodeE = Ivy_Not(Ivy_ObjChild0(pNode1));
            return Ivy_ObjChild0(pNode0);
        }
    }
    else if ( Ivy_ObjFaninId1(pNode0) == Ivy_ObjFaninId0(pNode1) && (Ivy_ObjFaninC1(pNode0) ^ Ivy_ObjFaninC0(pNode1)) )
    {
        if ( Ivy_ObjFaninC1(pNode0) )
        { 
            *ppNodeT = Ivy_Not(Ivy_ObjChild1(pNode1));
            *ppNodeE = Ivy_Not(Ivy_ObjChild0(pNode0));
            return Ivy_ObjChild0(pNode1);
        }
        else
        { 
            *ppNodeT = Ivy_Not(Ivy_ObjChild0(pNode0));
            *ppNodeE = Ivy_Not(Ivy_ObjChild1(pNode1));
            return Ivy_ObjChild1(pNode0);
        }
    }
    else if ( Ivy_ObjFaninId1(pNode0) == Ivy_ObjFaninId1(pNode1) && (Ivy_ObjFaninC1(pNode0) ^ Ivy_ObjFaninC1(pNode1)) )
    {
        if ( Ivy_ObjFaninC1(pNode0) )
        { 
            *ppNodeT = Ivy_Not(Ivy_ObjChild0(pNode1));
            *ppNodeE = Ivy_Not(Ivy_ObjChild0(pNode0));
            return Ivy_ObjChild1(pNode1);
        }
        else
        { 
            *ppNodeT = Ivy_Not(Ivy_ObjChild0(pNode0));
            *ppNodeE = Ivy_Not(Ivy_ObjChild0(pNode1));
            return Ivy_ObjChild1(pNode0);
        }
    }
    assert( 0 ); 
    return NULL;
}
Ivy_Obj_t * Ivy_ObjRecognizeMux ( Ivy_Obj_t * pNode , Ivy_Obj_t * * ppNodeT , Ivy_Obj_t * * ppNodeE ) { Ivy_Obj_t * pNode0 , * pNode1 ; assert ( ! Ivy_IsComplement ( pNode ) ) ; assert ( Ivy_ObjIsMuxType ( pNode ) ) ; pNode0 = Ivy_ObjFanin0 ( pNode ) ; pNode1 = Ivy_ObjFanin1 ( pNode ) ; if ( Ivy_ObjFaninId0 ( pNode0 ) == Ivy_ObjFaninId0 ( pNode1 ) && ( Ivy_ObjFaninC0 ( pNode0 ) ^ Ivy_ObjFaninC0 ( pNode1 ) ) ) { if ( Ivy_ObjFaninC0 ( pNode0 ) ) { * ppNodeT = Ivy_Not ( Ivy_ObjChild1 ( pNode1 ) ) ; * ppNodeE = Ivy_Not ( Ivy_ObjChild1 ( pNode0 ) ) ; return Ivy_ObjChild0 ( pNode1 ) ; } else { * ppNodeT = Ivy_Not ( Ivy_ObjChild1 ( pNode0 ) ) ; * ppNodeE = Ivy_Not ( Ivy_ObjChild1 ( pNode1 ) ) ; return Ivy_ObjChild0 ( pNode0 ) ; } } else if ( Ivy_ObjFaninId0 ( pNode0 ) == Ivy_ObjFaninId1 ( pNode1 ) && ( Ivy_ObjFaninC0 ( pNode0 ) ^ Ivy_ObjFaninC1 ( pNode1 ) ) ) { if ( Ivy_ObjFaninC0 ( pNode0 ) ) { * ppNodeT = Ivy_Not ( Ivy_ObjChild0 ( pNode1 ) ) ; * ppNodeE = Ivy_Not ( Ivy_ObjChild1 ( pNode0 ) ) ; return Ivy_ObjChild1 ( pNode1 ) ; } else { * ppNodeT = Ivy_Not ( Ivy_ObjChild1 ( pNode0 ) ) ; * ppNodeE = Ivy_Not ( Ivy_ObjChild0 ( pNode1 ) ) ; return Ivy_ObjChild0 ( pNode0 ) ; } } else if ( Ivy_ObjFaninId1 ( pNode0 ) == Ivy_ObjFaninId0 ( pNode1 ) && ( Ivy_ObjFaninC1 ( pNode0 ) ^ Ivy_ObjFaninC0 ( pNode1 ) ) ) { if ( Ivy_ObjFaninC1 ( pNode0 ) ) { * ppNodeT = Ivy_Not ( Ivy_ObjChild1 ( pNode1 ) ) ; * ppNodeE = Ivy_Not ( Ivy_ObjChild0 ( pNode0 ) ) ; return Ivy_ObjChild0 ( pNode1 ) ; } else { * ppNodeT = Ivy_Not ( Ivy_ObjChild0 ( pNode0 ) ) ; * ppNodeE = Ivy_Not ( Ivy_ObjChild1 ( pNode1 ) ) ; return Ivy_ObjChild1 ( pNode0 ) ; } } else if ( Ivy_ObjFaninId1 ( pNode0 ) == Ivy_ObjFaninId1 ( pNode1 ) && ( Ivy_ObjFaninC1 ( pNode0 ) ^ Ivy_ObjFaninC1 ( pNode1 ) ) ) { if ( Ivy_ObjFaninC1 ( pNode0 ) ) { * ppNodeT = Ivy_Not ( Ivy_ObjChild0 ( pNode1 ) ) ; * ppNodeE = Ivy_Not ( Ivy_ObjChild0 ( pNode0 ) ) ; return Ivy_ObjChild1 ( pNode1 ) ; } else { * ppNodeT = Ivy_Not ( Ivy_ObjChild0 ( pNode0 ) ) ; * ppNodeE = Ivy_Not ( Ivy_ObjChild0 ( pNode1 ) ) ; return Ivy_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 . ]
// get children // find the control variable //    if ( pNode1->p1 == Fraig_Not(pNode2->p1) ) //        if ( Fraig_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; //    else if ( pNode1->p1 == Fraig_Not(pNode2->p2) ) //        if ( Fraig_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; //    else if ( pNode1->p2 == Fraig_Not(pNode2->p1) ) //        if ( Fraig_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; //    else if ( pNode1->p2 == Fraig_Not(pNode2->p2) ) //        if ( Fraig_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; // this is not MUX