Skip to content

Commit 633481d

Browse files
fix: rename sw_read/write to arch_read/write
- Update register_file_schema.json: Rename sw_read()/sw_write(value) to arch_read()/arch_write(value) and clarify their descriptions as architecturally mandated behavior. - Drop writable flag from register entries. - Remove redundant type declarations where const already fixes the value. - Adjust the register-file example and README.adoc to reference the new function names. - register_file.rb: Expose arch_read/arch_write while retaining sw_* aliases for backward compatibility with existing YAML.
1 parent 60a664f commit 633481d

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

spec/schemas/register_file_schema.json

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
"when": {
2929
"$ref": "schema_defs.json#/$defs/requires_entry"
3030
},
31-
"sw_read()": {
31+
"arch_read()": {
3232
"type": "string",
33-
"description": "Function that returns the value of the register when read by software. Use this to define special behavior for registers (e.g., x0 always reads as zero)."
33+
"description": "Function describing the architecturally defined read behavior. Use this for architecturally mandated effects (e.g., x0 always reads as zero)."
3434
},
35-
"sw_write(value)": {
35+
"arch_write(value)": {
3636
"type": "string",
37-
"description": "Function implementing custom write behavior for the register. Given a 'value', return either the value to be written or a modified value. Use this to define special behavior for registers (e.g., x0 ignores writes)."
37+
"description": "Function describing the architecturally defined write behavior. Given a 'value', return the architecturally required result (e.g., x0 ignores writes and always yields zero)."
3838
},
3939
"caller_saved": {
4040
"type": "boolean",
@@ -63,11 +63,6 @@
6363
]
6464
},
6565
"uniqueItems": true
66-
},
67-
"writable": {
68-
"type": "boolean",
69-
"default": true,
70-
"description": "Whether the register is writable. If false, no sw_write() method is needed."
7166
}
7267
}
7368
},
@@ -85,13 +80,11 @@
8580
"additionalProperties": false,
8681
"properties": {
8782
"$schema": {
88-
"type": "string",
8983
"format": "uri-reference",
9084
"const": "register_file_schema.json#",
9185
"description": "Path to schema, relative to <UDB ROOT>/schemas"
9286
},
9387
"kind": {
94-
"type": "string",
9588
"const": "register_file"
9689
},
9790
"name": {

spec/std/isa/README.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ registers:
158158
- name: x0 # <2>
159159
abi_mnemonics: [zero] # <3>
160160
roles: [zero]
161-
sw_read(): | # <4>
161+
arch_read(): | # <4>
162162
return 0;
163-
sw_write(value): |
163+
arch_write(value): |
164164
# x0 ignores all writes
165165
- name: x1
166166
abi_mnemonics: [ra]
@@ -173,7 +173,7 @@ registers:
173173
<1> The registers in a register file have identical fixed widths, either an explicit width or from a parameter (e.g. MXLEN or VLEN).
174174
<2> Each register has a unique name (e.g., x0, x1, x2, etc.). The register's index is inferred from its position in the array (starting from 0).
175175
<3> Registers can optionally have ABI mnemonics (e.g., ra, sp, fp, etc.).
176-
<4> Individual registers can define `sw_read()` and `sw_write()` for special behavior (e.g., x0 hardwired to zero).
176+
<4> Individual registers can define `arch_read()` and `arch_write()` for architecturally mandated behavior (e.g., x0 hardwired to zero).
177177
<5> A register can have multiple ABI mnemonics (e.g., x8 is known as both s0 and fp).
178178

179179
[source,yaml]

spec/std/isa/register_file/X.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ registers:
1919
- name: x0
2020
abi_mnemonics: [zero]
2121
roles: [zero]
22-
writable: false
2322
description: |
2423
Register x0 is hardwired with all bits equal to 0.
25-
sw_read(): |
24+
arch_read(): |
25+
return 0;
26+
arch_write(value): |
2627
return 0;
2728
- name: x1
2829
abi_mnemonics: [ra]

tools/ruby-gems/udb/lib/udb/obj/register_file.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,20 @@ def caller_saved = @data["caller_saved"]
6666
def callee_saved = @data["callee_saved"]
6767

6868
sig { returns(T.nilable(String)) }
69-
def sw_read = @data["sw_read()"]
69+
def arch_read
70+
@data["arch_read()"] || @data["sw_read()"]
71+
end
72+
73+
sig { returns(T.nilable(String)) }
74+
def arch_write
75+
@data["arch_write(value)"] || @data["sw_write(value)"]
76+
end
77+
78+
sig { returns(T.nilable(String)) }
79+
def sw_read = arch_read
7080

7181
sig { returns(T.nilable(String)) }
72-
def sw_write = @data["sw_write(value)"]
82+
def sw_write = arch_write
7383

7484
sig { returns(T.nilable(ExtensionRequirementExpression)) }
7585
def defined_by_condition

0 commit comments

Comments
 (0)