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

Subversion Repositories openrisc

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

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
# endif
59
#endif
60
 
61
 
62
struct or32_letter {
63
  char letter;
64
  int  sign;
65
  /* int  reloc; relocation per letter ??*/
66
};
67
 
68
enum insn_type {
69
 it_unknown,
70
 it_exception,
71
 it_arith,
72
 it_shift,
73
 it_compare,
74
 it_branch,
75
 it_jump,
76
 it_load,
77
 it_store,
78
 it_movimm,
79
 it_move,
80
 it_extend,
81
 it_nop,
82
 it_mac,
83
 it_float };
84
 
85
/* Main instruction specification array.  */
86
struct or32_opcode {
87
  /* Name of the instruction.  */
88
  char *name;
89
 
90
  /* A string of characters which describe the operands.
91
     Valid characters are:
92
     ,() Itself.  Characters appears in the assembly code.
93
     rA  Register operand.
94
     rB  Register operand.
95
     rD  Register operand (destination).
96
     I   An immediate operand, range -32768 to 32767.
97
     J   An immediate operand, range . (unused)
98
     K   An immediate operand, range 0 to 65535.
99
     L   An immediate operand, range 0 to 63.
100
     M   An immediate operand, range . (unused)
101
     N   An immediate operand, range -33554432 to 33554431.
102
     O   An immediate operand, range . (unused) */
103
  char *args;
104
 
105
  /* Opcode and operand encoding. */
106
  char *encoding;
107
 
108
#ifdef HAVE_EXECUTION
109
# if COMPLEX_EXECUTION
110
  char *function_name;
111
# elif SIMPLE_EXECUTION
112
  void (*exec)(struct iqueue_entry *);
113
# endif
114
#else  /* HAVE_EXECUTION */
115
  void (*exec)(void);
116
#endif
117
 
118
  unsigned int flags;
119
  enum insn_type func_unit;
120
};
121
 
122
/* This operand is the last in the list */
123
#define OPTYPE_LAST (0x80000000)
124
/* This operand marks the end of the operand sequence (for things like I(rD)) */
125
#define OPTYPE_OP   (0x40000000)
126
/* The operand specifies a register index */
127
#define OPTYPE_REG  (0x20000000)
128
/* The operand must be sign extended */
129
#define OPTYPE_SIG  (0x10000000)
130
/* Operand is a relative address, the `I' in `I(rD)' */
131
#define OPTYPE_DIS  (0x08000000)
132
/* The operand is a destination */
133
#define OPTYPE_DST  (0x04000000)
134
/* Which bit of the operand is the sign bit */
135
#define OPTYPE_SBIT (0x00001F00)
136
/* Amount to shift the instruction word right to get the operand */
137
#define OPTYPE_SHR  (0x0000001F)
138
#define OPTYPE_SBIT_SHR (8)
139
 
140
/* MM: Data how to decode operands.  */
141
extern struct insn_op_struct {
142
  unsigned long type;
143
  unsigned long data;
144 230 jeremybenn
} **or1ksim_op_start;
145 19 jeremybenn
 
146
/* Leaf flag used in automata building */
147
#define LEAF_FLAG         (0x80000000)
148
 
149
struct temp_insn_struct
150
{
151
  unsigned long insn;
152
  unsigned long insn_mask;
153
  int in_pass;
154
};
155
 
156 420 jeremybenn
 
157 230 jeremybenn
extern unsigned long *or1ksim_automata;
158
extern struct temp_insn_struct *or1ksim_ti;
159 19 jeremybenn
 
160 230 jeremybenn
extern CONST struct  or32_opcode  or1ksim_or32_opcodes[];
161 19 jeremybenn
 
162 230 jeremybenn
extern char *or1ksim_disassembled;
163 19 jeremybenn
 
164 420 jeremybenn
/* trace data */
165
extern int           trace_dest_reg;
166
extern int           trace_store_addr_reg;
167
extern unsigned int  trace_store_imm;
168
extern int           trace_store_val_reg;
169
extern int           trace_store_width;
170 458 julius
extern int           trace_dest_spr;
171 420 jeremybenn
 
172 19 jeremybenn
/* Calculates instruction length in bytes.  Always 4 for OR32. */
173 230 jeremybenn
extern int or1ksim_insn_len PARAMS((int insn_index));
174 19 jeremybenn
 
175
/* MM: Returns instruction name from index.  */
176 230 jeremybenn
extern CONST char *or1ksim_insn_name PARAMS ((int index));
177 19 jeremybenn
 
178 230 jeremybenn
/* MM: Constructs new FSM, based on or1ksim_or32_opcodes.  */
179
extern void or1ksim_build_automata PARAMS ((int  quiet));
180 19 jeremybenn
 
181
/* MM: Destructs FSM.  */
182 230 jeremybenn
extern void or1ksim_destruct_automata PARAMS ((void));
183 19 jeremybenn
 
184 230 jeremybenn
/* MM: Decodes instruction using FSM.  Call or1ksim_build_automata first.  */
185
extern int or1ksim_insn_decode PARAMS((unsigned int insn));
186 19 jeremybenn
 
187
/* Disassemble one instruction from insn to disassemble.
188
   Return the size of the instruction.  */
189 230 jeremybenn
extern int or1ksim_disassemble_insn (unsigned long insn);
190 19 jeremybenn
 
191
/* Disassemble one instruction from insn index.
192
   Return the size of the instruction.  */
193 230 jeremybenn
int or1ksim_disassemble_index (unsigned long insn, int index);
194 19 jeremybenn
 
195 420 jeremybenn
/* Disassemble one instruction from insn index for tracing. */
196
void or1ksim_disassemble_trace_index (unsigned long int  insn,
197
                                      int                index);
198
 
199 19 jeremybenn
/* FOR INTERNAL USE ONLY */
200
/* Automatically does zero- or sign- extension and also finds correct
201
   sign bit position if sign extension is correct extension. Which extension
202
   is proper is figured out from letter description. */
203 230 jeremybenn
unsigned long or1ksim_extend_imm(unsigned long imm, char l);
204 19 jeremybenn
 
205
/* Extracts value from opcode */
206 230 jeremybenn
unsigned long or1ksim_or32_extract(char param_ch, char *enc_initial, unsigned long insn);
207 19 jeremybenn
 
208
#endif
209
 

powered by: WebSVN 2.1.0

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