Skip to content

Commit a9baab8

Browse files
Merge pull request #230 from riscv/add_behavior_to_warl_enum
Changed "type" to "enum" object that accepts more info.
2 parents 7d8a94b + 6572f1d commit a9baab8

File tree

15 files changed

+592
-152
lines changed

15 files changed

+592
-152
lines changed

schemas/param-common-schema.json

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,53 @@
7777
"type": "string",
7878
"enum": ["WARL", "WLRL"]
7979
},
80-
"csrType": {
81-
"type": "array",
82-
"items": { "type": "integer" },
83-
"minItems": 1
80+
"csrEnum": {
81+
"type": "object",
82+
"properties": {
83+
"legal": {
84+
"type": "array",
85+
"items": { "$ref": "#/multiBaseValue" },
86+
"minItems": 1,
87+
"description": "Array of one or more legal values (decimal integer, 0x hex, or 0b binary)"
88+
},
89+
"illegal-write-ignore": {
90+
"const": true,
91+
"description": "Must be true; indicates illegal writes are silently ignored"
92+
},
93+
"illegal-write-return": {
94+
"$ref": "#/multiBaseValue",
95+
"description": "If specified, illegal writes return this value (decimal integer, 0x hex, or 0b binary)"
96+
}
97+
},
98+
"required": ["legal"],
99+
"oneOf": [
100+
{ "required": ["legal", "illegal-write-ignore"] },
101+
{ "required": ["legal", "illegal-write-return"] }
102+
]
103+
},
104+
"csrEnumOutput": {
105+
"type": "object",
106+
"properties": {
107+
"legal": {
108+
"type": "array",
109+
"items": { "type": "integer" },
110+
"minItems": 1,
111+
"description": "Array of one or more legal integers (converted to decimal)"
112+
},
113+
"illegal-write-ignore": {
114+
"const": true,
115+
"description": "Must be true; indicates illegal writes are silently ignored"
116+
},
117+
"illegal-write-return": {
118+
"type": "integer",
119+
"description": "Value returned on illegal writes (converted to decimal)"
120+
}
121+
},
122+
"required": ["legal"],
123+
"oneOf": [
124+
{ "required": ["legal", "illegal-write-ignore"] },
125+
{ "required": ["legal", "illegal-write-return"] }
126+
]
84127
},
85128
"multiBaseValue": {
86129
"oneOf": [

schemas/param-defs-schema.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@
148148
"$ref": "param-common-schema.json#/csrNameArray",
149149
"description": "Multiple CSR field names"
150150
},
151-
"type": {
152-
"$ref": "param-common-schema.json#/csrType",
153-
"description": "List of possible legal values"
151+
"enum": {
152+
"$ref": "param-common-schema.json#/csrEnum",
153+
"description": "Enum definition specifying legal write values and associated behavior (including handling of illegal writes)"
154154
},
155155
"width": {
156156
"$ref": "param-common-schema.json#/paramName",
@@ -186,11 +186,13 @@
186186
}
187187
},
188188
{
189-
"oneOf": [
190-
{ "required": ["type"] },
191-
{ "required": ["width"] },
192-
{ "required": ["ro-mask"] }
193-
]
189+
"not": {
190+
"anyOf": [
191+
{ "required": ["enum", "width"] },
192+
{ "required": ["enum", "ro-mask"] },
193+
{ "required": ["width", "ro-mask"] }
194+
]
195+
}
194196
},
195197
{
196198
"if": {

schemas/params-schema.json

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@
134134
"$ref": "param-common-schema.json#/csrCategory",
135135
"description": "CSR category"
136136
},
137-
"type": {
138-
"$ref": "param-common-schema.json#/csrType"
137+
"enum": {
138+
"$ref": "param-common-schema.json#/csrEnumOutput",
139+
"description": "CSR legal values and illegal-write behavior"
139140
},
140141
"width": {
141142
"$ref": "param-common-schema.json#/paramName",
@@ -173,35 +174,13 @@
173174
}
174175
},
175176
{
176-
"oneOf": [
177-
{
178-
"required": ["type"],
179-
"not": {
180-
"anyOf": [
181-
{ "required": ["width"] },
182-
{ "required": ["ro-mask"] }
183-
]
184-
}
185-
},
186-
{
187-
"required": ["width"],
188-
"not": {
189-
"anyOf": [
190-
{ "required": ["type"] },
191-
{ "required": ["ro-mask"] }
192-
]
193-
}
194-
},
195-
{
196-
"required": ["ro-mask"],
197-
"not": {
198-
"anyOf": [
199-
{ "required": ["type"] },
200-
{ "required": ["width"] }
201-
]
202-
}
203-
}
204-
]
177+
"not": {
178+
"anyOf": [
179+
{ "required": ["enum", "width"] },
180+
{ "required": ["enum", "ro-mask"] },
181+
{ "required": ["width", "ro-mask"] }
182+
]
183+
}
205184
}
206185
],
207186
"additionalProperties": false

tests/norm-rule/expected/test-ch2-norm-tags.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
"norm:mock-csr-x": "Here’s a normative rule for mock CSR \"X\".",
1818
"norm:mock-csr-field-y": "Here’s a normative rule for mock CSR field \"Y\".",
1919
"norm:mock-ext-dep-A-on-B": "Here’s a normative rule for mock extension dependency of extension A on extension B.",
20-
"norm:foo_abc_warl_legal_list": "The architecturally-defined values for the 4-bit foo.ABC CSR field are 0, 3, or 10.\nAn implementation can support any subset of these values.",
21-
"norm:foo_def_warl_width_uint4to8": "The foo.DEF CSR field width ranges from 4 to 8 bits as specified by the UINT_4TO8 parameter value.",
20+
"norm:foo_abc_warl_enum": "The architecturally-defined values for the 4-bit foo.ABC\nCSR field are 0, 0b11, or 0xffff_ffff. Returns 0x7fff if written with an illegal value.",
21+
"norm:foo_def_warl_enum": "The architecturally-defined values for the 8-bit foo.DEF\nCSR field are -1 or 0xf0. Ignores writes with an illegal value.",
22+
"norm:foo_ghi_warl_width_uint4to8": "The foo.GHI CSR field width ranges from 4 to 8 bits as specified by the UINT_4TO8 parameter value.",
2223
"norm:zort_xyz_wlrl_readonly_zero": "An implementation may treat each bit of the zort.XYZ CSR as\nread-only or read-write. Read-only bits can be 0 or 1.",
23-
"norm:bar_warl_readonly_value": "An implementation may treat each bit of the bar CSR as\nread-only or read-write. Read-only bits are 0."
24+
"norm:bar_warl_readonly_value": "An implementation may treat each bit of the bar CSR as\nread-only or read-write. Read-only bits are 0.",
25+
"norm:qux_qqq_wlrl_no_selector": "The qux.QQQ CSR field has implementation-defined behavior\nwithout an enum, width, or read-only mask selector."
2426
},
2527
"sections": {
2628
"title": "",
@@ -66,10 +68,12 @@
6668
"id": "_chapter_2_3_csr_field_types",
6769
"children": [],
6870
"tags": [
69-
"norm:foo_abc_warl_legal_list",
70-
"norm:foo_def_warl_width_uint4to8",
71+
"norm:foo_abc_warl_enum",
72+
"norm:foo_def_warl_enum",
73+
"norm:foo_ghi_warl_width_uint4to8",
7174
"norm:zort_xyz_wlrl_readonly_zero",
72-
"norm:bar_warl_readonly_value"
75+
"norm:bar_warl_readonly_value",
76+
"norm:qux_qqq_wlrl_no_selector"
7377
]
7478
}
7579
],

0 commit comments

Comments
 (0)