source: trunk/IPs/systemC/processor/Morpheo/Behavioural/include/Types.h @ 88

Last change on this file since 88 was 88, checked in by rosiere, 16 years ago

Almost complete design
with Test and test platform

  • Property svn:keywords set to Id
File size: 12.1 KB
Line 
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
10namespace morpheo {
11namespace 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            Texception_t;
21  typedef uint8_t            Tcontext_t;
22  typedef uint8_t            Tpacket_t;
23  typedef uint8_t            Toperation_t;
24  typedef uint8_t            Ttype_t;
25  typedef uint8_t            Tcounter_t; // universal counter
26  typedef uint8_t            Tptr_t;     // universal pointer
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 uint8_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  //--------------------------------------------------[ instruction ]-----
116  class instruction_t
117  {
118  public :
119    Ttype_t      _type      ;
120    Toperation_t _operation ;
121    ISA          _isa_subset;
122    uint8_t      _isa_class ;
123
124    instruction_t (Ttype_t      type      ,
125                   Toperation_t operation ,
126                   ISA          isa_subset,
127                   uint8_t      isa_class )
128    {
129      _type       = type      ;
130      _operation  = operation ;
131      _isa_subset = isa_subset;
132      _isa_class  = isa_class ;
133    }
134  };
135
136  instruction_t instruction_information (uint32_t instruction);
137  uint32_t      instruction_size_data   (uint32_t instruction);
138
139  //----------------------------------------------[ spr_mode_access ]-----
140  class spr_access_mode_t
141  {
142  public : uint8_t _user_access_mode      ;
143  public : uint8_t _supervisor_access_mode;
144   
145  public : spr_access_mode_t (uint32_t user_access_mode       = SPR_ACCESS_MODE_NONE,
146                              uint32_t supervisor_access_mode = SPR_ACCESS_MODE_NONE)
147    {
148      _user_access_mode       = user_access_mode      ;
149      _supervisor_access_mode = supervisor_access_mode;
150    }
151  };
152
153}; // end namespace behavioural
154
155  inline std::string toString_type(const morpheo::behavioural::Ttype_t& x)
156  {
157    switch (x)
158      {
159      case TYPE_ALU     : return "ALU"        ; break;
160      case TYPE_SHIFT   : return "SHIFT"      ; break;
161      case TYPE_MOVE    : return "MOVE"       ; break;
162      case TYPE_TEST    : return "TEST"       ; break;
163      case TYPE_MUL     : return "MUL"        ; break;
164      case TYPE_DIV     : return "DIV"        ; break;
165      case TYPE_EXTEND  : return "EXTEND"     ; break;
166      case TYPE_FIND    : return "FIND"       ; break;
167      case TYPE_SPECIAL : return "SPECIAL"    ; break;
168      case TYPE_CUSTOM  : return "CUSTOM"     ; break;
169      case TYPE_BRANCH  : return "BRANCH"     ; break;
170      case TYPE_MEMORY  : return "MEMORY"     ; break;
171      default           : return "Unknow type"; break;
172      }
173  };
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("0")                    == 0) or
188         (x.compare("priority_static")      == 0))
189      return morpheo::behavioural::PRIORITY_STATIC;
190    if ( (x.compare("1")                    == 0) or
191         (x.compare("priority_round_robin") == 0))
192      return morpheo::behavioural::PRIORITY_ROUND_ROBIN;
193    throw (ERRORMORPHEO ("fromString","Unknow string : \""+x+"\""));
194  };
195
196  template<> inline std::string toString<morpheo::behavioural::Tload_balancing_t>(const morpheo::behavioural::Tload_balancing_t& x)
197  {
198    switch (x)
199      {
200      case morpheo::behavioural::LOAD_BALANCING_BALANCE              : return "load_balancing_balance"; break;
201      case morpheo::behavioural::LOAD_BALANCING_MAXIMUM_FOR_PRIORITY : return "load_balancing_maximum_for_priority"; break;
202      default    : return ""      ; break;
203      }
204  };
205
206  template<> inline morpheo::behavioural::Tload_balancing_t fromString<morpheo::behavioural::Tload_balancing_t>(const std::string& x)
207  {
208    if ( (x.compare("0")                      == 0) or
209         (x.compare("load_balancing_balance") == 0))
210      return morpheo::behavioural::LOAD_BALANCING_BALANCE;
211    if ( (x.compare("1")                                   == 0) or
212         (x.compare("load_balancing_maximum_for_priority") == 0))
213      return morpheo::behavioural::LOAD_BALANCING_MAXIMUM_FOR_PRIORITY;
214    throw (ERRORMORPHEO ("fromString","Unknow string : \""+x+"\""));
215  };
216
217  template<> inline std::string toString<morpheo::behavioural::Tvictim_t>(const morpheo::behavioural::Tvictim_t& x)
218  {
219    switch (x)
220      {
221      case morpheo::behavioural::VICTIM_RANDOM      : return "victim_random"     ; break;
222      case morpheo::behavioural::VICTIM_ROUND_ROBIN : return "victim_round_robin"; break;
223      case morpheo::behavioural::VICTIM_NLU         : return "victim_nlu"        ; break;
224      case morpheo::behavioural::VICTIM_PSEUDO_LRU  : return "victim_pseudo_lru" ; break;
225      case morpheo::behavioural::VICTIM_LRU         : return "victim_lru"        ; break;
226      case morpheo::behavioural::VICTIM_FIFO        : return "victim_fifo"       ; break;
227      default    : return ""      ; break;
228      }
229  };
230
231  template<> inline morpheo::behavioural::Tvictim_t fromString<morpheo::behavioural::Tvictim_t>(const std::string& x)
232  {
233    if ( (x.compare("0")                  == 0) or
234         (x.compare("victim_random")      == 0))
235      return morpheo::behavioural::VICTIM_RANDOM;
236    if ( (x.compare("1")                  == 0) or
237         (x.compare("victim_round_robin") == 0))
238      return morpheo::behavioural::VICTIM_ROUND_ROBIN;
239    if ( (x.compare("2")                  == 0) or
240         (x.compare("victim_nlu")         == 0))
241      return morpheo::behavioural::VICTIM_NLU;
242    if ( (x.compare("3")                  == 0) or
243         (x.compare("victim_pseudo_lru")  == 0))
244      return morpheo::behavioural::VICTIM_PSEUDO_LRU;
245    if ( (x.compare("4")                  == 0) or
246         (x.compare("victim_lru")         == 0))
247      return morpheo::behavioural::VICTIM_LRU;
248    if ( (x.compare("5")                  == 0) or
249         (x.compare("victim_fifo")        == 0))
250      return morpheo::behavioural::VICTIM_FIFO;
251    throw (ERRORMORPHEO ("fromString","Unknow string : \""+x+"\""));
252  };
253
254  template<> inline std::string toString<morpheo::behavioural::Tpredictor_t>(const morpheo::behavioural::Tpredictor_t& x)
255  {
256    switch (x)
257      {
258      case morpheo::behavioural::PREDICTOR_NEVER_TAKE  : return "predictor_never_take" ; break;
259      case morpheo::behavioural::PREDICTOR_ALWAYS_TAKE : return "predictor_always_take"; break;
260      case morpheo::behavioural::PREDICTOR_STATIC      : return "predictor_static"     ; break;
261      case morpheo::behavioural::PREDICTOR_LAST_TAKE   : return "predictor_last_take"  ; break;
262      case morpheo::behavioural::PREDICTOR_COUNTER     : return "predictor_counter"    ; break;
263      case morpheo::behavioural::PREDICTOR_LOCAL       : return "predictor_local"      ; break;
264      case morpheo::behavioural::PREDICTOR_GLOBAL      : return "predictor_global"     ; break;
265      case morpheo::behavioural::PREDICTOR_META        : return "predictor_meta"       ; break;
266      case morpheo::behavioural::PREDICTOR_CUSTOM      : return "predictor_custom"     ; break;
267      default    : return ""      ; break;
268      }
269  };
270
271  template<> inline morpheo::behavioural::Tpredictor_t fromString<morpheo::behavioural::Tpredictor_t>(const std::string& x)
272  {
273    if ( (x.compare("0")                     == 0) or
274         (x.compare("predictor_never_take")  == 0))
275      return morpheo::behavioural::PREDICTOR_NEVER_TAKE;
276    if ( (x.compare("1")                     == 0) or
277         (x.compare("predictor_always_take") == 0))
278      return morpheo::behavioural::PREDICTOR_ALWAYS_TAKE;
279    if ( (x.compare("2")                     == 0) or
280         (x.compare("predictor_static")      == 0))
281      return morpheo::behavioural::PREDICTOR_STATIC;
282    if ( (x.compare("3")                     == 0) or
283         (x.compare("predictor_last_take")   == 0))
284      return morpheo::behavioural::PREDICTOR_LAST_TAKE;
285    if ( (x.compare("4")                     == 0) or
286         (x.compare("predictor_counter")     == 0))
287      return morpheo::behavioural::PREDICTOR_COUNTER;
288    if ( (x.compare("5")                     == 0) or
289         (x.compare("predictor_local")       == 0))
290      return morpheo::behavioural::PREDICTOR_LOCAL;
291    if ( (x.compare("6")                     == 0) or
292         (x.compare("predictor_global")      == 0))
293      return morpheo::behavioural::PREDICTOR_GLOBAL;
294    if ( (x.compare("7")                     == 0) or
295         (x.compare("predictor_meta")        == 0))
296      return morpheo::behavioural::PREDICTOR_META;
297    if ( (x.compare("8")                     == 0) or
298         (x.compare("predictor_custom")      == 0))
299      return morpheo::behavioural::PREDICTOR_CUSTOM;
300    throw (ERRORMORPHEO ("fromString","Unknow string : \""+x+"\""));
301  };
302
303}; // end namespace morpheo             
304#endif
Note: See TracBrowser for help on using the repository browser.