All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
design.h
Go to the documentation of this file.
1 #ifndef DESGIN_H_INCLUDED_
2 #define DESGIN_H_INCLUDED_
3 
4 #include "rose.h"
5 #include "mapping_info.h"
6 #include <vector>
7 #include <iostream>
8 #include <map>
9 #include <set>
10 #include <utility>
11 
12 #include "boost/graph/adjacency_list.hpp"
13 #include "boost/graph/graphviz.hpp"
14 #include "boost/algorithm/string.hpp"
15 
16 
17 #define PSG_MODE risc::get_design()->psg_mode
18 
19 namespace risc {
20 
21 class Thread;
22 class Event;
23 class Function;
24 class HierarchicalChannel;
25 class HierarchicalChannelInstance;
26 class Instance;
27 class InstanceTree;
28 class Interface;
29 class Module;
30 class PathInstanceMapper;
31 class PrimitiveChannel;
32 class PrimitiveChannelInstance;
33 class Variable;
34 class ModuleInstance;
35 class Socket;
36 typedef std::vector<Event*> EventVector;
37 typedef std::vector<Function*> FunctionVector;
38 typedef std::vector<HierarchicalChannel*> HierarchicalChannelVector;
39 typedef std::vector<HierarchicalChannelInstance*> HierarchicalChannelInstanceVector;
40 typedef std::vector<Instance*> InstanceVector;
41 typedef std::vector<Interface*> InterfaceVector;
42 typedef std::vector<Module*> ModuleVector;
43 typedef std::vector<ModuleInstance*> ModuleInstanceVector;
44 typedef std::vector<PrimitiveChannel*> PrimitiveChannelVector;
45 typedef std::vector<PrimitiveChannelInstance*> PrimitiveChannelInstanceVector;
46 typedef std::vector<Variable*> VariableVector;
47 //typedef boost::adjacency_list<boost::listS,
48 // boost::listS, boost::bidirectionalS, Port_mapping_node, Port_mapping_edge > Graph;
49 //typedef boost::graph_traits<Graph>::vertex_descriptor VertexDescriptor;
50 
51 
52 
57 class Design {
58 
59 public:
60 
69  explicit Design(int argc, char* argv[],
70  std::vector<std::string> psg_file_names = std::vector<std::string>(0),
71  bool is_psg_mode = false,
72  bool PrintFrontendArgs = false);
73  ~Design();
74 
75 // typedef boost::adjacency_list<boost::listS,
76  // boost::listS, boost::bidirectionalS, Port_mapping_node > Graph;
77 
78 // typedef boost::graph_traits<Graph>::vertex_descriptor VertexDescriptor;
79 
81  void initialize_interfaces();
87 
88  /*
89  * Functions to print design properties
90  */
93  void print_design();
94 
95  /*
96  * Interface for the instance tree
97  */
99 
100  /*
101  * Containers for the different design elements
102  */
108 
109  /*
110  * global and sc_main related design stuff
111  */
114 
115  /*
116  * Functions to search in design
117  */
118  Module *find_module_definition(SgClassDefinition* cd);
119  PrimitiveChannel* find_prim_channel_definition(SgClassDefinition* cd);
120  HierarchicalChannel* find_channel_definition(SgClassDefinition* cd);
121  Interface *find_interface(SgClassDefinition* cd);
122 
126  Variable* find_global_variable(SgVariableDefinition* var_def);
127 
128  /*
129  * Rose specific elements
130  */
131  SgProject *project_;
132 
133  /*
134  * misc
135  */
137  char **old_argv_;
138 
139  std::vector<std::string> input_files_;
140  std::vector<std::string> psg_file_names_;
142 
144 
150  void reset_instance_counter();
151 
157 
163 
169 
177  void add_module_to_definition_list(SgClassDefinition *class_def);
178 
186  void add_hierarchical_channel_to_defintion_list(SgClassDefinition *class_def);
187 
192  std::string get_design_file_name();
193 
198  void store_port_mapping(std::string);
199 
204  void load_port_mapping(std::string);
205 
206  //TLM 2.0
211  Socket* find_socket(SgVariableDefinition*);
212 
213  //TLM 2.0
218  ModuleInstance* find_module_instance(SgVariableDefinition*);
219 
220  bool is_analyzable();
221 
222  bool psg_mode;
224  std::vector<int> psg_seg_count;
225 
231  std::vector<Thread*> loaded_threads;
232  std::vector<Thread*> simulation_threads;
234 
235  //risc::Graph port_mapping_graph;
236 
237  class SegNode {
238  public:
239  std::string label;
240  };
241 
242  class SegEdge {
243 
244  };
245 
246  typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS,
249  typedef boost::adjacency_list<>::vertex_descriptor VertexDescriptor;
250  class label_writer {
251  public:
252  label_writer(graph_t graph) : g(graph) {}
253  template <class VertexOrEdge>
254  void operator()(std::ostream& out, const VertexOrEdge& v) const {
255  out << "[label=\"" << g[v].label << "\"]";
256  }
257  private:
259  };
260 
261  void draw_port_mapping();
262 
263 private:
264 
268  Design(const Design &d);
269 };
270 
272 public:
274 };
275 Design* get_design();
276 SgProject* get_project();
277 
278 }; // end namespace risc
279 
280 #endif /* DESGIN_H_INCLUDED_ */
281 
282 /* ex: set softtabstop=2 tabstop=2 shiftwidth=2 expandtab: */
PathInstanceMapper * path_instance_mapper_
Definition: design.h:141
PrimitiveChannelVector primitive_channel_
Definition: design.h:105
bool perform_static_analysis()
The functions return if a static analysis will be performed.
Definition: design.cpp:817
Definition: hierarchical_channel.h:13
void add_hierarchical_channel_to_defintion_list(SgClassDefinition *class_def)
Only for internal use! This function triggers the analysis of a module. The new analyzed module will ...
Definition: design.cpp:829
std::vector< PrimitiveChannel * > PrimitiveChannelVector
Definition: design.h:44
std::vector< Module * > ModuleVector
Definition: design.h:42
InstanceVector top_modules_
Definition: design.h:104
Definition: instance_tree.h:15
Definition: design.h:57
void draw_port_mapping()
Definition: design.cpp:1156
bool is_analyzable()
Definition: design.cpp:874
SgProject * get_project()
Definition: design.cpp:760
bool psg_mode
Definition: design.h:222
char ** old_argv_
Definition: design.h:137
InterfaceVector interfaces_
Definition: design.h:107
Interface * find_interface(SgClassDefinition *cd)
Definition: design.cpp:444
Definition: design.h:242
std::vector< std::string > psg_file_names_
Definition: design.h:140
std::string dynamic_analysis_filename_
This variable contains the filename of the input file for the dynamic analysis.
Definition: design.h:156
void initialize_interfaces()
Definition: design.cpp:971
boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, SegNode, SegEdge > graph_t
Definition: design.h:247
ModuleInstance * find_module_instance(SgVariableDefinition *)
This function finds the socket according to its underlying symbol.
Definition: design.cpp:391
Definition: design.h:237
std::vector< Function * > FunctionVector
Definition: class.h:37
std::vector< std::string > input_files_
Definition: design.h:139
This class can be used as a lookup table between an instance id of a module or hierarchical channel a...
Definition: path_instance_mapper.h:13
std::vector< ModuleInstance * > ModuleInstanceVector
Definition: class.h:42
Definition: socket.h:13
HierarchicalChannel * find_channel_definition(SgClassDefinition *cd)
Definition: design.cpp:413
std::vector< Variable * > VariableVector
Definition: class.h:46
VariableVector global_variables_
Definition: design.h:112
label_writer(graph_t graph)
Definition: design.h:252
void initialize_global_functions()
Definition: design.cpp:621
void reset_instance_counter()
This function resets the instance counter of the module and hierarchical channel instances to zero...
Definition: design.cpp:799
Definition: primitive_channel.h:15
std::string label
Definition: design.h:239
ModuleInstanceVector loaded_module_instances
Definition: design.h:233
void operator()(std::ostream &out, const VertexOrEdge &v) const
Definition: design.h:254
std::vector< Instance * > InstanceVector
Definition: design.h:40
void initialize_top_modules()
Definition: design.cpp:458
std::vector< PrimitiveChannelInstance * > PrimitiveChannelInstanceVector
Definition: class.h:45
std::vector< HierarchicalChannel * > HierarchicalChannelVector
Definition: design.h:38
FunctionVector global_functions_
Definition: design.h:113
void print_all_class_definitions()
Definition: design.cpp:733
This class represents instances.
Definition: module.h:49
void initialize_path_instance_mapper()
Definition: design.cpp:1022
void initialize_port_mapping()
Definition: design.cpp:1005
int old_argc_
Definition: design.h:136
InstanceTree get_root()
Definition: design.cpp:782
std::string get_design_file_name()
This function returns the input file name of the design.
Definition: design.cpp:836
std::vector< HierarchicalChannelInstance * > HierarchicalChannelInstanceVector
Definition: class.h:39
boost::adjacency_list::vertex_descriptor VertexDescriptor
Definition: design.h:249
graph_t port_mapping_graph
Definition: design.h:248
void load_port_mapping(std::string)
This function loads the port mapping information from .psg file.
Definition: design.cpp:1168
SgProject * project_
Definition: design.h:131
Socket * find_socket(SgVariableDefinition *)
This function finds the socket according to its underlying symbol.
Definition: design.cpp:354
Design * get_design()
Definition: design.cpp:755
void print_all_global_functions()
Definition: design.cpp:742
Definition: design.h:271
This class represents a instance of a module.
Definition: module_instance.h:27
Definition: mapping_info.h:31
Design(int argc, char *argv[], std::vector< std::string > psg_file_names=std::vector< std::string >(0), bool is_psg_mode=false, bool PrintFrontendArgs=false)
default constructor
Definition: design.cpp:52
Definition: design.h:250
void add_module_to_definition_list(SgClassDefinition *class_def)
Only for internal use! This function triggers the analysis of a module. The new analyzed module will ...
Definition: design.cpp:822
Definition: interface.h:10
int psg_count
Definition: design.h:223
Variable * find_global_variable(SgVariableDefinition *var_def)
Find a port by it&#39;s ast variable definition.
Definition: design.cpp:766
std::string instrumentor_output_filename_
This variable contains the name which will be used for the dir file during the presimulation.
Definition: design.h:162
std::vector< Thread * > loaded_threads
functions that are implemented in the psg but are not simulation processes
Definition: design.h:231
MappingInfo mapping_info_
Definition: design.h:143
static Design * design_static
Definition: design.h:273
PrimitiveChannel * find_prim_channel_definition(SgClassDefinition *cd)
Definition: design.cpp:429
std::vector< Thread * > simulation_threads
Definition: design.h:232
~Design()
Definition: design.cpp:215
void initialize_global_variables()
Definition: design.cpp:542
graph_t g
Definition: design.h:258
std::vector< Event * > EventVector
Definition: class.h:32
ModuleVector module_definitions_
Definition: design.h:103
std::vector< int > psg_seg_count
Definition: design.h:224
Module * find_module_definition(SgClassDefinition *cd)
Definition: design.cpp:341
HierarchicalChannelVector hierarchical_channel_
Definition: design.h:106
std::vector< Interface * > InterfaceVector
Definition: design.h:41
void initialize_definitions()
Definition: design.cpp:249
This class represents a variable in a module.
Definition: variable.h:22
void print_design()
Definition: design.cpp:676
void store_port_mapping(std::string)
This function stores the port mapping information to .psg file.
Definition: design.cpp:1039