Add code to download csv files from wiki if they don't exist
[soc.git] / src / decoder / power_enums.py
1 from enum import Enum, unique
2 import csv
3 import os
4 import requests
5
6 def get_csv(name):
7 file_dir = os.path.dirname(os.path.realpath(__file__))
8 file_path = os.path.join(file_dir, name)
9 if not os.path.isfile(file_path):
10 url = 'https://libre-riscv.org/openpower/isatables/' + name
11 r = requests.get(url, allow_redirects=True)
12 with open(file_path, 'w') as outfile:
13 outfile.write(r.content.decode("utf-8"))
14 with open(file_path, 'r') as csvfile:
15 reader = csv.DictReader(csvfile)
16 return list(reader)
17
18 @unique
19 class Function(Enum):
20 ALU = 0
21 LDST = 1
22
23
24 @unique
25 class InternalOp(Enum):
26 OP_ADD = 0
27 OP_AND = 1
28 OP_B = 2
29 OP_BC = 3
30 OP_CMP = 4
31 OP_LOAD = 5
32 OP_MUL_L64 = 6
33 OP_OR = 7
34 OP_RLC = 8
35 OP_STORE = 9
36 OP_TDI = 10
37 OP_XOR = 11
38
39
40 @unique
41 class In1Sel(Enum):
42 RA = 0
43 RA_OR_ZERO = 1
44 NONE = 2
45 SPR = 3
46
47
48 @unique
49 class In2Sel(Enum):
50 CONST_SI = 0
51 CONST_SI_HI = 1
52 CONST_UI = 2
53 CONST_UI_HI = 3
54 CONST_LI = 4
55 CONST_BD = 5
56 CONST_SH32 = 6
57 RB = 7
58
59
60 @unique
61 class In3Sel(Enum):
62 NONE = 0
63 RS = 1
64
65
66 @unique
67 class OutSel(Enum):
68 RT = 0
69 RA = 1
70 NONE = 2
71 SPR = 3
72
73
74 @unique
75 class LdstLen(Enum):
76 NONE = 0
77 is1B = 1
78 is2B = 2
79 is4B = 3
80
81
82 @unique
83 class RC(Enum):
84 NONE = 0
85 ONE = 1
86 RC = 2
87
88
89 @unique
90 class CryIn(Enum):
91 ZERO = 0
92 ONE = 1
93 CA = 2