[59] | 1 | #ifndef morpheo_behavioural_Constants_h |
---|
| 2 | #define morpheo_behavioural_Constants_h |
---|
| 3 | |
---|
| 4 | namespace morpheo { |
---|
| 5 | namespace behavioural { |
---|
| 6 | |
---|
| 7 | //=========================================================[ Type ]===== |
---|
[72] | 8 | # define TYPE_ALU 0x0 // 000000 - unit multiple |
---|
| 9 | # define TYPE_BRANCH 0x1 // 000001 - unit multiple, to a special routing |
---|
| 10 | # define TYPE_MEMORY 0x2 // 000010 - unit uniq |
---|
| 11 | # define TYPE_MAC 0x4 // 000100 - unit uniq |
---|
| 12 | # define TYPE_TIMER 0x8 // 001000 - unit uniq |
---|
| 13 | # define TYPE_CUSTOM 0x10 // 010000 - unit uniq |
---|
[59] | 14 | |
---|
| 15 | //====================================================[ Operation ]===== |
---|
| 16 | |
---|
| 17 | //-------------------------------------------------------[ Memory ]----- |
---|
[72] | 18 | # define OPERATION_MEMORY_LOAD 0x0 // 000_0000 |
---|
| 19 | # define OPERATION_MEMORY_LOAD_8_Z 0x0 // 000_0000 |
---|
| 20 | # define OPERATION_MEMORY_LOAD_16_Z 0x20 // 010_0000 |
---|
| 21 | # define OPERATION_MEMORY_LOAD_32_Z 0x40 // 100_0000 |
---|
| 22 | # define OPERATION_MEMORY_LOAD_64_Z 0x60 // 110_0000 |
---|
| 23 | # define OPERATION_MEMORY_LOAD_8_S 0x10 // 001_0000 |
---|
| 24 | # define OPERATION_MEMORY_LOAD_16_S 0x30 // 011_0000 |
---|
| 25 | # define OPERATION_MEMORY_LOAD_32_S 0x50 // 101_0000 |
---|
| 26 | # define OPERATION_MEMORY_LOAD_64_S 0x70 // 111_0000 |
---|
[59] | 27 | |
---|
[72] | 28 | # define OPERATION_MEMORY_STORE_8 0x8 // 000_1000 |
---|
| 29 | # define OPERATION_MEMORY_STORE_16 0x9 // 000_1001 |
---|
| 30 | # define OPERATION_MEMORY_STORE_32 0xa // 000_1010 |
---|
| 31 | # define OPERATION_MEMORY_STORE_64 0xb // 000_1011 |
---|
| 32 | # define OPERATION_MEMORY_STORE_HEAD_OK 0xc // 000_1100 |
---|
| 33 | # define OPERATION_MEMORY_STORE_HEAD_KO 0xd // 000_1101 |
---|
[59] | 34 | |
---|
[72] | 35 | # define OPERATION_MEMORY_LOCK 0x1 // 000_0001 |
---|
| 36 | # define OPERATION_MEMORY_INVALIDATE 0x2 // 000_0010 |
---|
| 37 | # define OPERATION_MEMORY_PREFETCH 0x3 // 000_0011 |
---|
| 38 | # define OPERATION_MEMORY_FLUSH 0x6 // 000_0110 |
---|
| 39 | # define OPERATION_MEMORY_SYNCHRONIZATION 0x7 // 000_0111 |
---|
| 40 | |
---|
[59] | 41 | #define is_operation_memory_load(x) \ |
---|
[72] | 42 | ((x == OPERATION_MEMORY_LOAD_8_Z ) or \ |
---|
| 43 | (x == OPERATION_MEMORY_LOAD_16_Z) or \ |
---|
| 44 | (x == OPERATION_MEMORY_LOAD_32_Z) or \ |
---|
| 45 | (x == OPERATION_MEMORY_LOAD_64_Z) or \ |
---|
| 46 | (x == OPERATION_MEMORY_LOAD_8_S ) or \ |
---|
| 47 | (x == OPERATION_MEMORY_LOAD_16_S) or \ |
---|
| 48 | (x == OPERATION_MEMORY_LOAD_32_S) or \ |
---|
| 49 | (x == OPERATION_MEMORY_LOAD_64_S) ) |
---|
| 50 | |
---|
| 51 | #define is_operation_memory_store(x) \ |
---|
| 52 | ((x == OPERATION_MEMORY_STORE_8 ) or \ |
---|
| 53 | (x == OPERATION_MEMORY_STORE_16 ) or \ |
---|
| 54 | (x == OPERATION_MEMORY_STORE_32 ) or \ |
---|
| 55 | (x == OPERATION_MEMORY_STORE_64 ) or \ |
---|
| 56 | (x == OPERATION_MEMORY_STORE_HEAD_OK) or \ |
---|
| 57 | (x == OPERATION_MEMORY_STORE_HEAD_KO)) |
---|
[59] | 58 | |
---|
[72] | 59 | #define is_operation_memory_store_head(x) \ |
---|
| 60 | ((x == OPERATION_MEMORY_STORE_HEAD_OK) or \ |
---|
| 61 | (x == OPERATION_MEMORY_STORE_HEAD_KO)) |
---|
| 62 | |
---|
| 63 | #define is_operation_memory_load_signed(x) \ |
---|
| 64 | ((x == OPERATION_MEMORY_LOAD_8_S ) or \ |
---|
| 65 | (x == OPERATION_MEMORY_LOAD_16_S) or \ |
---|
| 66 | (x == OPERATION_MEMORY_LOAD_32_S) or \ |
---|
| 67 | (x == OPERATION_MEMORY_LOAD_64_S) ) |
---|
[59] | 68 | |
---|
[72] | 69 | # define MEMORY_ACCESS_8 0x0 |
---|
| 70 | # define MEMORY_ACCESS_16 0x1 |
---|
| 71 | # define MEMORY_ACCESS_32 0x2 |
---|
| 72 | # define MEMORY_ACCESS_64 0x3 |
---|
[59] | 73 | |
---|
[72] | 74 | # define MEMORY_SIZE_8 8 |
---|
| 75 | # define MEMORY_SIZE_16 16 |
---|
| 76 | # define MEMORY_SIZE_32 32 |
---|
| 77 | # define MEMORY_SIZE_64 64 |
---|
[71] | 78 | |
---|
[72] | 79 | # define MASK_MEMORY_ACCESS_8 0x0 |
---|
| 80 | # define MASK_MEMORY_ACCESS_16 0x1 |
---|
| 81 | # define MASK_MEMORY_ACCESS_32 0x3 |
---|
| 82 | # define MASK_MEMORY_ACCESS_64 0x7 |
---|
[59] | 83 | |
---|
[72] | 84 | #define memory_size(x) \ |
---|
| 85 | (((x==OPERATION_MEMORY_LOAD_16_Z)or \ |
---|
| 86 | (x==OPERATION_MEMORY_LOAD_16_S)or \ |
---|
| 87 | (x==OPERATION_MEMORY_STORE_16 ))?MEMORY_SIZE_16: \ |
---|
| 88 | (((x==OPERATION_MEMORY_LOAD_32_Z)or \ |
---|
| 89 | (x==OPERATION_MEMORY_LOAD_32_S)or \ |
---|
| 90 | (x==OPERATION_MEMORY_STORE_32 ))?MEMORY_SIZE_32: \ |
---|
| 91 | (((x==OPERATION_MEMORY_LOAD_64_Z)or \ |
---|
| 92 | (x==OPERATION_MEMORY_LOAD_64_S)or \ |
---|
| 93 | (x==OPERATION_MEMORY_STORE_64 ))?MEMORY_SIZE_64:MEMORY_SIZE_8))) |
---|
| 94 | |
---|
| 95 | #define memory_access(x) \ |
---|
| 96 | (((x==OPERATION_MEMORY_LOAD_16_Z)or \ |
---|
| 97 | (x==OPERATION_MEMORY_LOAD_16_S)or \ |
---|
| 98 | (x==OPERATION_MEMORY_STORE_16 ))?MEMORY_ACCESS_16: \ |
---|
| 99 | (((x==OPERATION_MEMORY_LOAD_32_Z)or \ |
---|
| 100 | (x==OPERATION_MEMORY_LOAD_32_S)or \ |
---|
| 101 | (x==OPERATION_MEMORY_STORE_32 ))?MEMORY_ACCESS_32: \ |
---|
| 102 | (((x==OPERATION_MEMORY_LOAD_64_Z)or \ |
---|
| 103 | (x==OPERATION_MEMORY_LOAD_64_S)or \ |
---|
| 104 | (x==OPERATION_MEMORY_STORE_64 ))?MEMORY_ACCESS_64:MEMORY_ACCESS_8))) |
---|
| 105 | |
---|
| 106 | #define mask_memory_access(x) \ |
---|
| 107 | (((x==OPERATION_MEMORY_LOAD_16_Z)or \ |
---|
| 108 | (x==OPERATION_MEMORY_LOAD_16_S)or \ |
---|
| 109 | (x==OPERATION_MEMORY_STORE_16 ))?MASK_MEMORY_ACCESS_16: \ |
---|
| 110 | (((x==OPERATION_MEMORY_LOAD_32_Z)or \ |
---|
| 111 | (x==OPERATION_MEMORY_LOAD_32_S)or \ |
---|
| 112 | (x==OPERATION_MEMORY_STORE_32 ))?MASK_MEMORY_ACCESS_32: \ |
---|
| 113 | (((x==OPERATION_MEMORY_LOAD_64_Z)or \ |
---|
| 114 | (x==OPERATION_MEMORY_LOAD_64_S)or \ |
---|
| 115 | (x==OPERATION_MEMORY_STORE_64 ))?MASK_MEMORY_ACCESS_64:MASK_MEMORY_ACCESS_8))) |
---|
[71] | 116 | |
---|
[72] | 117 | //---------------------------------------------[ Functionnal Unit ]----- |
---|
| 118 | # define OPERATION_ALU_L_ADD 0x0 // 000_0000 l.add , l.addi |
---|
| 119 | # define OPERATION_ALU_L_ADDC 0x1 // 000_0000 l.addc , l.addic |
---|
| 120 | # define OPERATION_ALU_L_SUB 0x2 // 000_0000 l.sub |
---|
| 121 | # define OPERATION_ALU_L_MUL 0x3 // 000_0000 l.mul , l.muli |
---|
| 122 | # define OPERATION_ALU_L_MULU 0x4 // 000_0000 l.mulu |
---|
| 123 | # define OPERATION_ALU_L_DIV 0x5 // 000_0000 l.div |
---|
| 124 | # define OPERATION_ALU_L_DIVU 0x6 // 000_0000 l.divu |
---|
| 125 | # define OPERATION_ALU_L_AND 0x7 // 000_0000 l.and , l.andi |
---|
| 126 | # define OPERATION_ALU_L_OR 0x8 // 000_0000 l.or , l.ori |
---|
| 127 | # define OPERATION_ALU_L_XOR 0x9 // 000_0000 l.xor , l.xori |
---|
| 128 | # define OPERATION_ALU_L_TEST_F 0xa // 000_0000 l.bf |
---|
| 129 | # define OPERATION_ALU_L_TEST_NF 0xb // 000_0000 l.bnf |
---|
| 130 | # define OPERATION_ALU_L_JALR 0xc // 000_0000 l.jal , l.jalr , l.jr |
---|
| 131 | # define OPERATION_ALU_L_SLL 0xd // 000_0000 l.sll , l.slli |
---|
| 132 | # define OPERATION_ALU_L_SRA 0xe // 000_0000 l.sra , l.srai |
---|
| 133 | # define OPERATION_ALU_L_SRL 0xf // 000_0000 l.srl , l.srli |
---|
| 134 | # define OPERATION_ALU_L_ROR 0x10 // 000_0000 l.ror , l.rori |
---|
| 135 | # define OPERATION_ALU_L_MOVHI 0x11 // 000_0000 l.movhi |
---|
| 136 | # define OPERATION_ALU_L_EXTEND_S 0x12 // 000_0000 l.extbs , l.exths, l.extws |
---|
| 137 | # define OPERATION_ALU_L_EXTEND_Z 0x13 // 000_0000 l.extbz , l.exthz, l.extwz |
---|
| 138 | # define OPERATION_ALU_L_CMOV 0x14 // 000_0000 l.cmov |
---|
| 139 | # define OPERATION_ALU_L_FF1 0x15 // 000_0000 l.ff1 |
---|
| 140 | # define OPERATION_ALU_L_FL1 0x16 // 000_0000 l.fl1 |
---|
| 141 | # define OPERATION_ALU_L_MFSPR 0x17 // 000_0000 l.mfspr |
---|
| 142 | # define OPERATION_ALU_L_MTSPR 0x18 // 000_0000 l.mtspr |
---|
| 143 | # define OPERATION_ALU_L_SFGES 0x19 // 000_0000 l.sfges , l.sfges |
---|
| 144 | # define OPERATION_ALU_L_SFGEU 0x1a // 000_0000 l.sfgeu , l.sfgeu |
---|
| 145 | # define OPERATION_ALU_L_SFGTS 0x1b // 000_0000 L.sfgts , l.sfgts |
---|
| 146 | # define OPERATION_ALU_L_SFGTU 0x1c // 000_0000 l.sfgtu , l.sfgtu |
---|
| 147 | # define OPERATION_ALU_L_SFLES 0x1d // 000_0000 l.sfles , l.sfles |
---|
| 148 | # define OPERATION_ALU_L_SFLEU 0x1e // 000_0000 l.sfleu , l.sfleu |
---|
| 149 | # define OPERATION_ALU_L_SFLTS 0x1f // 000_0000 l.sflts , l.sflts |
---|
| 150 | # define OPERATION_ALU_L_SFLTU 0x20 // 000_0000 l.sfltu , l.sfltu |
---|
| 151 | # define OPERATION_ALU_L_SFEQ 0x21 // 000_0000 l.sfeq , l.sfeqi |
---|
| 152 | # define OPERATION_ALU_L_SFNE 0x22 // 000_0000 l.sfne , l.sfnei |
---|
| 153 | # define OPERATION_ALU_L_MAC 0x23 // 000_0000 l.mac , l.maci |
---|
| 154 | # define OPERATION_ALU_L_MACRC 0x24 // 000_0000 l.macrc |
---|
| 155 | # define OPERATION_ALU_L_MSB 0x25 // 000_0000 l.msb |
---|
[59] | 156 | |
---|
[72] | 157 | //-------------------------------------------------------[ Custom ]----- |
---|
[71] | 158 | |
---|
[72] | 159 | # define OPERATION_CUSTOM_L_1 0x40 // 100_0000 |
---|
| 160 | # define OPERATION_CUSTOM_L_2 0x41 // 100_0001 |
---|
| 161 | # define OPERATION_CUSTOM_L_3 0x42 // 100_0010 |
---|
| 162 | # define OPERATION_CUSTOM_L_4 0x43 // 100_0011 |
---|
| 163 | # define OPERATION_CUSTOM_L_5 0x44 // 100_0100 |
---|
| 164 | # define OPERATION_CUSTOM_L_6 0x45 // 100_0101 |
---|
| 165 | # define OPERATION_CUSTOM_L_7 0x46 // 100_0110 |
---|
| 166 | # define OPERATION_CUSTOM_L_8 0x47 // 100_0111 |
---|
| 167 | # define OPERATION_CUSTOM_LF_1_D 0x48 // 100_1000 |
---|
| 168 | # define OPERATION_CUSTOM_LF_1_S 0x49 // 100_1001 |
---|
| 169 | # define OPERATION_CUSTOM_LV_1 0x4c // 100_1100 |
---|
| 170 | # define OPERATION_CUSTOM_LV_2 0x4d // 100_1101 |
---|
| 171 | # define OPERATION_CUSTOM_LV_3 0x4e // 100_1110 |
---|
| 172 | # define OPERATION_CUSTOM_LV_4 0x4f // 100_1111 |
---|
| 173 | |
---|
| 174 | # define MAX_OPERATION 0x80 |
---|
| 175 | |
---|
[59] | 176 | //====================================================[ Exception ]===== |
---|
| 177 | // Exception - OpenRISC |
---|
| 178 | |
---|
[72] | 179 | # define SIZE_EXCEPTION 5 |
---|
[59] | 180 | |
---|
[72] | 181 | # define EXCEPTION_NONE 0x00 // none exception |
---|
| 182 | # define EXCEPTION_RESET 0x01 // software or hardware reset |
---|
| 183 | # define EXCEPTION_BUS_ERROR 0x02 // Access at a invalid physical adress |
---|
| 184 | # define EXCEPTION_DATA_PAGE 0x03 // No matching or page violation protection in pages tables |
---|
| 185 | # define EXCEPTION_INSTRUCTION_PAGE 0x04 // No matching or page violation protection in pages tables |
---|
| 186 | # define EXCEPTION_TICK_TIMER 0x05 // Tick timer interruption |
---|
| 187 | # define EXCEPTION_ALIGNMENT 0x06 // Load/Store access is not aligned |
---|
| 188 | # define EXCEPTION_ILLEGAL_INSTRUCTION 0x07 // Instruction is illegal (no implemented) |
---|
| 189 | # define EXCEPTION_INTERRUPT 0x08 // External interruption |
---|
| 190 | # define EXCEPTION_DATA_TLB 0x09 // DTLB miss |
---|
| 191 | # define EXCEPTION_INSTRUCTION_TLB 0x0a // ITLB miss |
---|
| 192 | # define EXCEPTION_RANGE 0x0b // Overflow or access at a unimplemented register or context |
---|
| 193 | # define EXCEPTION_SYSCALL 0x0c // System Call |
---|
| 194 | # define EXCEPTION_FLOATING_POINT 0x0d // Caused by a floating instruction |
---|
| 195 | # define EXCEPTION_TRAP 0x0e // L.trap or debug unit |
---|
| 196 | # define EXCEPTION_RESERVED_0 0x0f // Reserved for a futur usage |
---|
| 197 | # define EXCEPTION_RESERVED_1 0x10 // Reserved for a futur usage |
---|
| 198 | # define EXCEPTION_RESERVED_2 0x11 // Reserved for a futur usage |
---|
| 199 | # define EXCEPTION_RESERVED_3 0x12 // Reserved for a futur usage |
---|
| 200 | # define EXCEPTION_RESERVED_4 0x13 // Reserved for a futur usage |
---|
| 201 | # define EXCEPTION_RESERVED_5 0x14 // Reserved for a futur usage |
---|
| 202 | # define EXCEPTION_RESERVED_6 0x15 // Reserved for implemented specific exceptions |
---|
| 203 | # define EXCEPTION_RESERVED_7 0x16 // Reserved for implemented specific exceptions |
---|
| 204 | # define EXCEPTION_RESERVED_8 0x17 // Reserved for implemented specific exceptions |
---|
| 205 | # define EXCEPTION_RESERVED_9 0x18 // Reserved for implemented specific exceptions |
---|
| 206 | # define EXCEPTION_CUSTOM_0 0x19 // Reserved for custom exceptions |
---|
| 207 | # define EXCEPTION_CUSTOM_1 0x1a // Reserved for custom exceptions |
---|
| 208 | # define EXCEPTION_CUSTOM_2 0x1b // Reserved for custom exceptions |
---|
| 209 | # define EXCEPTION_CUSTOM_3 0x1c // Reserved for custom exceptions |
---|
| 210 | # define EXCEPTION_CUSTOM_4 0x1d // Reserved for custom exceptions |
---|
| 211 | # define EXCEPTION_CUSTOM_5 0x1e // Reserved for custom exceptions |
---|
| 212 | # define EXCEPTION_CUSTOM_6 0x1f // Reserved for custom exceptions |
---|
| 213 | |
---|
| 214 | #define exception_to_address(x) (x<<8) |
---|
| 215 | |
---|
[59] | 216 | // Exception Execution |
---|
[72] | 217 | # define EXCEPTION_MEMORY_NONE 0x0 // Load/Store generate none exception |
---|
| 218 | # define EXCEPTION_MEMORY_ALIGNMENT 0x1 // Load/Store access is not aligned |
---|
| 219 | # define EXCEPTION_MEMORY_DATA_TLB 0x2 // DTLB miss |
---|
| 220 | # define EXCEPTION_MEMORY_DATA_PAGE 0x3 // No matching or page violation protection in pages tables |
---|
| 221 | # define EXCEPTION_MEMORY_BUS_ERROR 0x4 // Access at a invalid physical address |
---|
| 222 | # define EXCEPTION_MEMORY_MISS_SPECULATION 0x5 // Load miss speculation |
---|
| 223 | # define EXCEPTION_MEMORY_LOAD_SPECULATIVE 0x6 // The load is speculative : write in register file, but don't commit |
---|
[59] | 224 | |
---|
[72] | 225 | # define EXCEPTION_CUSTOM_NONE 0x1 // Custom unit generate none exception |
---|
| 226 | # define EXCEPTION_CUSTOM_CUST_0 0x1 // Reserved for custom exceptions |
---|
| 227 | # define EXCEPTION_CUSTOM_CUST_1 0x2 // Reserved for custom exceptions |
---|
| 228 | # define EXCEPTION_CUSTOM_CUST_2 0x3 // Reserved for custom exceptions |
---|
| 229 | # define EXCEPTION_CUSTOM_CUST_3 0x4 // Reserved for custom exceptions |
---|
| 230 | # define EXCEPTION_CUSTOM_CUST_4 0x5 // Reserved for custom exceptions |
---|
| 231 | # define EXCEPTION_CUSTOM_CUST_5 0x6 // Reserved for custom exceptions |
---|
| 232 | # define EXCEPTION_CUSTOM_CUST_6 0x7 // Reserved for custom exceptions |
---|
[62] | 233 | |
---|
[72] | 234 | # define EXCEPTION_ALU_NONE 0x0 // Functionnal unit generate none exception |
---|
| 235 | # define EXCEPTION_ALU_RANGE 0x1 // |
---|
| 236 | # define EXCEPTION_ALU_SPR_ACCESS_INVALID 0x2 // SPR present in ALU but not compatible privilege |
---|
| 237 | # define EXCEPTION_ALU_SPR_ACCESS_NOT_COMPLETE 0x3 // SPR not present in ALU |
---|
[62] | 238 | |
---|
[72] | 239 | //=======================================================[ dcache ]===== |
---|
| 240 | |
---|
| 241 | //--------------------------------------------------[ dcache_type ]----- |
---|
| 242 | |
---|
| 243 | # define SIZE_DCACHE_TYPE 4 |
---|
| 244 | |
---|
| 245 | # define DCACHE_TYPE_LOAD 0x0 // 0000 |
---|
| 246 | # define DCACHE_TYPE_LOCK 0x1 // 0001 |
---|
| 247 | # define DCACHE_TYPE_INVALIDATE 0x2 // 0010 |
---|
| 248 | # define DCACHE_TYPE_PREFETCH 0x3 // 0011 |
---|
| 249 | //#define DCACHE_TYPE_ 0x4 // 0100 |
---|
| 250 | //#define DCACHE_TYPE_ 0x5 // 0101 |
---|
| 251 | # define DCACHE_TYPE_FLUSH 0x6 // 0110 |
---|
| 252 | # define DCACHE_TYPE_SYNCHRONIZATION 0x7 // 0111 |
---|
| 253 | # define DCACHE_TYPE_STORE_8 0x8 // 1000 |
---|
| 254 | # define DCACHE_TYPE_STORE_16 0x9 // 1001 |
---|
| 255 | # define DCACHE_TYPE_STORE_32 0xa // 1010 |
---|
| 256 | # define DCACHE_TYPE_STORE_64 0xb // 1011 |
---|
| 257 | //#define DCACHE_TYPE_ 0xc // 1100 |
---|
| 258 | //#define DCACHE_TYPE_ 0xd // 1101 |
---|
| 259 | //#define DCACHE_TYPE_ 0xe // 1110 |
---|
| 260 | //#define DCACHE_TYPE_ 0xf // 1111 |
---|
| 261 | |
---|
[62] | 262 | // just take the 4 less significative bits. |
---|
| 263 | #define operation_to_dcache_type(x) (x&0xf) |
---|
| 264 | |
---|
[72] | 265 | //-------------------------------------------------[ dcache_error ]----- |
---|
| 266 | |
---|
| 267 | # define SIZE_DCACHE_ERROR 1 |
---|
| 268 | |
---|
| 269 | # define DCACHE_ERROR_NONE 0x0 |
---|
| 270 | # define DCACHE_ERROR_BUS_ERROR 0x1 |
---|
| 271 | |
---|
| 272 | //=================================================[ special_data ]===== |
---|
| 273 | |
---|
| 274 | # define SIZE_SPECIAL_DATA 2 |
---|
| 275 | |
---|
| 276 | // Position of flag in "rename register SR" (NOT IN "SR") |
---|
| 277 | # define FLAG_POSITION_F 0x0 // Conditionnal branch flag |
---|
| 278 | # define FLAG_POSITION_CY 0x1 // Carry was produced by last arithmetic operation |
---|
| 279 | # define FLAG_POSITION_OV 0x0 // Overflow occured during last arithmetic operation |
---|
| 280 | |
---|
| 281 | # define FLAG_F (1<<FLAG_POSITION_F ) // Conditionnal branch flag |
---|
| 282 | # define FLAG_CY (1<<FLAG_POSITION_CY) // Carry was produced by last arithmetic operation |
---|
| 283 | # define FLAG_OV (1<<FLAG_POSITION_OV) // Overflow occured during last arithmetic operation |
---|
| 284 | |
---|
| 285 | //==========================================================[ spr ]===== |
---|
| 286 | |
---|
| 287 | enum |
---|
| 288 | { |
---|
| 289 | GROUP_SYSTEM_AND_CONTROL, // 0 |
---|
| 290 | GROUP_DMMU, // 1 |
---|
| 291 | GROUP_IMMU, // 2 |
---|
| 292 | GROUP_DCACHE, // 3 |
---|
| 293 | GROUP_ICACHE, // 4 |
---|
| 294 | GROUP_MAC, // 5 |
---|
| 295 | GROUP_DEBUG, // 6 |
---|
| 296 | GROUP_PERFORMANCE_COUNTER, // 7 |
---|
| 297 | GROUP_POWER_MANAGEMENT, // 8 |
---|
| 298 | GROUP_PIC, // 9 |
---|
| 299 | GROUP_TICK_TIMER, // 10 |
---|
| 300 | GROUP_FLOATING_POINT, // 11 |
---|
| 301 | GROUP_RESERVED_1, // 12 |
---|
| 302 | GROUP_RESERVED_2, // 13 |
---|
| 303 | GROUP_RESERVED_3, // 14 |
---|
| 304 | GROUP_RESERVED_4, // 15 |
---|
| 305 | GROUP_RESERVED_5, // 16 |
---|
| 306 | GROUP_RESERVED_6, // 17 |
---|
| 307 | GROUP_RESERVED_7, // 18 |
---|
| 308 | GROUP_RESERVED_8, // 19 |
---|
| 309 | GROUP_RESERVED_9, // 20 |
---|
| 310 | GROUP_RESERVED_10, // 21 |
---|
| 311 | GROUP_RESERVED_11, // 22 |
---|
| 312 | GROUP_RESERVED_12, // 23 |
---|
| 313 | GROUP_CUSTOM_1, // 24 |
---|
| 314 | GROUP_CUSTOM_2, // 25 |
---|
| 315 | GROUP_CUSTOM_3, // 26 |
---|
| 316 | GROUP_CUSTOM_4, // 27 |
---|
| 317 | GROUP_CUSTOM_5, // 28 |
---|
| 318 | GROUP_CUSTOM_6, // 29 |
---|
| 319 | GROUP_CUSTOM_7, // 30 |
---|
| 320 | GROUP_CUSTOM_8 // 31 |
---|
| 321 | }; |
---|
| 322 | |
---|
| 323 | # define NB_GROUP 32 |
---|
| 324 | # define NB_REG_GROUP_SYSTEM_AND_CONTROL 1536 |
---|
| 325 | # define NB_REG_GROUP_DMMU 1536 |
---|
| 326 | # define NB_REG_GROUP_IMMU 1536 |
---|
| 327 | # define NB_REG_GROUP_DCACHE 6 |
---|
| 328 | # define NB_REG_GROUP_ICACHE 4 |
---|
| 329 | # define NB_REG_GROUP_MAC 3 |
---|
| 330 | # define NB_REG_GROUP_DEBUG 22 |
---|
| 331 | # define NB_REG_GROUP_PERFORMANCE_COUNTER 16 |
---|
| 332 | # define NB_REG_GROUP_POWER_MANAGEMENT 1 |
---|
| 333 | # define NB_REG_GROUP_PIC 3 |
---|
| 334 | # define NB_REG_GROUP_TICK_TIMER 2 |
---|
| 335 | # define NB_REG_GROUP_FLOATING_POINT 0 |
---|
| 336 | # define NB_REG_GROUP_RESERVED_1 0 |
---|
| 337 | # define NB_REG_GROUP_RESERVED_2 0 |
---|
| 338 | # define NB_REG_GROUP_RESERVED_3 0 |
---|
| 339 | # define NB_REG_GROUP_RESERVED_4 0 |
---|
| 340 | # define NB_REG_GROUP_RESERVED_5 0 |
---|
| 341 | # define NB_REG_GROUP_RESERVED_6 0 |
---|
| 342 | # define NB_REG_GROUP_RESERVED_7 0 |
---|
| 343 | # define NB_REG_GROUP_RESERVED_8 0 |
---|
| 344 | # define NB_REG_GROUP_RESERVED_9 0 |
---|
| 345 | # define NB_REG_GROUP_RESERVED_10 0 |
---|
| 346 | # define NB_REG_GROUP_RESERVED_11 0 |
---|
| 347 | # define NB_REG_GROUP_RESERVED_12 0 |
---|
| 348 | # define NB_REG_GROUP_CUSTOM_1 0 |
---|
| 349 | # define NB_REG_GROUP_CUSTOM_2 0 |
---|
| 350 | # define NB_REG_GROUP_CUSTOM_3 0 |
---|
| 351 | # define NB_REG_GROUP_CUSTOM_4 0 |
---|
| 352 | # define NB_REG_GROUP_CUSTOM_5 0 |
---|
| 353 | # define NB_REG_GROUP_CUSTOM_6 0 |
---|
| 354 | # define NB_REG_GROUP_CUSTOM_7 0 |
---|
| 355 | # define NB_REG_GROUP_CUSTOM_8 0 |
---|
| 356 | |
---|
| 357 | |
---|
| 358 | // GROUP_MAC |
---|
| 359 | # define SPR_MACLO 1 // MAC Low |
---|
| 360 | # define SPR_MACHI 2 // MAC High |
---|
| 361 | |
---|
| 362 | //----------------------------------------------[ spr_mode_access ]----- |
---|
| 363 | |
---|
| 364 | # define SPR_ACCESS_MODE_NONE 0x0 // 000 |
---|
| 365 | # define SPR_ACCESS_MODE_READ_ONLY 0x1 // 001 |
---|
| 366 | # define SPR_ACCESS_MODE_WRITE_ONLY 0x2 // 010 |
---|
| 367 | # define SPR_ACCESS_MODE_READ_WRITE 0x3 // 011 |
---|
| 368 | # define SPR_ACCESS_MODE_READ_ONLY_COND 0x5 // 101 special read |
---|
| 369 | |
---|
[59] | 370 | /* |
---|
| 371 | #define _size_instruction 32 |
---|
| 372 | #define _size_instruction_log2 5 |
---|
| 373 | |
---|
| 374 | //----------------------------------------------------[ Operation ]----- |
---|
| 375 | // #define _nb_operation 32 |
---|
| 376 | // #define _size_operation 5 |
---|
| 377 | |
---|
| 378 | #define _operation_none 0x0 |
---|
| 379 | #define _operation_l_adds 0x1 |
---|
| 380 | #define _operation_l_addu 0x2 |
---|
| 381 | #define _operation_l_subs 0x3 |
---|
| 382 | #define _operation_l_and 0x4 |
---|
| 383 | #define _operation_l_or 0x5 |
---|
| 384 | #define _operation_l_xor 0x6 |
---|
| 385 | #define _operation_l_cmove 0x7 |
---|
| 386 | #define _operation_l_read_imm 0x8 |
---|
| 387 | #define _operation_l_movhi 0x9 |
---|
| 388 | #define _operation_l_muls 0xa |
---|
| 389 | #define _operation_l_mulu 0xb |
---|
| 390 | #define _operation_l_divs 0xc |
---|
| 391 | #define _operation_l_divu 0xd |
---|
| 392 | #define _operation_l_exts 0xe |
---|
| 393 | #define _operation_l_extz 0xf |
---|
| 394 | #define _operation_l_ff1 0x10 |
---|
| 395 | #define _operation_l_fl1 0x11 |
---|
| 396 | #define _operation_l_sll 0x12 |
---|
| 397 | #define _operation_l_sla 0x13 |
---|
| 398 | #define _operation_l_srl 0x14 |
---|
| 399 | #define _operation_l_ror 0x15 |
---|
| 400 | #define _operation_l_cmp_eq 0x16 |
---|
| 401 | #define _operation_l_cmp_ne 0x17 |
---|
| 402 | #define _operation_l_cmp_ges 0x18 |
---|
| 403 | #define _operation_l_cmp_geu 0x19 |
---|
| 404 | #define _operation_l_cmp_gts 0x1a |
---|
| 405 | #define _operation_l_cmp_gtu 0x1b |
---|
| 406 | #define _operation_l_cmp_les 0x1c |
---|
| 407 | #define _operation_l_cmp_leu 0x1d |
---|
| 408 | #define _operation_l_cmp_lts 0x1e |
---|
| 409 | #define _operation_l_cmp_ltu 0x1f |
---|
| 410 | |
---|
| 411 | //--------------------------------------------------[ destination ]----- |
---|
| 412 | #define _size_destination1 4 |
---|
| 413 | |
---|
| 414 | #define cst_DESTINATION1_NONE 0x0 |
---|
| 415 | #define mask_DESTINATION1_GPR 0x1 |
---|
| 416 | #define mask_DESTINATION1_MEMORY 0x2 |
---|
| 417 | #define mask_DESTINATION1_SPR 0x4 |
---|
| 418 | #define mask_DESTINATION1_MAC_UNIT 0x8 |
---|
| 419 | |
---|
| 420 | #define _size_destination2 3 |
---|
| 421 | |
---|
| 422 | #define cst_DESTINATION2_NONE 0x0 |
---|
| 423 | #define mask_DESTINATION2_COMMIT 0x1 |
---|
| 424 | #define mask_DESTINATION2_MEMORY 0x2 |
---|
| 425 | #define mask_DESTINATION2_SPR 0x4 |
---|
| 426 | |
---|
| 427 | //----------------------------------------------------[ exec_flag ]----- |
---|
| 428 | #define _size_exec_flag 2 |
---|
| 429 | |
---|
| 430 | #define mask_EXEC_FLAG_NONE 0x1 |
---|
| 431 | #define mask_EXEC_FLAG_CARRY 0x1 |
---|
| 432 | #define mask_EXEC_FLAG_FLAG 0x1 |
---|
| 433 | #define mask_EXEC_FLAG_OVERFLOW 0x2 |
---|
| 434 | |
---|
| 435 | //---------------------------------------------------[ exec_excep ]----- |
---|
| 436 | #define _size_exec_excep 1 |
---|
| 437 | |
---|
| 438 | #define mask_EXEC_EXCEP_NONE 0x0 |
---|
| 439 | #define mask_EXEC_EXCEP_RANGE 0x1 |
---|
| 440 | |
---|
| 441 | //----------------------------------------------------[ Condition ]----- |
---|
| 442 | #define _size_condition 3 |
---|
| 443 | |
---|
| 444 | #define cst_CONDITION_UNCONDITIONAL 0x0 // None condition (jump) |
---|
| 445 | #define mask_CONDITION_CONDITIONAL 0x2 |
---|
| 446 | #define mask_CONDITION_CONDITIONAL_NF 0x0 // Branch if Flag is clear |
---|
| 447 | #define mask_CONDITION_CONDITIONAL_F 0x1 // Branch if Flag is set |
---|
| 448 | #define mask_CONDITION_REG 0x4 // Branch if a register is read |
---|
| 449 | #define mask_CONDITION_STACK 0x8 // Branch with pop in stack pointer |
---|
| 450 | |
---|
| 451 | //-------------------------------------------------[ branch_state ]----- |
---|
| 452 | #define cst_BRANCH_STATE_NONE 0x0 // 0 0 |
---|
| 453 | #define cst_BRANCH_STATE_NSPEC_TAKE 0x1 // 0 1 -> incondionnal |
---|
| 454 | #define cst_BRANCH_STATE_SPEC_NTAKE 0x2 // 1 0 |
---|
| 455 | #define cst_BRANCH_STATE_SPEC_TAKE 0x3 // 1 1 |
---|
| 456 | */ |
---|
| 457 | |
---|
| 458 | /* |
---|
| 459 | #define M_CPU_SIZE_INST 32 |
---|
| 460 | |
---|
| 461 | //---------------------------------------------------- |
---|
| 462 | // Exception type |
---|
| 463 | //---------------------------------------------------- |
---|
| 464 | |
---|
| 465 | #define M_CPU_LOG2_NB_EXCP 5 |
---|
| 466 | #define M_CPU_NB_EXCP 32 |
---|
| 467 | |
---|
| 468 | #define EXCP_NO 0x00 // none exception |
---|
| 469 | #define EXCP_RESET 0x01 // software or hardware reset |
---|
| 470 | #define EXCP_BERR 0x02 // Access at a invalid physical adress |
---|
| 471 | #define EXCP_D_PAGE 0x03 // No matching or page violation protection in pages tables |
---|
| 472 | #define EXCP_I_PAGE 0x04 // No matching or page violation protection in pages tables |
---|
| 473 | #define EXCP_TICK_TIMER 0x05 // Tick timer interruption |
---|
| 474 | #define EXCP_ALIGNMENT 0x06 // Load/Store access is not aligned |
---|
| 475 | #define EXCP_ILL_INST 0x07 // Instruction is illegal (no implemented) |
---|
| 476 | #define EXCP_IRQ 0x08 // External interruption |
---|
| 477 | #define EXCP_D_TLB 0x09 // DTLB miss |
---|
| 478 | #define EXCP_I_TLB 0x0a // ITLB miss |
---|
| 479 | #define EXCP_RANGE 0x0b // Overflow or access at a unimplemented register or context |
---|
| 480 | #define EXCP_SYSCALL 0x0c // System Call |
---|
| 481 | #define EXCP_FP 0x0d // Caused by a floating instruction |
---|
| 482 | #define EXCP_TRAP 0x0e // L.trap or debug unit |
---|
| 483 | #define EXCP_RES0 0x0f // Reserved for a futur usage |
---|
| 484 | #define EXCP_RES1 0x10 // Reserved for a futur usage |
---|
| 485 | #define EXCP_RES2 0x11 // Reserved for a futur usage |
---|
| 486 | #define EXCP_RES3 0x12 // Reserved for a futur usage |
---|
| 487 | #define EXCP_RES4 0x13 // Reserved for a futur usage |
---|
| 488 | #define EXCP_RES5 0x14 // Reserved for a futur usage |
---|
| 489 | #define EXCP_RES6 0x15 // Reserved for implemented specific exceptions |
---|
| 490 | #define EXCP_RES7 0x16 // Reserved for implemented specific exceptions |
---|
| 491 | #define EXCP_RES8 0x17 // Reserved for implemented specific exceptions |
---|
| 492 | #define EXCP_RES9 0x18 // Reserved for implemented specific exceptions |
---|
| 493 | #define EXCP_CUST0 0x19 // Reserved for custom exceptions |
---|
| 494 | #define EXCP_CUST1 0x1a // Reserved for custom exceptions |
---|
| 495 | #define EXCP_CUST2 0x1b // Reserved for custom exceptions |
---|
| 496 | #define EXCP_CUST3 0x1c // Reserved for custom exceptions |
---|
| 497 | #define EXCP_CUST4 0x1d // Reserved for custom exceptions |
---|
| 498 | #define EXCP_CUST5 0x1e // Reserved for custom exceptions |
---|
| 499 | #define EXCP_CUST6 0x1f // Reserved for custom exceptions |
---|
| 500 | |
---|
| 501 | //---------------------------------------------------- |
---|
| 502 | // Flags |
---|
| 503 | //---------------------------------------------------- |
---|
| 504 | |
---|
| 505 | #define M_CPU_NB_FLAG 3 |
---|
| 506 | |
---|
| 507 | // Integer flags |
---|
| 508 | #define FLAG_F 0x1 // Conditionnal branch flag |
---|
| 509 | #define FLAG_CY 0x2 // Carry was produced by last arithmétic operation |
---|
| 510 | #define FLAG_OV 0x4 // Overflow occured during last arithmetic operation |
---|
| 511 | |
---|
| 512 | // Floating flags |
---|
| 513 | #define FLAG_OVF 0x004 // Overflow occured during last arithmetic operation |
---|
| 514 | #define FLAG_UNF 0x008 // Underflow flags |
---|
| 515 | #define FLAG_SNF 0x010 // Result SNAN |
---|
| 516 | #define FLAG_QNF 0x020 // Result QNAN |
---|
| 517 | #define FLAG_ZF 0x040 // Result is nul |
---|
| 518 | #define FLAG_IXF 0x080 // Result is inexact |
---|
| 519 | #define FLAG_IVF 0x100 // Result is invalid |
---|
| 520 | #define FLAG_INF 0x200 // Result is infinite |
---|
| 521 | #define FLAG_DZF 0x400 // Division by zero |
---|
| 522 | |
---|
| 523 | // Position of flag in "rename register SR" (NOT IN "SR") |
---|
| 524 | #define FLAG_POS_F 0x0 // Conditionnal branch flag |
---|
| 525 | #define FLAG_POS_CY 0x1 // Carry was produced by last arithmétic operation |
---|
| 526 | #define FLAG_POS_OV 0x0 // Overflow occured during last arithmetic operation |
---|
| 527 | |
---|
| 528 | //---------------------------------------------------- |
---|
| 529 | // Instruction type |
---|
| 530 | //---------------------------------------------------- |
---|
| 531 | |
---|
| 532 | #define M_CPU_LOG2_NB_TYPE 4 |
---|
| 533 | |
---|
| 534 | #define TYPE_NOP 0x0 |
---|
| 535 | #define TYPE_ALU_F 0x1 // Instruction ALU with flag using (ADD, SUB, ADDC ...) |
---|
| 536 | #define TYPE_ALU_NF 0x2 // Instruction ALU without flag using (AND, OR ...) |
---|
| 537 | #define TYPE_MAC 0x3 // Instruction ALU with utilisation of register HI/LO |
---|
| 538 | #define TYPE_J 0x4 // Branch instruction |
---|
| 539 | #define TYPE_SPR_READ 0x5 // Instruction special : l.mfspr |
---|
| 540 | #define TYPE_SPR_WRITE 0x6 // Instruction special : l.mtspr |
---|
| 541 | #define TYPE_SPECIAL 0x7 // Instruction execute in decode stage |
---|
| 542 | #define TYPE_CUSTOM 0x8 // Instruction Custom |
---|
| 543 | |
---|
| 544 | #define TYPE_LOAD_Z 0x9 // Load access (extended by zero) |
---|
| 545 | #define TYPE_LOAD_S 0xa // Load access (sign extended) |
---|
| 546 | #define TYPE_STORE 0xc // Store access |
---|
| 547 | |
---|
| 548 | //---------------------------------------------------- |
---|
| 549 | // Condition to branch |
---|
| 550 | //---------------------------------------------------- |
---|
| 551 | |
---|
| 552 | #define M_CPU_LOG2_NB_COND 4 |
---|
| 553 | |
---|
| 554 | #define COND_NONE 0x0 // None condition (jump) |
---|
| 555 | #define COND_F 0x2 // Branch if Flag is set |
---|
| 556 | #define COND_NF 0x3 // Branch if Flag is clear |
---|
| 557 | #define COND_REG 0x4 // Branch if a register is read |
---|
| 558 | #define COND_STACK 0x8 // Branch with pop in stack pointer |
---|
| 559 | |
---|
| 560 | //---------------------------------------------------- |
---|
| 561 | // Event : State and Type |
---|
| 562 | //---------------------------------------------------- |
---|
| 563 | |
---|
| 564 | #define EVENT_STATE_NO_EVENT 0 // no event : current case |
---|
| 565 | #define EVENT_STATE_EVENT 1 // Have a event : make necessary to manage the event |
---|
| 566 | #define EVENT_STATE_WAITEND 2 // Wait end of manage event (restaure a good context) |
---|
| 567 | #define EVENT_STATE_END 3 // CPU can continue |
---|
| 568 | |
---|
| 569 | #define EVENT_TYPE_MISS 0 // miss of speculation |
---|
| 570 | #define EVENT_TYPE_EXCP 1 // exception or interruption occure |
---|
| 571 | |
---|
| 572 | // SPEC? TAKE? |
---|
| 573 | #define BRANCH_STATE_NONE 0 // 0 0 |
---|
| 574 | #define BRANCH_STATE_NSPEC_TAKE 1 // 0 1 -> incondionnal |
---|
| 575 | #define BRANCH_STATE_SPEC_NTAKE 2 // 1 0 |
---|
| 576 | #define BRANCH_STATE_SPEC_TAKE 3 // 1 1 |
---|
| 577 | |
---|
| 578 | //---------------------------------------------------- |
---|
| 579 | // Name to particular register |
---|
| 580 | //---------------------------------------------------- |
---|
| 581 | |
---|
| 582 | //~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 583 | // GENERAL PURPOSE REGISTER |
---|
| 584 | //~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 585 | #define M_CPU_LOG2_NB_GPR_LOG 5 |
---|
| 586 | #define M_CPU_NB_GPR_LOG (1<<M_CPU_LOG2_NB_GPR_LOG) |
---|
| 587 | |
---|
| 588 | #define GPR_LOG_LR 0x09 // Link register |
---|
| 589 | #define REG_PHY_SR 0x00 // Status register |
---|
| 590 | |
---|
| 591 | //~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 592 | // SPECIAL PURPOSE REGISTER |
---|
| 593 | //~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 594 | #define M_CPU_LOG2_NB_SPR_LOG 1 |
---|
| 595 | #define M_CPU_NB_SPR_LOG (1<<M_CPU_LOG2_NB_SPR_LOG) |
---|
| 596 | #define M_CPU_SPR_SIZE_DATA 2 // Size of the most great register |
---|
| 597 | |
---|
| 598 | #define SPR_LOG_SR_F 0x00 // Status register bit F (size = 1) |
---|
| 599 | #define SPR_LOG_SR_CY_OV 0x01 // Status register bit overflow and carry (size = 2) |
---|
| 600 | //#define SPR_LOG_SR_LO 0x02 // MAC LSB (size = 32) |
---|
| 601 | //#define SPR_LOG_SR_HI 0x03 // MAC MSB (size = 32) |
---|
| 602 | */ |
---|
| 603 | |
---|
| 604 | /* |
---|
| 605 | //---------------------------------------------------- |
---|
| 606 | // Code Operation (before decode) |
---|
| 607 | //---------------------------------------------------- |
---|
| 608 | |
---|
| 609 | // Codop - [31:26] Instructions with immediat |
---|
| 610 | #define OPCOD_L_J 0x00 // 000_000 |
---|
| 611 | #define OPCOD_L_JAL 0x01 // 000_001 |
---|
| 612 | #define OPCOD_L_BNF 0x03 // 000_011 |
---|
| 613 | #define OPCOD_L_BF 0x04 // 000_100 |
---|
| 614 | #define OPCOD_L_RFE 0x09 // 001_001 |
---|
| 615 | #define OPCOD_L_JR 0x11 // 010_001 |
---|
| 616 | #define OPCOD_L_JALR 0x12 // 010_010 |
---|
| 617 | #define OPCOD_L_MACI 0x13 // 010_011 |
---|
| 618 | #define OPCOD_L_CUST1 0x1c // 011_100 |
---|
| 619 | #define OPCOD_L_CUST2 0x1d // 011_101 |
---|
| 620 | #define OPCOD_L_CUST3 0x1e // 011_110 |
---|
| 621 | #define OPCOD_L_CUST4 0x1f // 011_111 |
---|
| 622 | #define OPCOD_L_CUST5 0x3c // 111_100 |
---|
| 623 | #define OPCOD_L_CUST6 0x3d // 111_101 |
---|
| 624 | #define OPCOD_L_CUST7 0x3e // 111_110 |
---|
| 625 | #define OPCOD_L_CUST8 0x3f // 111_111 |
---|
| 626 | #define OPCOD_L_LD 0x20 // 100_000 |
---|
| 627 | #define OPCOD_L_LWZ 0x21 // 100_001 |
---|
| 628 | #define OPCOD_L_LWS 0x22 // 100_010 |
---|
| 629 | #define OPCOD_L_LBZ 0x23 // 100_011 |
---|
| 630 | #define OPCOD_L_LBS 0x24 // 100_100 |
---|
| 631 | #define OPCOD_L_LHZ 0x25 // 100_101 |
---|
| 632 | #define OPCOD_L_LHS 0x26 // 100_110 |
---|
| 633 | #define OPCOD_L_ADDI 0x27 // 100_111 |
---|
| 634 | #define OPCOD_L_ADDIC 0x28 // 101_000 |
---|
| 635 | #define OPCOD_L_ANDI 0x29 // 101_001 |
---|
| 636 | #define OPCOD_L_ORI 0x2a // 101_010 |
---|
| 637 | #define OPCOD_L_XORI 0x2b // 101_011 |
---|
| 638 | #define OPCOD_L_MULI 0x2c // 101_100 |
---|
| 639 | #define OPCOD_L_MFSPR 0x2d // 101_101 |
---|
| 640 | #define OPCOD_L_MTSPR 0x30 // 110_000 |
---|
| 641 | #define OPCOD_L_SD 0x32 // 110_010 |
---|
| 642 | #define OPCOD_L_SW 0x35 // 110_101 |
---|
| 643 | #define OPCOD_L_SB 0x36 // 110_110 |
---|
| 644 | #define OPCOD_L_SH 0x37 // 110_111 |
---|
| 645 | |
---|
| 646 | #define OPCOD_INST_LV 0x0a // 001_010 // Instruction ORVDX64 |
---|
| 647 | #define OPCOD_INST_LF 0x33 // 110_011 // Instruction ORFPX32/64 |
---|
| 648 | |
---|
| 649 | #define OPCOD_SPECIAL 0x38 // 111_000 // Instructions Register-Register |
---|
| 650 | #define OPCOD_SPECIAL_1 0x39 // 111_001 // Instructions "set flag" with register |
---|
| 651 | #define OPCOD_SPECIAL_2 0x2f // 101_111 // Instructions "set flag" with immediat |
---|
| 652 | #define OPCOD_SPECIAL_6 0x2e // 101_110 // Instruction Shift/Rotate with immediat |
---|
| 653 | #define OPCOD_SPECIAL_7 0x31 // 110_001 // Instructions multiply with HI-LO |
---|
| 654 | #define OPCOD_SPECIAL_8 0x06 // 000_110 // Instructions acces at HI-LO |
---|
| 655 | |
---|
| 656 | // OPCOD_SPECIAL instructions - [9:8] [3:0] Instructions Register-Register |
---|
| 657 | #define OPCOD_L_ADD 0x00 // 00_0000 |
---|
| 658 | #define OPCOD_L_ADDC 0x01 // 00_0001 |
---|
| 659 | #define OPCOD_L_SUB 0x02 // 00_0010 |
---|
| 660 | #define OPCOD_L_AND 0x03 // 00_0011 |
---|
| 661 | #define OPCOD_L_OR 0x04 // 00_0100 |
---|
| 662 | #define OPCOD_L_XOR 0x05 // 00_0101 |
---|
| 663 | #define OPCOD_L_CMOV 0x0e // 00_1110 |
---|
| 664 | #define OPCOD_L_FF1 0x0f // 00_1111 |
---|
| 665 | #define OPCOD_L_FL1 0x1f // 01_1111 |
---|
| 666 | #define OPCOD_L_MUL 0x36 // 11_0110 |
---|
| 667 | #define OPCOD_L_DIV 0x39 // 11_1001 |
---|
| 668 | #define OPCOD_L_DIVU 0x3a // 11_1010 |
---|
| 669 | #define OPCOD_L_MULU 0x3b // 11_1011 |
---|
| 670 | |
---|
| 671 | #define OPCOD_SPECIAL_3 0xc // 1100 // Instructions extend |
---|
| 672 | #define OPCOD_SPECIAL_4 0xd // 1101 // Instructions extend (64b) |
---|
| 673 | #define OPCOD_SPECIAL_5 0x8 // 1000 // Instruction Shift/Rotate with register |
---|
| 674 | |
---|
| 675 | // OPCOD_SPECIAL_1 instructions - [25:21] Instructions "set flag" with register |
---|
| 676 | #define OPCOD_L_SFEQ 0x00 // 00000 |
---|
| 677 | #define OPCOD_L_SFNE 0x01 // 00001 |
---|
| 678 | #define OPCOD_L_SFGTU 0x02 // 00010 |
---|
| 679 | #define OPCOD_L_SFGEU 0x03 // 00011 |
---|
| 680 | #define OPCOD_L_SFLTU 0x04 // 00100 |
---|
| 681 | #define OPCOD_L_SFLEU 0x05 // 00101 |
---|
| 682 | #define OPCOD_L_SFGTS 0x0a // 01010 |
---|
| 683 | #define OPCOD_L_SFGES 0x0b // 01011 |
---|
| 684 | #define OPCOD_L_SFLTS 0x0c // 01100 |
---|
| 685 | #define OPCOD_L_SFLES 0x0d // 01101 |
---|
| 686 | |
---|
| 687 | // OPCOD_SPECIAL_2 instructions - [25:21] Instructions "set flag" with immediat |
---|
| 688 | #define OPCOD_L_SFEQI 0x00 // 00000 |
---|
| 689 | #define OPCOD_L_SFNEI 0x01 // 00001 |
---|
| 690 | #define OPCOD_L_SFGTUI 0x02 // 00010 |
---|
| 691 | #define OPCOD_L_SFGEUI 0x03 // 00011 |
---|
| 692 | #define OPCOD_L_SFLTUI 0x04 // 00100 |
---|
| 693 | #define OPCOD_L_SFLEUI 0x05 // 00101 |
---|
| 694 | #define OPCOD_L_SFGTSI 0x0a // 01010 |
---|
| 695 | #define OPCOD_L_SFGESI 0x0b // 01011 |
---|
| 696 | #define OPCOD_L_SFLTSI 0x0c // 01100 |
---|
| 697 | #define OPCOD_L_SFLESI 0x0d // 01101 |
---|
| 698 | |
---|
| 699 | // OPCOD_SPECIAL_3 instructions - [9:6] Instructions extend |
---|
| 700 | #define OPCOD_L_EXTHS 0x0 // 0000 |
---|
| 701 | #define OPCOD_L_EXTHZ 0x2 // 0010 |
---|
| 702 | #define OPCOD_L_EXTBS 0x1 // 0001 |
---|
| 703 | #define OPCOD_L_EXTBZ 0x3 // 0011 |
---|
| 704 | |
---|
| 705 | // OPCOD_SPECIAL_4 instructions - [9:6] Instructions extend (64b) |
---|
| 706 | #define OPCOD_L_EXTWS 0x0 // 0000 |
---|
| 707 | #define OPCOD_L_EXTWZ 0x1 // 0001 |
---|
| 708 | |
---|
| 709 | // OPCOD_SPECIAL_5 instructions - [7:6] Instruction Shift/Rotate with register |
---|
| 710 | #define OPCOD_L_SLL 0x0 // 00 |
---|
| 711 | #define OPCOD_L_SRL 0x1 // 01 |
---|
| 712 | #define OPCOD_L_SRA 0x2 // 10 |
---|
| 713 | #define OPCOD_L_ROR 0x3 // 11 |
---|
| 714 | |
---|
| 715 | // OPCOD_SPECIAL_6 instructions - [7:6] Instruction Shift/Rotate with immediat |
---|
| 716 | #define OPCOD_L_SLLI 0x0 // 00 |
---|
| 717 | #define OPCOD_L_SRLI 0x1 // 01 |
---|
| 718 | #define OPCOD_L_SRAI 0x2 // 10 |
---|
| 719 | #define OPCOD_L_RORI 0x3 // 11 |
---|
| 720 | |
---|
| 721 | // OPCOD_SPECIAL_7 instructions - [3:0] Instructions multiply with HI-LO |
---|
| 722 | #define OPCOD_L_MAC 0x1 // 0001 |
---|
| 723 | #define OPCOD_L_MSB 0x2 // 0010 |
---|
| 724 | |
---|
| 725 | // OPCOD_SPECIAL_8 instructions - [17] Instructions acces at HI-LO |
---|
| 726 | #define OPCOD_L_MOVHI 0x0 // 0 |
---|
| 727 | #define OPCOD_L_MACRC 0x1 // 1 |
---|
| 728 | |
---|
| 729 | // Particular case Instructions systems |
---|
| 730 | #define OPCOD_L_MSYNC 0x22000000 |
---|
| 731 | #define OPCOD_L_CSYNC 0x23000000 |
---|
| 732 | #define OPCOD_L_PSYNC 0x22800000 |
---|
| 733 | #define OPCOD_L_NOP 0x1500 |
---|
| 734 | #define OPCOD_L_SYS 0x2000 |
---|
| 735 | #define OPCOD_L_TRAP 0x2100 |
---|
| 736 | |
---|
| 737 | //---------------------------------------------------- |
---|
| 738 | // Code Operation (after decode) |
---|
| 739 | //---------------------------------------------------- |
---|
| 740 | |
---|
| 741 | typedef enum |
---|
| 742 | { |
---|
| 743 | // ##### WARNING : This opcode must be the first##### |
---|
| 744 | INST_L_NO_IMPLEMENTED , // Operation is not implemented |
---|
| 745 | |
---|
| 746 | INST_L_ADD , // L.ADD , L.ADDI , L.ADDC , L.ADDIC |
---|
| 747 | INST_L_AND , // L.AND , L.ANDI |
---|
| 748 | INST_L_OR , // L.OR , L.ORI |
---|
| 749 | INST_L_XOR , // L.XOR , L.XORI |
---|
| 750 | INST_L_CMOV , // L.CMOV |
---|
| 751 | INST_L_SUB , // L.SUB |
---|
| 752 | INST_L_FF1 , // L.FF1 |
---|
| 753 | INST_L_EXTBS , // L.EXTBS |
---|
| 754 | INST_L_EXTBZ , // L.EXTBZ |
---|
| 755 | INST_L_EXTHS , // L.EXTHS |
---|
| 756 | INST_L_EXTHZ , // L.EXTHZ |
---|
| 757 | INST_L_EXTWS , // L.EXTWS |
---|
| 758 | INST_L_EXTWZ , // L.EXTWZ |
---|
| 759 | INST_L_e , // |
---|
| 760 | INST_L_f , // |
---|
| 761 | INST_L_MUL , // L.MUL , L.MULI |
---|
| 762 | INST_L_MULU , // L.MULU |
---|
| 763 | INST_L_DIV , // L.DIV |
---|
| 764 | INST_L_DIVU , // L.DIVU |
---|
| 765 | INST_L_SLL , // L.SLL , L.SLLI |
---|
| 766 | INST_L_SRL , // L.SRL , L.SRLI |
---|
| 767 | INST_L_SRA , // L.SRA , L.SRAI |
---|
| 768 | INST_L_ROR , // L.ROR , L.RORI |
---|
| 769 | INST_L_SFGES , // L.SFGES , L.SFGESI |
---|
| 770 | INST_L_SFGEU , // L.SFGEU , L.SFGEUI |
---|
| 771 | INST_L_SFGTS , // L.SFGTS , L.SFGTSI |
---|
| 772 | INST_L_SFGTU , // L.SFGTU , L.SFGTUI |
---|
| 773 | INST_L_SFLES , // L.SFLES , L.SFLESI |
---|
| 774 | INST_L_SFLEU , // L.SFLEU , L.SFLEUI |
---|
| 775 | INST_L_SFLTS , // L.SFLTS , L.SFLTSI |
---|
| 776 | INST_L_SFLTU , // L.SFLTU , L.SFLTUI |
---|
| 777 | INST_L_SFEQ , // L.SFEQ , L.SFEQI |
---|
| 778 | INST_L_SFNE , // L.SFNE , L.SFNEI |
---|
| 779 | INST_L_READ , // L.BNF , L.BF , L.JR |
---|
| 780 | INST_L_MOVHI , // L.MOVI |
---|
| 781 | INST_L_CSYNC , // L.CSYNC |
---|
| 782 | INST_L_MSYNC , // L.MSYNC |
---|
| 783 | INST_L_PSYNC , // L.PSYNC |
---|
| 784 | INST_L_RFE , // L.RFE |
---|
| 785 | INST_L_MAC , // L.MAC , L.MACI |
---|
| 786 | INST_L_MSB , // L.MSB |
---|
| 787 | INST_L_MACRC , // L.MACRC |
---|
| 788 | INST_L_2b , // |
---|
| 789 | INST_L_MEMB , // L.LBS , L.LBZ , L.SB |
---|
| 790 | INST_L_MEMH , // L.LHS , L.LHZ , L.SH |
---|
| 791 | INST_L_MEMW , // L.LWS , L.LWZ , L.SW |
---|
| 792 | INST_L_MEMD , // L.LD , L.SD |
---|
| 793 | INST_L_CUST1 , // L.CUST1 |
---|
| 794 | INST_L_CUST2 , // L.CUST2 |
---|
| 795 | INST_L_CUST3 , // L.CUST3 |
---|
| 796 | INST_L_CUST4 , // L.CUST4 |
---|
| 797 | INST_L_CUST5 , // L.CUST5 |
---|
| 798 | INST_L_CUST6 , // L.CUST6 |
---|
| 799 | INST_L_CUST7 , // L.CUST7 |
---|
| 800 | INST_L_CUST8 , // L.CUST8 |
---|
| 801 | INST_L_38 , // |
---|
| 802 | INST_L_39 , // |
---|
| 803 | INST_L_3a , // |
---|
| 804 | INST_L_3b , // |
---|
| 805 | INST_L_3c , // |
---|
| 806 | INST_L_3d , // |
---|
| 807 | INST_L_3e , // |
---|
| 808 | INST_NOP // L.NOP |
---|
| 809 | } opcod_t; |
---|
| 810 | |
---|
| 811 | #define LOG2_NB_INST_L 6 |
---|
| 812 | #define NB_INST_L 64 // +1 -> INST_L_NO_IMPLEMENTED |
---|
| 813 | //#define NB_INST_L (INST_L_NO_IMPLEMENTED+1) |
---|
| 814 | */ |
---|
| 815 | |
---|
| 816 | }; // end namespace behavioural |
---|
| 817 | }; // end namespace morpheo |
---|
| 818 | |
---|
| 819 | #endif |
---|