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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [sim/] [instr.h] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 hellwig
/*
2
 * instr.h -- instruction encoding
3
 */
4
 
5
 
6
#ifndef _INSTR_H_
7
#define _INSTR_H_
8
 
9
 
10
#define FORMAT_N        0        /* no operands */
11
#define FORMAT_RH       1       /* one register and a half operand */
12
#define FORMAT_RHH      2       /* one register and a half operand */
13
                                /* ATTENTION: high-order 16 bits encoded */
14
#define FORMAT_RRH      3       /* two registers and a half operand */
15
#define FORMAT_RRS      4       /* two registers and a signed half operand */
16
#define FORMAT_RRR      5       /* three register operands */
17
#define FORMAT_RRX      6       /* either FORMAT_RRR or FORMAT_RRH */
18
#define FORMAT_RRY      7       /* either FORMAT_RRR or FORMAT_RRS */
19
#define FORMAT_RRB      8       /* two registers and a 16 bit signed
20
                                   offset operand */
21
#define FORMAT_J        9       /* no registers and a 26 bit signed
22
                                   offset operand */
23
#define FORMAT_JR       10      /* one register operand */
24
 
25
 
26
#define MASK(n)         ((((Word) 1) << n) - 1)
27
#define SIGN(n)         (((Word) 1) << (n - 1))
28
#define ZEXT16(x)       (((Word) (x)) & MASK(16))
29
#define SEXT16(x)       (((Word) (x)) & SIGN(16) ? \
30
                         (((Word) (x)) | ~MASK(16)) : \
31
                         (((Word) (x)) & MASK(16)))
32
#define SEXT26(x)       (((Word) (x)) & SIGN(26) ? \
33
                         (((Word) (x)) | ~MASK(26)) : \
34
                         (((Word) (x)) & MASK(26)))
35
 
36
 
37
#define OP_ADD          0x00
38
#define OP_ADDI         0x01
39
#define OP_SUB          0x02
40
#define OP_SUBI         0x03
41
 
42
#define OP_MUL          0x04
43
#define OP_MULI         0x05
44
#define OP_MULU         0x06
45
#define OP_MULUI        0x07
46
#define OP_DIV          0x08
47
#define OP_DIVI         0x09
48
#define OP_DIVU         0x0A
49
#define OP_DIVUI        0x0B
50
#define OP_REM          0x0C
51
#define OP_REMI         0x0D
52
#define OP_REMU         0x0E
53
#define OP_REMUI        0x0F
54
 
55
#define OP_AND          0x10
56
#define OP_ANDI         0x11
57
#define OP_OR           0x12
58
#define OP_ORI          0x13
59
#define OP_XOR          0x14
60
#define OP_XORI         0x15
61
#define OP_XNOR         0x16
62
#define OP_XNORI        0x17
63
 
64
#define OP_SLL          0x18
65
#define OP_SLLI         0x19
66
#define OP_SLR          0x1A
67
#define OP_SLRI         0x1B
68
#define OP_SAR          0x1C
69
#define OP_SARI         0x1D
70
 
71
#define OP_LDHI         0x1F
72
 
73
#define OP_BEQ          0x20
74
#define OP_BNE          0x21
75
#define OP_BLE          0x22
76
#define OP_BLEU         0x23
77
#define OP_BLT          0x24
78
#define OP_BLTU         0x25
79
#define OP_BGE          0x26
80
#define OP_BGEU         0x27
81
#define OP_BGT          0x28
82
#define OP_BGTU         0x29
83
 
84
#define OP_J            0x2A
85
#define OP_JR           0x2B
86
#define OP_JAL          0x2C
87
#define OP_JALR         0x2D
88
 
89
#define OP_TRAP         0x2E
90
#define OP_RFX          0x2F
91
 
92
#define OP_LDW          0x30
93
#define OP_LDH          0x31
94
#define OP_LDHU         0x32
95
#define OP_LDB          0x33
96
#define OP_LDBU         0x34
97
 
98
#define OP_STW          0x35
99
#define OP_STH          0x36
100
#define OP_STB          0x37
101
 
102
#define OP_MVFS         0x38
103
#define OP_MVTS         0x39
104
#define OP_TBS          0x3A
105
#define OP_TBWR         0x3B
106
#define OP_TBRI         0x3C
107
#define OP_TBWI         0x3D
108
 
109
 
110
typedef struct {
111
  char *name;
112
  int format;
113
  Byte opcode;
114
} Instr;
115
 
116
 
117
extern Instr instrTbl[];
118
extern Instr *instrCodeTbl[];
119
 
120
 
121
void initInstrTable(void);
122
Instr *lookupInstr(char *name);
123
 
124
 
125
#endif /* _INSTR_H_ */

powered by: WebSVN 2.1.0

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