-
Notifications
You must be signed in to change notification settings - Fork 333
/
Copy pathcsr_template.yaml
120 lines (117 loc) · 3.48 KB
/
csr_template.yaml
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
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Base CSR template that should be followed when describing all processor supported CSRs to enable correct generation of directed test sequences
#- csr: CSR_NAME
# description: >
# BRIEF_DESCRIPTION
# address: 0x###
# privilege_mode: MODE (D/M/S/H/U)
# rv32:
# - MSB_FIELD_NAME:
# - description: >
# BRIEF_DESCRIPTION
# - type: TYPE (WPRI/WLRL/WARL/R)
# - reset_val: RESET_VAL
# - msb: MSB_POS
# - lsb: LSB_POS
# - ...
# - ...
# - LSB_FIELD_NAME:
# - description: ...
# - type: ...
# - ...
# rv64:
# - MSB_FIELD_NAME:
# - description: >
# BRIEF_DESCRIPTION
# - type: TYPE (WPRI/WLRL/WARL/R)
# - reset_val: RESET_VAL
# - msb: MSB_POS
# - lsb: LSB_POS
# - ...
# - ...
# - LSB_FIELD_NAME:
# - description: ...
# - type: ...
# - ...
# For WARL fields an additional 'warl_legalize' option can be added. This
# provides a fragment of python in a string. This python transforms values into
# legal values for that field. The 'val_in' variable contains the value to
# legalize and 'val_out' should be written with the legalized value. 'val_orig'
# contains the value that is currently in the CSR. See the examples below.
# Example template, using the CSR misa
# Note: assume the processor supports only the RISC-V I/C extensions
- csr: misa
description: >
Machine ISA Register
address: 0x301
privilege_mode: M
rv32:
- field_name: MXL
description: >
Encodes native base ISA width
type: WARL
reset_val: 1
msb: 31
lsb: 30
- field_name: Extensions
description: >
Encodes all supported ISA extensions
type: WARL
reset_val: 0x104
msb: 25
lsb: 0
warl_legalize: |
# I bit remains 1, C bit can be toggled, all other bits are 0
val_out = (val_in & 0x4) | 0x100
rv64:
- field_name: MXL
description: >
Encodes native base ISA width
type: WARL
reset_val: 2
msb: 63
lsb: 62
- field_name: Extensions
description: >
Encodes all supported ISA extensions
type: WARL
reset_val: 0x104
msb: 25
lsb: 0
warl_legalize: |
# I bit remains 1, C bit can be toggled, all other bits are 0
val_out = (val_in & 0x4) | 0x100
- csr: mwarlexample
description: >
Example of WARL field
address: 0x100
privilege_mode: M
rv32:
- field_name: WARLTest
description: >
Demonstrates more advanced WARL legalization
type: WARL
reset_val: 0xf
msb: 31
lsb: 0
warl_legalize: |
# Top 16 bits can be any value, bottom 16 bits can only be 0xf000 or
# 0x000f retain existing bottom bits if new value isn't legal
bottom_half = val_in & 0xffff
if bottom_half != 0x000f and bottom_half != 0xf000:
bottom_half = val_orig & 0xffff
val_out = (val_in & 0xffff0000) | bottom_half