Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 157 additions & 0 deletions spec/schemas/register_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",

"title": "Register File Schema",
"description": "Schema for describing a register file",

"$defs": {
"count_variant": {
"type": "object",
"required": ["value", "when"],
"additionalProperties": false,
"properties": {
"value": {
"type": "integer",
"description": "Override count when condition is satisfied"
},
"when": {
"$ref": "schema_defs.json#/$defs/requires_entry"
},
"description": {
"$ref": "schema_defs.json#/$defs/spec_text"
}
}
},
"register_entry": {
"type": "object",
"required": ["name", "index"],
"additionalProperties": false,
"properties": {
"name": {
"$ref": "schema_defs.json#/$defs/register_name"
},
"abi_mnemonic": {
"$ref": "schema_defs.json#/$defs/register_alias"
},
"index": {
"type": "integer",
"minimum": 0,
"description": "Register index"
},
"description": {
"$ref": "schema_defs.json#/$defs/spec_text"
},
"definedBy": {
"$ref": "schema_defs.json#/$defs/requires_entry"
},
"when": {
"$ref": "schema_defs.json#/$defs/requires_entry"
},
"length": {
"$ref": "schema_defs.json#/$defs/bit_length_value"
},
"roles": {
"type": "array",
"items": {
"type": "string",
"enum": [
"zero",
"return_address",
"stack_pointer",
"global_pointer",
"thread_pointer",
"frame_pointer",
"return_value",
"argument",
"caller_saved",
"callee_saved",
"temporary"
]
},
"uniqueItems": true
}
}
},
"register_file": {
"type": "object",
"required": [
"$schema",
"kind",
"name",
"long_name",
"description",
"length",
"registers"
],
"additionalProperties": false,
"properties": {
"$schema": {
"type": "string",
"format": "uri-reference",
"const": "register_schema.json#",
"description": "Path to schema, relative to <UDB ROOT>/schemas"
},
"kind": {
"type": "string",
"const": "register_file"
},
"name": {
"$ref": "schema_defs.json#/$defs/register_name"
},
"long_name": {
"type": "string"
},
"description": {
"$ref": "schema_defs.json#/$defs/spec_text"
},
"definedBy": {
"$ref": "schema_defs.json#/$defs/requires_entry"
},
"register_class": {
"type": "string",
"enum": ["general_purpose", "floating_point", "vector"]
},
"length": {
"$ref": "schema_defs.json#/$defs/bit_length_value"
},
"count": {
"oneOf": [
{
"type": "integer",
"minimum": 0
},
{
"type": "object",
"required": ["default"],
"additionalProperties": false,
"properties": {
"default": {
"type": "integer",
"minimum": 0
},
"variants": {
"type": "array",
"items": {
"$ref": "#/$defs/count_variant"
}
}
}
}
]
},
"registers": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "#/$defs/register_entry"
}
},
"$source": {
"type": "string",
"format": "uri-reference"
}
}
}
},
"$ref": "#/$defs/register_file"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you probably copied this from something I did, but I've since learned that our JSON schema linter flags this as bad form.

Instead of "$ref"ing the register file, the register file should just be at the top level of the schema.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is resolved, but please confirm.

}
23 changes: 23 additions & 0 deletions spec/schemas/schema_defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,29 @@
],
"description": "Location of a field in a register"
},
"bit_length_value": {
"description": "Bit width value for a register or field",
"oneOf": [
{
"type": "integer",
"minimum": 1
},
{
"type": "string",
"minLength": 1
}
]
},
"register_name": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_.-]*$",
"description": "Register name"
},
"register_alias": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_.-]*$",
"description": "Register alias or ABI mnemonic"
},
"possibly_split_field_location": {
"description": "Location specifier for a field",
"oneOf": [
Expand Down
37 changes: 35 additions & 2 deletions spec/std/isa/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Three standard configs are present:
* `rv64`: A configuration where only `MXLEN` is known to be 64, i.e., the RV64 ISA.

The architecture is specified in a series of https://en.wikipedia.org/wiki/YAML[YAML]
files for _Extensions_, _Instructions_, and _Control and Status Registers (CSRs)_.
Each extension/instruction/CSR has its own file.
files for _Extensions_, _Instructions_, _Registers_, and _Control and Status Registers (CSRs)_.
Each extension/instruction/register/CSR has its own file.

== Flow

Expand Down Expand Up @@ -142,6 +142,39 @@ H: # <1>

=== Instructions

=== Registers

.Example register file specification
[source,yaml]
----
$schema: register_schema.json#
kind: register_file
name: X
long_name: Integer General Purpose Registers
definedBy: I
register_class: general_purpose
length: XLEN # <1>
count:
default: 32
variants:
- value: 16
when: { name: E } # <2>
registers:
- name: x0
index: 0
abi_mnemonic: zero # <3>
roles: [zero]
- name: x1
index: 1
abi_mnemonic: ra
roles: [return_address]
----

<1> Register files are defined independently of the resolved XLEN; individual register entries
may override the default bit length when necessary.
<2> Conditional presence uses the same `when`/`definedBy` semantics as other database objects.
<3> Entries can record ABI mnemonics and semantic roles.

[source,yaml]
----
add: # <1>
Expand Down
Loading
Loading