1 | #ifndef morpheo_behavioural_Types_h |
---|
2 | #define morpheo_behavioural_Types_h |
---|
3 | |
---|
4 | #include "Common/include/Types.h" |
---|
5 | #include "Common/include/ToString.h" |
---|
6 | #include "Common/include/FromString.h" |
---|
7 | #include "Common/include/ErrorMorpheo.h" |
---|
8 | #include "Behavioural/include/Constants.h" |
---|
9 | |
---|
10 | namespace morpheo { |
---|
11 | namespace behavioural { |
---|
12 | |
---|
13 | //============================================ |
---|
14 | // Type definition |
---|
15 | //============================================ |
---|
16 | |
---|
17 | // ***** general |
---|
18 | typedef uint32_t Tcounter_t; // universal counter |
---|
19 | typedef uint32_t Tptr_t; // universal pointer |
---|
20 | typedef uint32_t Tinstruction_t; |
---|
21 | typedef bool Tcontrol_t; |
---|
22 | typedef uint8_t Texception_t; |
---|
23 | typedef uint8_t Tcontext_t; |
---|
24 | typedef Tptr_t Tpacket_t; |
---|
25 | typedef uint8_t Toperation_t; |
---|
26 | typedef uint8_t Ttype_t; |
---|
27 | typedef uint32_t Tspr_t; |
---|
28 | typedef uint16_t Tspr_address_t; |
---|
29 | |
---|
30 | //typedef uint32_t Tdestination1_t; |
---|
31 | //typedef uint32_t Tdestination2_t; |
---|
32 | //typedef uint32_t Texec_flag_t; |
---|
33 | //typedef bool Texec_excep_t; |
---|
34 | |
---|
35 | // ***** Event |
---|
36 | typedef uint8_t Tevent_state_t; |
---|
37 | typedef uint8_t Tevent_type_t; |
---|
38 | |
---|
39 | // ***** Register |
---|
40 | typedef uint32_t Tgeneral_address_t; |
---|
41 | typedef uint32_t Tgeneral_data_t; |
---|
42 | typedef uint32_t Tspecial_address_t; |
---|
43 | typedef uint32_t Tspecial_data_t; |
---|
44 | |
---|
45 | // ~~~~~ prediction_unit |
---|
46 | typedef uint64_t Thistory_t; |
---|
47 | typedef Tptr_t Tprediction_ptr_t; |
---|
48 | typedef uint8_t Tbranch_state_t; |
---|
49 | typedef uint8_t Tbranch_condition_t; |
---|
50 | typedef Tprediction_ptr_t Tdepth_t; |
---|
51 | typedef Tgeneral_data_t Taddress_t; |
---|
52 | |
---|
53 | // ***** component dependant |
---|
54 | // ~~~~~ load store queue |
---|
55 | typedef uint8_t Taccess_t; |
---|
56 | typedef Tptr_t Tlsq_ptr_t; |
---|
57 | typedef Tgeneral_address_t Tdcache_address_t; |
---|
58 | typedef Tgeneral_data_t Tdcache_data_t; |
---|
59 | typedef bool Tdcache_error_t; |
---|
60 | typedef uint8_t Tdcache_type_t; |
---|
61 | |
---|
62 | |
---|
63 | // ~~~~~ ifetch |
---|
64 | typedef Tptr_t Tinst_ifetch_ptr_t; |
---|
65 | typedef Tptr_t Tifetch_queue_ptr_t; |
---|
66 | typedef Tgeneral_address_t Ticache_address_t; |
---|
67 | typedef Tgeneral_data_t Ticache_instruction_t; |
---|
68 | typedef bool Ticache_error_t; |
---|
69 | typedef uint8_t Ticache_type_t; |
---|
70 | |
---|
71 | typedef enum |
---|
72 | { |
---|
73 | ORBIS32, |
---|
74 | ORBIS64, |
---|
75 | ORFPX32, |
---|
76 | ORFPX64, |
---|
77 | ORVDX64 |
---|
78 | } ISA; |
---|
79 | |
---|
80 | typedef enum |
---|
81 | { |
---|
82 | PRIORITY_STATIC, |
---|
83 | PRIORITY_ROUND_ROBIN |
---|
84 | } Tpriority_t; |
---|
85 | |
---|
86 | typedef enum |
---|
87 | { |
---|
88 | LOAD_BALANCING_BALANCE, |
---|
89 | LOAD_BALANCING_MAXIMUM_FOR_PRIORITY |
---|
90 | } Tload_balancing_t; |
---|
91 | |
---|
92 | typedef enum |
---|
93 | { |
---|
94 | VICTIM_RANDOM , // Random |
---|
95 | VICTIM_ROUND_ROBIN, // Round Robin |
---|
96 | VICTIM_NLU , // Not Last Used |
---|
97 | VICTIM_PSEUDO_LRU , // Pseudo Least Recently Used |
---|
98 | VICTIM_LRU , // Least Recently Used |
---|
99 | VICTIM_FIFO // First IN First OUT |
---|
100 | } Tvictim_t; |
---|
101 | |
---|
102 | typedef enum |
---|
103 | { |
---|
104 | PREDICTOR_NEVER_TAKE , // Branch is never Take |
---|
105 | PREDICTOR_ALWAYS_TAKE , // Branch is always Take |
---|
106 | PREDICTOR_STATIC , // If the address of destination is previous, then the branch is take |
---|
107 | PREDICTOR_LAST_TAKE , // The direction is as the last time (if is the first time : static) |
---|
108 | PREDICTOR_COUNTER , // Counter table |
---|
109 | PREDICTOR_LOCAL , // Counter bank indexed with history bank |
---|
110 | PREDICTOR_GLOBAL , // Counter bank indexed with history table |
---|
111 | PREDICTOR_META , // A meta_predictor choose between 2 predictor : the local or the global |
---|
112 | PREDICTOR_CUSTOM // Not predefined scheme |
---|
113 | } Tpredictor_t; |
---|
114 | |
---|
115 | typedef enum |
---|
116 | { |
---|
117 | PHT_SCHEME_COUNTER, |
---|
118 | PHT_SCHEME_FSM |
---|
119 | } Tpht_scheme_t; |
---|
120 | |
---|
121 | typedef enum |
---|
122 | { |
---|
123 | MANAGE_EVENT_WAIT_ALL, |
---|
124 | MANAGE_EVENT_WAIT_DECODE, |
---|
125 | MANAGE_EVENT_NO_WAIT |
---|
126 | } Tmanage_event_t; |
---|
127 | |
---|
128 | typedef enum |
---|
129 | { |
---|
130 | RAT_NO_SAVE , // Rat without save |
---|
131 | RAT_ONE_SAVE , // Rat with one save |
---|
132 | RAT_DEPTH_SAVE // RAT with multiple save (depth) |
---|
133 | } Trat_scheme_t; |
---|
134 | |
---|
135 | //--------------------------------------------------[ instruction ]----- |
---|
136 | class instruction_t |
---|
137 | { |
---|
138 | public : |
---|
139 | Ttype_t _type ; |
---|
140 | Toperation_t _operation ; |
---|
141 | ISA _isa_subset; |
---|
142 | uint8_t _isa_class ; |
---|
143 | |
---|
144 | instruction_t (Ttype_t type , |
---|
145 | Toperation_t operation , |
---|
146 | ISA isa_subset, |
---|
147 | uint8_t isa_class ) |
---|
148 | { |
---|
149 | _type = type ; |
---|
150 | _operation = operation ; |
---|
151 | _isa_subset = isa_subset; |
---|
152 | _isa_class = isa_class ; |
---|
153 | } |
---|
154 | }; |
---|
155 | |
---|
156 | instruction_t instruction_information (uint32_t instruction); |
---|
157 | uint32_t instruction_size_data (uint32_t instruction); |
---|
158 | |
---|
159 | //----------------------------------------------[ spr_mode_access ]----- |
---|
160 | class spr_access_mode_t |
---|
161 | { |
---|
162 | public : uint8_t _user_access_mode ; |
---|
163 | public : uint8_t _supervisor_access_mode; |
---|
164 | |
---|
165 | public : spr_access_mode_t (uint32_t user_access_mode = SPR_ACCESS_MODE_NONE, |
---|
166 | uint32_t supervisor_access_mode = SPR_ACCESS_MODE_NONE) |
---|
167 | { |
---|
168 | _user_access_mode = user_access_mode ; |
---|
169 | _supervisor_access_mode = supervisor_access_mode; |
---|
170 | } |
---|
171 | }; |
---|
172 | |
---|
173 | }; // end namespace behavioural |
---|
174 | |
---|
175 | template<> inline std::string toString<morpheo::behavioural::Tpriority_t>(const morpheo::behavioural::Tpriority_t& x) |
---|
176 | { |
---|
177 | switch (x) |
---|
178 | { |
---|
179 | case morpheo::behavioural::PRIORITY_STATIC : return "priority_static"; break; |
---|
180 | case morpheo::behavioural::PRIORITY_ROUND_ROBIN : return "priority_round_robin"; break; |
---|
181 | default : return "" ; break; |
---|
182 | } |
---|
183 | }; |
---|
184 | |
---|
185 | template<> inline morpheo::behavioural::Tpriority_t fromString<morpheo::behavioural::Tpriority_t>(const std::string& x) |
---|
186 | { |
---|
187 | if ((x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::PRIORITY_STATIC))) == 0) or |
---|
188 | (x.compare(toString( morpheo::behavioural::PRIORITY_STATIC )) == 0)) |
---|
189 | return morpheo::behavioural::PRIORITY_STATIC; |
---|
190 | |
---|
191 | if ((x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::PRIORITY_ROUND_ROBIN))) == 0) or |
---|
192 | (x.compare(toString( morpheo::behavioural::PRIORITY_ROUND_ROBIN )) == 0)) |
---|
193 | return morpheo::behavioural::PRIORITY_ROUND_ROBIN; |
---|
194 | |
---|
195 | throw (ERRORMORPHEO ("fromString","Unknow string : \""+x+"\"")); |
---|
196 | }; |
---|
197 | |
---|
198 | template<> inline std::string toString<morpheo::behavioural::Tload_balancing_t>(const morpheo::behavioural::Tload_balancing_t& x) |
---|
199 | { |
---|
200 | switch (x) |
---|
201 | { |
---|
202 | case morpheo::behavioural::LOAD_BALANCING_BALANCE : return "load_balancing_balance"; break; |
---|
203 | case morpheo::behavioural::LOAD_BALANCING_MAXIMUM_FOR_PRIORITY : return "load_balancing_maximum_for_priority"; break; |
---|
204 | default : return "" ; break; |
---|
205 | } |
---|
206 | }; |
---|
207 | |
---|
208 | template<> inline morpheo::behavioural::Tload_balancing_t fromString<morpheo::behavioural::Tload_balancing_t>(const std::string& x) |
---|
209 | { |
---|
210 | if ((x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::LOAD_BALANCING_BALANCE))) == 0) or |
---|
211 | (x.compare(toString( morpheo::behavioural::LOAD_BALANCING_BALANCE )) == 0)) |
---|
212 | return morpheo::behavioural::LOAD_BALANCING_BALANCE; |
---|
213 | |
---|
214 | if ((x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::LOAD_BALANCING_MAXIMUM_FOR_PRIORITY))) == 0) or |
---|
215 | (x.compare(toString( morpheo::behavioural::LOAD_BALANCING_MAXIMUM_FOR_PRIORITY )) == 0)) |
---|
216 | return morpheo::behavioural::LOAD_BALANCING_MAXIMUM_FOR_PRIORITY; |
---|
217 | |
---|
218 | throw (ERRORMORPHEO ("fromString","Unknow string : \""+x+"\"")); |
---|
219 | }; |
---|
220 | |
---|
221 | template<> inline std::string toString<morpheo::behavioural::Tvictim_t>(const morpheo::behavioural::Tvictim_t& x) |
---|
222 | { |
---|
223 | switch (x) |
---|
224 | { |
---|
225 | case morpheo::behavioural::VICTIM_RANDOM : return "victim_random" ; break; |
---|
226 | case morpheo::behavioural::VICTIM_ROUND_ROBIN : return "victim_round_robin"; break; |
---|
227 | case morpheo::behavioural::VICTIM_NLU : return "victim_nlu" ; break; |
---|
228 | case morpheo::behavioural::VICTIM_PSEUDO_LRU : return "victim_pseudo_lru" ; break; |
---|
229 | case morpheo::behavioural::VICTIM_LRU : return "victim_lru" ; break; |
---|
230 | case morpheo::behavioural::VICTIM_FIFO : return "victim_fifo" ; break; |
---|
231 | default : return "" ; break; |
---|
232 | } |
---|
233 | }; |
---|
234 | |
---|
235 | template<> inline morpheo::behavioural::Tvictim_t fromString<morpheo::behavioural::Tvictim_t>(const std::string& x) |
---|
236 | { |
---|
237 | if ((x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::VICTIM_RANDOM ))) == 0) or |
---|
238 | (x.compare(toString( morpheo::behavioural::VICTIM_RANDOM )) == 0)) |
---|
239 | return morpheo::behavioural::VICTIM_RANDOM; |
---|
240 | |
---|
241 | if ((x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::VICTIM_ROUND_ROBIN))) == 0) or |
---|
242 | (x.compare(toString( morpheo::behavioural::VICTIM_ROUND_ROBIN )) == 0)) |
---|
243 | return morpheo::behavioural::VICTIM_ROUND_ROBIN; |
---|
244 | |
---|
245 | if ((x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::VICTIM_NLU ))) == 0) or |
---|
246 | (x.compare(toString( morpheo::behavioural::VICTIM_NLU )) == 0)) |
---|
247 | return morpheo::behavioural::VICTIM_NLU; |
---|
248 | |
---|
249 | if ((x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::VICTIM_PSEUDO_LRU ))) == 0) or |
---|
250 | (x.compare(toString( morpheo::behavioural::VICTIM_PSEUDO_LRU )) == 0)) |
---|
251 | return morpheo::behavioural::VICTIM_PSEUDO_LRU; |
---|
252 | |
---|
253 | if ((x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::VICTIM_LRU ))) == 0) or |
---|
254 | (x.compare(toString( morpheo::behavioural::VICTIM_LRU )) == 0)) |
---|
255 | return morpheo::behavioural::VICTIM_LRU; |
---|
256 | |
---|
257 | if ((x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::VICTIM_FIFO ))) == 0) or |
---|
258 | (x.compare(toString( morpheo::behavioural::VICTIM_FIFO )) == 0)) |
---|
259 | return morpheo::behavioural::VICTIM_FIFO; |
---|
260 | |
---|
261 | throw (ERRORMORPHEO ("fromString","Unknow string : \""+x+"\"")); |
---|
262 | }; |
---|
263 | |
---|
264 | template<> inline std::string toString<morpheo::behavioural::Tpredictor_t>(const morpheo::behavioural::Tpredictor_t& x) |
---|
265 | { |
---|
266 | switch (x) |
---|
267 | { |
---|
268 | case morpheo::behavioural::PREDICTOR_NEVER_TAKE : return "predictor_never_take" ; break; |
---|
269 | case morpheo::behavioural::PREDICTOR_ALWAYS_TAKE : return "predictor_always_take"; break; |
---|
270 | case morpheo::behavioural::PREDICTOR_STATIC : return "predictor_static" ; break; |
---|
271 | case morpheo::behavioural::PREDICTOR_LAST_TAKE : return "predictor_last_take" ; break; |
---|
272 | case morpheo::behavioural::PREDICTOR_COUNTER : return "predictor_counter" ; break; |
---|
273 | case morpheo::behavioural::PREDICTOR_LOCAL : return "predictor_local" ; break; |
---|
274 | case morpheo::behavioural::PREDICTOR_GLOBAL : return "predictor_global" ; break; |
---|
275 | case morpheo::behavioural::PREDICTOR_META : return "predictor_meta" ; break; |
---|
276 | case morpheo::behavioural::PREDICTOR_CUSTOM : return "predictor_custom" ; break; |
---|
277 | default : return "" ; break; |
---|
278 | } |
---|
279 | }; |
---|
280 | |
---|
281 | template<> inline morpheo::behavioural::Tpredictor_t fromString<morpheo::behavioural::Tpredictor_t>(const std::string& x) |
---|
282 | { |
---|
283 | if ((x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::PREDICTOR_NEVER_TAKE ))) == 0) or |
---|
284 | (x.compare(toString( morpheo::behavioural::PREDICTOR_NEVER_TAKE )) == 0)) |
---|
285 | return morpheo::behavioural::PREDICTOR_NEVER_TAKE; |
---|
286 | |
---|
287 | if ((x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::PREDICTOR_ALWAYS_TAKE))) == 0) or |
---|
288 | (x.compare(toString( morpheo::behavioural::PREDICTOR_ALWAYS_TAKE )) == 0)) |
---|
289 | return morpheo::behavioural::PREDICTOR_ALWAYS_TAKE; |
---|
290 | |
---|
291 | if ((x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::PREDICTOR_STATIC ))) == 0) or |
---|
292 | (x.compare(toString( morpheo::behavioural::PREDICTOR_STATIC )) == 0)) |
---|
293 | return morpheo::behavioural::PREDICTOR_STATIC; |
---|
294 | |
---|
295 | if ((x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::PREDICTOR_LAST_TAKE ))) == 0) or |
---|
296 | (x.compare(toString( morpheo::behavioural::PREDICTOR_LAST_TAKE )) == 0)) |
---|
297 | return morpheo::behavioural::PREDICTOR_LAST_TAKE; |
---|
298 | |
---|
299 | if ((x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::PREDICTOR_COUNTER ))) == 0) or |
---|
300 | (x.compare(toString( morpheo::behavioural::PREDICTOR_COUNTER )) == 0)) |
---|
301 | return morpheo::behavioural::PREDICTOR_COUNTER; |
---|
302 | |
---|
303 | if ((x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::PREDICTOR_LOCAL ))) == 0) or |
---|
304 | (x.compare(toString( morpheo::behavioural::PREDICTOR_LOCAL )) == 0)) |
---|
305 | return morpheo::behavioural::PREDICTOR_LOCAL; |
---|
306 | |
---|
307 | if ((x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::PREDICTOR_GLOBAL ))) == 0) or |
---|
308 | (x.compare(toString( morpheo::behavioural::PREDICTOR_GLOBAL )) == 0)) |
---|
309 | return morpheo::behavioural::PREDICTOR_GLOBAL; |
---|
310 | |
---|
311 | if ((x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::PREDICTOR_META ))) == 0) or |
---|
312 | (x.compare(toString( morpheo::behavioural::PREDICTOR_META )) == 0)) |
---|
313 | return morpheo::behavioural::PREDICTOR_META; |
---|
314 | |
---|
315 | if ((x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::PREDICTOR_CUSTOM ))) == 0) or |
---|
316 | (x.compare(toString( morpheo::behavioural::PREDICTOR_CUSTOM )) == 0)) |
---|
317 | return morpheo::behavioural::PREDICTOR_CUSTOM; |
---|
318 | |
---|
319 | throw (ERRORMORPHEO ("fromString","Unknow string : \""+x+"\"")); |
---|
320 | }; |
---|
321 | |
---|
322 | |
---|
323 | template<> inline std::string toString<morpheo::behavioural::Tpht_scheme_t>(const morpheo::behavioural::Tpht_scheme_t& x) |
---|
324 | { |
---|
325 | switch (x) |
---|
326 | { |
---|
327 | case morpheo::behavioural::PHT_SCHEME_COUNTER : return "counter"; break; |
---|
328 | case morpheo::behavioural::PHT_SCHEME_FSM : return "fsm" ; break; |
---|
329 | default : return ""; break; |
---|
330 | } |
---|
331 | }; |
---|
332 | |
---|
333 | template<> inline morpheo::behavioural::Tpht_scheme_t fromString<morpheo::behavioural::Tpht_scheme_t>(const std::string& x) |
---|
334 | { |
---|
335 | if ( (x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::PHT_SCHEME_COUNTER ))) == 0) or |
---|
336 | (x.compare(toString( morpheo::behavioural::PHT_SCHEME_COUNTER )) == 0)) |
---|
337 | return morpheo::behavioural::PHT_SCHEME_COUNTER; |
---|
338 | if ( (x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::PHT_SCHEME_FSM))) == 0) or |
---|
339 | (x.compare(toString( morpheo::behavioural::PHT_SCHEME_FSM )) == 0)) |
---|
340 | return morpheo::behavioural::PHT_SCHEME_FSM; |
---|
341 | |
---|
342 | throw (ErrorMorpheo ("<fromString> : Unknow string : \""+x+"\"")); |
---|
343 | }; |
---|
344 | |
---|
345 | |
---|
346 | template<> inline std::string toString<morpheo::behavioural::Trat_scheme_t>(const morpheo::behavioural::Trat_scheme_t& x) |
---|
347 | { |
---|
348 | switch (x) |
---|
349 | { |
---|
350 | case morpheo::behavioural::RAT_NO_SAVE : return "rat_no_save" ; break; |
---|
351 | case morpheo::behavioural::RAT_ONE_SAVE : return "rat_one_save" ; break; |
---|
352 | case morpheo::behavioural::RAT_DEPTH_SAVE : return "rat_depth_save"; break; |
---|
353 | default : return "" ; break; |
---|
354 | } |
---|
355 | }; |
---|
356 | |
---|
357 | template<> inline morpheo::behavioural::Trat_scheme_t fromString<morpheo::behavioural::Trat_scheme_t>(const std::string& x) |
---|
358 | { |
---|
359 | if ((x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::RAT_NO_SAVE ))) == 0) or |
---|
360 | (x.compare(toString( morpheo::behavioural::RAT_NO_SAVE )) == 0)) |
---|
361 | return morpheo::behavioural::RAT_NO_SAVE; |
---|
362 | |
---|
363 | if ((x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::RAT_ONE_SAVE ))) == 0) or |
---|
364 | (x.compare(toString( morpheo::behavioural::RAT_ONE_SAVE )) == 0)) |
---|
365 | return morpheo::behavioural::RAT_ONE_SAVE; |
---|
366 | |
---|
367 | if ((x.compare(toString(static_cast<uint32_t>(morpheo::behavioural::RAT_DEPTH_SAVE))) == 0) or |
---|
368 | (x.compare(toString( morpheo::behavioural::RAT_DEPTH_SAVE )) == 0)) |
---|
369 | return morpheo::behavioural::RAT_DEPTH_SAVE; |
---|
370 | |
---|
371 | throw (ERRORMORPHEO ("fromString","Unknow string : \""+x+"\"")); |
---|
372 | }; |
---|
373 | |
---|
374 | }; // end namespace morpheo |
---|
375 | #endif |
---|