/**Function************************************************************* Synopsis [Recognizes what nodes are inputs of the EXOR.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Hop_ObjRecognizeExor( Hop_Obj_t * pObj, Hop_Obj_t ** ppFan0, Hop_Obj_t ** ppFan1 ) { Hop_Obj_t * p0, * p1; assert( !Hop_IsComplement(pObj) ); if ( !Hop_ObjIsNode(pObj) ) return 0; if ( Hop_ObjIsExor(pObj) ) { *ppFan0 = Hop_ObjChild0(pObj); *ppFan1 = Hop_ObjChild1(pObj); return 1; } assert( Hop_ObjIsAnd(pObj) ); p0 = Hop_ObjChild0(pObj); p1 = Hop_ObjChild1(pObj); if ( !Hop_IsComplement(p0) || !Hop_IsComplement(p1) ) return 0; p0 = Hop_Regular(p0); p1 = Hop_Regular(p1); if ( !Hop_ObjIsAnd(p0) || !Hop_ObjIsAnd(p1) ) return 0; if ( Hop_ObjFanin0(p0) != Hop_ObjFanin0(p1) || Hop_ObjFanin1(p0) != Hop_ObjFanin1(p1) ) return 0; if ( Hop_ObjFaninC0(p0) == Hop_ObjFaninC0(p1) || Hop_ObjFaninC1(p0) == Hop_ObjFaninC1(p1) ) return 0; *ppFan0 = Hop_ObjChild0(p0); *ppFan1 = Hop_ObjChild1(p0); return 1; }
/**Function************************************************************* Synopsis [Computes truth table of the cut.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ unsigned * Hop_ManConvertAigToTruth_rec2( Hop_Obj_t * pObj, Vec_Int_t * vTruth, int nWords ) { unsigned * pTruth, * pTruth0, * pTruth1; int i; assert( !Hop_IsComplement(pObj) ); if ( !Hop_ObjIsNode(pObj) || !Hop_ObjIsMarkA(pObj) ) return (unsigned *)pObj->pData; // compute the truth tables of the fanins pTruth0 = Hop_ManConvertAigToTruth_rec2( Hop_ObjFanin0(pObj), vTruth, nWords ); pTruth1 = Hop_ManConvertAigToTruth_rec2( Hop_ObjFanin1(pObj), vTruth, nWords ); // creat the truth table of the node pTruth = Vec_IntFetch( vTruth, nWords ); if ( Hop_ObjIsExor(pObj) ) for ( i = 0; i < nWords; i++ ) pTruth[i] = pTruth0[i] ^ pTruth1[i]; else if ( !Hop_ObjFaninC0(pObj) && !Hop_ObjFaninC1(pObj) ) for ( i = 0; i < nWords; i++ ) pTruth[i] = pTruth0[i] & pTruth1[i]; else if ( !Hop_ObjFaninC0(pObj) && Hop_ObjFaninC1(pObj) ) for ( i = 0; i < nWords; i++ ) pTruth[i] = pTruth0[i] & ~pTruth1[i]; else if ( Hop_ObjFaninC0(pObj) && !Hop_ObjFaninC1(pObj) ) for ( i = 0; i < nWords; i++ ) pTruth[i] = ~pTruth0[i] & pTruth1[i]; else // if ( Hop_ObjFaninC0(pObj) && Hop_ObjFaninC1(pObj) ) for ( i = 0; i < nWords; i++ ) pTruth[i] = ~pTruth0[i] & ~pTruth1[i]; assert( Hop_ObjIsMarkA(pObj) ); // loop detection Hop_ObjClearMarkA( pObj ); pObj->pData = pTruth; return pTruth; }
// hashing the node static unsigned long Hop_Hash( Hop_Obj_t * pObj, int TableSize ) { unsigned long Key = Hop_ObjIsExor(pObj) * 1699; Key ^= (long)Hop_ObjFanin0(pObj) * 7937; Key ^= (long)Hop_ObjFanin1(pObj) * 2971; Key ^= Hop_ObjFaninC0(pObj) * 911; Key ^= Hop_ObjFaninC1(pObj) * 353; return Key % TableSize; }
word Hop_ManComputeTruth6_rec( Hop_Man_t * p, Hop_Obj_t * pObj ) { word Truth0, Truth1; if ( Hop_ObjIsPi(pObj) ) return Truth[pObj->iData]; assert( Hop_ObjIsNode(pObj) ); Truth0 = Hop_ManComputeTruth6_rec( p, Hop_ObjFanin0(pObj) ); Truth1 = Hop_ManComputeTruth6_rec( p, Hop_ObjFanin1(pObj) ); Truth0 = Hop_ObjFaninC0(pObj) ? ~Truth0 : Truth0; Truth1 = Hop_ObjFaninC1(pObj) ? ~Truth1 : Truth1; return Truth0 & Truth1; }
/**Function************************************************************* Synopsis [Returns 1 if the node is the root of MUX or EXOR/NEXOR.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Hop_ObjIsMuxType( Hop_Obj_t * pNode ) { Hop_Obj_t * pNode0, * pNode1; // check that the node is regular assert( !Hop_IsComplement(pNode) ); // if the node is not AND, this is not MUX if ( !Hop_ObjIsAnd(pNode) ) return 0; // if the children are not complemented, this is not MUX if ( !Hop_ObjFaninC0(pNode) || !Hop_ObjFaninC1(pNode) ) return 0; // get children pNode0 = Hop_ObjFanin0(pNode); pNode1 = Hop_ObjFanin1(pNode); // if the children are not ANDs, this is not MUX if ( !Hop_ObjIsAnd(pNode0) || !Hop_ObjIsAnd(pNode1) ) return 0; // otherwise the node is MUX iff it has a pair of equal grandchildren return (Hop_ObjFanin0(pNode0) == Hop_ObjFanin0(pNode1) && (Hop_ObjFaninC0(pNode0) ^ Hop_ObjFaninC0(pNode1))) || (Hop_ObjFanin0(pNode0) == Hop_ObjFanin1(pNode1) && (Hop_ObjFaninC0(pNode0) ^ Hop_ObjFaninC1(pNode1))) || (Hop_ObjFanin1(pNode0) == Hop_ObjFanin0(pNode1) && (Hop_ObjFaninC1(pNode0) ^ Hop_ObjFaninC0(pNode1))) || (Hop_ObjFanin1(pNode0) == Hop_ObjFanin1(pNode1) && (Hop_ObjFaninC1(pNode0) ^ Hop_ObjFaninC1(pNode1))); }
ABC_NAMESPACE_IMPL_START //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// // hashing the node static unsigned long Hop_Hash( Hop_Obj_t * pObj, int TableSize ) { unsigned long Key = Hop_ObjIsExor(pObj) * 1699; Key ^= Hop_ObjFanin0(pObj)->Id * 7937; Key ^= Hop_ObjFanin1(pObj)->Id * 2971; Key ^= Hop_ObjFaninC0(pObj) * 911; Key ^= Hop_ObjFaninC1(pObj) * 353; return Key % TableSize; }
/**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 [] ***********************************************************************/ Hop_Obj_t * Hop_ObjRecognizeMux( Hop_Obj_t * pNode, Hop_Obj_t ** ppNodeT, Hop_Obj_t ** ppNodeE ) { Hop_Obj_t * pNode0, * pNode1; assert( !Hop_IsComplement(pNode) ); assert( Hop_ObjIsMuxType(pNode) ); // get children pNode0 = Hop_ObjFanin0(pNode); pNode1 = Hop_ObjFanin1(pNode); // find the control variable if ( Hop_ObjFanin1(pNode0) == Hop_ObjFanin1(pNode1) && (Hop_ObjFaninC1(pNode0) ^ Hop_ObjFaninC1(pNode1)) ) { // if ( Fraig_IsComplement(pNode1->p2) ) if ( Hop_ObjFaninC1(pNode0) ) { // pNode2->p2 is positive phase of C *ppNodeT = Hop_Not(Hop_ObjChild0(pNode1));//pNode2->p1); *ppNodeE = Hop_Not(Hop_ObjChild0(pNode0));//pNode1->p1); return Hop_ObjChild1(pNode1);//pNode2->p2; } else { // pNode1->p2 is positive phase of C *ppNodeT = Hop_Not(Hop_ObjChild0(pNode0));//pNode1->p1); *ppNodeE = Hop_Not(Hop_ObjChild0(pNode1));//pNode2->p1); return Hop_ObjChild1(pNode0);//pNode1->p2; } } else if ( Hop_ObjFanin0(pNode0) == Hop_ObjFanin0(pNode1) && (Hop_ObjFaninC0(pNode0) ^ Hop_ObjFaninC0(pNode1)) ) { // if ( Fraig_IsComplement(pNode1->p1) ) if ( Hop_ObjFaninC0(pNode0) ) { // pNode2->p1 is positive phase of C *ppNodeT = Hop_Not(Hop_ObjChild1(pNode1));//pNode2->p2); *ppNodeE = Hop_Not(Hop_ObjChild1(pNode0));//pNode1->p2); return Hop_ObjChild0(pNode1);//pNode2->p1; } else { // pNode1->p1 is positive phase of C *ppNodeT = Hop_Not(Hop_ObjChild1(pNode0));//pNode1->p2); *ppNodeE = Hop_Not(Hop_ObjChild1(pNode1));//pNode2->p2); return Hop_ObjChild0(pNode0);//pNode1->p1; } } else if ( Hop_ObjFanin0(pNode0) == Hop_ObjFanin1(pNode1) && (Hop_ObjFaninC0(pNode0) ^ Hop_ObjFaninC1(pNode1)) ) { // if ( Fraig_IsComplement(pNode1->p1) ) if ( Hop_ObjFaninC0(pNode0) ) { // pNode2->p2 is positive phase of C *ppNodeT = Hop_Not(Hop_ObjChild0(pNode1));//pNode2->p1); *ppNodeE = Hop_Not(Hop_ObjChild1(pNode0));//pNode1->p2); return Hop_ObjChild1(pNode1);//pNode2->p2; } else { // pNode1->p1 is positive phase of C *ppNodeT = Hop_Not(Hop_ObjChild1(pNode0));//pNode1->p2); *ppNodeE = Hop_Not(Hop_ObjChild0(pNode1));//pNode2->p1); return Hop_ObjChild0(pNode0);//pNode1->p1; } } else if ( Hop_ObjFanin1(pNode0) == Hop_ObjFanin0(pNode1) && (Hop_ObjFaninC1(pNode0) ^ Hop_ObjFaninC0(pNode1)) ) { // if ( Fraig_IsComplement(pNode1->p2) ) if ( Hop_ObjFaninC1(pNode0) ) { // pNode2->p1 is positive phase of C *ppNodeT = Hop_Not(Hop_ObjChild1(pNode1));//pNode2->p2); *ppNodeE = Hop_Not(Hop_ObjChild0(pNode0));//pNode1->p1); return Hop_ObjChild0(pNode1);//pNode2->p1; } else { // pNode1->p2 is positive phase of C *ppNodeT = Hop_Not(Hop_ObjChild0(pNode0));//pNode1->p1); *ppNodeE = Hop_Not(Hop_ObjChild1(pNode1));//pNode2->p2); return Hop_ObjChild1(pNode0);//pNode1->p2; } } assert( 0 ); // this is not MUX return NULL; }