00001 #ifndef DESGIN_H_INCLUDED_ 00002 #define DESGIN_H_INCLUDED_ 00003 00004 #include "rose.h" 00005 #include "port_mapping_cache.h" 00006 #include <vector> 00007 #include <iostream> 00008 #include <map> 00009 #include <set> 00010 #include <utility> 00011 00012 #include "boost/graph/adjacency_list.hpp" 00013 #include "boost/graph/graphviz.hpp" 00014 #include "boost/algorithm/string.hpp" 00015 00016 00017 #define PSG_MODE risc::get_design()->psg_mode 00018 00019 namespace risc { 00020 00021 class Thread; 00022 class Event; 00023 class Function; 00024 class HierarchicalChannel; 00025 class HierarchicalChannelInstance; 00026 class Instance; 00027 class InstanceTree; 00028 class Interface; 00029 class Module; 00030 class PathInstanceMapper; 00031 class PrimitiveChannel; 00032 class PrimitiveChannelInstance; 00033 class Variable; 00034 class ModuleInstance; 00035 typedef std::vector<Event*> EventVector; 00036 typedef std::vector<Function*> FunctionVector; 00037 typedef std::vector<HierarchicalChannel*> HierarchicalChannelVector; 00038 typedef std::vector<HierarchicalChannelInstance*> HierarchicalChannelInstanceVector; 00039 typedef std::vector<Instance*> InstanceVector; 00040 typedef std::vector<Interface*> InterfaceVector; 00041 typedef std::vector<Module*> ModuleVector; 00042 typedef std::vector<ModuleInstance*> ModuleInstanceVector; 00043 typedef std::vector<PrimitiveChannel*> PrimitiveChannelVector; 00044 typedef std::vector<PrimitiveChannelInstance*> PrimitiveChannelInstanceVector; 00045 typedef std::vector<Variable*> VariableVector; 00046 //typedef boost::adjacency_list<boost::listS, 00047 // boost::listS, boost::bidirectionalS, Port_mapping_node, Port_mapping_edge > Graph; 00048 //typedef boost::graph_traits<Graph>::vertex_descriptor VertexDescriptor; 00049 00050 00051 00056 class Design { 00057 00058 public: 00059 00065 explicit Design(int argc, char* argv[], 00066 std::vector<std::string> psg_file_names = std::vector<std::string>(0), 00067 bool is_psg_mode = false, 00068 bool PrintFrontendArgs = false); 00069 ~Design(); 00070 00071 // typedef boost::adjacency_list<boost::listS, 00072 // boost::listS, boost::bidirectionalS, Port_mapping_node > Graph; 00073 00074 // typedef boost::graph_traits<Graph>::vertex_descriptor VertexDescriptor; 00075 00076 void initialize_port_mapping(); 00077 void initialize_interfaces(); 00078 void initialize_definitions(); 00079 void initialize_top_modules(); 00080 void initialize_global_functions(); 00081 void initialize_global_variables(); 00082 void initialize_path_instance_mapper(); 00083 00084 /* 00085 * Functions to print design properties 00086 */ 00087 void print_all_class_definitions(); 00088 void print_all_global_functions(); 00089 void print_design(); 00090 00091 /* 00092 * Interface for the instance tree 00093 */ 00094 InstanceTree get_root(); 00095 00096 /* 00097 * Containers for the different design elements 00098 */ 00099 ModuleVector module_definitions_; 00100 InstanceVector top_modules_; 00101 PrimitiveChannelVector primitive_channel_; 00102 HierarchicalChannelVector hierarchical_channel_; 00103 InterfaceVector interfaces_; 00104 00105 /* 00106 * global and sc_main related design stuff 00107 */ 00108 VariableVector global_variables_; 00109 FunctionVector global_functions_; 00110 00111 /* 00112 * Functions to search in design 00113 */ 00114 Module *find_module_definition(SgClassDefinition* cd); 00115 PrimitiveChannel* find_prim_channel_definition(SgClassDefinition* cd); 00116 HierarchicalChannel* find_channel_definition(SgClassDefinition* cd); 00117 Interface *find_interface(SgClassDefinition* cd); 00118 00122 Variable* find_global_variable(SgVariableDefinition* var_def); 00123 00124 /* 00125 * Rose specific elements 00126 */ 00127 SgProject *project_; 00128 00129 /* 00130 * misc 00131 */ 00132 int old_argc_; 00133 char **old_argv_; 00134 00135 std::vector<std::string> input_files_; 00136 std::vector<std::string> psg_file_names_; 00137 PathInstanceMapper *path_instance_mapper_; 00138 00139 PortMappingCache port_mapping_cache_; 00140 00146 void reset_instance_counter(); 00147 00152 std::string dynamic_analysis_filename_; 00153 00158 std::string instrumentor_output_filename_; 00159 00164 bool perform_static_analysis(); 00165 00173 void add_module_to_definition_list(SgClassDefinition *class_def); 00174 00182 void add_hierarchical_channel_to_defintion_list(SgClassDefinition *class_def); 00183 00188 std::string get_design_file_name(); 00189 00194 void store_port_mapping(std::string); 00195 00200 void load_port_mapping(std::string); 00201 00202 bool is_analyzable(); 00203 00204 bool psg_mode; 00205 int psg_count; 00206 std::vector<int> psg_seg_count; 00207 00213 std::vector<Thread*> loaded_threads; 00214 std::vector<Thread*> simulation_threads; 00215 ModuleInstanceVector loaded_module_instances; 00216 00217 //risc::Graph port_mapping_graph; 00218 00219 class SegNode { 00220 public: 00221 std::string label; 00222 }; 00223 00224 class SegEdge { 00225 00226 }; 00227 00228 typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, 00229 SegNode, SegEdge> graph_t; 00230 graph_t port_mapping_graph; 00231 typedef boost::adjacency_list<>::vertex_descriptor VertexDescriptor; 00232 class label_writer { 00233 public: 00234 label_writer(graph_t graph) : g(graph) {} 00235 template <class VertexOrEdge> 00236 void operator()(std::ostream& out, const VertexOrEdge& v) const { 00237 out << "[label=\"" << g[v].label << "\"]"; 00238 } 00239 private: 00240 graph_t g; 00241 }; 00242 00243 void draw_port_mapping(); 00244 00245 private: 00246 00250 Design(const Design &d); 00251 }; 00252 00253 class GlobalDesign { 00254 public: 00255 static Design *design_static; 00256 }; 00257 Design* get_design(); 00258 SgProject* get_project(); 00259 00260 }; // end namespace risc 00261 00262 #endif /* DESGIN_H_INCLUDED_ */ 00263 00264 /* ex: set softtabstop=2 tabstop=2 shiftwidth=2 expandtab: */