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 Tinstruction_t; |
---|
19 | typedef bool Tcontrol_t; |
---|
20 | typedef uint8_t Toperation_t; |
---|
21 | //typedef uint32_t Tdestination1_t; |
---|
22 | //typedef uint32_t Tdestination2_t; |
---|
23 | //typedef uint32_t Texec_flag_t; |
---|
24 | //typedef bool Texec_excep_t; |
---|
25 | |
---|
26 | typedef uint8_t Texception_t; |
---|
27 | typedef uint8_t Tcontext_t; |
---|
28 | typedef uint8_t Tpacket_t; |
---|
29 | typedef uint8_t Ttype_t; |
---|
30 | typedef uint8_t Tevent_state_t; |
---|
31 | typedef uint8_t Tevent_type_t; |
---|
32 | typedef uint8_t Tcounter_t; // universal counter |
---|
33 | typedef uint8_t Tptr_t; // universal pointer |
---|
34 | |
---|
35 | // ***** Register |
---|
36 | typedef uint32_t Tgeneral_address_t; |
---|
37 | typedef uint32_t Tgeneral_data_t; |
---|
38 | typedef uint32_t Tspecial_address_t; |
---|
39 | typedef uint32_t Tspecial_data_t; |
---|
40 | |
---|
41 | // ***** component dependant |
---|
42 | // ~~~~~ load store queue |
---|
43 | typedef uint8_t Taccess_t; |
---|
44 | typedef uint8_t Tlsq_ptr_t; |
---|
45 | typedef uint32_t Tdcache_address_t; |
---|
46 | typedef uint32_t Tdcache_data_t; |
---|
47 | typedef bool Tdcache_error_t; |
---|
48 | typedef uint8_t Tdcache_type_t; |
---|
49 | |
---|
50 | // ~~~~~ prediction_unit |
---|
51 | typedef uint8_t Thistory_t; |
---|
52 | typedef uint8_t Tprediction_ptr_t; |
---|
53 | typedef uint8_t Tbranch_state_t; |
---|
54 | typedef uint8_t Tbranch_condition_t; |
---|
55 | typedef uint8_t Tdepth_t; |
---|
56 | typedef Tgeneral_data_t Taddress_t; |
---|
57 | |
---|
58 | |
---|
59 | // ~~~~~ ifetch |
---|
60 | typedef uint8_t Tinst_ifetch_ptr_t; |
---|
61 | typedef uint8_t Tifetch_queue_ptr_t; |
---|
62 | typedef uint32_t Ticache_address_t; |
---|
63 | typedef uint32_t Ticache_instruction_t; |
---|
64 | typedef bool Ticache_error_t; |
---|
65 | typedef uint8_t Ticache_type_t; |
---|
66 | |
---|
67 | typedef enum |
---|
68 | { |
---|
69 | PRIORITY_STATIC, |
---|
70 | PRIORITY_ROUND_ROBIN |
---|
71 | } Tpriority_t; |
---|
72 | |
---|
73 | typedef enum |
---|
74 | { |
---|
75 | LOAD_BALANCING_BALANCE, |
---|
76 | LOAD_BALANCING_MAXIMUM_FOR_PRIORITY |
---|
77 | } Tload_balancing_t; |
---|
78 | |
---|
79 | typedef enum |
---|
80 | { |
---|
81 | VICTIM_RANDOM , // Random |
---|
82 | VICTIM_ROUND_ROBIN, // Round Robin |
---|
83 | VICTIM_NLU , // Not Last Used |
---|
84 | VICTIM_PSEUDO_LRU , // Pseudo Least Recently Used |
---|
85 | VICTIM_LRU , // Least Recently Used |
---|
86 | VICTIM_FIFO // First IN First OUT |
---|
87 | } Tvictim_t; |
---|
88 | |
---|
89 | typedef enum |
---|
90 | { |
---|
91 | PREDICTOR_NEVER_TAKE , // Branch is never Take |
---|
92 | PREDICTOR_ALWAYS_TAKE , // Branch is always Take |
---|
93 | PREDICTOR_STATIC , // If the adress of destination is previous, then the branch is take |
---|
94 | PREDICTOR_LAST_TAKE , // The direction is as the last time (if is the first time : static) |
---|
95 | PREDICTOR_COUNTER , // Counter table |
---|
96 | PREDICTOR_LOCAL , // Counter bank indexed with history bank |
---|
97 | PREDICTOR_GLOBAL , // Counter bank indexed with history table |
---|
98 | PREDICTOR_META , // A meta_predictor choose between 2 predictor : the local or the global |
---|
99 | PREDICTOR_CUSTOM // Note predefined scheme |
---|
100 | } Tpredictor_t; |
---|
101 | |
---|
102 | //----------------------------------------------[ spr_mode_access ]----- |
---|
103 | class spr_access_mode_t |
---|
104 | { |
---|
105 | public : uint8_t _user_access_mode ; |
---|
106 | public : uint8_t _supervisor_access_mode; |
---|
107 | |
---|
108 | public : spr_access_mode_t (uint32_t user_access_mode = SPR_ACCESS_MODE_NONE, |
---|
109 | uint32_t supervisor_access_mode = SPR_ACCESS_MODE_NONE) |
---|
110 | { |
---|
111 | _user_access_mode = user_access_mode ; |
---|
112 | _supervisor_access_mode = supervisor_access_mode; |
---|
113 | } |
---|
114 | }; |
---|
115 | |
---|
116 | }; // end namespace behavioural |
---|
117 | |
---|
118 | inline std::string toString_type(const morpheo::behavioural::Ttype_t& x) |
---|
119 | { |
---|
120 | switch (x) |
---|
121 | { |
---|
122 | case TYPE_ALU : return "ALU" ; break; |
---|
123 | case TYPE_SHIFT : return "SHIFT" ; break; |
---|
124 | case TYPE_MOVE : return "MOVE" ; break; |
---|
125 | case TYPE_TEST : return "TEST" ; break; |
---|
126 | case TYPE_MUL_DIV : return "MUL_DIV"; break; |
---|
127 | case TYPE_EXTEND : return "EXTEND" ; break; |
---|
128 | case TYPE_FIND : return "FIND" ; break; |
---|
129 | case TYPE_SPECIAL : return "SPECIAL"; break; |
---|
130 | case TYPE_CUSTOM : return "CUSTOM" ; break; |
---|
131 | case TYPE_BRANCH : return "BRANCH" ; break; |
---|
132 | case TYPE_MEMORY : return "MEMORY" ; break; |
---|
133 | default : return "" ; break; |
---|
134 | } |
---|
135 | }; |
---|
136 | |
---|
137 | template<> inline std::string toString<morpheo::behavioural::Tpriority_t>(const morpheo::behavioural::Tpriority_t& x) |
---|
138 | { |
---|
139 | switch (x) |
---|
140 | { |
---|
141 | case morpheo::behavioural::PRIORITY_STATIC : return "priority_static"; break; |
---|
142 | case morpheo::behavioural::PRIORITY_ROUND_ROBIN : return "priority_round_robin"; break; |
---|
143 | default : return "" ; break; |
---|
144 | } |
---|
145 | }; |
---|
146 | |
---|
147 | template<> inline morpheo::behavioural::Tpriority_t fromString<morpheo::behavioural::Tpriority_t>(const std::string& x) |
---|
148 | { |
---|
149 | if ( (x.compare("0") == 0) or |
---|
150 | (x.compare("priority_static") == 0)) |
---|
151 | return morpheo::behavioural::PRIORITY_STATIC; |
---|
152 | if ( (x.compare("1") == 0) or |
---|
153 | (x.compare("priority_round_robin") == 0)) |
---|
154 | return morpheo::behavioural::PRIORITY_ROUND_ROBIN; |
---|
155 | throw (ERRORMORPHEO ("fromString","Unknow string : \""+x+"\"")); |
---|
156 | }; |
---|
157 | |
---|
158 | template<> inline std::string toString<morpheo::behavioural::Tload_balancing_t>(const morpheo::behavioural::Tload_balancing_t& x) |
---|
159 | { |
---|
160 | switch (x) |
---|
161 | { |
---|
162 | case morpheo::behavioural::LOAD_BALANCING_BALANCE : return "load_balancing_balance"; break; |
---|
163 | case morpheo::behavioural::LOAD_BALANCING_MAXIMUM_FOR_PRIORITY : return "load_balancing_maximum_for_priority"; break; |
---|
164 | default : return "" ; break; |
---|
165 | } |
---|
166 | }; |
---|
167 | |
---|
168 | template<> inline morpheo::behavioural::Tload_balancing_t fromString<morpheo::behavioural::Tload_balancing_t>(const std::string& x) |
---|
169 | { |
---|
170 | if ( (x.compare("0") == 0) or |
---|
171 | (x.compare("load_balancing_balance") == 0)) |
---|
172 | return morpheo::behavioural::LOAD_BALANCING_BALANCE; |
---|
173 | if ( (x.compare("1") == 0) or |
---|
174 | (x.compare("load_balancing_maximum_for_priority") == 0)) |
---|
175 | return morpheo::behavioural::LOAD_BALANCING_MAXIMUM_FOR_PRIORITY; |
---|
176 | throw (ERRORMORPHEO ("fromString","Unknow string : \""+x+"\"")); |
---|
177 | }; |
---|
178 | |
---|
179 | template<> inline std::string toString<morpheo::behavioural::Tvictim_t>(const morpheo::behavioural::Tvictim_t& x) |
---|
180 | { |
---|
181 | switch (x) |
---|
182 | { |
---|
183 | case morpheo::behavioural::VICTIM_RANDOM : return "victim_random" ; break; |
---|
184 | case morpheo::behavioural::VICTIM_ROUND_ROBIN : return "victim_round_robin"; break; |
---|
185 | case morpheo::behavioural::VICTIM_NLU : return "victim_nlu" ; break; |
---|
186 | case morpheo::behavioural::VICTIM_PSEUDO_LRU : return "victim_pseudo_lru" ; break; |
---|
187 | case morpheo::behavioural::VICTIM_LRU : return "victim_lru" ; break; |
---|
188 | case morpheo::behavioural::VICTIM_FIFO : return "victim_fifo" ; break; |
---|
189 | default : return "" ; break; |
---|
190 | } |
---|
191 | }; |
---|
192 | |
---|
193 | template<> inline morpheo::behavioural::Tvictim_t fromString<morpheo::behavioural::Tvictim_t>(const std::string& x) |
---|
194 | { |
---|
195 | if ( (x.compare("0") == 0) or |
---|
196 | (x.compare("victim_random") == 0)) |
---|
197 | return morpheo::behavioural::VICTIM_RANDOM; |
---|
198 | if ( (x.compare("1") == 0) or |
---|
199 | (x.compare("victim_round_robin") == 0)) |
---|
200 | return morpheo::behavioural::VICTIM_ROUND_ROBIN; |
---|
201 | if ( (x.compare("2") == 0) or |
---|
202 | (x.compare("victim_nlu") == 0)) |
---|
203 | return morpheo::behavioural::VICTIM_NLU; |
---|
204 | if ( (x.compare("3") == 0) or |
---|
205 | (x.compare("victim_pseudo_lru") == 0)) |
---|
206 | return morpheo::behavioural::VICTIM_PSEUDO_LRU; |
---|
207 | if ( (x.compare("4") == 0) or |
---|
208 | (x.compare("victim_lru") == 0)) |
---|
209 | return morpheo::behavioural::VICTIM_LRU; |
---|
210 | if ( (x.compare("5") == 0) or |
---|
211 | (x.compare("victim_fifo") == 0)) |
---|
212 | return morpheo::behavioural::VICTIM_FIFO; |
---|
213 | throw (ERRORMORPHEO ("fromString","Unknow string : \""+x+"\"")); |
---|
214 | }; |
---|
215 | |
---|
216 | template<> inline std::string toString<morpheo::behavioural::Tpredictor_t>(const morpheo::behavioural::Tpredictor_t& x) |
---|
217 | { |
---|
218 | switch (x) |
---|
219 | { |
---|
220 | case morpheo::behavioural::PREDICTOR_NEVER_TAKE : return "predictor_never_take" ; break; |
---|
221 | case morpheo::behavioural::PREDICTOR_ALWAYS_TAKE : return "predictor_always_take"; break; |
---|
222 | case morpheo::behavioural::PREDICTOR_STATIC : return "predictor_static" ; break; |
---|
223 | case morpheo::behavioural::PREDICTOR_LAST_TAKE : return "predictor_last_take" ; break; |
---|
224 | case morpheo::behavioural::PREDICTOR_COUNTER : return "predictor_counter" ; break; |
---|
225 | case morpheo::behavioural::PREDICTOR_LOCAL : return "predictor_local" ; break; |
---|
226 | case morpheo::behavioural::PREDICTOR_GLOBAL : return "predictor_global" ; break; |
---|
227 | case morpheo::behavioural::PREDICTOR_META : return "predictor_meta" ; break; |
---|
228 | case morpheo::behavioural::PREDICTOR_CUSTOM : return "predictor_custom" ; break; |
---|
229 | default : return "" ; break; |
---|
230 | } |
---|
231 | }; |
---|
232 | |
---|
233 | template<> inline morpheo::behavioural::Tpredictor_t fromString<morpheo::behavioural::Tpredictor_t>(const std::string& x) |
---|
234 | { |
---|
235 | if ( (x.compare("0") == 0) or |
---|
236 | (x.compare("predictor_never_take") == 0)) |
---|
237 | return morpheo::behavioural::PREDICTOR_NEVER_TAKE; |
---|
238 | if ( (x.compare("1") == 0) or |
---|
239 | (x.compare("predictor_always_take") == 0)) |
---|
240 | return morpheo::behavioural::PREDICTOR_ALWAYS_TAKE; |
---|
241 | if ( (x.compare("2") == 0) or |
---|
242 | (x.compare("predictor_static") == 0)) |
---|
243 | return morpheo::behavioural::PREDICTOR_STATIC; |
---|
244 | if ( (x.compare("3") == 0) or |
---|
245 | (x.compare("predictor_last_take") == 0)) |
---|
246 | return morpheo::behavioural::PREDICTOR_LAST_TAKE; |
---|
247 | if ( (x.compare("4") == 0) or |
---|
248 | (x.compare("predictor_counter") == 0)) |
---|
249 | return morpheo::behavioural::PREDICTOR_COUNTER; |
---|
250 | if ( (x.compare("5") == 0) or |
---|
251 | (x.compare("predictor_local") == 0)) |
---|
252 | return morpheo::behavioural::PREDICTOR_LOCAL; |
---|
253 | if ( (x.compare("6") == 0) or |
---|
254 | (x.compare("predictor_global") == 0)) |
---|
255 | return morpheo::behavioural::PREDICTOR_GLOBAL; |
---|
256 | if ( (x.compare("7") == 0) or |
---|
257 | (x.compare("predictor_meta") == 0)) |
---|
258 | return morpheo::behavioural::PREDICTOR_META; |
---|
259 | if ( (x.compare("8") == 0) or |
---|
260 | (x.compare("predictor_custom") == 0)) |
---|
261 | return morpheo::behavioural::PREDICTOR_CUSTOM; |
---|
262 | throw (ERRORMORPHEO ("fromString","Unknow string : \""+x+"\"")); |
---|
263 | }; |
---|
264 | |
---|
265 | }; // end namespace morpheo |
---|
266 | #endif |
---|