source: trunk/IPs/systemC/processor/Morpheo/Behavioural/include/Constants.h @ 97

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

1) Update Prediction Table : statistics
2) Size instruction address on 30 bits
3) Change Log File
4) Add debug_level in simulation configuration file

  • Property svn:keywords set to Id
File size: 55.2 KB
Line 
1#ifndef morpheo_behavioural_Constants_h
2#define morpheo_behavioural_Constants_h
3
4/*
5  WARNING :
6 
7  I Use reserved exception :
8
9  0x10 - EXCEPTION_MEMORY_MISS_SPECULATION   - Load miss speculation
10  0x11 - EXCEPTION_MEMORY_LOAD_SPECULATIVE   - The load is speculative : write in register file, but don't commit
11  0x12 - EXCEPTION_ALU_SPR_ACCESS_INVALID    - SPR     present in ALU but not compatible privilege
12  0x13 - EXCEPTION_ALU_SPR_ACCESS_MUST_READ  - SPR not present in ALU
13  0x14 - EXCEPTION_ALU_SPR_ACCESS_MUST_WRITE - SPR not present in ALU
14
15  I Use reserved SPR :
16  [0][19] - SPR_CID
17*/
18
19#include "Common/include/ToString.h"
20
21namespace morpheo {
22namespace behavioural {
23
24#  define SET_FLAG(     x,pos)  {(x) |=  (1<<(pos));} while (0)
25#  define UNSET_FLAG(   x,pos)  {(x) &= ~(1<<(pos));} while (0)
26#  define IS_SET_FLAG(  x,pos) (((x) &   (1<<(pos))) != 0)
27#  define IS_UNSET_FLAG(x,pos) (((x) &   (1<<(pos))) == 0)
28#  define CHANGE_FLAG(  x,pos,f) \
29   {                        \
30     if (f)                 \
31       {SET_FLAG(x,pos);}   \
32     else                   \
33       {UNSET_FLAG(x,pos);} \
34   } while (0)
35
36  //=========================================================[ Type ]=====
37typedef enum
38  {
39    TYPE_ALU                               = 0x0,       // 00000 - unit multiple
40    TYPE_SHIFT                             = 0x1,       // 00000 - unit multiple
41    TYPE_MOVE                              = 0x2,       // 00000 - unit multiple
42    TYPE_TEST                              = 0x3,       // 00000 - unit multiple
43    TYPE_MUL                               = 0x4,       // 00000 - unit multiple
44    TYPE_DIV                               = 0x5,       // 00000 - unit multiple, type optionnal
45    TYPE_EXTEND                            = 0x6,       // 00000 - unit multiple, type optionnal
46    TYPE_FIND                              = 0x7,       // 00000 - unit multiple, type optionnal
47    TYPE_SPECIAL                           = 0x8,       // 00000 - unit uniq
48    TYPE_CUSTOM                            = 0x9,       // 00000 - unit uniq    , type optionnal
49    TYPE_BRANCH                            = 0xa,       // 00000 - unit multiple
50    TYPE_MEMORY                            = 0xb        // 00000 - unit uniq
51  } type_t;
52
53//#define NB_TYPE                                  11
54#  define SIZE_TYPE                                5
55#  define MAX_TYPE                                 (1<<SIZE_TYPE)
56
57#  define is_type_valid(x) \
58  (( x == TYPE_ALU    ) or \
59   ( x == TYPE_SHIFT  ) or \
60   ( x == TYPE_MOVE   ) or \
61   ( x == TYPE_TEST   ) or \
62   ( x == TYPE_MUL    ) or \
63   ( x == TYPE_DIV    ) or \
64   ( x == TYPE_EXTEND ) or \
65   ( x == TYPE_FIND   ) or \
66   ( x == TYPE_SPECIAL) or \
67   ( x == TYPE_CUSTOM ) or \
68   ( x == TYPE_BRANCH ) or \
69   ( x == TYPE_MEMORY ))
70
71  //====================================================[ Operation ]=====
72
73  //-------------------------------------------------------[ Memory ]-----
74#  define OPERATION_MEMORY_LOAD_8_Z                0x08       // 0_1000
75#  define OPERATION_MEMORY_LOAD_16_Z               0x09       // 0_1001
76#  define OPERATION_MEMORY_LOAD_32_Z               0x0a       // 0_1010
77#  define OPERATION_MEMORY_LOAD_64_Z               0x0b       // 0_1011
78#  define OPERATION_MEMORY_LOAD_8_S                0x18       // 1_1000
79#  define OPERATION_MEMORY_LOAD_16_S               0x19       // 1_1001
80#  define OPERATION_MEMORY_LOAD_32_S               0x1a       // 1_1010
81#  define OPERATION_MEMORY_LOAD_64_S               0x1b       // 1_1011
82
83#  define OPERATION_MEMORY_STORE_8                 0x0c       // 0_1100
84#  define OPERATION_MEMORY_STORE_16                0x0d       // 0_1101
85#  define OPERATION_MEMORY_STORE_32                0x0e       // 0_1110
86#  define OPERATION_MEMORY_STORE_64                0x0f       // 0_1111
87#  define OPERATION_MEMORY_STORE_HEAD_OK           0x1c       // 1_1100
88#  define OPERATION_MEMORY_STORE_HEAD_KO           0x1d       // 1_1101
89
90#  define OPERATION_MEMORY_LOCK                    0x01       // 0_0001
91#  define OPERATION_MEMORY_INVALIDATE              0x02       // 0_0010
92#  define OPERATION_MEMORY_PREFETCH                0x03       // 0_0011
93#  define OPERATION_MEMORY_FLUSH                   0x06       // 0_0110
94#  define OPERATION_MEMORY_SYNCHRONIZATION         0x07       // 0_0111
95 
96#define is_operation_memory_load(x)             \
97  ((x == OPERATION_MEMORY_LOAD_8_Z ) or         \
98   (x == OPERATION_MEMORY_LOAD_16_Z) or         \
99   (x == OPERATION_MEMORY_LOAD_32_Z) or         \
100   (x == OPERATION_MEMORY_LOAD_64_Z) or         \
101   (x == OPERATION_MEMORY_LOAD_8_S ) or         \
102   (x == OPERATION_MEMORY_LOAD_16_S) or         \
103   (x == OPERATION_MEMORY_LOAD_32_S) or         \
104   (x == OPERATION_MEMORY_LOAD_64_S) )
105 
106#define is_operation_memory_store(x)            \
107  ((x == OPERATION_MEMORY_STORE_8      ) or     \
108   (x == OPERATION_MEMORY_STORE_16     ) or     \
109   (x == OPERATION_MEMORY_STORE_32     ) or     \
110   (x == OPERATION_MEMORY_STORE_64     ) or     \
111   (x == OPERATION_MEMORY_STORE_HEAD_OK) or     \
112   (x == OPERATION_MEMORY_STORE_HEAD_KO))
113
114#define is_operation_memory_store_head(x)       \
115  ((x == OPERATION_MEMORY_STORE_HEAD_OK) or     \
116   (x == OPERATION_MEMORY_STORE_HEAD_KO))
117 
118#define is_operation_memory_load_signed(x)      \
119  ((x == OPERATION_MEMORY_LOAD_8_S ) or         \
120   (x == OPERATION_MEMORY_LOAD_16_S) or         \
121   (x == OPERATION_MEMORY_LOAD_32_S) or         \
122   (x == OPERATION_MEMORY_LOAD_64_S) )
123
124#  define MEMORY_ACCESS_8                          0x0
125#  define MEMORY_ACCESS_16                         0x1
126#  define MEMORY_ACCESS_32                         0x2
127#  define MEMORY_ACCESS_64                         0x3
128
129#  define MEMORY_SIZE_8                            8
130#  define MEMORY_SIZE_16                           16
131#  define MEMORY_SIZE_32                           32
132#  define MEMORY_SIZE_64                           64
133
134#  define MASK_MEMORY_ACCESS_8                     0x0
135#  define MASK_MEMORY_ACCESS_16                    0x1
136#  define MASK_MEMORY_ACCESS_32                    0x3
137#  define MASK_MEMORY_ACCESS_64                    0x7
138
139#define memory_size(x)                                                  \
140  (((x==OPERATION_MEMORY_LOAD_16_Z)or                                   \
141    (x==OPERATION_MEMORY_LOAD_16_S)or                                   \
142    (x==OPERATION_MEMORY_STORE_16 ))?MEMORY_SIZE_16:                    \
143   (((x==OPERATION_MEMORY_LOAD_32_Z)or                                  \
144     (x==OPERATION_MEMORY_LOAD_32_S)or                                  \
145     (x==OPERATION_MEMORY_STORE_32 ))?MEMORY_SIZE_32:                   \
146    (((x==OPERATION_MEMORY_LOAD_64_Z)or                                 \
147      (x==OPERATION_MEMORY_LOAD_64_S)or                                 \
148      (x==OPERATION_MEMORY_STORE_64 ))?MEMORY_SIZE_64:MEMORY_SIZE_8)))
149 
150#define memory_access(x)                                                \
151  (((x==OPERATION_MEMORY_LOAD_16_Z)or                                   \
152    (x==OPERATION_MEMORY_LOAD_16_S)or                                   \
153    (x==OPERATION_MEMORY_STORE_16 ))?MEMORY_ACCESS_16:                  \
154   (((x==OPERATION_MEMORY_LOAD_32_Z)or                                  \
155     (x==OPERATION_MEMORY_LOAD_32_S)or                                  \
156     (x==OPERATION_MEMORY_STORE_32 ))?MEMORY_ACCESS_32:                 \
157    (((x==OPERATION_MEMORY_LOAD_64_Z)or                                 \
158      (x==OPERATION_MEMORY_LOAD_64_S)or                                 \
159      (x==OPERATION_MEMORY_STORE_64 ))?MEMORY_ACCESS_64:MEMORY_ACCESS_8)))
160 
161#define mask_memory_access(x)                                           \
162  (((x==OPERATION_MEMORY_LOAD_16_Z)or                                   \
163    (x==OPERATION_MEMORY_LOAD_16_S)or                                   \
164    (x==OPERATION_MEMORY_STORE_16 ))?MASK_MEMORY_ACCESS_16:             \
165   (((x==OPERATION_MEMORY_LOAD_32_Z)or                                  \
166     (x==OPERATION_MEMORY_LOAD_32_S)or                                  \
167     (x==OPERATION_MEMORY_STORE_32 ))?MASK_MEMORY_ACCESS_32:            \
168    (((x==OPERATION_MEMORY_LOAD_64_Z)or                                 \
169      (x==OPERATION_MEMORY_LOAD_64_S)or                                 \
170      (x==OPERATION_MEMORY_STORE_64 ))?MASK_MEMORY_ACCESS_64:MASK_MEMORY_ACCESS_8)))
171
172  //---------------------------------------------[ Functionnal Unit ]-----
173#  define OPERATION_ALU_L_ADD                      0x1        // 000_0000 l.add   , l.addi
174#  define OPERATION_ALU_L_ADDC                     0x2        // 000_0000 l.addc  , l.addic
175#  define OPERATION_ALU_L_SUB                      0x4        // 000_0000 l.sub
176#  define OPERATION_ALU_L_AND                      0x8        // 000_0000 l.and   , l.andi
177#  define OPERATION_ALU_L_OR                       0x10       // 000_0000 l.or    , l.ori
178#  define OPERATION_ALU_L_XOR                      0x20       // 000_0000 l.xor   , l.xori
179
180#  define OPERATION_SHIFT_L_SLL                    0x1        // 000_0000 l.sll   , l.slli
181#  define OPERATION_SHIFT_L_SRA                    0x2        // 000_0000 l.sra   , l.srai
182#  define OPERATION_SHIFT_L_SRL                    0x4        // 000_0000 l.srl   , l.srli
183#  define OPERATION_SHIFT_L_ROR                    0x8        // 000_0000 l.ror   , l.rori
184
185#  define OPERATION_MOVE_L_MOVHI                   0x1        // 000_0000 l.movhi
186#  define OPERATION_MOVE_L_CMOV                    0x2        // 000_0000 l.cmov
187
188#  define OPERATION_TEST_L_SFGES                   0x41       // 000_0000 l.sfges , l.sfges
189#  define OPERATION_TEST_L_SFGEU                   0x1        // 000_0000 l.sfgeu , l.sfgeu
190#  define OPERATION_TEST_L_SFGTS                   0x42       // 000_0000 L.sfgts , l.sfgts
191#  define OPERATION_TEST_L_SFGTU                   0x2        // 000_0000 l.sfgtu , l.sfgtu
192#  define OPERATION_TEST_L_SFLES                   0x44       // 000_0000 l.sfles , l.sfles
193#  define OPERATION_TEST_L_SFLEU                   0x4        // 000_0000 l.sfleu , l.sfleu
194#  define OPERATION_TEST_L_SFLTS                   0x48       // 000_0000 l.sflts , l.sflts
195#  define OPERATION_TEST_L_SFLTU                   0x8        // 000_0000 l.sfltu , l.sfltu
196#  define OPERATION_TEST_L_SFEQ                    0x10       // 000_0000 l.sfeq  , l.sfeqi
197#  define OPERATION_TEST_L_SFNE                    0x20       // 000_0000 l.sfne  , l.sfnei
198
199#  define OPERATION_MUL_L_MUL                      0x1        // 000_0000 l.mul   , l.muli
200#  define OPERATION_MUL_L_MULU                     0x2        // 000_0000 l.mulu
201
202#  define OPERATION_DIV_L_DIV                      0x1        // 000_0000 l.div
203#  define OPERATION_DIV_L_DIVU                     0x2        // 000_0000 l.divu
204
205#  define OPERATION_EXTEND_L_EXTEND_Z              0x1        // 000_0000 l.extbz , l.exthz, l.extwz
206#  define OPERATION_EXTEND_L_EXTEND_S              0x2        // 000_0000 l.extbs , l.exths, l.extws
207
208#  define OPERATION_FIND_L_FF1                     0x1        // 000_0000 l.ff1
209#  define OPERATION_FIND_L_FL1                     0x2        // 000_0000 l.fl1
210
211#  define OPERATION_SPECIAL_L_NOP                  0xff       // 000_0000 l.nop   
212#  define OPERATION_SPECIAL_L_MFSPR                0x1        // 000_0001 l.mfspr
213#  define OPERATION_SPECIAL_L_MTSPR                0x2        // 000_0010 l.mtspr
214#  define OPERATION_SPECIAL_L_RFE                  0x4        // 000_0100 l.rfe 
215#  define OPERATION_SPECIAL_L_MAC                  0x11       // 001_0001 l.mac   , l.maci
216#  define OPERATION_SPECIAL_L_MACRC                0x12       // 001_0010 l.macrc
217#  define OPERATION_SPECIAL_L_MSB                  0x14       // 001_0100 l.msb
218#  define OPERATION_SPECIAL_L_MSYNC                0x21       // 010_0001 l.msync
219#  define OPERATION_SPECIAL_L_PSYNC                0x22       // 010_0010 l.psync
220#  define OPERATION_SPECIAL_L_CSYNC                0x24       // 010_0100 l.csync
221#  define OPERATION_SPECIAL_L_SYS                  0x41       // 100_0001 l.sys 
222#  define OPERATION_SPECIAL_L_TRAP                 0x42       // 100_0010 l.trap
223
224
225#  define OPERATION_BRANCH_NONE                    0x1        // 000_0000 l.j
226#  define OPERATION_BRANCH_L_TEST_NF               0x2        // 000_0000 l.bnf
227#  define OPERATION_BRANCH_L_TEST_F                0x4        // 000_0000 l.bf
228#  define OPERATION_BRANCH_L_JALR                  0x8        // 000_0000 l.jal   , l.jalr , l.jr
229
230  //-------------------------------------------------------[ Custom ]-----
231
232#  define OPERATION_CUSTOM_L_1                     0x40       // 100_0000
233#  define OPERATION_CUSTOM_L_2                     0x41       // 100_0001
234#  define OPERATION_CUSTOM_L_3                     0x42       // 100_0010
235#  define OPERATION_CUSTOM_L_4                     0x43       // 100_0011
236#  define OPERATION_CUSTOM_L_5                     0x44       // 100_0100
237#  define OPERATION_CUSTOM_L_6                     0x45       // 100_0101
238#  define OPERATION_CUSTOM_L_7                     0x46       // 100_0110
239#  define OPERATION_CUSTOM_L_8                     0x47       // 100_0111
240#  define OPERATION_CUSTOM_LF_1_D                  0x48       // 100_1000
241#  define OPERATION_CUSTOM_LF_1_S                  0x49       // 100_1001
242#  define OPERATION_CUSTOM_LV_1                    0x4c       // 100_1100
243#  define OPERATION_CUSTOM_LV_2                    0x4d       // 100_1101
244#  define OPERATION_CUSTOM_LV_3                    0x4e       // 100_1110
245#  define OPERATION_CUSTOM_LV_4                    0x4f       // 100_1111
246
247#  define SIZE_OPERATION                           7
248#  define MAX_OPERATION                            (1<<SIZE_OPERATION)
249
250  //====================================================[ Exception ]=====
251  // Exception - OpenRISC
252
253#  define SIZE_EXCEPTION                           5
254#  define SIZE_EXCEPTION_USE                       4
255#  define SIZE_EXCEPTION_MEMORY                    5
256#  define SIZE_EXCEPTION_CUSTOM                    5
257#  define SIZE_EXCEPTION_ALU                       5
258#  define SIZE_EXCEPTION_DECOD                     5
259#  define SIZE_EXCEPTION_IFETCH                    5
260
261#  define EXCEPTION_NONE                           0x00       // none exception
262#  define EXCEPTION_RESET                          0x01       // software or hardware reset
263#  define EXCEPTION_BUS_ERROR                      0x02       // Access at a invalid physical adress
264#  define EXCEPTION_DATA_PAGE                      0x03       // No matching or page violation protection in pages tables
265#  define EXCEPTION_INSTRUCTION_PAGE               0x04       // No matching or page violation protection in pages tables
266#  define EXCEPTION_TICK_TIMER                     0x05       // Tick timer interruption
267#  define EXCEPTION_ALIGNMENT                      0x06       // Load/Store access is not aligned
268#  define EXCEPTION_ILLEGAL_INSTRUCTION            0x07       // Instruction is illegal (no implemented)
269#  define EXCEPTION_INTERRUPT                      0x08       // External interruption
270#  define EXCEPTION_DATA_TLB                       0x09       // DTLB miss
271#  define EXCEPTION_INSTRUCTION_TLB                0x0a       // ITLB miss
272#  define EXCEPTION_RANGE                          0x0b       // Overflow or access at a unimplemented register or context
273#  define EXCEPTION_SYSCALL                        0x0c       // System Call
274#  define EXCEPTION_FLOATING_POINT                 0x0d       // Caused by a floating instruction
275#  define EXCEPTION_TRAP                           0x0e       // L.trap or debug unit
276#  define EXCEPTION_RESERVED_0                     0x0f       // Reserved for a futur usage
277#  define EXCEPTION_RESERVED_1                     0x10       // Reserved for a futur usage
278#  define EXCEPTION_RESERVED_2                     0x11       // Reserved for a futur usage
279#  define EXCEPTION_RESERVED_3                     0x12       // Reserved for a futur usage
280#  define EXCEPTION_RESERVED_4                     0x13       // Reserved for a futur usage
281#  define EXCEPTION_RESERVED_5                     0x14       // Reserved for a futur usage
282#  define EXCEPTION_RESERVED_6                     0x15       // Reserved for implemented specific exceptions
283#  define EXCEPTION_RESERVED_7                     0x16       // Reserved for implemented specific exceptions
284#  define EXCEPTION_RESERVED_8                     0x17       // Reserved for implemented specific exceptions
285#  define EXCEPTION_RESERVED_9                     0x18       // Reserved for implemented specific exceptions
286#  define EXCEPTION_CUSTOM_0                       0x19       // Reserved for custom exceptions
287#  define EXCEPTION_CUSTOM_1                       0x1a       // Reserved for custom exceptions
288#  define EXCEPTION_CUSTOM_2                       0x1b       // Reserved for custom exceptions
289#  define EXCEPTION_CUSTOM_3                       0x1c       // Reserved for custom exceptions
290#  define EXCEPTION_CUSTOM_4                       0x1d       // Reserved for custom exceptions
291#  define EXCEPTION_CUSTOM_5                       0x1e       // Reserved for custom exceptions
292#  define EXCEPTION_CUSTOM_6                       0x1f       // Reserved for custom exceptions
293
294  //SR[14].EPH : Exception Prefix High
295  // EPH = 0 Exceptions vectors are located in memory area starting at 0x0
296  // EPH = 1 Exception vectors are located in memory area starting at 0xF0000000
297
298#define exception_to_address(eph,x) (((eph==0)?0x0:0xF0000000)+(x<<8))
299
300  // Exception Execution
301#  define EXCEPTION_IFETCH_NONE                    0x00       // Fetch Unit generate none exception
302#  define EXCEPTION_IFETCH_INSTRUCTION_TLB         0x0a       // ITLB miss
303#  define EXCEPTION_IFETCH_INSTRUCTION_PAGE        0x04       // No matching or page violation protection in pages tables
304#  define EXCEPTION_IFETCH_BUS_ERROR               0x02       // Access at a invalid physical address
305
306#  define EXCEPTION_DECOD_NONE                     0x00       // none exception
307#  define EXCEPTION_DECOD_ILLEGAL_INSTRUCTION      0x01       // Instruction is illegal (no implemented)
308#  define EXCEPTION_DECOD_SYSCALL                  0x02       // System Call
309//#define EXCEPTION_DECOD_TRAP                     0x0e       // L.trap or debug unit (note : must read SR !)
310#  define EXCEPTION_DECOD_INSTRUCTION_TLB          0x0a       // ITLB miss
311#  define EXCEPTION_DECOD_INSTRUCTION_PAGE         0x04       // No matching or page violation protection in pages tables
312#  define EXCEPTION_DECOD_BUS_ERROR                0x02       // Access at a invalid physical address
313
314#  define EXCEPTION_ALU_NONE                       0x00       // Functionnal unit generate none exception
315#  define EXCEPTION_ALU_RANGE                      0x0b       //
316#  define EXCEPTION_ALU_SPR_ACCESS_INVALID         0x12       // SPR     present in ALU but not compatible privilege
317#  define EXCEPTION_ALU_SPR_ACCESS_MUST_READ       0x13       // SPR not present in ALU
318#  define EXCEPTION_ALU_SPR_ACCESS_MUST_WRITE      0x14       // SPR not present in ALU
319
320#  define EXCEPTION_MEMORY_NONE                    0x00       // Load/Store generate none exception
321#  define EXCEPTION_MEMORY_ALIGNMENT               0x06       // Load/Store access is not aligned
322#  define EXCEPTION_MEMORY_DATA_TLB                0x09       // DTLB miss
323#  define EXCEPTION_MEMORY_DATA_PAGE               0x03       // No matching or page violation protection in pages tables
324#  define EXCEPTION_MEMORY_BUS_ERROR               0x02       // Access at a invalid physical address
325#  define EXCEPTION_MEMORY_MISS_SPECULATION        0x10       // Load miss speculation
326#  define EXCEPTION_MEMORY_LOAD_SPECULATIVE        0x11       // The load is speculative : write in register file, but don't commit
327
328#  define EXCEPTION_CUSTOM_NONE                    0x00       // Custom unit generate none exception
329#  define EXCEPTION_CUSTOM_CUST_0                  0x19       // Reserved for custom exceptions
330#  define EXCEPTION_CUSTOM_CUST_1                  0x1a       // Reserved for custom exceptions
331#  define EXCEPTION_CUSTOM_CUST_2                  0x1b       // Reserved for custom exceptions
332#  define EXCEPTION_CUSTOM_CUST_3                  0x1c       // Reserved for custom exceptions
333#  define EXCEPTION_CUSTOM_CUST_4                  0x1d       // Reserved for custom exceptions
334#  define EXCEPTION_CUSTOM_CUST_5                  0x1e       // Reserved for custom exceptions
335#  define EXCEPTION_CUSTOM_CUST_6                  0x1f       // Reserved for custom exceptions
336
337#  define EXCEPTION_USE_NONE                       0x00       //
338#  define EXCEPTION_USE_ILLEGAL_INSTRUCTION        0x01       // illegal_instruction
339#  define EXCEPTION_USE_RANGE                      0x02       // range
340#  define EXCEPTION_USE_MEMORY_WITH_ALIGNMENT      0x03       // TLB miss, page fault, bus error, alignment
341#  define EXCEPTION_USE_MEMORY_WITHOUT_ALIGNMENT   0x04       // TLB miss, page fault, bus error
342#  define EXCEPTION_USE_SYSCALL                    0x05       // syscall
343#  define EXCEPTION_USE_TRAP                       0x06       // trap
344#  define EXCEPTION_USE_CUSTOM_0                   0x07       //
345#  define EXCEPTION_USE_CUSTOM_1                   0x08       //
346#  define EXCEPTION_USE_CUSTOM_2                   0x09       //
347#  define EXCEPTION_USE_CUSTOM_3                   0x0a       //
348#  define EXCEPTION_USE_CUSTOM_4                   0x0b       //
349#  define EXCEPTION_USE_CUSTOM_5                   0x0c       //
350#  define EXCEPTION_USE_CUSTOM_6                   0x0d       //
351
352#  define exception_ifetch_to_exception_decod(x) x
353#  define exception_decod_to_exception(x)        x
354#  define exception_alu_to_exception(x)          x
355#  define exception_memory_to_exception(x)       x
356#  define exception_custom_to_exception(x)       x
357
358  //=======================================================[ icache ]=====
359
360  //--------------------------------------------------[ icache_type ]-----
361
362#  define SIZE_ICACHE_TYPE                         2
363
364#  define ICACHE_TYPE_LOAD                         0x0        // 0000
365#  define ICACHE_TYPE_LOCK                         0x1        // 0001
366#  define ICACHE_TYPE_INVALIDATE                   0x2        // 0010
367#  define ICACHE_TYPE_PREFETCH                     0x3        // 0011
368
369// just take the 2 less significative bits.
370#define operation_to_icache_type(x) (x&0x3)
371
372  //-------------------------------------------------[ icache_error ]-----
373
374#  define SIZE_ICACHE_ERROR                        1
375
376#  define ICACHE_ERROR_NONE                        0x0
377#  define ICACHE_ERROR_BUS_ERROR                   0x1
378
379  //=======================================================[ dcache ]=====
380
381  //--------------------------------------------------[ dcache_type ]-----
382
383#  define SIZE_DCACHE_TYPE                         4
384
385//#define DCACHE_TYPE_                             0x0        // 0000
386#  define DCACHE_TYPE_LOCK                         0x1        // 0001
387#  define DCACHE_TYPE_INVALIDATE                   0x2        // 0010
388#  define DCACHE_TYPE_PREFETCH                     0x3        // 0011
389//#define DCACHE_TYPE_                             0x4        // 0100
390//#define DCACHE_TYPE_                             0x5        // 0101
391#  define DCACHE_TYPE_FLUSH                        0x6        // 0110
392#  define DCACHE_TYPE_SYNCHRONIZATION              0x7        // 0111
393#  define DCACHE_TYPE_LOAD_8                       0x8        // 1000
394#  define DCACHE_TYPE_LOAD_16                      0x9        // 1001
395#  define DCACHE_TYPE_LOAD_32                      0xa        // 1010
396#  define DCACHE_TYPE_LOAD_64                      0xb        // 1011
397#  define DCACHE_TYPE_STORE_8                      0xc        // 1100
398#  define DCACHE_TYPE_STORE_16                     0xd        // 1101
399#  define DCACHE_TYPE_STORE_32                     0xe        // 1110
400#  define DCACHE_TYPE_STORE_64                     0xf        // 1111
401
402// just take the 4 less significative bits.
403#define operation_to_dcache_type(x) (x&0xf)
404
405  //-------------------------------------------------[ dcache_error ]-----
406
407#  define SIZE_DCACHE_ERROR                        1
408
409#  define DCACHE_ERROR_NONE                        0x0
410#  define DCACHE_ERROR_BUS_ERROR                   0x1
411
412  //=================================================[ special_data ]=====
413
414#  define SIZE_SPECIAL_DATA                        2
415
416// Position of flag in "rename register SR" (NOT IN "SR")
417#  define FLAG_POSITION_F                          0x0         // Conditionnal branch flag
418#  define FLAG_POSITION_CY                         0x1         // Carry was produced by last arithmetic operation
419#  define FLAG_POSITION_OV                         0x0         // Overflow occured during last arithmetic operation
420
421#  define FLAG_F                                   (1<<FLAG_POSITION_F ) // Conditionnal branch flag
422#  define FLAG_CY                                  (1<<FLAG_POSITION_CY) // Carry was produced by last arithmetic operation
423#  define FLAG_OV                                  (1<<FLAG_POSITION_OV) // Overflow occured during last arithmetic operation
424
425  //==========================================================[ spr ]=====
426
427  enum
428    {
429      GROUP_SYSTEM_AND_CONTROL,  // 0
430      GROUP_DMMU,                // 1
431      GROUP_IMMU,                // 2
432      GROUP_DCACHE,              // 3
433      GROUP_ICACHE,              // 4
434      GROUP_MAC,                 // 5
435      GROUP_DEBUG,               // 6
436      GROUP_PERFORMANCE_COUNTER, // 7
437      GROUP_POWER_MANAGEMENT,    // 8
438      GROUP_PIC,                 // 9
439      GROUP_TICK_TIMER,          // 10
440      GROUP_FLOATING_POINT,      // 11
441      GROUP_RESERVED_1,          // 12     
442      GROUP_RESERVED_2,          // 13     
443      GROUP_RESERVED_3,          // 14     
444      GROUP_RESERVED_4,          // 15     
445      GROUP_RESERVED_5,          // 16     
446      GROUP_RESERVED_6,          // 17     
447      GROUP_RESERVED_7,          // 18     
448      GROUP_RESERVED_8,          // 19     
449      GROUP_RESERVED_9,          // 20     
450      GROUP_RESERVED_10,         // 21     
451      GROUP_RESERVED_11,         // 22     
452      GROUP_RESERVED_12,         // 23
453      GROUP_CUSTOM_1,            // 24     
454      GROUP_CUSTOM_2,            // 25     
455      GROUP_CUSTOM_3,            // 26     
456      GROUP_CUSTOM_4,            // 27     
457      GROUP_CUSTOM_5,            // 28     
458      GROUP_CUSTOM_6,            // 29     
459      GROUP_CUSTOM_7,            // 30     
460      GROUP_CUSTOM_8,            // 31     
461      NB_GROUP
462    };
463
464#  define NB_REG_GROUP_SYSTEM_AND_CONTROL          1536
465#  define NB_REG_GROUP_DMMU                        1536
466#  define NB_REG_GROUP_IMMU                        1536
467#  define NB_REG_GROUP_DCACHE                      6
468#  define NB_REG_GROUP_ICACHE                      4
469#  define NB_REG_GROUP_MAC                         3
470#  define NB_REG_GROUP_DEBUG                       22
471#  define NB_REG_GROUP_PERFORMANCE_COUNTER         16
472#  define NB_REG_GROUP_POWER_MANAGEMENT            1
473#  define NB_REG_GROUP_PIC                         3
474#  define NB_REG_GROUP_TICK_TIMER                  2
475#  define NB_REG_GROUP_FLOATING_POINT              0
476#  define NB_REG_GROUP_RESERVED_1                  0
477#  define NB_REG_GROUP_RESERVED_2                  0
478#  define NB_REG_GROUP_RESERVED_3                  0
479#  define NB_REG_GROUP_RESERVED_4                  0
480#  define NB_REG_GROUP_RESERVED_5                  0
481#  define NB_REG_GROUP_RESERVED_6                  0
482#  define NB_REG_GROUP_RESERVED_7                  0
483#  define NB_REG_GROUP_RESERVED_8                  0
484#  define NB_REG_GROUP_RESERVED_9                  0
485#  define NB_REG_GROUP_RESERVED_10                 0
486#  define NB_REG_GROUP_RESERVED_11                 0
487#  define NB_REG_GROUP_RESERVED_12                 0
488#  define NB_REG_GROUP_CUSTOM_1                    0
489#  define NB_REG_GROUP_CUSTOM_2                    0
490#  define NB_REG_GROUP_CUSTOM_3                    0
491#  define NB_REG_GROUP_CUSTOM_4                    0
492#  define NB_REG_GROUP_CUSTOM_5                    0
493#  define NB_REG_GROUP_CUSTOM_6                    0
494#  define NB_REG_GROUP_CUSTOM_7                    0
495#  define NB_REG_GROUP_CUSTOM_8                    0
496
497  static const uint32_t NB_REG_GROUP [] =
498    {NB_REG_GROUP_SYSTEM_AND_CONTROL  ,
499     NB_REG_GROUP_DMMU                ,
500     NB_REG_GROUP_IMMU                ,
501     NB_REG_GROUP_DCACHE              ,
502     NB_REG_GROUP_ICACHE              ,
503     NB_REG_GROUP_MAC                 ,
504     NB_REG_GROUP_DEBUG               ,
505     NB_REG_GROUP_PERFORMANCE_COUNTER ,
506     NB_REG_GROUP_POWER_MANAGEMENT    ,
507     NB_REG_GROUP_PIC                 ,
508     NB_REG_GROUP_TICK_TIMER          ,
509     NB_REG_GROUP_FLOATING_POINT      ,
510     NB_REG_GROUP_RESERVED_1          ,
511     NB_REG_GROUP_RESERVED_2          ,
512     NB_REG_GROUP_RESERVED_3          ,
513     NB_REG_GROUP_RESERVED_4          ,
514     NB_REG_GROUP_RESERVED_5          ,
515     NB_REG_GROUP_RESERVED_6          ,
516     NB_REG_GROUP_RESERVED_7          ,
517     NB_REG_GROUP_RESERVED_8          ,
518     NB_REG_GROUP_RESERVED_9          ,
519     NB_REG_GROUP_RESERVED_10         ,
520     NB_REG_GROUP_RESERVED_11         ,
521     NB_REG_GROUP_RESERVED_12         ,
522     NB_REG_GROUP_CUSTOM_1            ,
523     NB_REG_GROUP_CUSTOM_2            ,
524     NB_REG_GROUP_CUSTOM_3            ,
525     NB_REG_GROUP_CUSTOM_4            ,
526     NB_REG_GROUP_CUSTOM_5            ,
527     NB_REG_GROUP_CUSTOM_6            ,
528     NB_REG_GROUP_CUSTOM_7            ,
529     NB_REG_GROUP_CUSTOM_8            };
530 
531  // GROUP_SYSTEM_AND_CONTROL
532#  define SPR_VR                                   0          // Version register
533#  define SPR_UPR                                  1          // Unit Present register
534#  define SPR_CPUCFGR                              2          // CPU Configuration register
535#  define SPR_DMMUCFGR                             3          // Data MMU Configuration register
536#  define SPR_IMMUCFGR                             4          // Instruction MMU Configuration register
537#  define SPR_DCCFGR                               5          // Data Cache Configuration register
538#  define SPR_ICCFGR                               6          // Instruction Cache Configuration register
539#  define SPR_DCFGR                                7          // Debug Configuration register
540#  define SPR_PCCFGR                               8          // Performance Counters Configuration register
541#  define SPR_NPC                                  16         // PC mapped to SPR space (next PC)
542#  define SPR_SR                                   17         // Supervision register
543#  define SPR_PPC                                  18         // PC mapped to SPR space (previous PC)
544#  define SPR_CID                                  19         // Context Id
545#  define SPR_FPCSR                                20         // FP Control Status register
546#  define SPR_EPCR                                 32         // Exception PC register
547#  define SPR_EEAR                                 48         // Exception EA register
548#  define SPR_ESR                                  64         // Exception SR register
549#  define SPR_GPR                                  1024       // GPRs mappted to SPR space
550 
551  // GROUP_DCACHE
552#  define SPR_DCCR                                 0          // DC Control register
553#  define SPR_DCBPR                                1          // DC Block Prefetch register
554#  define SPR_DCBFR                                2          // DC Block Flush register
555#  define SPR_DCBIR                                3          // DC Block Invalidate register
556#  define SPR_DCBWR                                4          // DC Block Write-back register
557#  define SPR_DCBLR                                5          // DC Block Lock register
558
559  // GROUP_ICACHE
560#  define SPR_ICCR                                 0          // IC Control register
561#  define SPR_ICBPR                                1          // IC Block Prefetch register
562#  define SPR_ICBIR                                2          // IC Block Invalidate register
563#  define SPR_ICBLR                                3          // IC Block Lock register
564                                                   
565  // GROUP_MAC                                     
566#  define SPR_MACLO                                1          // MAC Low
567#  define SPR_MACHI                                2          // MAC High
568
569
570
571  // SR RENAME
572#  define NB_SPR_LOGIC                             2
573#  define LOG2_NB_SPR_LOGIC                        1
574  // SPR_LOGIC[0] = F
575  // SPR_LOGIC[1] = Carry, Overflow
576#  define SPR_LOGIC_SR_F                           0x0        // Status register bit F                   (size = 1)
577#  define SPR_LOGIC_SR_CY_OV                       0x1        // Status register bit overflow and carry  (size = 2)
578
579  //----------------------------------------------[ spr_mode_access ]-----
580
581#  define SPR_ACCESS_MODE_NONE                     0x0        // 000
582#  define SPR_ACCESS_MODE_READ_ONLY                0x1        // 001
583#  define SPR_ACCESS_MODE_WRITE_ONLY               0x2        // 010
584#  define SPR_ACCESS_MODE_READ_WRITE               0x3        // 011
585#  define SPR_ACCESS_MODE_READ_ONLY_COND           0x5        // 101 special read
586
587  //--------------------------------------------------------[ event ]-----
588#  define SIZE_EVENT_STATE                         2
589
590#  define EVENT_STATE_NO_EVENT                     0          // no event : current case
591#  define EVENT_STATE_EVENT                        1          // Have a event : make necessary to manage the event
592#  define EVENT_STATE_WAITEND                      2          // Wait end of manage event (restaure a good context)
593#  define EVENT_STATE_END                          3          // CPU can continue
594
595#  define SIZE_EVENT_TYPE                          3
596
597#  define EVENT_TYPE_NONE                          0          // no event
598#  define EVENT_TYPE_MISS_SPECULATION              1          // miss of speculation (load or branch miss speculation)
599#  define EVENT_TYPE_EXCEPTION                     2          // exception or interruption occure
600#  define EVENT_TYPE_BRANCH_NO_ACCURATE            3          // branch is no accurate (old speculation is a miss)
601#  define EVENT_TYPE_SPR_ACCESS                    4          // decod a mtspr or mfspr instruction
602#  define EVENT_TYPE_MSYNC                         5          // decod a memory   synchronization
603#  define EVENT_TYPE_PSYNC                         6          // decod a pipeline synchronization
604#  define EVENT_TYPE_CSYNC                         7          // decod a context  synchronization
605
606  //-------------------------------------------------[ branch_state ]-----
607#  define SIZE_BRANCH_STATE                        2
608
609#  define BRANCH_STATE_NONE                        0x0        // 0 0
610#  define BRANCH_STATE_NSPEC_TAKE                  0x1        // 0 1  -> incondionnal
611#  define BRANCH_STATE_SPEC_NTAKE                  0x2        // 1 0
612#  define BRANCH_STATE_SPEC_TAKE                   0x3        // 1 1
613
614  //---------------------------------------------[ branch_condition ]-----
615
616#  define SIZE_BRANCH_CONDITION                    4
617#  define MAX_BRANCH_CONDITION                     (1<<SIZE_BRANCH_CONDITION)
618  typedef enum
619    {
620      BRANCH_CONDITION_NONE_WITHOUT_WRITE_STACK          = 0x0,        // None condition (jump)
621      BRANCH_CONDITION_NONE_WITH_WRITE_STACK             = 0x8,        // None condition (jump)
622      BRANCH_CONDITION_FLAG_UNSET                        = 0x2,        // Branch if Flag is clear
623      BRANCH_CONDITION_FLAG_SET                          = 0x3,        // Branch if Flag is set
624      BRANCH_CONDITION_READ_REGISTER_WITHOUT_WRITE_STACK = 0x4,        // Branch if a register is read
625      BRANCH_CONDITION_READ_REGISTER_WITH_WRITE_STACK    = 0xc,        // Branch if a register is read
626      BRANCH_CONDITION_READ_STACK                        = 0xf         // Branch with pop  in stack pointer
627    } branch_condition_t;
628
629#  define is_branch_condition_valid(x)                           \
630  (( x == BRANCH_CONDITION_NONE_WITHOUT_WRITE_STACK         ) or \
631   ( x == BRANCH_CONDITION_NONE_WITH_WRITE_STACK            ) or \
632   ( x == BRANCH_CONDITION_FLAG_UNSET                       ) or \
633   ( x == BRANCH_CONDITION_FLAG_SET                         ) or \
634   ( x == BRANCH_CONDITION_READ_REGISTER_WITHOUT_WRITE_STACK) or \
635   ( x == BRANCH_CONDITION_READ_REGISTER_WITH_WRITE_STACK   ) or \
636   ( x == BRANCH_CONDITION_READ_STACK                       ))
637
638
639  /*
640enum
641  {
642    BRANCH_TYPE_SEQUENTIAL,
643    BRANCH_TYPE_JUMP,
644    BRANCH_TYPE_CONDITIONNAL,
645    BRANCH_TYPE_REGISTER,
646    BRANCH_TYPE_CALL,
647    BRANCH_TYPE_RETURN,
648    NB_BRANCH_TYPE
649  };
650
651#  define branch_condition_to_type(x)                                   \
652  (x == BRANCH_CONDITION_NONE_WITHOUT_WRITE_STACK         )?BRANCH_TYPE_JUMP: \
653  ((x == BRANCH_CONDITION_NONE_WITH_WRITE_STACK            )?BRANCH_TYPE_CALL: \
654   ((x == BRANCH_CONDITION_FLAG_UNSET                       )?BRANCH_TYPE_CONDITIONNAL: \
655    ((x == BRANCH_CONDITION_FLAG_SET                         )?BRANCH_TYPE_CONDITIONNAL: \
656     ((x == BRANCH_CONDITION_READ_REGISTER_WITHOUT_WRITE_STACK)?BRANCH_TYPE_REGISTER: \
657      ((x == BRANCH_CONDITION_READ_REGISTER_WITH_WRITE_STACK   )?BRANCH_TYPE_CALL: \
658       ((x == BRANCH_CONDITION_READ_STACK                       )?BRANCH_TYPE_RETURN:BRANCH_TYPE_SEQUENTIAL))))));
659  */
660 
661  //--------------------------------------------------[ instruction ]-----
662#  define NB_INSTRUCTION                           213        // 92 ORBIS, 30 ORFPX (15 simple, 15 double), 91 ORVDX (38 on byte, 41 on half, 12 independant format)
663
664  enum 
665    {
666      // ORBIS
667      INSTRUCTION_L_ADD,
668      INSTRUCTION_L_ADDC,
669      INSTRUCTION_L_ADDI,
670      INSTRUCTION_L_ADDIC,
671      INSTRUCTION_L_AND,
672      INSTRUCTION_L_ANDI,
673      INSTRUCTION_L_BF,
674      INSTRUCTION_L_BNF,
675      INSTRUCTION_L_CMOV,
676      INSTRUCTION_L_CSYNC,
677      INSTRUCTION_L_CUST1,
678      INSTRUCTION_L_CUST2,
679      INSTRUCTION_L_CUST3,
680      INSTRUCTION_L_CUST4,
681      INSTRUCTION_L_CUST5,
682      INSTRUCTION_L_CUST6,
683      INSTRUCTION_L_CUST7,
684      INSTRUCTION_L_CUST8,
685      INSTRUCTION_L_DIV,
686      INSTRUCTION_L_DIVU,
687      INSTRUCTION_L_EXTBS,
688      INSTRUCTION_L_EXTBZ,
689      INSTRUCTION_L_EXTHS,
690      INSTRUCTION_L_EXTHZ,
691      INSTRUCTION_L_EXTWS,
692      INSTRUCTION_L_EXTWZ,
693      INSTRUCTION_L_FF1,
694      INSTRUCTION_L_FL1,
695      INSTRUCTION_L_J,
696      INSTRUCTION_L_JAL,
697      INSTRUCTION_L_JALR,
698      INSTRUCTION_L_JR,
699      INSTRUCTION_L_LBS,
700      INSTRUCTION_L_LBZ,
701      INSTRUCTION_L_LD,
702      INSTRUCTION_L_LHS,
703      INSTRUCTION_L_LHZ,
704      INSTRUCTION_L_LWS,
705      INSTRUCTION_L_LWZ,
706      INSTRUCTION_L_MAC,
707      INSTRUCTION_L_MACI,
708      INSTRUCTION_L_MACRC,
709      INSTRUCTION_L_MFSPR,
710      INSTRUCTION_L_MOVHI,
711      INSTRUCTION_L_MSB,
712      INSTRUCTION_L_MSYNC,
713      INSTRUCTION_L_MTSPR,
714      INSTRUCTION_L_MUL,
715      INSTRUCTION_L_MULI,
716      INSTRUCTION_L_MULU,
717      INSTRUCTION_L_NOP,
718      INSTRUCTION_L_OR,
719      INSTRUCTION_L_ORI,
720      INSTRUCTION_L_PSYNC,
721      INSTRUCTION_L_RFE,
722      INSTRUCTION_L_ROR,
723      INSTRUCTION_L_RORI,
724      INSTRUCTION_L_SB,
725      INSTRUCTION_L_SD,
726      INSTRUCTION_L_SFEQ,
727      INSTRUCTION_L_SFEQI,
728      INSTRUCTION_L_SFGES,
729      INSTRUCTION_L_SFGESI,
730      INSTRUCTION_L_SFGEU,
731      INSTRUCTION_L_SFGEUI,
732      INSTRUCTION_L_SFGTS,
733      INSTRUCTION_L_SFGTSI,
734      INSTRUCTION_L_SFGTU,
735      INSTRUCTION_L_SFGTUI,
736      INSTRUCTION_L_SFLES,
737      INSTRUCTION_L_SFLESI,
738      INSTRUCTION_L_SFLEU,
739      INSTRUCTION_L_SFLEUI,
740      INSTRUCTION_L_SFLTS,
741      INSTRUCTION_L_SFLTSI,
742      INSTRUCTION_L_SFLTU,
743      INSTRUCTION_L_SFLTUI,
744      INSTRUCTION_L_SFNE,
745      INSTRUCTION_L_SFNEI,
746      INSTRUCTION_L_SH,
747      INSTRUCTION_L_SLL,
748      INSTRUCTION_L_SLLI,
749      INSTRUCTION_L_SRA,
750      INSTRUCTION_L_SRAI,
751      INSTRUCTION_L_SRL,
752      INSTRUCTION_L_SRLI,
753      INSTRUCTION_L_SUB,
754      INSTRUCTION_L_SW,
755      INSTRUCTION_L_SYS,
756      INSTRUCTION_L_TRAP,
757      INSTRUCTION_L_XOR,
758      INSTRUCTION_L_XORI,
759      // ORFPX
760      INSTRUCTION_LF_ADD_D,
761      INSTRUCTION_LF_ADD_S,
762      INSTRUCTION_LF_CUST1_D,
763      INSTRUCTION_LF_CUST1_S,
764      INSTRUCTION_LF_DIV_D,
765      INSTRUCTION_LF_DIV_S,
766      INSTRUCTION_LF_FTOI_D,
767      INSTRUCTION_LF_FTOI_S,
768      INSTRUCTION_LF_ITOF_D,
769      INSTRUCTION_LF_ITOF_S,
770      INSTRUCTION_LF_MADD_D,
771      INSTRUCTION_LF_MADD_S,
772      INSTRUCTION_LF_MUL_D,
773      INSTRUCTION_LF_MUL_S,
774      INSTRUCTION_LF_REM_D,
775      INSTRUCTION_LF_REM_S,
776      INSTRUCTION_LF_SFEQ_D,
777      INSTRUCTION_LF_SFEQ_S,
778      INSTRUCTION_LF_SFGE_D,
779      INSTRUCTION_LF_SFGE_S,
780      INSTRUCTION_LF_SFGT_D,
781      INSTRUCTION_LF_SFGT_S,
782      INSTRUCTION_LF_SFLE_D,
783      INSTRUCTION_LF_SFLE_S,
784      INSTRUCTION_LF_SFLT_D,
785      INSTRUCTION_LF_SFLT_S,
786      INSTRUCTION_LF_SFNE_D,
787      INSTRUCTION_LF_SFNE_S,
788      INSTRUCTION_LF_SUB_D,
789      INSTRUCTION_LF_SUB_S,
790      // ORVDX
791      INSTRUCTION_LV_ADD_B,
792      INSTRUCTION_LV_ADD_H,
793      INSTRUCTION_LV_ADDS_B,
794      INSTRUCTION_LV_ADDS_H,
795      INSTRUCTION_LV_ADDU_B,
796      INSTRUCTION_LV_ADDU_H,
797      INSTRUCTION_LV_ADDUS_B,
798      INSTRUCTION_LV_ADDUS_H,
799      INSTRUCTION_LV_ALL_EQ_B,
800      INSTRUCTION_LV_ALL_EQ_H,
801      INSTRUCTION_LV_ALL_GE_B,
802      INSTRUCTION_LV_ALL_GE_H,
803      INSTRUCTION_LV_ALL_GT_B,
804      INSTRUCTION_LV_ALL_GT_H,
805      INSTRUCTION_LV_ALL_LE_B,
806      INSTRUCTION_LV_ALL_LE_H,
807      INSTRUCTION_LV_ALL_LT_B,
808      INSTRUCTION_LV_ALL_LT_H,
809      INSTRUCTION_LV_ALL_NE_B,
810      INSTRUCTION_LV_ALL_NE_H,
811      INSTRUCTION_LV_AND,
812      INSTRUCTION_LV_ANY_EQ_B,
813      INSTRUCTION_LV_ANY_EQ_H,
814      INSTRUCTION_LV_ANY_GE_B,
815      INSTRUCTION_LV_ANY_GE_H,
816      INSTRUCTION_LV_ANY_GT_B,
817      INSTRUCTION_LV_ANY_GT_H,
818      INSTRUCTION_LV_ANY_LE_B,
819      INSTRUCTION_LV_ANY_LE_H,
820      INSTRUCTION_LV_ANY_LT_B,
821      INSTRUCTION_LV_ANY_LT_H,
822      INSTRUCTION_LV_ANY_NE_B,
823      INSTRUCTION_LV_ANY_NE_H,
824      INSTRUCTION_LV_AVG_B,
825      INSTRUCTION_LV_AVG_H,
826      INSTRUCTION_LV_CMP_EQ_B,
827      INSTRUCTION_LV_CMP_EQ_H,
828      INSTRUCTION_LV_CMP_GE_B,
829      INSTRUCTION_LV_CMP_GE_H,
830      INSTRUCTION_LV_CMP_GT_B,
831      INSTRUCTION_LV_CMP_GT_H,
832      INSTRUCTION_LV_CMP_LE_B,
833      INSTRUCTION_LV_CMP_LE_H,
834      INSTRUCTION_LV_CMP_LT_B,
835      INSTRUCTION_LV_CMP_LT_H,
836      INSTRUCTION_LV_CMP_NE_B,
837      INSTRUCTION_LV_CMP_NE_H,
838      INSTRUCTION_LV_CUST1,
839      INSTRUCTION_LV_CUST2,
840      INSTRUCTION_LV_CUST3,
841      INSTRUCTION_LV_CUST4,
842      INSTRUCTION_LV_MADDS_H,
843      INSTRUCTION_LV_MAX_B,
844      INSTRUCTION_LV_MAX_H,
845      INSTRUCTION_LV_MERGE_B,
846      INSTRUCTION_LV_MERGE_H,
847      INSTRUCTION_LV_MIN_B,
848      INSTRUCTION_LV_MIN_H,
849      INSTRUCTION_LV_MSUBS_H,
850      INSTRUCTION_LV_MULS_H,
851      INSTRUCTION_LV_NAND,
852      INSTRUCTION_LV_NOR,
853      INSTRUCTION_LV_OR,
854      INSTRUCTION_LV_PACK_B,
855      INSTRUCTION_LV_PACK_H,
856      INSTRUCTION_LV_PACKS_B,
857      INSTRUCTION_LV_PACKS_H,
858      INSTRUCTION_LV_PACKUS_B,
859      INSTRUCTION_LV_PACKUS_H,
860      INSTRUCTION_LV_PERM_N,
861      INSTRUCTION_LV_RL_B,
862      INSTRUCTION_LV_RL_H,
863      INSTRUCTION_LV_SLL,
864      INSTRUCTION_LV_SLL_B,
865      INSTRUCTION_LV_SLL_H,
866      INSTRUCTION_LV_SRA_B,
867      INSTRUCTION_LV_SRA_H,
868      INSTRUCTION_LV_SRL,
869      INSTRUCTION_LV_SRL_B,
870      INSTRUCTION_LV_SRL_H,
871      INSTRUCTION_LV_SUB_B,
872      INSTRUCTION_LV_SUB_H,
873      INSTRUCTION_LV_SUBS_B,
874      INSTRUCTION_LV_SUBS_H,
875      INSTRUCTION_LV_SUBU_B,
876      INSTRUCTION_LV_SUBU_H,
877      INSTRUCTION_LV_SUBUS_B,
878      INSTRUCTION_LV_SUBUS_H,
879      INSTRUCTION_LV_UNPACK_B,
880      INSTRUCTION_LV_UNPACK_H,
881      INSTRUCTION_LV_XOR
882    };
883
884  //-----------------------------------------------[ Code Operation ]-----
885
886#  define MAX_OPCOD_0                              64            // Instructions with immediat
887#  define MAX_OPCOD_1                              64            // Instruction ORFPX32/64                 
888#  define MAX_OPCOD_2                              256           // Instruction ORVDX64
889#  define MAX_OPCOD_3                              256           // Instructions Register-Register
890#  define MAX_OPCOD_4                              32            // Instructions "set flag" with register
891#  define MAX_OPCOD_5                              32            // Instructions "set flag" with immediat
892#  define MAX_OPCOD_6                              4             // Instruction Shift/Rotate with immediat
893#  define MAX_OPCOD_7                              16            // Instructions multiply with HI-LO
894#  define MAX_OPCOD_8                              2             // Instructions acces at HI-LO
895#  define MAX_OPCOD_9                              8             // Instructions special       
896#  define MAX_OPCOD_10                             4             // Instructions no operation
897#  define MAX_OPCOD_11                             4             // Instruction Shift/Rotate with register
898#  define MAX_OPCOD_12                             4             // Instructions extend
899#  define MAX_OPCOD_13                             4             // Instructions extend (64b)
900
901// OPCOD_0                                         - [31:26]      Instructions with immediat
902#  define OPCOD_L_J                                0x00          // 000_000
903#  define OPCOD_L_JAL                              0x01          // 000_001
904#  define OPCOD_L_BNF                              0x03          // 000_011
905#  define OPCOD_L_BF                               0x04          // 000_100
906#  define OPCOD_L_RFE                              0x09          // 001_001
907#  define OPCOD_L_JR                               0x11          // 010_001
908#  define OPCOD_L_JALR                             0x12          // 010_010
909#  define OPCOD_L_MACI                             0x13          // 010_011
910#  define OPCOD_L_CUST1                            0x1c          // 011_100
911#  define OPCOD_L_CUST2                            0x1d          // 011_101
912#  define OPCOD_L_CUST3                            0x1e          // 011_110
913#  define OPCOD_L_CUST4                            0x1f          // 011_111
914#  define OPCOD_L_CUST5                            0x3c          // 111_100
915#  define OPCOD_L_CUST6                            0x3d          // 111_101
916#  define OPCOD_L_CUST7                            0x3e          // 111_110
917#  define OPCOD_L_CUST8                            0x3f          // 111_111
918#  define OPCOD_L_LD                               0x20          // 100_000
919#  define OPCOD_L_LWZ                              0x21          // 100_001
920#  define OPCOD_L_LWS                              0x22          // 100_010
921#  define OPCOD_L_LBZ                              0x23          // 100_011
922#  define OPCOD_L_LBS                              0x24          // 100_100
923#  define OPCOD_L_LHZ                              0x25          // 100_101
924#  define OPCOD_L_LHS                              0x26          // 100_110
925#  define OPCOD_L_ADDI                             0x27          // 100_111
926#  define OPCOD_L_ADDIC                            0x28          // 101_000
927#  define OPCOD_L_ANDI                             0x29          // 101_001
928#  define OPCOD_L_ORI                              0x2a          // 101_010
929#  define OPCOD_L_XORI                             0x2b          // 101_011
930#  define OPCOD_L_MULI                             0x2c          // 101_100
931#  define OPCOD_L_MFSPR                            0x2d          // 101_101
932#  define OPCOD_L_MTSPR                            0x30          // 110_000
933#  define OPCOD_L_SD                               0x34          // 110_100
934#  define OPCOD_L_SW                               0x35          // 110_101
935#  define OPCOD_L_SB                               0x36          // 110_110
936#  define OPCOD_L_SH                               0x37          // 110_111
937                                                   
938#  define OPCOD_1                                  0x33          // 110_011         // Instruction ORFPX32/64
939#  define OPCOD_2                                  0x0a          // 001_010         // Instruction ORVDX64
940#  define OPCOD_3                                  0x38          // 111_000         // Instructions Register-Register
941#  define OPCOD_4                                  0x39          // 111_001         // Instructions "set flag" with register
942#  define OPCOD_5                                  0x2f          // 101_111         // Instructions "set flag" with immediat
943#  define OPCOD_6                                  0x2e          // 101_110         // Instruction Shift/Rotate with immediat
944#  define OPCOD_7                                  0x31          // 110_001         // Instructions multiply with HI-LO
945#  define OPCOD_8                                  0x06          // 000_110         // Instructions acces at HI-LO
946#  define OPCOD_9                                  0x08          // 001_000         // Instructions special
947#  define OPCOD_10                                 0x05          // 000_101         // Instructions no operation
948                                                   
949// OPCOD_3         instructions                    - [9:8] [3:0]  Instructions Register-Register
950#  define OPCOD_L_ADD                              0x00          // 00_0000
951#  define OPCOD_L_ADDC                             0x01          // 00_0001
952#  define OPCOD_L_SUB                              0x02          // 00_0010
953#  define OPCOD_L_AND                              0x03          // 00_0011
954#  define OPCOD_L_OR                               0x04          // 00_0100
955#  define OPCOD_L_XOR                              0x05          // 00_0101
956#  define OPCOD_L_CMOV                             0x0e          // 00_1110
957#  define OPCOD_L_FF1                              0x0f          // 00_1111
958#  define OPCOD_L_FL1                              0x1f          // 01_1111
959#  define OPCOD_L_MUL                              0x36          // 11_0110
960#  define OPCOD_L_DIV                              0x39          // 11_1001
961#  define OPCOD_L_DIVU                             0x3a          // 11_1010
962#  define OPCOD_L_MULU                             0x3b          // 11_1011
963                                                   
964#  define OPCOD_11                                 0x8           // 1000          // Instruction Shift/Rotate with register
965#  define OPCOD_12                                 0xc           // 1100          // Instructions extend
966#  define OPCOD_13                                 0xd           // 1101          // Instructions extend (64b)
967                                                   
968// OPCOD_4         instructions                    - [25:21]      Instructions "set flag" with register
969#  define OPCOD_L_SFEQ                             0x00          // 00000
970#  define OPCOD_L_SFNE                             0x01          // 00001
971#  define OPCOD_L_SFGTU                            0x02          // 00010
972#  define OPCOD_L_SFGEU                            0x03          // 00011
973#  define OPCOD_L_SFLTU                            0x04          // 00100
974#  define OPCOD_L_SFLEU                            0x05          // 00101
975#  define OPCOD_L_SFGTS                            0x0a          // 01010
976#  define OPCOD_L_SFGES                            0x0b          // 01011
977#  define OPCOD_L_SFLTS                            0x0c          // 01100
978#  define OPCOD_L_SFLES                            0x0d          // 01101
979                                                   
980// OPCOD_5         instructions                    - [25:21]      Instructions "set flag" with immediat
981#  define OPCOD_L_SFEQI                            0x00          // 00000
982#  define OPCOD_L_SFNEI                            0x01          // 00001
983#  define OPCOD_L_SFGTUI                           0x02          // 00010
984#  define OPCOD_L_SFGEUI                           0x03          // 00011
985#  define OPCOD_L_SFLTUI                           0x04          // 00100
986#  define OPCOD_L_SFLEUI                           0x05          // 00101
987#  define OPCOD_L_SFGTSI                           0x0a          // 01010
988#  define OPCOD_L_SFGESI                           0x0b          // 01011
989#  define OPCOD_L_SFLTSI                           0x0c          // 01100
990#  define OPCOD_L_SFLESI                           0x0d          // 01101
991                                                   
992// OPCOD_6         instructions                    - [7:6]        Instruction Shift/Rotate with immediat
993#  define OPCOD_L_SLLI                             0x0           // 00
994#  define OPCOD_L_SRLI                             0x1           // 01
995#  define OPCOD_L_SRAI                             0x2           // 10
996#  define OPCOD_L_RORI                             0x3           // 11
997                                                   
998// OPCOD_7         instructions                    - [3:0]        Instructions multiply with HI-LO
999#  define OPCOD_L_MAC                              0x1           // 0001
1000#  define OPCOD_L_MSB                              0x2           // 0010
1001                                                   
1002// OPCOD_8         instructions                    - [17]         Instructions acces at HI-LO
1003#  define OPCOD_L_MOVHI                            0x0           // 0
1004#  define OPCOD_L_MACRC                            0x1           // 1
1005
1006// OPCOD_9         instructions                    - [25:23]      Instruction special
1007#  define OPCOD_L_SYS                              0x0           // 000
1008#  define OPCOD_L_TRAP                             0x2           // 010
1009#  define OPCOD_L_MSYNC                            0x4           // 100
1010#  define OPCOD_L_PSYNC                            0x5           // 101
1011#  define OPCOD_L_CSYNC                            0x6           // 110
1012
1013// OPCOD_10        instructions                    - [25:24]      Instruction no operation
1014#  define OPCOD_L_NOP                              0x1           // 01
1015                                                   
1016// OPCOD_11        instructions                    - [7:6]        Instruction Shift/Rotate with register
1017#  define OPCOD_L_SLL                              0x0           // 00
1018#  define OPCOD_L_SRL                              0x1           // 01
1019#  define OPCOD_L_SRA                              0x2           // 10
1020#  define OPCOD_L_ROR                              0x3           // 11
1021                                                   
1022// OPCOD_12        instructions                    - [9:6]          Instructions extend
1023#  define OPCOD_L_EXTHS                            0x0           // 0000
1024#  define OPCOD_L_EXTHZ                            0x2           // 0010
1025#  define OPCOD_L_EXTBS                            0x1           // 0001
1026#  define OPCOD_L_EXTBZ                            0x3           // 0011
1027                                                   
1028// OPCOD_13        instructions                    - [9:6]        Instructions extend (64b)
1029#  define OPCOD_L_EXTWS                            0x0           // 0000
1030#  define OPCOD_L_EXTWZ                            0x1           // 0001
1031
1032}; // end namespace behavioural
1033
1034  template<> inline std::string toString<morpheo::behavioural::type_t>(const morpheo::behavioural::type_t& x)
1035  {
1036    switch (x)
1037      {
1038      case morpheo::behavioural::TYPE_ALU     : return "ALU"        ;
1039      case morpheo::behavioural::TYPE_SHIFT   : return "SHIFT"      ;
1040      case morpheo::behavioural::TYPE_MOVE    : return "MOVE"       ;
1041      case morpheo::behavioural::TYPE_TEST    : return "TEST"       ;
1042      case morpheo::behavioural::TYPE_MUL     : return "MUL"        ;
1043      case morpheo::behavioural::TYPE_DIV     : return "DIV"        ;
1044      case morpheo::behavioural::TYPE_EXTEND  : return "EXTEND"     ;
1045      case morpheo::behavioural::TYPE_FIND    : return "FIND"       ;
1046      case morpheo::behavioural::TYPE_SPECIAL : return "SPECIAL"    ;
1047      case morpheo::behavioural::TYPE_CUSTOM  : return "CUSTOM"     ;
1048      case morpheo::behavioural::TYPE_BRANCH  : return "BRANCH"     ;
1049      case morpheo::behavioural::TYPE_MEMORY  : return "MEMORY"     ;
1050      default : return "";
1051      }
1052  };
1053
1054  template<> inline std::string toString<morpheo::behavioural::branch_condition_t>(const morpheo::behavioural::branch_condition_t& x)
1055  {
1056    switch (x)
1057      {
1058      case morpheo::behavioural::BRANCH_CONDITION_NONE_WITHOUT_WRITE_STACK          : return "none_without_write_stack"         ;
1059      case morpheo::behavioural::BRANCH_CONDITION_NONE_WITH_WRITE_STACK             : return "none_with_write_stack"            ;
1060      case morpheo::behavioural::BRANCH_CONDITION_FLAG_UNSET                        : return "flag_unset"                       ;
1061      case morpheo::behavioural::BRANCH_CONDITION_FLAG_SET                          : return "flag_set"                         ;
1062      case morpheo::behavioural::BRANCH_CONDITION_READ_REGISTER_WITHOUT_WRITE_STACK : return "read_register_without_write_stack";
1063      case morpheo::behavioural::BRANCH_CONDITION_READ_REGISTER_WITH_WRITE_STACK    : return "read_register_with_write_stack"   ;
1064      case morpheo::behavioural::BRANCH_CONDITION_READ_STACK                        : return "read_stack"                       ;
1065      default : return "";
1066      }
1067  };
1068
1069}; // end namespace morpheo             
1070
1071#endif
Note: See TracBrowser for help on using the repository browser.