4 * Copyright 2018 Jacob Lifshay
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 from migen
import Constant
29 cause_instruction_address_misaligned
= Constant(0x0, 4)
30 cause_instruction_access_fault
= Constant(0x1, 4)
31 cause_illegal_instruction
= Constant(0x2, 4)
32 cause_breakpoint
= Constant(0x3, 4)
33 cause_load_address_misaligned
= Constant(0x4, 4)
34 cause_load_access_fault
= Constant(0x5, 4)
35 cause_store_amo_address_misaligned
= Constant(0x6, 4)
36 cause_store_amo_access_fault
= Constant(0x7, 4)
37 cause_user_environment_call
= Constant(0x8, 4)
38 cause_supervisor_environment_call
= Constant(0x9, 4)
39 cause_machine_environment_call
= Constant(0xB, 4)
40 cause_instruction_page_fault
= Constant(0xC, 4)
41 cause_load_page_fault
= Constant(0xD, 4)
42 cause_store_amo_page_fault
= Constant(0xF, 4)
44 opcode_load
= Constant(0x03, 7)
45 opcode_load_fp
= Constant(0x07, 7)
46 opcode_custom_0
= Constant(0x0B, 7)
47 opcode_misc_mem
= Constant(0x0F, 7)
48 opcode_op_imm
= Constant(0x13, 7)
49 opcode_auipc
= Constant(0x17, 7)
50 opcode_op_imm_32
= Constant(0x1B, 7)
51 opcode_48b_escape_0
= Constant(0x1F, 7)
53 opcode_store
= Constant(0x23, 7)
54 opcode_store_fp
= Constant(0x27, 7)
55 opcode_custom_1
= Constant(0x2B, 7)
56 opcode_amo
= Constant(0x2F, 7)
57 opcode_op
= Constant(0x33, 7)
58 opcode_lui
= Constant(0x37, 7)
59 opcode_op_32
= Constant(0x3B, 7)
60 opcode_64b_escape
= Constant(0x3F, 7)
62 opcode_madd
= Constant(0x43, 7)
63 opcode_msub
= Constant(0x47, 7)
64 opcode_nmsub
= Constant(0x4B, 7)
65 opcode_nmadd
= Constant(0x4F, 7)
66 opcode_op_fp
= Constant(0x53, 7)
67 opcode_reserved_10101
= Constant(0x57, 7)
68 opcode_rv128_0
= Constant(0x5B, 7)
69 opcode_48b_escape_1
= Constant(0x5F, 7)
71 opcode_branch
= Constant(0x63, 7)
72 opcode_jalr
= Constant(0x67, 7)
73 opcode_reserved_11010
= Constant(0x6B, 7)
74 opcode_jal
= Constant(0x6F, 7)
75 opcode_system
= Constant(0x73, 7)
76 opcode_reserved_11101
= Constant(0x77, 7)
77 opcode_rv128_1
= Constant(0x7B, 7)
78 opcode_80b_escape
= Constant(0x7F, 7)
80 funct3_jalr
= Constant(0x0, 3)
81 funct3_beq
= Constant(0x0, 3)
82 funct3_bne
= Constant(0x1, 3)
83 funct3_blt
= Constant(0x4, 3)
84 funct3_bge
= Constant(0x5, 3)
85 funct3_bltu
= Constant(0x6, 3)
86 funct3_bgeu
= Constant(0x7, 3)
87 funct3_lb
= Constant(0x0, 3)
88 funct3_lh
= Constant(0x1, 3)
89 funct3_lw
= Constant(0x2, 3)
90 funct3_lbu
= Constant(0x4, 3)
91 funct3_lhu
= Constant(0x5, 3)
92 funct3_sb
= Constant(0x0, 3)
93 funct3_sh
= Constant(0x1, 3)
94 funct3_sw
= Constant(0x2, 3)
95 funct3_addi
= Constant(0x0, 3)
96 funct3_slli
= Constant(0x1, 3)
97 funct3_slti
= Constant(0x2, 3)
98 funct3_sltiu
= Constant(0x3, 3)
99 funct3_xori
= Constant(0x4, 3)
100 funct3_srli_srai
= Constant(0x5, 3)
101 funct3_ori
= Constant(0x6, 3)
102 funct3_andi
= Constant(0x7, 3)
103 funct3_add_sub
= Constant(0x0, 3)
104 funct3_sll
= Constant(0x1, 3)
105 funct3_slt
= Constant(0x2, 3)
106 funct3_sltu
= Constant(0x3, 3)
107 funct3_xor
= Constant(0x4, 3)
108 funct3_srl_sra
= Constant(0x5, 3)
109 funct3_or
= Constant(0x6, 3)
110 funct3_and
= Constant(0x7, 3)
111 funct3_fence
= Constant(0x0, 3)
112 funct3_fence_i
= Constant(0x1, 3)
113 funct3_ecall_ebreak
= Constant(0x0, 3)
114 funct3_csrrw
= Constant(0x1, 3)
115 funct3_csrrs
= Constant(0x2, 3)
116 funct3_csrrc
= Constant(0x3, 3)
117 funct3_csrrwi
= Constant(0x5, 3)
118 funct3_csrrsi
= Constant(0x6, 3)
119 funct3_csrrci
= Constant(0x7, 3)
121 csr_ustatus
= Constant(0x000, 12)
122 csr_fflags
= Constant(0x001, 12)
123 csr_frm
= Constant(0x002, 12)
124 csr_fcsr
= Constant(0x003, 12)
125 csr_uie
= Constant(0x004, 12)
126 csr_utvec
= Constant(0x005, 12)
127 csr_uscratch
= Constant(0x040, 12)
128 csr_uepc
= Constant(0x041, 12)
129 csr_ucause
= Constant(0x042, 12)
130 csr_utval
= Constant(0x043, 12)
131 csr_uip
= Constant(0x044, 12)
132 csr_cycle
= Constant(0xC00, 12)
133 csr_time
= Constant(0xC01, 12)
134 csr_instret
= Constant(0xC02, 12)
135 csr_cycleh
= Constant(0xC80, 12)
136 csr_timeh
= Constant(0xC81, 12)
137 csr_instreth
= Constant(0xC82, 12)
139 csr_sstatus
= Constant(0x100, 12)
140 csr_sedeleg
= Constant(0x102, 12)
141 csr_sideleg
= Constant(0x103, 12)
142 csr_sie
= Constant(0x104, 12)
143 csr_stvec
= Constant(0x105, 12)
144 csr_scounteren
= Constant(0x106, 12)
145 csr_sscratch
= Constant(0x140, 12)
146 csr_sepc
= Constant(0x141, 12)
147 csr_scause
= Constant(0x142, 12)
148 csr_stval
= Constant(0x143, 12)
149 csr_sip
= Constant(0x144, 12)
150 csr_satp
= Constant(0x180, 12)
152 csr_mvendorid
= Constant(0xF11, 12)
153 csr_marchid
= Constant(0xF12, 12)
154 csr_mimpid
= Constant(0xF13, 12)
155 csr_mhartid
= Constant(0xF14, 12)
156 csr_mstatus
= Constant(0x300, 12)
157 csr_misa
= Constant(0x301, 12)
158 csr_medeleg
= Constant(0x302, 12)
159 csr_mideleg
= Constant(0x303, 12)
160 csr_mie
= Constant(0x304, 12)
161 csr_mtvec
= Constant(0x305, 12)
162 csr_mcounteren
= Constant(0x306, 12)
163 csr_mscratch
= Constant(0x340, 12)
164 csr_mepc
= Constant(0x341, 12)
165 csr_mcause
= Constant(0x342, 12)
166 csr_mtval
= Constant(0x343, 12)
167 csr_mip
= Constant(0x344, 12)
168 csr_mcycle
= Constant(0xB00, 12)
169 csr_minstret
= Constant(0xB02, 12)
170 csr_mcycleh
= Constant(0xB80, 12)
171 csr_minstreth
= Constant(0xB82, 12)
173 csr_dcsr
= Constant(0x7B0, 12)
174 csr_dpc
= Constant(0x7B1, 12)
175 csr_dscratch
= Constant(0x7B2, 12)