-
Notifications
You must be signed in to change notification settings - Fork 78
read-only-zero case when CSR disabled - misa.yaml file #918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
b1a2a4d
f857538
a176914
7ae01d6
15c0c7a
1fbc3e7
37cf99a
4ede842
0bf0534
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,10 +8,14 @@ kind: csr | |
| name: misa | ||
| long_name: Machine ISA Control | ||
| address: 0x301 | ||
| # writable when misa CSR is implemented; read-only-0 otherwise | ||
| writable: true | ||
| priv_mode: M | ||
| length: MXLEN | ||
| description: Reports the XLEN and "major" extensions supported by the ISA. | ||
| description: | | ||
| Reports the XLEN and "major" extensions supported by the ISA. | ||
| [when,"MISA_CSR_IMPLEMENTED == false"] | ||
| This CSR is read-only-0 (all bits hardwired to zero) and cannot be written. | ||
| definedBy: Sm | ||
| fields: | ||
| MXL: | ||
|
|
@@ -20,7 +24,7 @@ fields: | |
| description: XLEN in M-mode. | ||
| type: RO | ||
| reset_value(): | | ||
| return (MXLEN == 32) ? 2'b01 : 2'b10; | ||
| return (!MISA_CSR_IMPLEMENTED) ? 0 : (MXLEN == 32) ? 2'b01 : 2'b10; | ||
|
||
| A: | ||
| location: 0 | ||
| description: | | ||
|
|
@@ -29,9 +33,10 @@ fields: | |
| [when,"MUTABLE_MISA_A == true"] | ||
| Writing 0 to this field will cause all atomic instructions to raise an `IllegalInstruction` exception. | ||
| type(): | | ||
| return (implemented?(ExtensionName::A) && MUTABLE_MISA_A) ? CsrFieldType::RW : CsrFieldType::RO; | ||
| return (!MISA_CSR_IMPLEMENTED) ? CsrFieldType::RO : | ||
| (implemented?(ExtensionName::A) && MUTABLE_MISA_A) ? CsrFieldType::RW : CsrFieldType::RO; | ||
| reset_value(): | | ||
| return implemented?(ExtensionName::A) ? 1 : 0; | ||
| return (!MISA_CSR_IMPLEMENTED) ? 0 : implemented?(ExtensionName::A) ? 1 : 0; | ||
| definedBy: A | ||
| B: | ||
| location: 1 | ||
|
|
@@ -41,9 +46,10 @@ fields: | |
| [when,"MUTABLE_MISA_B == true"] | ||
| Writing 0 to this field will cause all bitmanip instructions to raise an `IllegalInstruction` exception. | ||
| type(): | | ||
| return (implemented?(ExtensionName::B) && MUTABLE_MISA_B) ? CsrFieldType::RW : CsrFieldType::RO; | ||
| return (!MISA_CSR_IMPLEMENTED) ? CsrFieldType::RO : | ||
| (implemented?(ExtensionName::B) && MUTABLE_MISA_B) ? CsrFieldType::RW : CsrFieldType::RO; | ||
| reset_value(): | | ||
| return implemented?(ExtensionName::B) ? 1 : 0; | ||
| return (!MISA_CSR_IMPLEMENTED) ? 0 : implemented?(ExtensionName::B) ? 1 : 0; | ||
| definedBy: B | ||
| C: | ||
| location: 2 | ||
|
|
@@ -54,9 +60,10 @@ fields: | |
| Writing 0 to this field will cause all compressed instructions to raise an `IllegalInstruction` exception. | ||
| Additionally, IALIGN becomes 32. | ||
| type(): | | ||
| return (implemented?(ExtensionName::C) && MUTABLE_MISA_C) ? CsrFieldType::RW : CsrFieldType::RO; | ||
| return (!MISA_CSR_IMPLEMENTED) ? CsrFieldType::RO : | ||
| (implemented?(ExtensionName::C) && MUTABLE_MISA_C) ? CsrFieldType::RW : CsrFieldType::RO; | ||
| reset_value(): | | ||
| return implemented?(ExtensionName::C) ? 1 : 0; | ||
| return (!MISA_CSR_IMPLEMENTED) ? 0 : implemented?(ExtensionName::C) ? 1 : 0; | ||
| definedBy: C | ||
| D: | ||
| location: 3 | ||
|
|
@@ -70,9 +77,10 @@ fields: | |
| Additionally, the upper 32-bits of the f registers will read as zero. | ||
| -- | ||
| type(): | | ||
| return (implemented?(ExtensionName::D) && MUTABLE_MISA_D) ? CsrFieldType::RW : CsrFieldType::RO; | ||
| return (!MISA_CSR_IMPLEMENTED) ? CsrFieldType::RO : | ||
| (implemented?(ExtensionName::D) && MUTABLE_MISA_D) ? CsrFieldType::RW : CsrFieldType::RO; | ||
| reset_value(): | | ||
| return implemented?(ExtensionName::D) ? 1 : 0; | ||
| return (!MISA_CSR_IMPLEMENTED) ? 0 : implemented?(ExtensionName::D) ? 1 : 0; | ||
| definedBy: D | ||
| F: | ||
| location: 5 | ||
|
|
@@ -86,24 +94,34 @@ fields: | |
| Writing 0 to this field with `misa.D` set will result in UNDEFINED behavior. | ||
| -- | ||
| type(): | | ||
| return (implemented?(ExtensionName::F) && MUTABLE_MISA_F) ? CsrFieldType::RW : CsrFieldType::RO; | ||
| return (!MISA_CSR_IMPLEMENTED) ? CsrFieldType::RO : | ||
| (implemented?(ExtensionName::F) && MUTABLE_MISA_F) ? CsrFieldType::RW : CsrFieldType::RO; | ||
| reset_value(): | | ||
| return implemented?(ExtensionName::F) ? 1 : 0; | ||
| return (!MISA_CSR_IMPLEMENTED) ? 0 : implemented?(ExtensionName::F) ? 1 : 0; | ||
| definedBy: F | ||
| sw_write(csr_value): | | ||
| if (!MISA_CSR_IMPLEMENTED) { | ||
| return 0; | ||
| } | ||
| if (csr_value.F == 0 && csr_value.D == 1) { | ||
| return UNDEFINED_LEGAL_DETERMINISTIC; | ||
| } | ||
|
|
||
| # fall-through; write the intended value | ||
| return csr_value.F; | ||
| legal?(csr_value): | | ||
| if (!MISA_CSR_IMPLEMENTED) { | ||
| return true; | ||
| } | ||
| return !(csr_value.F == 0 && csr_value.D == 1); | ||
| G: | ||
| location: 6 | ||
| description: | | ||
| Indicates support for all of the following extensions: `I`, `A`, `M`, `F`, `D`. | ||
| type(): | | ||
| if (!MISA_CSR_IMPLEMENTED) { | ||
| return CsrFieldType::RO; | ||
| } | ||
| if ((implemented?(ExtensionName::A) && MUTABLE_MISA_A) || | ||
| (implemented?(ExtensionName::M) && MUTABLE_MISA_M) || | ||
| (implemented?(ExtensionName::F) && MUTABLE_MISA_F) || | ||
|
|
@@ -113,6 +131,9 @@ fields: | |
| return CsrFieldType::RO; | ||
| } | ||
| reset_value(): | | ||
| if (!MISA_CSR_IMPLEMENTED) { | ||
| return 0; | ||
| } | ||
| return ( | ||
| implemented?(ExtensionName::A) && | ||
| implemented?(ExtensionName::M) && | ||
|
|
@@ -126,17 +147,19 @@ fields: | |
| [when,"MUTABLE_MISA_H == true"] | ||
| Writing 0 to this field will cause all attempts to enter VS- or VU- mode, execute a hypervisor instruction, or access a hypervisor CSR to raise an `IllegalInstruction` fault. | ||
| type(): | | ||
| return (implemented?(ExtensionName::H) && MUTABLE_MISA_H) ? CsrFieldType::RW : CsrFieldType::RO; | ||
| return (!MISA_CSR_IMPLEMENTED) ? CsrFieldType::RO : | ||
| (implemented?(ExtensionName::H) && MUTABLE_MISA_H) ? CsrFieldType::RW : CsrFieldType::RO; | ||
| definedBy: H | ||
| reset_value(): | | ||
| return implemented?(ExtensionName::H) ? 1 : 0; | ||
| return (!MISA_CSR_IMPLEMENTED) ? 0 : implemented?(ExtensionName::H) ? 1 : 0; | ||
| I: | ||
| location: 8 | ||
| description: | | ||
| Indicates support for the `I` (base) extension. | ||
| type: RO | ||
| definedBy: I | ||
| reset_value: 1 | ||
| reset_value(): | | ||
| return (!MISA_CSR_IMPLEMENTED) ? 0 : 1; | ||
| M: | ||
| location: 12 | ||
| description: | | ||
|
|
@@ -145,9 +168,10 @@ fields: | |
| [when,"MUTABLE_MISA_M == true"] | ||
| Writing 0 to this field will cause all attempts to execute an integer multiply or divide instruction to raise an `IllegalInstruction` exception. | ||
| type(): | | ||
| return (implemented?(ExtensionName::M) && MUTABLE_MISA_M) ? CsrFieldType::RW : CsrFieldType::RO; | ||
| return (!MISA_CSR_IMPLEMENTED) ? CsrFieldType::RO : | ||
| (implemented?(ExtensionName::M) && MUTABLE_MISA_M) ? CsrFieldType::RW : CsrFieldType::RO; | ||
| reset_value(): | | ||
| return implemented?(ExtensionName::M) ? 1 : 0; | ||
| return (!MISA_CSR_IMPLEMENTED) ? 0 : implemented?(ExtensionName::M) ? 1 : 0; | ||
| definedBy: M | ||
| cert_normative_rules: | ||
| - id: csr_field.misa.M.disabled | ||
|
|
@@ -182,17 +206,25 @@ fields: | |
| Writing 0 to this field will cause all quad-precision floating point instructions to raise an `IllegalInstruction` exception. | ||
| -- | ||
| type(): | | ||
| return MUTABLE_MISA_Q ? CsrFieldType::RW : CsrFieldType::RO; | ||
| reset_value: 1 | ||
| return (!MISA_CSR_IMPLEMENTED) ? CsrFieldType::RO : | ||
| MUTABLE_MISA_Q ? CsrFieldType::RW : CsrFieldType::RO; | ||
| reset_value(): | | ||
| return (!MISA_CSR_IMPLEMENTED) ? 0 : 1; | ||
| definedBy: Q | ||
| sw_write(csr_value): | | ||
| if (!MISA_CSR_IMPLEMENTED) { | ||
| return 0; | ||
| } | ||
| if ((csr_value.F == 0 || csr_value.D == 0) && csr_value.Q == 1) { | ||
| return UNDEFINED_LEGAL_DETERMINISTIC; | ||
| } | ||
|
|
||
| # fall-through; write the intended value | ||
| return csr_value.Q; | ||
| legal?(csr_value): | | ||
| if (!MISA_CSR_IMPLEMENTED) { | ||
| return true; | ||
| } | ||
| return !(csr_value.Q == 1 && csr_value.D == 0); | ||
| S: | ||
| location: 18 | ||
|
|
@@ -202,9 +234,10 @@ fields: | |
| [when,"MUTABLE_MISA_S == true"] | ||
| Writing 0 to this field will cause all attempts to enter S-mode or access S-mode state to raise an exception. | ||
| type(): | | ||
| return (implemented?(ExtensionName::S) && MUTABLE_MISA_S) ? CsrFieldType::RW : CsrFieldType::RO; | ||
| return (!MISA_CSR_IMPLEMENTED) ? CsrFieldType::RO : | ||
| (implemented?(ExtensionName::S) && MUTABLE_MISA_S) ? CsrFieldType::RW : CsrFieldType::RO; | ||
| reset_value(): | | ||
| return implemented?(ExtensionName::S) ? 1 : 0; | ||
| return (!MISA_CSR_IMPLEMENTED) ? 0 : implemented?(ExtensionName::S) ? 1 : 0; | ||
| definedBy: S | ||
| U: | ||
| location: 20 | ||
|
|
@@ -214,33 +247,41 @@ fields: | |
| [when,"MUTABLE_MISA_U == true"] | ||
| Writing 0 to this field will cause all attempts to enter U-mode to raise an exception. | ||
| type(): | | ||
| return (implemented?(ExtensionName::U) && MUTABLE_MISA_U) ? CsrFieldType::RW : CsrFieldType::RO; | ||
| return (!MISA_CSR_IMPLEMENTED) ? CsrFieldType::RO : | ||
| (implemented?(ExtensionName::U) && MUTABLE_MISA_U) ? CsrFieldType::RW : CsrFieldType::RO; | ||
| reset_value(): | | ||
| return implemented?(ExtensionName::U) ? 1 : 0; | ||
| return (!MISA_CSR_IMPLEMENTED) ? 0 : implemented?(ExtensionName::U) ? 1 : 0; | ||
| definedBy: U | ||
| V: | ||
| location: 21 | ||
| description: | | ||
| Indicates support for the `V` (vector) extension. | ||
|
|
||
| [when,"MUTABLE_MISA_V == true"] | ||
| [when,"MUTABLE_MISA_V == true && MISA_CSR_IMPLEMENTED == true"] | ||
|
||
| Writing 0 to this field will cause all attempts to execute a vector instruction to raise an `IllegalInstruction` trap. | ||
|
|
||
| [when,"MISA_CSR_IMPLEMENTED == false"] | ||
| This field reads as 0 and cannot be modified. | ||
| type(): | | ||
| return (implemented?(ExtensionName::V) && MUTABLE_MISA_V) ? CsrFieldType::RW : CsrFieldType::RO; | ||
| return (!MISA_CSR_IMPLEMENTED) ? CsrFieldType::RO : | ||
| (implemented?(ExtensionName::V) && MUTABLE_MISA_V) ? CsrFieldType::RW : CsrFieldType::RO; | ||
| reset_value(): | | ||
| return implemented?(ExtensionName::V) ? 1 : 0; | ||
| return (!MISA_CSR_IMPLEMENTED) ? 0 : implemented?(ExtensionName::V) ? 1 : 0; | ||
| definedBy: V | ||
| sw_read(): | | ||
| if (!MISA_CSR_IMPLEMENTED) { | ||
| return 0; | ||
| } | ||
| return ( | ||
| (CSR[misa].MXL << (xlen() - 2)) | | ||
| (CSR[misa].V << 21) | | ||
| (CSR[misa].U << 20) | | ||
| (CSR[misa].S << 18) | | ||
| (CSR[misa].M << 12) | | ||
| (CSR[misa].I << 7) | | ||
| (CSR[misa].H << 6) | | ||
| ((CSR[misa].A & CSR[misa].M & CSR[misa].F & CSR[misa].D) << 5) | # 'G' | ||
| (CSR[misa].F << 4) | | ||
| (CSR[misa].I << 8) | | ||
| (CSR[misa].H << 7) | | ||
| ((CSR[misa].A & CSR[misa].M & CSR[misa].F & CSR[misa].D) << 6) | # 'G' | ||
| (CSR[misa].F << 5) | | ||
| (CSR[misa].D << 3) | | ||
| (CSR[misa].C << 2) | | ||
| (CSR[misa].B << 1) | | ||
|
|
@@ -261,4 +302,4 @@ cert_test_procedures: | |
| . Loop | ||
| .. Turn off each present bit invidually and try affected behaviors | ||
| . Check | ||
| .. Fail unless turning off bit disables extension as expected | ||
| .. Fail unless turning off bit disables extension as expected | ||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've update how this is handled:
Note that the schema will reject this until #891 ships