source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Custom/src/Custom_example.cpp @ 72

Last change on this file since 72 was 72, checked in by rosiere, 16 years ago
  • SystemC de l'unite fonctionnelle.
  • gestion des groupes / instructions custom
File size: 6.7 KB
Line 
1/*
2 * $Id$
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
12namespace morpheo {
13namespace behavioural {
14namespace 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
149    return NULL; // unimplemented function
150
151  }
152
153#undef  FUNCTION
154#define FUNCTION "custom::example_get_custom_execute_genMoore"
155  custom_execute_genMoore_t * example_get_custom_execute_genMoore (Toperation_t operation)
156  {
157    switch (operation)
158      {
159      case OPERATION_CUSTOM_L_4    :
160      case OPERATION_CUSTOM_L_8    :
161        {
162          return group_encryption.get_custom_execute_genMoore(operation);
163        }
164      case OPERATION_CUSTOM_L_1    :
165      case OPERATION_CUSTOM_L_2    :
166      case OPERATION_CUSTOM_L_3    :
167      case OPERATION_CUSTOM_L_5    :
168      case OPERATION_CUSTOM_L_6    :
169      case OPERATION_CUSTOM_L_7    :
170      case OPERATION_CUSTOM_LF_1_D :
171      case OPERATION_CUSTOM_LF_1_S :
172      case OPERATION_CUSTOM_LV_1   :
173      case OPERATION_CUSTOM_LV_2   :
174      case OPERATION_CUSTOM_LV_3   :
175      case OPERATION_CUSTOM_LV_4   :
176        {
177          break;
178        }
179      default :
180        {
181          throw ERRORMORPHEO(FUNCTION, "Invalid custom operation");
182        }
183      }
184
185    return &(morpheo::behavioural::core::multi_execute_loop::execute_loop::multi_execute_unit::execute_unit::functionnal_unit::operation_unimplemented); // unimplemented function
186  }
187
188#undef  FUNCTION
189#define FUNCTION "custom::example_get_custom_execute_transition"
190  custom_execute_transition_t * example_get_custom_execute_transition (uint32_t group)
191  {
192    switch (group)
193      {
194      case 26 : // CUSTOM_3
195        {
196          return group_encryption.get_custom_execute_transition();
197        }
198      case 30 : // CUSTOM_7
199        {
200          return group_random    .get_custom_execute_transition();
201        }
202      case 24 : // CUSTOM_1
203      case 25 : // CUSTOM_2
204      case 27 : // CUSTOM_4
205      case 28 : // CUSTOM_5
206      case 29 : // CUSTOM_6
207      case 31 : // CUSTOM_8
208        {
209          break;
210        }
211      default :
212        {
213          throw ERRORMORPHEO(FUNCTION, "Invalid custom group number");
214        }
215      }
216   
217    return NULL; // unimplemented function
218  }
219
220#undef  FUNCTION
221#define FUNCTION "custom::example_get_custom_execute_reset"
222  custom_execute_transition_t * example_get_custom_execute_reset (uint32_t group)
223  {
224    switch (group)
225      {
226      case 26 : // CUSTOM_3
227        {
228          return group_encryption.get_custom_execute_reset();
229        }
230      case 30 : // CUSTOM_7
231        {
232          return group_random    .get_custom_execute_reset();
233        }
234      case 24 : // CUSTOM_1
235      case 25 : // CUSTOM_2
236      case 27 : // CUSTOM_4
237      case 28 : // CUSTOM_5
238      case 29 : // CUSTOM_6
239      case 31 : // CUSTOM_8
240        {
241          break;
242        }
243      default :
244        {
245          throw ERRORMORPHEO(FUNCTION, "Invalid custom group number");
246        }
247      }
248   
249    return NULL; // unimplemented function
250  }
251
252#undef  FUNCTION
253#define FUNCTION "custom::example_get_custom_information"
254  custom_information_t example_get_custom_information (uint32_t context)
255  {
256    // for all context
257
258    custom_information_t info;
259   
260    info._get_valid_group               = &morpheo::behavioural::custom::example_get_valid_group              ;
261    info._get_nb_register               = &morpheo::behavioural::custom::example_get_nb_register              ;
262    info._get_access_mode               = &morpheo::behavioural::custom::example_get_access_mode              ;
263    info._get_custom_decod              = &morpheo::behavioural::custom::example_get_custom_decod             ;
264    info._get_custom_execute_genMoore   = &morpheo::behavioural::custom::example_get_custom_execute_genMoore  ;
265    info._get_custom_execute_transition = &morpheo::behavioural::custom::example_get_custom_execute_transition;
266    info._get_custom_execute_reset      = &morpheo::behavioural::custom::example_get_custom_execute_reset     ;
267    return info;
268  }
269 
270}; // end namespace custom
271}; // end namespace behavioural
272}; // end namespace morpheo             
Note: See TracBrowser for help on using the repository browser.