Add default case to decoder
[soc.git] / src / decoder / power_enums.py
1 from enum import Enum, unique
2 import csv
3 import os
4 import requests
5
6
7 def get_csv(name):
8 file_dir = os.path.dirname(os.path.realpath(__file__))
9 file_path = os.path.join(file_dir, name)
10 if not os.path.isfile(file_path):
11 url = 'https://libre-riscv.org/openpower/isatables/' + name
12 r = requests.get(url, allow_redirects=True)
13 with open(file_path, 'w') as outfile:
14 outfile.write(r.content.decode("utf-8"))
15 with open(file_path, 'r') as csvfile:
16 reader = csv.DictReader(csvfile)
17 return list(reader)
18
19
20 # names of the fields in the tables that don't correspond to an enum
21 single_bit_flags = ['CR in', 'CR out', 'inv A', 'inv out',
22 'cry out', 'BR', 'sgn ext', 'upd', 'rsrv', '32b',
23 'sgn', 'lk', 'sgl pipe']
24
25
26 def get_signal_name(name):
27 return name.lower().replace(' ', '_')
28
29
30 @unique
31 class Function(Enum):
32 NONE = 0
33 ALU = 1
34 LDST = 2
35
36
37 @unique
38 class InternalOp(Enum):
39 OP_ILLEGAL = 0
40 OP_NOP = 1
41 OP_ADD = 2
42 OP_ADDPCIS = 3
43 OP_AND = 4
44 OP_ATTN = 5
45 OP_B = 6
46 OP_BC = 7
47 OP_BCREG = 8
48 OP_BPERM = 9
49 OP_CMP = 10
50 OP_CMPB = 11
51 OP_CMPEQB = 12
52 OP_CMPRB = 13
53 OP_CNTZ = 14
54 OP_CRAND = 15
55 OP_CRANDC = 16
56 OP_CREQV = 17
57 OP_CRNAND = 18
58 OP_CRNOR = 19
59 OP_CROR = 20
60 OP_CRORC = 21
61 OP_CRXOR = 22
62 OP_DARN = 23
63 OP_DCBF = 24
64 OP_DCBST = 25
65 OP_DCBT = 26
66 OP_DCBTST = 27
67 OP_DCBZ = 28
68 OP_DIV = 29
69 OP_DIVE = 30
70 OP_EXTS = 31
71 OP_EXTSWSLI = 32
72 OP_ICBI = 33
73 OP_ICBT = 34
74 OP_ISEL = 35
75 OP_ISYNC = 36
76 OP_LOAD = 37
77 OP_STORE = 38
78 OP_MADDHD = 39
79 OP_MADDHDU = 40
80 OP_MADDLD = 41
81 OP_MCRF = 42
82 OP_MCRXR = 43
83 OP_MCRXRX = 44
84 OP_MFCR = 45
85 OP_MFSPR = 46
86 OP_MOD = 47
87 OP_MTCRF = 48
88 OP_MTSPR = 49
89 OP_MUL_L64 = 50
90 OP_MUL_H64 = 51
91 OP_MUL_H32 = 52
92 OP_OR = 53
93 OP_POPCNT = 54
94 OP_PRTY = 55
95 OP_RLC = 56
96 OP_RLCL = 57
97 OP_RLCR = 58
98 OP_SETB = 59
99 OP_SHL = 60
100 OP_SHR = 61
101 OP_SYNC = 62
102 OP_TD = 63
103 OP_TDI = 64
104 OP_TW = 65
105 OP_TWI = 66
106 OP_XOR = 67
107 OP_SIM_CONFIG = 68
108
109
110 @unique
111 class In1Sel(Enum):
112 RA = 0
113 RA_OR_ZERO = 1
114 NONE = 2
115 SPR = 3
116
117
118 @unique
119 class In2Sel(Enum):
120 NONE = 0
121 RB = 1
122 CONST_UI = 2
123 CONST_SI = 3
124 CONST_UI_HI = 4
125 CONST_SI_HI = 5
126 CONST_LI = 6
127 CONST_BD = 7
128 CONST_DS = 8
129 CONST_M1 = 9
130 CONST_SH = 10
131 CONST_SH32 = 11
132 SPR = 12
133
134
135 @unique
136 class In3Sel(Enum):
137 NONE = 0
138 RS = 1
139
140
141 @unique
142 class OutSel(Enum):
143 NONE = 0
144 RT = 1
145 RA = 2
146 SPR = 3
147
148
149 @unique
150 class LdstLen(Enum):
151 NONE = 0
152 is1B = 1
153 is2B = 2
154 is4B = 3
155 is8B = 4
156
157
158 @unique
159 class RC(Enum):
160 NONE = 0
161 ONE = 1
162 RC = 2
163
164
165 @unique
166 class CryIn(Enum):
167 ZERO = 0
168 ONE = 1
169 CA = 2