OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1ksim/] [cpu/] [or1k/] [opcode/] [or32.h] - Blame information for rev 35

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jeremybenn
/* Table of opcodes for the OpenRISC 1000 ISA.
2
 
3
   Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
4
   Copyright (C) 2008 Embecosm Limited
5
 
6
   Contributed by Damjan Lampret (lampret@opencores.org).
7
   Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
8
 
9
   This file is part of Or1ksim, the OpenRISC 1000 Architectural Simulator.
10
   This file is also part of or1k_gen_isa, GDB and GAS.
11
 
12
   This program is free software; you can redistribute it and/or modify it
13
   under the terms of the GNU General Public License as published by the Free
14
   Software Foundation; either version 3 of the License, or (at your option)
15
   any later version.
16
 
17
   This program is distributed in the hope that it will be useful, but WITHOUT
18
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
20
   more details.
21
 
22
   You should have received a copy of the GNU General Public License along
23
   with this program.  If not, see <http://www.gnu.org/licenses/>.  */
24
 
25
/* This program is commented throughout in a fashion suitable for processing
26
   with Doxygen. */
27
 
28
/* We treat all letters the same in encode/decode routines so
29
   we need to assign some characteristics to them like signess etc.*/
30
 
31
#ifndef OR32_H_ISA
32
#define OR32_H_ISA
33
 
34
#define NUM_UNSIGNED (0)
35
#define NUM_SIGNED (1)
36
 
37
#ifndef PARAMS
38
#define PARAMS(x) x
39
#endif
40
 
41
#ifndef CONST
42
#define CONST const
43
#endif
44
 
45
#define MAX_GPRS 32
46
#define PAGE_SIZE 8192
47
#undef __HALF_WORD_INSN__
48
 
49
#define OPERAND_DELIM (',')
50
 
51
#define OR32_IF_DELAY (1)
52
#define OR32_W_FLAG   (2)
53
#define OR32_R_FLAG   (4)
54
 
55
#if defined(HAVE_EXECUTION)
56
# if SIMPLE_EXECUTION
57
#  include "simpl32-defs.h"
58
# elif DYNAMIC_EXECUTION
59
#  include "dyn32-defs.h"
60
# else
61
extern void l_none PARAMS((void));
62
# endif
63
#else
64
extern void l_none PARAMS((void));
65
#endif
66
 
67
 
68
struct or32_letter {
69
  char letter;
70
  int  sign;
71
  /* int  reloc; relocation per letter ??*/
72
};
73
 
74
enum insn_type {
75
 it_unknown,
76
 it_exception,
77
 it_arith,
78
 it_shift,
79
 it_compare,
80
 it_branch,
81
 it_jump,
82
 it_load,
83
 it_store,
84
 it_movimm,
85
 it_move,
86
 it_extend,
87
 it_nop,
88
 it_mac,
89
 it_float };
90
 
91
/* Main instruction specification array.  */
92
struct or32_opcode {
93
  /* Name of the instruction.  */
94
  char *name;
95
 
96
  /* A string of characters which describe the operands.
97
     Valid characters are:
98
     ,() Itself.  Characters appears in the assembly code.
99
     rA  Register operand.
100
     rB  Register operand.
101
     rD  Register operand (destination).
102
     I   An immediate operand, range -32768 to 32767.
103
     J   An immediate operand, range . (unused)
104
     K   An immediate operand, range 0 to 65535.
105
     L   An immediate operand, range 0 to 63.
106
     M   An immediate operand, range . (unused)
107
     N   An immediate operand, range -33554432 to 33554431.
108
     O   An immediate operand, range . (unused) */
109
  char *args;
110
 
111
  /* Opcode and operand encoding. */
112
  char *encoding;
113
 
114
#ifdef HAVE_EXECUTION
115
# if COMPLEX_EXECUTION
116
  char *function_name;
117
# elif SIMPLE_EXECUTION
118
  void (*exec)(struct iqueue_entry *);
119
# else /* DYNAMIC_EXECUTION */
120
  void (*exec)(struct op_queue *opq, int param_t[3], int);
121
# endif
122
#else  /* HAVE_EXECUTION */
123
  void (*exec)(void);
124
#endif
125
 
126
  unsigned int flags;
127
  enum insn_type func_unit;
128
};
129
 
130
/* This operand is the last in the list */
131
#define OPTYPE_LAST (0x80000000)
132
/* This operand marks the end of the operand sequence (for things like I(rD)) */
133
#define OPTYPE_OP   (0x40000000)
134
/* The operand specifies a register index */
135
#define OPTYPE_REG  (0x20000000)
136
/* The operand must be sign extended */
137
#define OPTYPE_SIG  (0x10000000)
138
/* Operand is a relative address, the `I' in `I(rD)' */
139
#define OPTYPE_DIS  (0x08000000)
140
/* The operand is a destination */
141
#define OPTYPE_DST  (0x04000000)
142
/* Which bit of the operand is the sign bit */
143
#define OPTYPE_SBIT (0x00001F00)
144
/* Amount to shift the instruction word right to get the operand */
145
#define OPTYPE_SHR  (0x0000001F)
146
#define OPTYPE_SBIT_SHR (8)
147
 
148
/* MM: Data how to decode operands.  */
149
extern struct insn_op_struct {
150
  unsigned long type;
151
  unsigned long data;
152
} **op_start;
153
 
154
/* Leaf flag used in automata building */
155
#define LEAF_FLAG         (0x80000000)
156
 
157
struct temp_insn_struct
158
{
159
  unsigned long insn;
160
  unsigned long insn_mask;
161
  int in_pass;
162
};
163
 
164
extern unsigned long *automata;
165
extern struct temp_insn_struct *ti;
166
 
167
extern CONST struct or32_letter or32_letters[];
168
 
169
extern CONST struct  or32_opcode or32_opcodes[];
170
 
171
extern CONST int num_opcodes;
172
 
173
extern char *disassembled;
174
 
175
/* Calculates instruction length in bytes.  Always 4 for OR32. */
176
extern int insn_len PARAMS((int insn_index));
177
 
178
/* Is individual insn's operand signed or unsigned? */
179
extern int letter_signed PARAMS((char l));
180
 
181
/* Number of letters in the individual lettered operand. */
182
extern int letter_range PARAMS((char l));
183
 
184
/* MM: Returns index of given instruction name.  */
185
extern int insn_index PARAMS((char *insn));
186
 
187
/* MM: Returns instruction name from index.  */
188
extern CONST char *insn_name PARAMS ((int index));
189
 
190
/* MM: Constructs new FSM, based on or32_opcodes.  */
191
extern void build_automata PARAMS ((void));
192
 
193
/* MM: Destructs FSM.  */
194
extern void destruct_automata PARAMS ((void));
195
 
196
/* MM: Decodes instruction using FSM.  Call build_automata first.  */
197
extern int insn_decode PARAMS((unsigned int insn));
198
 
199
/* Disassemble one instruction from insn to disassemble.
200
   Return the size of the instruction.  */
201
int disassemble_insn (unsigned long insn);
202
 
203
/* Disassemble one instruction from insn index.
204
   Return the size of the instruction.  */
205
int disassemble_index (unsigned long insn, int index);
206
 
207
/* FOR INTERNAL USE ONLY */
208
/* Automatically does zero- or sign- extension and also finds correct
209
   sign bit position if sign extension is correct extension. Which extension
210
   is proper is figured out from letter description. */
211
unsigned long extend_imm(unsigned long imm, char l);
212
 
213
/* Extracts value from opcode */
214
unsigned long or32_extract(char param_ch, char *enc_initial, unsigned long insn);
215
 
216
#endif
217
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.