[72] | 1 | /* |
---|
| 2 | * $Id: Custom_example.cpp 88 2008-12-10 18:31:39Z rosiere $ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #include "Behavioural/Custom/include/Custom_example.h" |
---|
| 9 | #include "Behavioural/Custom/include/Encryption.h" |
---|
| 10 | #include "Behavioural/Custom/include/Random.h" |
---|
| 11 | |
---|
| 12 | namespace morpheo { |
---|
| 13 | namespace behavioural { |
---|
| 14 | namespace custom { |
---|
| 15 | |
---|
| 16 | static encryption::Encryption group_encryption (GROUP_CUSTOM_3, |
---|
| 17 | OPERATION_CUSTOM_L_4, |
---|
| 18 | OPERATION_CUSTOM_L_8); |
---|
| 19 | |
---|
| 20 | static random::Random group_random (GROUP_CUSTOM_7); |
---|
| 21 | |
---|
| 22 | |
---|
| 23 | #undef FUNCTION |
---|
| 24 | #define FUNCTION "custom::example_get_valid_group" |
---|
| 25 | bool example_get_valid_group (uint32_t group) |
---|
| 26 | { |
---|
| 27 | switch (group) |
---|
| 28 | { |
---|
| 29 | case 26 : // CUSTOM_3 |
---|
| 30 | case 30 : // CUSTOM_7 |
---|
| 31 | { |
---|
| 32 | return true; |
---|
| 33 | break; |
---|
| 34 | } |
---|
| 35 | case 24 : // CUSTOM_1 |
---|
| 36 | case 25 : // CUSTOM_2 |
---|
| 37 | case 27 : // CUSTOM_4 |
---|
| 38 | case 28 : // CUSTOM_5 |
---|
| 39 | case 29 : // CUSTOM_6 |
---|
| 40 | case 31 : // CUSTOM_8 |
---|
| 41 | { |
---|
| 42 | break; |
---|
| 43 | } |
---|
| 44 | default : |
---|
| 45 | { |
---|
| 46 | throw ERRORMORPHEO(FUNCTION, "Invalid custom group number"); |
---|
| 47 | } |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | return false; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | #undef FUNCTION |
---|
| 54 | #define FUNCTION "custom::example_get_nb_register" |
---|
| 55 | uint32_t example_get_nb_register (uint32_t group) |
---|
| 56 | { |
---|
| 57 | switch (group) |
---|
| 58 | { |
---|
| 59 | case 26 : // CUSTOM_3 |
---|
| 60 | { |
---|
| 61 | return group_encryption.get_nb_register(); |
---|
| 62 | } |
---|
| 63 | case 30 : // CUSTOM_7 |
---|
| 64 | { |
---|
| 65 | return group_random .get_nb_register(); |
---|
| 66 | } |
---|
| 67 | case 24 : // CUSTOM_1 |
---|
| 68 | case 25 : // CUSTOM_2 |
---|
| 69 | case 27 : // CUSTOM_4 |
---|
| 70 | case 28 : // CUSTOM_5 |
---|
| 71 | case 29 : // CUSTOM_6 |
---|
| 72 | case 31 : // CUSTOM_8 |
---|
| 73 | { |
---|
| 74 | break; |
---|
| 75 | } |
---|
| 76 | default : |
---|
| 77 | { |
---|
| 78 | throw ERRORMORPHEO(FUNCTION, "Invalid custom group number"); |
---|
| 79 | } |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | return 0; |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | #undef FUNCTION |
---|
| 86 | #define FUNCTION "custom::example_get_access_mode" |
---|
| 87 | access_mode_t example_get_access_mode (uint32_t group, uint32_t reg) |
---|
| 88 | { |
---|
| 89 | if (reg < example_get_nb_register (group)) |
---|
| 90 | switch (group) |
---|
| 91 | { |
---|
| 92 | case 26 : // CUSTOM_3 |
---|
| 93 | { |
---|
| 94 | return group_encryption.get_access_mode(reg); |
---|
| 95 | } |
---|
| 96 | case 30 : // CUSTOM_7 |
---|
| 97 | { |
---|
| 98 | return group_random .get_access_mode(reg); |
---|
| 99 | } |
---|
| 100 | case 24 : // CUSTOM_1 |
---|
| 101 | case 25 : // CUSTOM_2 |
---|
| 102 | case 27 : // CUSTOM_4 |
---|
| 103 | case 28 : // CUSTOM_5 |
---|
| 104 | case 29 : // CUSTOM_6 |
---|
| 105 | case 31 : // CUSTOM_8 |
---|
| 106 | { |
---|
| 107 | break; |
---|
| 108 | } |
---|
| 109 | default : |
---|
| 110 | { |
---|
| 111 | throw ERRORMORPHEO(FUNCTION, "Invalid custom group number"); |
---|
| 112 | } |
---|
| 113 | } |
---|
| 114 | return access_mode_t (SPR_ACCESS_MODE_NONE, SPR_ACCESS_MODE_NONE); |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | #undef FUNCTION |
---|
| 118 | #define FUNCTION "custom::example_get_custom_decod" |
---|
| 119 | custom_decod_t * example_get_custom_decod (Toperation_t operation) |
---|
| 120 | { |
---|
| 121 | switch (operation) |
---|
| 122 | { |
---|
| 123 | case OPERATION_CUSTOM_L_4 : |
---|
| 124 | case OPERATION_CUSTOM_L_8 : |
---|
| 125 | { |
---|
| 126 | return group_encryption.get_custom_decod(operation); |
---|
| 127 | } |
---|
| 128 | case OPERATION_CUSTOM_L_1 : |
---|
| 129 | case OPERATION_CUSTOM_L_2 : |
---|
| 130 | case OPERATION_CUSTOM_L_3 : |
---|
| 131 | case OPERATION_CUSTOM_L_5 : |
---|
| 132 | case OPERATION_CUSTOM_L_6 : |
---|
| 133 | case OPERATION_CUSTOM_L_7 : |
---|
| 134 | case OPERATION_CUSTOM_LF_1_D : |
---|
| 135 | case OPERATION_CUSTOM_LF_1_S : |
---|
| 136 | case OPERATION_CUSTOM_LV_1 : |
---|
| 137 | case OPERATION_CUSTOM_LV_2 : |
---|
| 138 | case OPERATION_CUSTOM_LV_3 : |
---|
| 139 | case OPERATION_CUSTOM_LV_4 : |
---|
| 140 | { |
---|
| 141 | break; |
---|
| 142 | } |
---|
| 143 | default : |
---|
| 144 | { |
---|
| 145 | throw ERRORMORPHEO(FUNCTION, "Invalid custom operation"); |
---|
| 146 | } |
---|
| 147 | } |
---|
| 148 | |
---|
[78] | 149 | return &(morpheo::behavioural::core::multi_front_end::front_end::decod_unit::decod::instruction_illegal); // unimplemented function |
---|
[72] | 150 | } |
---|
| 151 | |
---|
| 152 | #undef FUNCTION |
---|
| 153 | #define FUNCTION "custom::example_get_custom_execute_genMoore" |
---|
| 154 | custom_execute_genMoore_t * example_get_custom_execute_genMoore (Toperation_t operation) |
---|
| 155 | { |
---|
| 156 | switch (operation) |
---|
| 157 | { |
---|
| 158 | case OPERATION_CUSTOM_L_4 : |
---|
| 159 | case OPERATION_CUSTOM_L_8 : |
---|
| 160 | { |
---|
| 161 | return group_encryption.get_custom_execute_genMoore(operation); |
---|
| 162 | } |
---|
| 163 | case OPERATION_CUSTOM_L_1 : |
---|
| 164 | case OPERATION_CUSTOM_L_2 : |
---|
| 165 | case OPERATION_CUSTOM_L_3 : |
---|
| 166 | case OPERATION_CUSTOM_L_5 : |
---|
| 167 | case OPERATION_CUSTOM_L_6 : |
---|
| 168 | case OPERATION_CUSTOM_L_7 : |
---|
| 169 | case OPERATION_CUSTOM_LF_1_D : |
---|
| 170 | case OPERATION_CUSTOM_LF_1_S : |
---|
| 171 | case OPERATION_CUSTOM_LV_1 : |
---|
| 172 | case OPERATION_CUSTOM_LV_2 : |
---|
| 173 | case OPERATION_CUSTOM_LV_3 : |
---|
| 174 | case OPERATION_CUSTOM_LV_4 : |
---|
| 175 | { |
---|
| 176 | break; |
---|
| 177 | } |
---|
| 178 | default : |
---|
| 179 | { |
---|
| 180 | throw ERRORMORPHEO(FUNCTION, "Invalid custom operation"); |
---|
| 181 | } |
---|
| 182 | } |
---|
| 183 | |
---|
| 184 | return &(morpheo::behavioural::core::multi_execute_loop::execute_loop::multi_execute_unit::execute_unit::functionnal_unit::operation_unimplemented); // unimplemented function |
---|
| 185 | } |
---|
| 186 | |
---|
| 187 | #undef FUNCTION |
---|
| 188 | #define FUNCTION "custom::example_get_custom_execute_transition" |
---|
| 189 | custom_execute_transition_t * example_get_custom_execute_transition (uint32_t group) |
---|
| 190 | { |
---|
| 191 | switch (group) |
---|
| 192 | { |
---|
| 193 | case 26 : // CUSTOM_3 |
---|
| 194 | { |
---|
| 195 | return group_encryption.get_custom_execute_transition(); |
---|
| 196 | } |
---|
| 197 | case 30 : // CUSTOM_7 |
---|
| 198 | { |
---|
| 199 | return group_random .get_custom_execute_transition(); |
---|
| 200 | } |
---|
| 201 | case 24 : // CUSTOM_1 |
---|
| 202 | case 25 : // CUSTOM_2 |
---|
| 203 | case 27 : // CUSTOM_4 |
---|
| 204 | case 28 : // CUSTOM_5 |
---|
| 205 | case 29 : // CUSTOM_6 |
---|
| 206 | case 31 : // CUSTOM_8 |
---|
| 207 | { |
---|
| 208 | break; |
---|
| 209 | } |
---|
| 210 | default : |
---|
| 211 | { |
---|
| 212 | throw ERRORMORPHEO(FUNCTION, "Invalid custom group number"); |
---|
| 213 | } |
---|
| 214 | } |
---|
| 215 | |
---|
| 216 | return NULL; // unimplemented function |
---|
| 217 | } |
---|
| 218 | |
---|
| 219 | #undef FUNCTION |
---|
| 220 | #define FUNCTION "custom::example_get_custom_execute_reset" |
---|
| 221 | custom_execute_transition_t * example_get_custom_execute_reset (uint32_t group) |
---|
| 222 | { |
---|
| 223 | switch (group) |
---|
| 224 | { |
---|
| 225 | case 26 : // CUSTOM_3 |
---|
| 226 | { |
---|
| 227 | return group_encryption.get_custom_execute_reset(); |
---|
| 228 | } |
---|
| 229 | case 30 : // CUSTOM_7 |
---|
| 230 | { |
---|
| 231 | return group_random .get_custom_execute_reset(); |
---|
| 232 | } |
---|
| 233 | case 24 : // CUSTOM_1 |
---|
| 234 | case 25 : // CUSTOM_2 |
---|
| 235 | case 27 : // CUSTOM_4 |
---|
| 236 | case 28 : // CUSTOM_5 |
---|
| 237 | case 29 : // CUSTOM_6 |
---|
| 238 | case 31 : // CUSTOM_8 |
---|
| 239 | { |
---|
| 240 | break; |
---|
| 241 | } |
---|
| 242 | default : |
---|
| 243 | { |
---|
| 244 | throw ERRORMORPHEO(FUNCTION, "Invalid custom group number"); |
---|
| 245 | } |
---|
| 246 | } |
---|
| 247 | |
---|
| 248 | return NULL; // unimplemented function |
---|
| 249 | } |
---|
| 250 | |
---|
| 251 | #undef FUNCTION |
---|
[78] | 252 | #define FUNCTION "custom::example_get_vhdl_decod" |
---|
| 253 | custom_vhdl_t * example_get_vhdl_decod (void) |
---|
| 254 | { |
---|
| 255 | return NULL; // unimplemented function |
---|
| 256 | } |
---|
| 257 | |
---|
| 258 | #undef FUNCTION |
---|
| 259 | #define FUNCTION "custom::example_get_vhdl_execute" |
---|
| 260 | custom_vhdl_t * example_get_vhdl_execute (void) |
---|
| 261 | { |
---|
| 262 | return NULL; // unimplemented function |
---|
| 263 | } |
---|
| 264 | |
---|
| 265 | #undef FUNCTION |
---|
[72] | 266 | #define FUNCTION "custom::example_get_custom_information" |
---|
[88] | 267 | //custom_information_t example_get_custom_information (uint32_t context) |
---|
| 268 | custom_information_t example_get_custom_information (void) |
---|
[72] | 269 | { |
---|
| 270 | custom_information_t info; |
---|
| 271 | |
---|
| 272 | info._get_valid_group = &morpheo::behavioural::custom::example_get_valid_group ; |
---|
| 273 | info._get_nb_register = &morpheo::behavioural::custom::example_get_nb_register ; |
---|
| 274 | info._get_access_mode = &morpheo::behavioural::custom::example_get_access_mode ; |
---|
| 275 | info._get_custom_decod = &morpheo::behavioural::custom::example_get_custom_decod ; |
---|
| 276 | info._get_custom_execute_genMoore = &morpheo::behavioural::custom::example_get_custom_execute_genMoore ; |
---|
| 277 | info._get_custom_execute_transition = &morpheo::behavioural::custom::example_get_custom_execute_transition; |
---|
| 278 | info._get_custom_execute_reset = &morpheo::behavioural::custom::example_get_custom_execute_reset ; |
---|
[78] | 279 | info._get_vhdl_decod = &morpheo::behavioural::custom::example_get_vhdl_decod ; |
---|
| 280 | info._get_vhdl_execute = &morpheo::behavioural::custom::example_get_vhdl_execute ; |
---|
[88] | 281 | |
---|
[72] | 282 | return info; |
---|
| 283 | } |
---|
| 284 | |
---|
| 285 | }; // end namespace custom |
---|
| 286 | }; // end namespace behavioural |
---|
| 287 | }; // end namespace morpheo |
---|