//========================================================================= //$Id: helper.hpp,v 1.1 2005/02/16 02:34:02 welson Exp $ // //File description // This is a collection of helper functions // //TO-DO: // 1. //========================================================================= #ifndef HELPER_H #define HELPER_H //--------------------------------------------------------------------- //Header files inclusion //--------------------------------------------------------------------- #include #include #include #include using namespace boost; //--------------------------------------------------------------------- //Global data structures and variables //--------------------------------------------------------------------- //Basci Operator types static OperatorType* portType = new BasicOperatorType("Port"); static OperatorType* addType = new BasicOperatorType("+"); static OperatorType* subType = new BasicOperatorType("-"); static OperatorType* constantType = new BasicOperatorType("Const"); static OperatorType* constMultType= new BasicOperatorType("*c"); static OperatorType* multType = new BasicOperatorType("X"); static OperatorType* delayType = new BasicOperatorType("z^-1"); //Our graph type typedef adjacency_list< vecS, vecS, directedS, BasicOperator, EP> Graph; //Class template of a vertex/edge property writer template < typename Graph > class property_writer { public: property_writer(Graph _g) : g(_g) {} template void operator()(std::ostream& out, const Vertex_or_Edge& v) { out << "[label=\"" << g[v].toString() << "\"]"; } private: Graph& g; }; //Function template to return an object of the above class template inline property_writer make_property_writer(Graph g){ return property_writer(g); } //--------------------------------------------------------------------- // Function declarations //--------------------------------------------------------------------- void firGraph(int tapNumber, Graph& fg); //--------------------------------------------------------------------- //Function description: // Convert anything to string //Input: // Anything //Output: // The string representation of "Anything" //--------------------------------------------------------------------- template std::string any2string(T i) { std::ostringstream buffer; buffer << i; return buffer.str(); } //--------------------------------------------------------------------- //Function description: // This is a function that creates a FIR filter graph and returns it //Input: // int tap -> tap number //Output: // Graph -> The FIR filter graph //--------------------------------------------------------------------- void firGraph(int tapNumber, Graph& fg) { //Declare all the nodes graph_traits::vertex_descriptor dataInNode, dataOutNode, tapsInNodes[tapNumber], multiplyNodes[tapNumber], addNodes[tapNumber - 1]; //Add nodes one by one dataInNode = add_vertex(fg); fg[dataInNode] = BasicOperator(portType, "dataIn"); for ( int i=0 ; i::edge_descriptor edge; bool b; for ( int i=0 ; i