/**Function************************************************************* Synopsis [Converts graph to BDD.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ DdNode * Dec_GraphDeriveBdd( DdManager * dd, Dec_Graph_t * pGraph ) { DdNode * bFunc, * bFunc0, * bFunc1; Dec_Node_t * pNode; int i; // sanity checks assert( Dec_GraphLeaveNum(pGraph) >= 0 ); assert( Dec_GraphLeaveNum(pGraph) <= pGraph->nSize ); // check for constant function if ( Dec_GraphIsConst(pGraph) ) return Cudd_NotCond( b1, Dec_GraphIsComplement(pGraph) ); // check for a literal if ( Dec_GraphIsVar(pGraph) ) return Cudd_NotCond( Cudd_bddIthVar(dd, Dec_GraphVarInt(pGraph)), Dec_GraphIsComplement(pGraph) ); // assign the elementary variables Dec_GraphForEachLeaf( pGraph, pNode, i ) pNode->pFunc = Cudd_bddIthVar( dd, i ); // compute the function for each internal node Dec_GraphForEachNode( pGraph, pNode, i ) { bFunc0 = Cudd_NotCond( Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl ); bFunc1 = Cudd_NotCond( Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl ); pNode->pFunc = Cudd_bddAnd( dd, bFunc0, bFunc1 ); Cudd_Ref( pNode->pFunc ); }
ABC_NAMESPACE_IMPL_START //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// /**Function************************************************************* Synopsis [Converts graph to BDD.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ DdNode * Dec_GraphDeriveBdd( DdManager * dd, Dec_Graph_t * pGraph ) { DdNode * bFunc, * bFunc0, * bFunc1; Dec_Node_t * pNode = NULL; // Suppress "might be used uninitialized" int i; // sanity checks assert( Dec_GraphLeaveNum(pGraph) >= 0 ); assert( Dec_GraphLeaveNum(pGraph) <= pGraph->nSize ); // check for constant function if ( Dec_GraphIsConst(pGraph) ) return Cudd_NotCond( b1, Dec_GraphIsComplement(pGraph) ); // check for a literal if ( Dec_GraphIsVar(pGraph) ) return Cudd_NotCond( Cudd_bddIthVar(dd, Dec_GraphVarInt(pGraph)), Dec_GraphIsComplement(pGraph) ); // assign the elementary variables Dec_GraphForEachLeaf( pGraph, pNode, i ) pNode->pFunc = Cudd_bddIthVar( dd, i ); // compute the function for each internal node Dec_GraphForEachNode( pGraph, pNode, i ) { bFunc0 = Cudd_NotCond( Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl ); bFunc1 = Cudd_NotCond( Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl ); pNode->pFunc = Cudd_bddAnd( dd, bFunc0, bFunc1 ); Cudd_Ref( (DdNode *)pNode->pFunc ); }