Skip to content

Commit 2f39ee7

Browse files
authored
docs: document the description/prose schema (#682)
1 parent 9eac31d commit 2f39ee7

File tree

3 files changed

+106
-1
lines changed

3 files changed

+106
-1
lines changed

REUSE.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ path = [
3636
"CONTRIBUTING.adoc",
3737
"doc/idl.adoc",
3838
"doc/ruby.adoc",
39-
"doc/schemas.adoc"
39+
"doc/schemas.adoc",
40+
"doc/prose_schema.adoc"
4041
]
4142
SPDX-FileCopyrightText = "2017-2025 Contributors to the RISCV ISA Manual <https://github.com/riscv/riscv-isa-manual>"
4243
SPDX-License-Identifier = "BSD-3-Clause-Clear"

doc/prose_schema.adoc

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
= Encoding prose in UDB architecture files
2+
3+
[WARNING]
4+
----
5+
The UDB project is transitioning to a more structured encoding of prose described in this document.
6+
7+
Legacy prose that is encoded as a simple Asciidoc string will continue to be supported until
8+
all files can be transitioned, but the legacy style is considered _DEPRECATED_.
9+
----
10+
11+
Many UDB database objects have associated prose included under the `description` tag.
12+
Prose is treated as an ordered sequence of tagged statements.
13+
14+
Every statement *MUST* include:
15+
16+
|===
17+
| Tag | Type | Note
18+
19+
| `id` | String | A globally unique, immutable identifier for the statement.
20+
| `normative` | Boolean | Whether or not the statement is considered normative.
21+
| `text` | String | Asciidoc-encoded contents of the statement
22+
|===
23+
24+
Additionally, statements *MAY* include:
25+
26+
|===
27+
| Tag | Type | Note
28+
29+
| `when()` | IDL | An IDL function body that returns a boolean.
30+
If present, represents the condition when the statement is effective.
31+
|===
32+
33+
== Examples
34+
35+
```yaml
36+
description:
37+
- id: csr-hstatus-vgein-behavior
38+
normative: false
39+
text: |
40+
Controls the endianness of data VS-mode (0 = little, 1 = big).
41+
Instructions are always little endian, regardless of the data setting.
42+
43+
- id: csr-hstatus-vgein-little-endian
44+
normative: false
45+
text: |
46+
Since the CPU does not support big endian in VS-mode, this is hardwired to 0.
47+
when(): return VS_MODE_ENDIANESS == "little";
48+
49+
- id: csr-hstatus-vgein-big-endian
50+
normative: false
51+
text: |
52+
Since the CPU does not support little endian in VS-mode, this is hardwired to 1.
53+
when(): return VS_MODE_ENDIANESS == "big";
54+
```
55+
56+
== ID conventions
57+
58+
IDs should be all lowercase, have no spaces, and follow the conventions below.
59+
In all cases, `WHAT` should be a short descriptor for the statement contents.
60+
61+
62+
=== Statements about an extension
63+
64+
```
65+
ext-<EXTENSION NAME>-<WHAT>
66+
67+
# examples
68+
ext-zammo-memory-order
69+
ext-zkt-latency-requirement
70+
```
71+
72+
=== Statements about an instruction
73+
74+
```
75+
inst-<INSTRUCTION MNEMONIC>-<WHAT>
76+
77+
# examples
78+
inst-add-behavior
79+
inst-fence.tso-behavior
80+
```
81+
82+
=== Statements about a CSR register
83+
84+
```
85+
csr-<CSR NAME>-<WHAT>
86+
87+
# examples
88+
csr-hstatus-purpose
89+
csr-misa-purpose
90+
```
91+
92+
=== Statements about a CSR field
93+
94+
```
95+
csr-<CSR NAME>-<FIELD NAME>-<WHAT>
96+
97+
# examples
98+
csr-hstatus-vgein-little-endian
99+
csr-misa-c-mutable
100+
```

doc/schemas.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@
33
Data in UnifiedDB is written in https://en.wikipedia.org/wiki/YAML[YAML] files,
44
and the structure of those files is checked using https://json-schema.org/[JSON Schema].
55

6+
Many UDB data objects share common field types, including:
7+
8+
* xref:doc/prose_schema.adoc[Schema for Prose]
9+
610
TODO

0 commit comments

Comments
 (0)