-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpu.yaml
More file actions
379 lines (353 loc) · 6.91 KB
/
cpu.yaml
File metadata and controls
379 lines (353 loc) · 6.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
%TAG !py! tag:yaml.org,2002:python/object/apply:builtins.
---
templates:
controller: controller.mlog.jinja
worker: worker.mlog.jinja
debugger: ../peripherals/debugger.mlog.jinja
display: ../peripherals/scrolling_display.mlog.jinja
schematics:
lookups: ../../schematics/lookup_procs.msch
ram: ../../schematics/ram_proc.msch
sortkb: ../../schematics/sortKB.msch
configs: ../config/configs.yaml
inputs:
LOOKUP_PROC_SIZE: 260 # number of variables per lookup proc
ROM_BYTE_OFFSET: 174 # start character for ROM string byte data
ROM_PROC_BYTES: 16384 # number of bytes per ROM proc
RAM_PROC_BYTES: 16384 # number of bytes per RAM proc
RAM_PROC_VARS: 4096 # number of variables per RAM proc
# ROM starts at 0x00000000, so we don't need a variable for it
RAM_START: '0x80000000'
MMIO_START: '0xf0000000'
SYSCON: '0xfffffff0'
# offsets from MMIO_START
UART_RX_OFFSET: '0x10'
UART_TX_OFFSET: '0x14'
UART_STATUS_OFFSET: '0x18'
UART_CONTROL_OFFSET: '0x1c'
# combined register size for one UART
UART_MMIO_SIZE: '0x10'
# bank addresses
UART_RX_READ: 254
UART_RX_WRITE: 255
UART_TX_START: 256
UART_TX_READ: 510
UART_TX_WRITE: 511
instructions:
# decoders
- label: decode_LOAD
align: 4
- label: decode_illegal_instruction # LOAD-FP
align: 4
- label: decode_custom-0
align: 4
- label: decode_MISC-MEM
align: 4
- label: decode_OP-IMM
align: 4
- label: decode_AUIPC
align: 4
- label: decode_illegal_instruction # OP-IMM-32
align: 4
- label: decode_illegal_instruction # 48b
align: 4
- label: decode_STORE
align: 4
- label: decode_illegal_instruction # STORE-FP
align: 4
- label: decode_illegal_instruction # custom-1
align: 4
- label: decode_AMO
align: 4
- label: decode_OP
align: 4
- label: decode_LUI
align: 4
- label: decode_illegal_instruction
align: 4
count: 10
# OP-32
# 64b
# MADD
# MSUB
# NMSUB
# NMADD
# OP-FP
# OP-V
# custom-2/rv128
# 48b
- label: decode_BRANCH
align: 4
- label: decode_JALR
align: 4
- label: decode_illegal_instruction # reserved
align: 4
- label: decode_JAL
align: 4
- label: decode_SYSTEM
align: 4
- label: decode_illegal_instruction
align: 4
count: 3
# OP-VE
# custom-3/rv128
# >=80b
# runtime handlers
- label: BEQ
address: 128
- label: BNE
- label: JAL
- label: JALR
- label: BLT
- label: BGE
- label: BLTU
- label: BGEU
- label: LB
- label: LH
- label: LW
- label: LUI
- label: LBU
- label: LHU
- label: SB
- label: SH
- label: SW
- label: AMOADD.W
- label: AMOSWAP.W
- label: LR.W
- label: SC.W
- label: AMOXOR.W
- label: AMOOR.W
- label: AMOAND.W
- label: AMOMIN.W
- label: AMOMAX.W
- label: AMOMINU.W
- label: AMOMAXU.W
- label: ADDI
- label: SUB
- label: SLTI
- label: SLTIU
- label: XORI
- label: SRA
- label: ORI
- label: ANDI
- label: ADD
- label: SLL
- label: SLT
- label: SLTU
- label: XOR
- label: SRL
- label: OR
- label: AND
- label: MUL
- label: MULH
- label: MULHSU
- label: MULHU
- label: DIV
- label: DIVU
- label: REM
- label: REMU
- label: PRIV
- label: CSRRW
- label: CSRRS
- label: CSRRC
- label: AUIPC
- label: CSRRWI
- label: CSRRSI
- label: CSRRCI
- label: FENCE
- label: SLLI
- label: SRLI
- label: SRAI
- label: ILLEGAL_OP
- label: MLOGSYS
- label: ILLEGAL_OP
up_to: 255
csrs:
# -- unprivileged --
# counter/timers
cycle:
read: mcycle
time:
read: LABEL
instret:
read: minstret
hpmcounter{}:
args: !py!range [3, 32]
read: hpmcounter
cycleh:
read: LABEL
timeh:
read: LABEL
instreth:
read: minstreth
hpmcounter{}h:
args: !py!range [3, 32]
read: hpmcounter
# -- supervisor --
# trap setup
sstatus:
read: LABEL
write: LABEL
# MXR -
# SUM -
# SPP -
# SPIE -
# SIE -
mask: 0b00000000000011000000000100100010
sie:
read: LABEL
write: LABEL
stvec:
read: csrs
write: csrs
mask: &align_4B 0xfffffffc
scounteren:
read: csrs
write: csrs
stimecmp:
read: LABEL
write: LABEL
stimecmph:
read: LABEL
write: LABEL
# configuration
senvcfg:
read: zero
write: readonly
# counter setup
scountinhibit:
read: zero
write: readonly
# trap handling
sscratch:
read: csrs
write: csrs
sepc:
read: csrs
write: csrs
mask: *align_4B
scause:
read: csrs
write: csrs
stval:
read: csrs
write: csrs
sip:
read: LABEL
write: LABEL
# protection and translation
satp:
read: LABEL
write: LABEL
# -- machine --
# information
mvendorid:
read: zero
marchid:
read: zero
mimpid:
read: zero
mhartid:
read: zero
mconfigptr:
read: zero
# trap setup
mstatus:
read: LABEL
write: LABEL
# state - ---- --
# WPRI -------- - - -
# UBE -
mask: 0b00000000011111100001100110101010
misa:
read: csrs
write: readonly
medeleg:
read: csrs
write: csrs
# custom --------
# reserved ---- -- - -
# M-call -
mask: 0b00000000000011001011001111111111
mideleg:
read: csrs
write: csrs
# MEI -
# SEI -
# MTI -
# STI -
# SSI -
mask: 0b00000000000000000000101010100010
mie:
read: LABEL
write: LABEL
mtvec:
read: csrs
write: csrs
mask: *align_4B
mcounteren:
read: csrs
write: csrs
mstatush:
read: zero
write: readonly
medelegh:
read: zero
write: readonly
# trap handling
mscratch:
read: csrs
write: csrs
mepc:
read: csrs
write: csrs
mask: *align_4B
mcause:
read: csrs
write: csrs
mtval:
read: csrs
write: csrs
mip:
read: LABEL
write: LABEL
# SEIP -
# SSIP -
mask: 0b00000000000000000000001000000010
# configuration
menvcfg:
read: zero
write: readonly
menvcfgh:
read: zero
write: readonly
# counter/timers
mcycle:
read: LABEL
write: LABEL
minstret:
read: LABEL
write: LABEL
mhpmcounter{}:
args: !py!range [3, 32]
read: zero
write: readonly
mcycleh:
read: csrs
write: csrs
minstreth:
read: LABEL
write: LABEL
mhpmcounter{}h:
args: !py!range [3, 32]
read: zero
write: readonly
# counter setup
# mhpmevent{}h is defined only if the Sscofpmf extension is implemented
mcountinhibit:
read: zero
write: readonly
mhpmevent{}:
args: !py!range [3, 32]
read: zero
write: readonly