1 | #ifndef morpheo_behavioural_Component_h |
---|
2 | #define morpheo_behavioural_Component_h |
---|
3 | |
---|
4 | /* |
---|
5 | * $Id: Component.h 115 2009-04-20 21:29:17Z rosiere $ |
---|
6 | * |
---|
7 | * [ Description ] |
---|
8 | * |
---|
9 | */ |
---|
10 | |
---|
11 | #include <stdint.h> |
---|
12 | #include <iostream> |
---|
13 | #include <list> |
---|
14 | #include <map> |
---|
15 | #ifdef VHDL |
---|
16 | #include "Behavioural/include/Vhdl.h" |
---|
17 | #endif |
---|
18 | //#include "Behavioural/include/Description.h" |
---|
19 | #include "Behavioural/include/Entity.h" |
---|
20 | #include "Common/include/ToString.h" |
---|
21 | #include "Common/include/Debug.h" |
---|
22 | #include "Behavioural/include/Usage.h" |
---|
23 | |
---|
24 | namespace morpheo { |
---|
25 | namespace behavioural { |
---|
26 | |
---|
27 | /* |
---|
28 | #ifdef DEBUG |
---|
29 | # define PORT_MAP(x,a,b,c,d) \ |
---|
30 | do \ |
---|
31 | { \ |
---|
32 | try \ |
---|
33 | { \ |
---|
34 | x->port_map(a,b,c,d); \ |
---|
35 | } \ |
---|
36 | catch (morpheo::ErrorMorpheo & error) \ |
---|
37 | { \ |
---|
38 | throw (ErrorMorpheo ("In file "+toString(__FILE__)+", at line "+toString(__LINE__)+"\n"+error.what ())); \ |
---|
39 | } \ |
---|
40 | } \ |
---|
41 | while (0) |
---|
42 | #else |
---|
43 | */ |
---|
44 | # define PORT_MAP(x,a,b,c,d) \ |
---|
45 | do \ |
---|
46 | { \ |
---|
47 | x->port_map(a,b,c,d); \ |
---|
48 | } \ |
---|
49 | while (0) |
---|
50 | // #endif |
---|
51 | |
---|
52 | #define COMPONENT_MAP(x,a,b,c,d) \ |
---|
53 | do \ |
---|
54 | { \ |
---|
55 | PORT_MAP(x,a,b,c,d); \ |
---|
56 | PORT_MAP(x,c,d,a,b); \ |
---|
57 | } \ |
---|
58 | while (0) |
---|
59 | |
---|
60 | |
---|
61 | typedef uint8_t Tinstance_t; |
---|
62 | |
---|
63 | #define INSTANCE_NONE 0x0 |
---|
64 | #define INSTANCE_LIBRARY 0x1 |
---|
65 | #define INSTANCE_COMPONENT 0x2 |
---|
66 | #define INSTANCE_POSITION 0x4 |
---|
67 | #define INSTANCE_ALL 0x7 |
---|
68 | |
---|
69 | class Component |
---|
70 | { |
---|
71 | typedef struct |
---|
72 | { |
---|
73 | public : Component * _component; |
---|
74 | public : Entity * _entity ; |
---|
75 | public : Tinstance_t _instance ; |
---|
76 | public : std::string _architecture; |
---|
77 | } Tcomponent_t; |
---|
78 | |
---|
79 | // -----[ fields ]---------------------------------------------------- |
---|
80 | private : const Tusage_t _usage; |
---|
81 | private : Entity * _entity ; |
---|
82 | private : std::list<Tcomponent_t*> * _list_component; |
---|
83 | |
---|
84 | // -----[ methods ]--------------------------------------------------- |
---|
85 | public : Component (Tusage_t usage); |
---|
86 | public : Component (const Component & component); |
---|
87 | public : ~Component (); |
---|
88 | |
---|
89 | public : std::string get_name (void); |
---|
90 | |
---|
91 | public : Entity * set_entity (std::string name |
---|
92 | ,std::string type |
---|
93 | #ifdef POSITION |
---|
94 | ,schema_t schema |
---|
95 | #endif |
---|
96 | ); |
---|
97 | private : std::string get_entity (void); |
---|
98 | |
---|
99 | public : void set_component (Component * component |
---|
100 | #ifdef POSITION |
---|
101 | ,uint32_t pos_x |
---|
102 | ,uint32_t pos_y |
---|
103 | ,uint32_t size_x |
---|
104 | ,uint32_t size_y |
---|
105 | #endif |
---|
106 | ,Tinstance_t instance=INSTANCE_ALL |
---|
107 | ,std::string architecture="" |
---|
108 | ); |
---|
109 | |
---|
110 | private : std::string get_component (void); |
---|
111 | |
---|
112 | private : Entity * find_entity (std::string name); |
---|
113 | //private : Interface * find_interface (std::string name , |
---|
114 | // Entity * entity); |
---|
115 | |
---|
116 | #ifdef VHDL |
---|
117 | public : void vhdl_instance (Vhdl * & vhdl); |
---|
118 | #endif |
---|
119 | |
---|
120 | |
---|
121 | private : Signal * signal_internal (Entity * entity_productor, |
---|
122 | Signal * signal_productor, |
---|
123 | Entity * entity_consumer, |
---|
124 | Signal * signal_consumer); |
---|
125 | |
---|
126 | public : void port_map (std::string component_src , |
---|
127 | std::string port_src , |
---|
128 | std::string component_dest, |
---|
129 | std::string port_dest ); |
---|
130 | |
---|
131 | public : bool test_map (bool recursive=true); |
---|
132 | private : bool test_map (uint32_t depth, bool recursive); |
---|
133 | |
---|
134 | public : void * get_sc_signal (std::string component, |
---|
135 | std::string port ); |
---|
136 | // public : void set_sc_signal (std::string component, |
---|
137 | // std::string port , |
---|
138 | // void * sc_signal); |
---|
139 | |
---|
140 | // public : bool test_equi (bool recursive=true); |
---|
141 | // private : bool test_equi (uint32_t depth, bool recursive); |
---|
142 | |
---|
143 | #ifdef POSITION |
---|
144 | public : void interface_map (std::string component_src , |
---|
145 | std::string port_dest, |
---|
146 | std::string component_dest, |
---|
147 | std::string port_dest ); |
---|
148 | |
---|
149 | public : XML toXML (void); |
---|
150 | |
---|
151 | public : void generate_file (void); |
---|
152 | #endif |
---|
153 | public : friend std::ostream& operator<< (std::ostream& output_stream, |
---|
154 | morpheo::behavioural::Component & x); |
---|
155 | |
---|
156 | |
---|
157 | #undef FUNCTION |
---|
158 | #define FUNCTION "Component::set_sc_signal" |
---|
159 | public : template <typename T> |
---|
160 | void set_sc_signal (std::string component, |
---|
161 | std::string port , |
---|
162 | void * sc_signal) |
---|
163 | { |
---|
164 | log_begin(Behavioural,FUNCTION); |
---|
165 | |
---|
166 | std::string name_entity = _entity->get_name(); |
---|
167 | |
---|
168 | Entity * entity = find_entity(component); |
---|
169 | |
---|
170 | if (entity == NULL) |
---|
171 | throw (ERRORMORPHEO (FUNCTION,"In component \""+name_entity+"\", the component \""+component+"\" is unknow.\n")); |
---|
172 | |
---|
173 | Signal * signal = entity->find_signal (port); |
---|
174 | |
---|
175 | if (signal == NULL) |
---|
176 | throw (ERRORMORPHEO (FUNCTION,"In component \""+name_entity+"\", the component \""+component+"\" have not the signal \""+port+"\".\n")); |
---|
177 | |
---|
178 | signal->alloc<T>(sc_signal); |
---|
179 | |
---|
180 | log_end(Behavioural,FUNCTION); |
---|
181 | }; |
---|
182 | }; |
---|
183 | |
---|
184 | }; // end namespace behavioural |
---|
185 | }; // end namespace morpheo |
---|
186 | |
---|
187 | #endif |
---|