2008-11-27 Øyvind Harboe <oyvind.harboe@zylin.com>
[nios2ecos.git] / packages / hal / nios2 / arch / current / include / nios2_opcode.h
blob8a8ef6b81a5ff0fce149813deb7d5d3635cbd1e9
1 #ifndef CYGONCE_NIOS2_OPCODE_H
2 #define CYGONCE_NIOS2_OPCODE_H
4 //=============================================================================
5 //
6 // nios2_opcode.h
7 //
8 // Opcodes for Nios II.
9 //
10 //=============================================================================
11 //####ECOSGPLCOPYRIGHTBEGIN####
12 // -------------------------------------------
13 // This file is part of eCos, the Embedded Configurable Operating System.
15 // eCos is free software; you can redistribute it and/or modify it under
16 // the terms of the GNU General Public License as published by the Free
17 // Software Foundation; either version 2 or (at your option) any later version.
19 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
20 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 // for more details.
24 // You should have received a copy of the GNU General Public License along
25 // with eCos; if not, write to the Free Software Foundation, Inc.,
26 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28 // As a special exception, if other files instantiate templates or use macros
29 // or inline functions from this file, or you compile this file and link it
30 // with other works to produce a work based on this file, this file does not
31 // by itself cause the resulting work to be covered by the GNU General Public
32 // License. However the source code for this file must still be made available
33 // in accordance with section (3) of the GNU General Public License.
35 // This exception does not invalidate any other reasons why a work based on
36 // this file might be covered by the GNU General Public License.
38 // -------------------------------------------
39 //####ECOSGPLCOPYRIGHTEND####
40 //=============================================================================
42 // Provide structures and defines used for decoding Nios II instructions
44 // Define the instruction formats.
46 typedef union {
47 unsigned word;
49 struct {
50 unsigned op: 6;
51 unsigned imm: 16;
52 unsigned b: 5;
53 unsigned a: 5;
54 } IType;
56 struct {
57 unsigned op: 6;
58 unsigned blank: 5;
59 unsigned opx: 6;
60 unsigned c: 5;
61 unsigned b: 5;
62 unsigned a: 5;
63 } RType;
65 struct {
66 unsigned op: 6;
67 unsigned imm: 26;
68 } JType;
69 } InstFmt;
71 //Values for the 'op' field.
73 #define OP_ADDI 0x04
74 #define OP_ANDHI 0x2c
75 #define OP_ANDI 0x0c
76 #define OP_BEQ 0x26
77 #define OP_BGE 0x0e
78 #define OP_BGEU 0x2e
79 #define OP_BLT 0x16
80 #define OP_BLTU 0x36
81 #define OP_BNE 0x1e
82 #define OP_BR 0x06
83 #define OP_CALL 0x00
84 #define OP_CMPEQI 0x20
85 #define OP_CMPGEI 0x08
86 #define OP_CMPGEUI 0x28
87 #define OP_CMPLTI 0x10
88 #define OP_CMPLTUI 0x30
89 #define OP_CMPNEI 0x18
90 #define OP_FLUSHD 0x3b
91 #define OP_LDB 0x07
92 #define OP_LDBIO 0x27
93 #define OP_LDBU 0x03
94 #define OP_LDBUIO 0x23
95 #define OP_LDH 0x0f
96 #define OP_LDHIO 0x2f
97 #define OP_LDHU 0x0b
98 #define OP_LDHUIO 0x2b
99 #define OP_LDW 0x17
100 #define OP_LDWIO 0x37
101 #define OP_MULI 0x24
102 #define OP_ORHI 0x34
103 #define OP_ORI 0x14
104 #define OP_STB 0x05
105 #define OP_STBIO 0x25
106 #define OP_STH 0x0d
107 #define OP_STHIO 0x2d
108 #define OP_STW 0x15
109 #define OP_STWIO 0x35
110 #define OP_USR 0x32
111 #define OP_XORHI 0x3c
112 #define OP_XORI 0x1c
113 #define OP_RTYPE 0x3a
115 // Values of the 'opx' field for when the opcode = OP_RTYPE
117 #define OPX_ERET 0x01
118 #define OPX_ROLI 0x02
119 #define OPX_ROL 0x03
120 #define OPX_FLUSHP 0x04
121 #define OPX_RET 0x05
122 #define OPX_NOR 0x06
123 #define OPX_MULXUU 0x07
124 #define OPX_CMPGE 0x08
125 #define OPX_BRET 0x09
126 #define OPX_ROR 0x0b
127 #define OPX_FLUSHI 0x0c
128 #define OPX_JMP 0x0d
129 #define OPX_AND 0x0e
130 #define OPX_CMPLT 0x10
131 #define OPX_SLLI 0x12
132 #define OPX_SLL 0x13
133 #define OPX_OR 0x16
134 #define OPX_MULXSU 0x17
135 #define OPX_CMPNE 0x18
136 #define OPX_SRLI 0x1a
137 #define OPX_SRL 0x1b
138 #define OPX_NEXTPC 0x1c
139 #define OPX_CALLR 0x1d
140 #define OPX_XOR 0x1e
141 #define OPX_MULXSS 0x1f
142 #define OPX_CMPEQ 0x20
143 #define OPX_DIVU 0x24
144 #define OPX_DIV 0x25
145 #define OPX_RDCTL 0x26
146 #define OPX_MUL 0x27
147 #define OPX_CMPGEU 0x28
148 #define OPX_TRAP 0x2d
149 #define OPX_WRCTL 0x2e
150 #define OPX_CMPLTU 0x30
151 #define OPX_ADD 0x31
152 #define OPX_BREAK 0x34
153 #define OPX_SYNC 0x36
154 #define OPX_SUB 0x39
155 #define OPX_SRAI 0x3a
156 #define OPX_SRA 0x3b
158 // Instructions with specal significance to debuggers.
160 #define BREAK_INSTR 0x005b603a // instruction code for break (actually trap)
161 #define NOP_INSTR 0x0001883a // instruction code for no-op
163 #endif // CYGONCE_NIOS2_OPCODE_H