From 0387598fd7383f161681862947659a31681ae332 Mon Sep 17 00:00:00 2001 From: sudo-apt-Abdullah Date: Thu, 28 Aug 2025 10:13:17 +0000 Subject: [PATCH 1/3] feat: added sie and sccountinhibit yaml files --- Rakefile | 10 + spec/std/isa/csr/scountinhibit.layout | 118 +++ spec/std/isa/csr/scountinhibit.yaml | 1181 +++++++++++++++++++++++++ spec/std/isa/csr/sie.yaml | 96 ++ 4 files changed, 1405 insertions(+) create mode 100644 spec/std/isa/csr/scountinhibit.layout create mode 100644 spec/std/isa/csr/scountinhibit.yaml create mode 100644 spec/std/isa/csr/sie.yaml diff --git a/Rakefile b/Rakefile index 434aab66ba..2650a7bea2 100755 --- a/Rakefile +++ b/Rakefile @@ -356,6 +356,15 @@ file "#{$resolver.std_path}/csr/Zicntr/mcountinhibit.yaml" => [ File.write(t.name, insert_warning(erb.result(binding), t.prerequisites.first)) end +file "#{$resolver.std_path}/csr/scountinhibit.yaml" => [ + "#{$resolver.std_path}/csr/scountinhibit.layout", + __FILE__ +] do |t| + erb = ERB.new(File.read($resolver.std_path / "csr/scountinhibit.layout"), trim_mode: "-") + erb.filename = "#{$resolver.std_path}/csr/scountinhibit.layout" + File.write(t.name, insert_warning(erb.result(binding), t.prerequisites.first)) +end + namespace :gen do desc "Generate architecture files from layouts" task :arch do @@ -374,6 +383,7 @@ namespace :gen do Rake::Task["#{$resolver.std_path}/csr/Sscofpmf/scountovf.yaml"].invoke Rake::Task["#{$resolver.std_path}/csr/H/hcounteren.yaml"].invoke Rake::Task["#{$resolver.std_path}/csr/Zicntr/mcountinhibit.yaml"].invoke + Rake::Task["#{$resolver.std_path}/csr/scountinhibit.yaml"].invoke (0..63).each do |pmpaddr_num| Rake::Task["#{$resolver.std_path}/csr/I/pmpaddr#{pmpaddr_num}.yaml"].invoke diff --git a/spec/std/isa/csr/scountinhibit.layout b/spec/std/isa/csr/scountinhibit.layout new file mode 100644 index 0000000000..93dc6d0217 --- /dev/null +++ b/spec/std/isa/csr/scountinhibit.layout @@ -0,0 +1,118 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause-Clear + +# yaml-language-server: $schema=../../../schemas/csr_schema.json + +$schema: csr_schema.json# +kind: csr +name: scountinhibit +long_name: Supervisor Counter-Inhibit Register +address: 0x120 +writable: true +priv_mode: S +length: 32 +description: | + For counters delegated to S-mode, the associated `mcountinhibit` bits can be accessed + via `scountinhibit`. For counters not delegated to S-mode, the associated bits in + `scountinhibit` are read-only zero. +definedBy: + anyOf: + - Smcdeleg + - Ssccfg +fields: + CY: + location: 0 + alias: mcountinhibit.CY + description: | + Cycle inhibit. When 1, the cycle counter does not increment. Only meaningful if + mcycle is delegated to S-mode; otherwise reads as 0. + type(): | + return COUNTINHIBIT_EN[0] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[0] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].CY = csr_value.CY; + return csr_value.CY; + IR: + location: 2 + alias: mcountinhibit.IR + description: | + Instructions-retired inhibit. When 1, the instret counter does not increment. Only + meaningful if minstret is delegated to S-mode; else reads 0. + type(): | + return COUNTINHIBIT_EN[2] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[2] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].IR = csr_value.IR; + return csr_value.IR; + <%- (3..31).each do |hpm_num| -%> + HPM<%= hpm_num %>: + location: <%= hpm_num %> + alias: mcountinhibit.HPM<%= hpm_num %> + description: + - id: csr-field-hpmcounter<%= hpm_num %>.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: <%= hpm_num %> + value: true + text: | + When bit is set `hpmcounter<%= hpm_num %>.COUNT` does not increment; when 0, `hpmcounter<%= hpm_num %>.COUNT` increments normally. + - id: unimplemented-hpmcounter<%= hpm_num %> + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: <%= hpm_num %> + value: false + text: | + Since hpmcounter<%= hpm_num %> is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[<%= hpm_num %>] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[<%= hpm_num %>] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM<%= hpm_num %> = csr_value.HPM<%= hpm_num %>; + return csr_value.HPM<%= hpm_num %>; + <%- end -%> + +sw_read(): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + return ($bits(CSR[mcountinhibit]) & ($bits(CSR[scounteren]) & ~32'd2)) ; diff --git a/spec/std/isa/csr/scountinhibit.yaml b/spec/std/isa/csr/scountinhibit.yaml new file mode 100644 index 0000000000..d5c3b4f6a5 --- /dev/null +++ b/spec/std/isa/csr/scountinhibit.yaml @@ -0,0 +1,1181 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + +# WARNING: This file is auto-generated from spec/std/isa/csr/scountinhibit.layout# SPDX-License-Identifier: BSD-3-Clause-Clear + +# yaml-language-server: $schema=../../../schemas/csr_schema.json + +$schema: csr_schema.json# +kind: csr +name: scountinhibit +long_name: Supervisor Counter-Inhibit Register +address: 0x120 +writable: true +priv_mode: S +length: 32 +description: | + For counters delegated to S-mode, the associated `mcountinhibit` bits can be accessed + via `scountinhibit`. For counters not delegated to S-mode, the associated bits in + `scountinhibit` are read-only zero. +definedBy: + anyOf: + - Smcdeleg + - Ssccfg +fields: + CY: + location: 0 + alias: mcountinhibit.CY + description: | + Cycle inhibit. When 1, the cycle counter does not increment. Only meaningful if + mcycle is delegated to S-mode; otherwise reads as 0. + type(): | + return COUNTINHIBIT_EN[0] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[0] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].CY = csr_value.CY; + return csr_value.CY; + IR: + location: 2 + alias: mcountinhibit.IR + description: | + Instructions-retired inhibit. When 1, the instret counter does not increment. Only + meaningful if minstret is delegated to S-mode; else reads 0. + type(): | + return COUNTINHIBIT_EN[2] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[2] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].IR = csr_value.IR; + return csr_value.IR; + HPM3: + location: 3 + alias: mcountinhibit.HPM3 + description: + - id: csr-field-hpmcounter3.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 3 + value: true + text: | + When bit is set `hpmcounter3.COUNT` does not increment; when 0, `hpmcounter3.COUNT` increments normally. + - id: unimplemented-hpmcounter3 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 3 + value: false + text: | + Since hpmcounter3 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[3] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[3] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM3 = csr_value.HPM3; + return csr_value.HPM3; + HPM4: + location: 4 + alias: mcountinhibit.HPM4 + description: + - id: csr-field-hpmcounter4.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 4 + value: true + text: | + When bit is set `hpmcounter4.COUNT` does not increment; when 0, `hpmcounter4.COUNT` increments normally. + - id: unimplemented-hpmcounter4 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 4 + value: false + text: | + Since hpmcounter4 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[4] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[4] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM4 = csr_value.HPM4; + return csr_value.HPM4; + HPM5: + location: 5 + alias: mcountinhibit.HPM5 + description: + - id: csr-field-hpmcounter5.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 5 + value: true + text: | + When bit is set `hpmcounter5.COUNT` does not increment; when 0, `hpmcounter5.COUNT` increments normally. + - id: unimplemented-hpmcounter5 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 5 + value: false + text: | + Since hpmcounter5 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[5] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[5] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM5 = csr_value.HPM5; + return csr_value.HPM5; + HPM6: + location: 6 + alias: mcountinhibit.HPM6 + description: + - id: csr-field-hpmcounter6.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 6 + value: true + text: | + When bit is set `hpmcounter6.COUNT` does not increment; when 0, `hpmcounter6.COUNT` increments normally. + - id: unimplemented-hpmcounter6 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 6 + value: false + text: | + Since hpmcounter6 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[6] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[6] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM6 = csr_value.HPM6; + return csr_value.HPM6; + HPM7: + location: 7 + alias: mcountinhibit.HPM7 + description: + - id: csr-field-hpmcounter7.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 7 + value: true + text: | + When bit is set `hpmcounter7.COUNT` does not increment; when 0, `hpmcounter7.COUNT` increments normally. + - id: unimplemented-hpmcounter7 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 7 + value: false + text: | + Since hpmcounter7 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[7] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[7] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM7 = csr_value.HPM7; + return csr_value.HPM7; + HPM8: + location: 8 + alias: mcountinhibit.HPM8 + description: + - id: csr-field-hpmcounter8.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 8 + value: true + text: | + When bit is set `hpmcounter8.COUNT` does not increment; when 0, `hpmcounter8.COUNT` increments normally. + - id: unimplemented-hpmcounter8 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 8 + value: false + text: | + Since hpmcounter8 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[8] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[8] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM8 = csr_value.HPM8; + return csr_value.HPM8; + HPM9: + location: 9 + alias: mcountinhibit.HPM9 + description: + - id: csr-field-hpmcounter9.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 9 + value: true + text: | + When bit is set `hpmcounter9.COUNT` does not increment; when 0, `hpmcounter9.COUNT` increments normally. + - id: unimplemented-hpmcounter9 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 9 + value: false + text: | + Since hpmcounter9 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[9] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[9] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM9 = csr_value.HPM9; + return csr_value.HPM9; + HPM10: + location: 10 + alias: mcountinhibit.HPM10 + description: + - id: csr-field-hpmcounter10.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 10 + value: true + text: | + When bit is set `hpmcounter10.COUNT` does not increment; when 0, `hpmcounter10.COUNT` increments normally. + - id: unimplemented-hpmcounter10 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 10 + value: false + text: | + Since hpmcounter10 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[10] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[10] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM10 = csr_value.HPM10; + return csr_value.HPM10; + HPM11: + location: 11 + alias: mcountinhibit.HPM11 + description: + - id: csr-field-hpmcounter11.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 11 + value: true + text: | + When bit is set `hpmcounter11.COUNT` does not increment; when 0, `hpmcounter11.COUNT` increments normally. + - id: unimplemented-hpmcounter11 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 11 + value: false + text: | + Since hpmcounter11 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[11] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[11] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM11 = csr_value.HPM11; + return csr_value.HPM11; + HPM12: + location: 12 + alias: mcountinhibit.HPM12 + description: + - id: csr-field-hpmcounter12.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 12 + value: true + text: | + When bit is set `hpmcounter12.COUNT` does not increment; when 0, `hpmcounter12.COUNT` increments normally. + - id: unimplemented-hpmcounter12 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 12 + value: false + text: | + Since hpmcounter12 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[12] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[12] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM12 = csr_value.HPM12; + return csr_value.HPM12; + HPM13: + location: 13 + alias: mcountinhibit.HPM13 + description: + - id: csr-field-hpmcounter13.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 13 + value: true + text: | + When bit is set `hpmcounter13.COUNT` does not increment; when 0, `hpmcounter13.COUNT` increments normally. + - id: unimplemented-hpmcounter13 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 13 + value: false + text: | + Since hpmcounter13 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[13] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[13] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM13 = csr_value.HPM13; + return csr_value.HPM13; + HPM14: + location: 14 + alias: mcountinhibit.HPM14 + description: + - id: csr-field-hpmcounter14.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 14 + value: true + text: | + When bit is set `hpmcounter14.COUNT` does not increment; when 0, `hpmcounter14.COUNT` increments normally. + - id: unimplemented-hpmcounter14 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 14 + value: false + text: | + Since hpmcounter14 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[14] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[14] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM14 = csr_value.HPM14; + return csr_value.HPM14; + HPM15: + location: 15 + alias: mcountinhibit.HPM15 + description: + - id: csr-field-hpmcounter15.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 15 + value: true + text: | + When bit is set `hpmcounter15.COUNT` does not increment; when 0, `hpmcounter15.COUNT` increments normally. + - id: unimplemented-hpmcounter15 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 15 + value: false + text: | + Since hpmcounter15 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[15] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[15] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM15 = csr_value.HPM15; + return csr_value.HPM15; + HPM16: + location: 16 + alias: mcountinhibit.HPM16 + description: + - id: csr-field-hpmcounter16.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 16 + value: true + text: | + When bit is set `hpmcounter16.COUNT` does not increment; when 0, `hpmcounter16.COUNT` increments normally. + - id: unimplemented-hpmcounter16 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 16 + value: false + text: | + Since hpmcounter16 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[16] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[16] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM16 = csr_value.HPM16; + return csr_value.HPM16; + HPM17: + location: 17 + alias: mcountinhibit.HPM17 + description: + - id: csr-field-hpmcounter17.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 17 + value: true + text: | + When bit is set `hpmcounter17.COUNT` does not increment; when 0, `hpmcounter17.COUNT` increments normally. + - id: unimplemented-hpmcounter17 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 17 + value: false + text: | + Since hpmcounter17 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[17] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[17] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM17 = csr_value.HPM17; + return csr_value.HPM17; + HPM18: + location: 18 + alias: mcountinhibit.HPM18 + description: + - id: csr-field-hpmcounter18.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 18 + value: true + text: | + When bit is set `hpmcounter18.COUNT` does not increment; when 0, `hpmcounter18.COUNT` increments normally. + - id: unimplemented-hpmcounter18 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 18 + value: false + text: | + Since hpmcounter18 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[18] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[18] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM18 = csr_value.HPM18; + return csr_value.HPM18; + HPM19: + location: 19 + alias: mcountinhibit.HPM19 + description: + - id: csr-field-hpmcounter19.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 19 + value: true + text: | + When bit is set `hpmcounter19.COUNT` does not increment; when 0, `hpmcounter19.COUNT` increments normally. + - id: unimplemented-hpmcounter19 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 19 + value: false + text: | + Since hpmcounter19 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[19] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[19] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM19 = csr_value.HPM19; + return csr_value.HPM19; + HPM20: + location: 20 + alias: mcountinhibit.HPM20 + description: + - id: csr-field-hpmcounter20.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 20 + value: true + text: | + When bit is set `hpmcounter20.COUNT` does not increment; when 0, `hpmcounter20.COUNT` increments normally. + - id: unimplemented-hpmcounter20 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 20 + value: false + text: | + Since hpmcounter20 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[20] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[20] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM20 = csr_value.HPM20; + return csr_value.HPM20; + HPM21: + location: 21 + alias: mcountinhibit.HPM21 + description: + - id: csr-field-hpmcounter21.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 21 + value: true + text: | + When bit is set `hpmcounter21.COUNT` does not increment; when 0, `hpmcounter21.COUNT` increments normally. + - id: unimplemented-hpmcounter21 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 21 + value: false + text: | + Since hpmcounter21 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[21] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[21] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM21 = csr_value.HPM21; + return csr_value.HPM21; + HPM22: + location: 22 + alias: mcountinhibit.HPM22 + description: + - id: csr-field-hpmcounter22.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 22 + value: true + text: | + When bit is set `hpmcounter22.COUNT` does not increment; when 0, `hpmcounter22.COUNT` increments normally. + - id: unimplemented-hpmcounter22 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 22 + value: false + text: | + Since hpmcounter22 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[22] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[22] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM22 = csr_value.HPM22; + return csr_value.HPM22; + HPM23: + location: 23 + alias: mcountinhibit.HPM23 + description: + - id: csr-field-hpmcounter23.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 23 + value: true + text: | + When bit is set `hpmcounter23.COUNT` does not increment; when 0, `hpmcounter23.COUNT` increments normally. + - id: unimplemented-hpmcounter23 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 23 + value: false + text: | + Since hpmcounter23 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[23] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[23] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM23 = csr_value.HPM23; + return csr_value.HPM23; + HPM24: + location: 24 + alias: mcountinhibit.HPM24 + description: + - id: csr-field-hpmcounter24.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 24 + value: true + text: | + When bit is set `hpmcounter24.COUNT` does not increment; when 0, `hpmcounter24.COUNT` increments normally. + - id: unimplemented-hpmcounter24 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 24 + value: false + text: | + Since hpmcounter24 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[24] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[24] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM24 = csr_value.HPM24; + return csr_value.HPM24; + HPM25: + location: 25 + alias: mcountinhibit.HPM25 + description: + - id: csr-field-hpmcounter25.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 25 + value: true + text: | + When bit is set `hpmcounter25.COUNT` does not increment; when 0, `hpmcounter25.COUNT` increments normally. + - id: unimplemented-hpmcounter25 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 25 + value: false + text: | + Since hpmcounter25 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[25] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[25] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM25 = csr_value.HPM25; + return csr_value.HPM25; + HPM26: + location: 26 + alias: mcountinhibit.HPM26 + description: + - id: csr-field-hpmcounter26.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 26 + value: true + text: | + When bit is set `hpmcounter26.COUNT` does not increment; when 0, `hpmcounter26.COUNT` increments normally. + - id: unimplemented-hpmcounter26 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 26 + value: false + text: | + Since hpmcounter26 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[26] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[26] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM26 = csr_value.HPM26; + return csr_value.HPM26; + HPM27: + location: 27 + alias: mcountinhibit.HPM27 + description: + - id: csr-field-hpmcounter27.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 27 + value: true + text: | + When bit is set `hpmcounter27.COUNT` does not increment; when 0, `hpmcounter27.COUNT` increments normally. + - id: unimplemented-hpmcounter27 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 27 + value: false + text: | + Since hpmcounter27 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[27] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[27] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM27 = csr_value.HPM27; + return csr_value.HPM27; + HPM28: + location: 28 + alias: mcountinhibit.HPM28 + description: + - id: csr-field-hpmcounter28.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 28 + value: true + text: | + When bit is set `hpmcounter28.COUNT` does not increment; when 0, `hpmcounter28.COUNT` increments normally. + - id: unimplemented-hpmcounter28 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 28 + value: false + text: | + Since hpmcounter28 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[28] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[28] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM28 = csr_value.HPM28; + return csr_value.HPM28; + HPM29: + location: 29 + alias: mcountinhibit.HPM29 + description: + - id: csr-field-hpmcounter29.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 29 + value: true + text: | + When bit is set `hpmcounter29.COUNT` does not increment; when 0, `hpmcounter29.COUNT` increments normally. + - id: unimplemented-hpmcounter29 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 29 + value: false + text: | + Since hpmcounter29 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[29] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[29] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM29 = csr_value.HPM29; + return csr_value.HPM29; + HPM30: + location: 30 + alias: mcountinhibit.HPM30 + description: + - id: csr-field-hpmcounter30.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 30 + value: true + text: | + When bit is set `hpmcounter30.COUNT` does not increment; when 0, `hpmcounter30.COUNT` increments normally. + - id: unimplemented-hpmcounter30 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 30 + value: false + text: | + Since hpmcounter30 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[30] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[30] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM30 = csr_value.HPM30; + return csr_value.HPM30; + HPM31: + location: 31 + alias: mcountinhibit.HPM31 + description: + - id: csr-field-hpmcounter31.COUNT-effect + normative: true + when: + param: + name: COUNTINHIBIT_EN + index: 31 + value: true + text: | + When bit is set `hpmcounter31.COUNT` does not increment; when 0, `hpmcounter31.COUNT` increments normally. + - id: unimplemented-hpmcounter31 + normative: false + when: + param: + name: COUNTINHIBIT_EN + index: 31 + value: false + text: | + Since hpmcounter31 is not implemented, this field is read-only zero. + type(): | + return COUNTINHIBIT_EN[31] ? CsrFieldType::RW : CsrFieldType::RO; + reset_value(): | + return COUNTINHIBIT_EN[31] ? UNDEFINED_LEGAL : 0; + sw_write(csr_value): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + CSR[mcountinhibit].HPM31 = csr_value.HPM31; + return csr_value.HPM31; + +sw_read(): | + if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { + if (mode() == PrivilegeMode::M) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + return ($bits(CSR[mcountinhibit]) & ($bits(CSR[scounteren]) & ~32'd2)) ; diff --git a/spec/std/isa/csr/sie.yaml b/spec/std/isa/csr/sie.yaml new file mode 100644 index 0000000000..0d95a58d5e --- /dev/null +++ b/spec/std/isa/csr/sie.yaml @@ -0,0 +1,96 @@ +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause-Clear + +# yaml-language-server: $schema=../../../schemas/csr_schema.json + +$schema: "csr_schema.json#" +kind: csr +name: sie +long_name: Supervisor Interrupt Enable +address: 0x104 +writable: true +priv_mode: S +description: | + `sie` is the read/write register containing interrupt enable bits. Interrupt cause + number i as reported in CSR scause corresponds with bit i in both `sip` and `sie`. + + An interrupt i will trap to S-mode if both of the following are true: + (a) Either the current privilege mode is S and the SIE bit in the sstatus register + is set, or the current privilege mode has less privilege than S-mode. + (b) Bit i is set in both `sip` and `sie`. + + These conditions for an interrupt trap to occur must be evaluated in a bounded amount + of time from when an interrupt becomes, or ceases to be, pending in sip , and must + also be evaluated immediately following the execution of an SRET instruction or an + explicit write to a CSR on which these interrupt trap conditions expressly depend + (including `sip`, `sie` and `sstatus`). + + Interrupts to S-mode take priority over any interrupts to lower privilege modes. + A bit in sie must be writable if the corresponding interrupt can ever become pending. + Bits of `sie` that are not writable are read-only zero. + + Each standard interrupt type (SEI, STI, SSI, or LCOFI) may not be implemented, in which + case the corresponding interrupt-pending and interrupt-enable bits are read-only zeros. + All bits in sip and sie are WARL fields. The implemented interrupts may be found by + writing one to every bit location in sie, then reading back to see which bit positions + hold a one. + + [NOTE] + The sie register is subsets of the mie register. Reading any implemented field, or + writing any writable field, of sie effects a read or write of the homonymous field + of mie. +length: SXLEN +definedBy: S +fields: + SSIE: + location: 1 + type: RW-H + reset_value: UNDEFINED_LEGAL + alias: + - mie.SSIE + definedBy: S + description: | + sie.SSIE is the interrupt-enable bit for supervisor-level software interrupts. + sw_write(csr_value): | + CSR[mie].SSIE = csr_value.SSIE; + return csr_value.SSIE; + STIE: + location: 5 + type: RW-H + reset_value: UNDEFINED_LEGAL + alias: + - mie.STIE + definedBy: S + description: | + sie.STIE is the interrupt-enable bit for supervisor-level timer interrupts. + sw_write(csr_value): | + CSR[mie].STIE = csr_value.STIE; + return csr_value.STIE; + SEIE: + location: 9 + type: RW-H + reset_value: UNDEFINED_LEGAL + alias: + - mie.SEIE + definedBy: S + description: | + sie.SEIE is the interrupt-enable bit for supervisor-level external interrupts. + sw_write(csr_value): | + CSR[mie].SEIE = csr_value.SEIE; + return csr_value.SEIE; + LCOFIE: + location: 13 + type: RW-H + reset_value: UNDEFINED_LEGAL + alias: + - mie.LCOFIE + definedBy: Sscofpmf + description: | + If the Sscofpmf extension is implemented, bit sie.LCOFIE is the interrupt-enable + bit for local-counter-overflow interrupts. If the Sscofpmf extension is not + implemented, sie.LCOFIE is read-only zeros. + sw_write(csr_value): | + CSR[mie].LCOFIE = csr_value.LCOFIE; + return csr_value.LCOFIE; +sw_read(): | + return $bits(CSR[mie]) & 0x2222; From c04a7726df21f899e78d851f2eb8e3da1dc7911d Mon Sep 17 00:00:00 2001 From: sudo-apt-Abdullah Date: Mon, 1 Sep 2025 05:04:15 +0000 Subject: [PATCH 2/3] improved descriptions a bit --- spec/std/isa/csr/scountinhibit.layout | 2 +- spec/std/isa/csr/scountinhibit.yaml | 58 +++++++++++++-------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/spec/std/isa/csr/scountinhibit.layout b/spec/std/isa/csr/scountinhibit.layout index 93dc6d0217..ed778bb266 100644 --- a/spec/std/isa/csr/scountinhibit.layout +++ b/spec/std/isa/csr/scountinhibit.layout @@ -77,7 +77,7 @@ fields: index: <%= hpm_num %> value: true text: | - When bit is set `hpmcounter<%= hpm_num %>.COUNT` does not increment; when 0, `hpmcounter<%= hpm_num %>.COUNT` increments normally. + When set, `hpmcounter<%= hpm_num %>.COUNT` does not increment; when 0, `hpmcounter<%= hpm_num %>.COUNT` increments normally. - id: unimplemented-hpmcounter<%= hpm_num %> normative: false when: diff --git a/spec/std/isa/csr/scountinhibit.yaml b/spec/std/isa/csr/scountinhibit.yaml index d5c3b4f6a5..5786bdebb6 100644 --- a/spec/std/isa/csr/scountinhibit.yaml +++ b/spec/std/isa/csr/scountinhibit.yaml @@ -77,7 +77,7 @@ fields: index: 3 value: true text: | - When bit is set `hpmcounter3.COUNT` does not increment; when 0, `hpmcounter3.COUNT` increments normally. + When set, `hpmcounter3.COUNT` does not increment; when 0, `hpmcounter3.COUNT` increments normally. - id: unimplemented-hpmcounter3 normative: false when: @@ -115,7 +115,7 @@ fields: index: 4 value: true text: | - When bit is set `hpmcounter4.COUNT` does not increment; when 0, `hpmcounter4.COUNT` increments normally. + When set, `hpmcounter4.COUNT` does not increment; when 0, `hpmcounter4.COUNT` increments normally. - id: unimplemented-hpmcounter4 normative: false when: @@ -153,7 +153,7 @@ fields: index: 5 value: true text: | - When bit is set `hpmcounter5.COUNT` does not increment; when 0, `hpmcounter5.COUNT` increments normally. + When set, `hpmcounter5.COUNT` does not increment; when 0, `hpmcounter5.COUNT` increments normally. - id: unimplemented-hpmcounter5 normative: false when: @@ -191,7 +191,7 @@ fields: index: 6 value: true text: | - When bit is set `hpmcounter6.COUNT` does not increment; when 0, `hpmcounter6.COUNT` increments normally. + When set, `hpmcounter6.COUNT` does not increment; when 0, `hpmcounter6.COUNT` increments normally. - id: unimplemented-hpmcounter6 normative: false when: @@ -229,7 +229,7 @@ fields: index: 7 value: true text: | - When bit is set `hpmcounter7.COUNT` does not increment; when 0, `hpmcounter7.COUNT` increments normally. + When set, `hpmcounter7.COUNT` does not increment; when 0, `hpmcounter7.COUNT` increments normally. - id: unimplemented-hpmcounter7 normative: false when: @@ -267,7 +267,7 @@ fields: index: 8 value: true text: | - When bit is set `hpmcounter8.COUNT` does not increment; when 0, `hpmcounter8.COUNT` increments normally. + When set, `hpmcounter8.COUNT` does not increment; when 0, `hpmcounter8.COUNT` increments normally. - id: unimplemented-hpmcounter8 normative: false when: @@ -305,7 +305,7 @@ fields: index: 9 value: true text: | - When bit is set `hpmcounter9.COUNT` does not increment; when 0, `hpmcounter9.COUNT` increments normally. + When set, `hpmcounter9.COUNT` does not increment; when 0, `hpmcounter9.COUNT` increments normally. - id: unimplemented-hpmcounter9 normative: false when: @@ -343,7 +343,7 @@ fields: index: 10 value: true text: | - When bit is set `hpmcounter10.COUNT` does not increment; when 0, `hpmcounter10.COUNT` increments normally. + When set, `hpmcounter10.COUNT` does not increment; when 0, `hpmcounter10.COUNT` increments normally. - id: unimplemented-hpmcounter10 normative: false when: @@ -381,7 +381,7 @@ fields: index: 11 value: true text: | - When bit is set `hpmcounter11.COUNT` does not increment; when 0, `hpmcounter11.COUNT` increments normally. + When set, `hpmcounter11.COUNT` does not increment; when 0, `hpmcounter11.COUNT` increments normally. - id: unimplemented-hpmcounter11 normative: false when: @@ -419,7 +419,7 @@ fields: index: 12 value: true text: | - When bit is set `hpmcounter12.COUNT` does not increment; when 0, `hpmcounter12.COUNT` increments normally. + When set, `hpmcounter12.COUNT` does not increment; when 0, `hpmcounter12.COUNT` increments normally. - id: unimplemented-hpmcounter12 normative: false when: @@ -457,7 +457,7 @@ fields: index: 13 value: true text: | - When bit is set `hpmcounter13.COUNT` does not increment; when 0, `hpmcounter13.COUNT` increments normally. + When set, `hpmcounter13.COUNT` does not increment; when 0, `hpmcounter13.COUNT` increments normally. - id: unimplemented-hpmcounter13 normative: false when: @@ -495,7 +495,7 @@ fields: index: 14 value: true text: | - When bit is set `hpmcounter14.COUNT` does not increment; when 0, `hpmcounter14.COUNT` increments normally. + When set, `hpmcounter14.COUNT` does not increment; when 0, `hpmcounter14.COUNT` increments normally. - id: unimplemented-hpmcounter14 normative: false when: @@ -533,7 +533,7 @@ fields: index: 15 value: true text: | - When bit is set `hpmcounter15.COUNT` does not increment; when 0, `hpmcounter15.COUNT` increments normally. + When set, `hpmcounter15.COUNT` does not increment; when 0, `hpmcounter15.COUNT` increments normally. - id: unimplemented-hpmcounter15 normative: false when: @@ -571,7 +571,7 @@ fields: index: 16 value: true text: | - When bit is set `hpmcounter16.COUNT` does not increment; when 0, `hpmcounter16.COUNT` increments normally. + When set, `hpmcounter16.COUNT` does not increment; when 0, `hpmcounter16.COUNT` increments normally. - id: unimplemented-hpmcounter16 normative: false when: @@ -609,7 +609,7 @@ fields: index: 17 value: true text: | - When bit is set `hpmcounter17.COUNT` does not increment; when 0, `hpmcounter17.COUNT` increments normally. + When set, `hpmcounter17.COUNT` does not increment; when 0, `hpmcounter17.COUNT` increments normally. - id: unimplemented-hpmcounter17 normative: false when: @@ -647,7 +647,7 @@ fields: index: 18 value: true text: | - When bit is set `hpmcounter18.COUNT` does not increment; when 0, `hpmcounter18.COUNT` increments normally. + When set, `hpmcounter18.COUNT` does not increment; when 0, `hpmcounter18.COUNT` increments normally. - id: unimplemented-hpmcounter18 normative: false when: @@ -685,7 +685,7 @@ fields: index: 19 value: true text: | - When bit is set `hpmcounter19.COUNT` does not increment; when 0, `hpmcounter19.COUNT` increments normally. + When set, `hpmcounter19.COUNT` does not increment; when 0, `hpmcounter19.COUNT` increments normally. - id: unimplemented-hpmcounter19 normative: false when: @@ -723,7 +723,7 @@ fields: index: 20 value: true text: | - When bit is set `hpmcounter20.COUNT` does not increment; when 0, `hpmcounter20.COUNT` increments normally. + When set, `hpmcounter20.COUNT` does not increment; when 0, `hpmcounter20.COUNT` increments normally. - id: unimplemented-hpmcounter20 normative: false when: @@ -761,7 +761,7 @@ fields: index: 21 value: true text: | - When bit is set `hpmcounter21.COUNT` does not increment; when 0, `hpmcounter21.COUNT` increments normally. + When set, `hpmcounter21.COUNT` does not increment; when 0, `hpmcounter21.COUNT` increments normally. - id: unimplemented-hpmcounter21 normative: false when: @@ -799,7 +799,7 @@ fields: index: 22 value: true text: | - When bit is set `hpmcounter22.COUNT` does not increment; when 0, `hpmcounter22.COUNT` increments normally. + When set, `hpmcounter22.COUNT` does not increment; when 0, `hpmcounter22.COUNT` increments normally. - id: unimplemented-hpmcounter22 normative: false when: @@ -837,7 +837,7 @@ fields: index: 23 value: true text: | - When bit is set `hpmcounter23.COUNT` does not increment; when 0, `hpmcounter23.COUNT` increments normally. + When set, `hpmcounter23.COUNT` does not increment; when 0, `hpmcounter23.COUNT` increments normally. - id: unimplemented-hpmcounter23 normative: false when: @@ -875,7 +875,7 @@ fields: index: 24 value: true text: | - When bit is set `hpmcounter24.COUNT` does not increment; when 0, `hpmcounter24.COUNT` increments normally. + When set, `hpmcounter24.COUNT` does not increment; when 0, `hpmcounter24.COUNT` increments normally. - id: unimplemented-hpmcounter24 normative: false when: @@ -913,7 +913,7 @@ fields: index: 25 value: true text: | - When bit is set `hpmcounter25.COUNT` does not increment; when 0, `hpmcounter25.COUNT` increments normally. + When set, `hpmcounter25.COUNT` does not increment; when 0, `hpmcounter25.COUNT` increments normally. - id: unimplemented-hpmcounter25 normative: false when: @@ -951,7 +951,7 @@ fields: index: 26 value: true text: | - When bit is set `hpmcounter26.COUNT` does not increment; when 0, `hpmcounter26.COUNT` increments normally. + When set, `hpmcounter26.COUNT` does not increment; when 0, `hpmcounter26.COUNT` increments normally. - id: unimplemented-hpmcounter26 normative: false when: @@ -989,7 +989,7 @@ fields: index: 27 value: true text: | - When bit is set `hpmcounter27.COUNT` does not increment; when 0, `hpmcounter27.COUNT` increments normally. + When set, `hpmcounter27.COUNT` does not increment; when 0, `hpmcounter27.COUNT` increments normally. - id: unimplemented-hpmcounter27 normative: false when: @@ -1027,7 +1027,7 @@ fields: index: 28 value: true text: | - When bit is set `hpmcounter28.COUNT` does not increment; when 0, `hpmcounter28.COUNT` increments normally. + When set, `hpmcounter28.COUNT` does not increment; when 0, `hpmcounter28.COUNT` increments normally. - id: unimplemented-hpmcounter28 normative: false when: @@ -1065,7 +1065,7 @@ fields: index: 29 value: true text: | - When bit is set `hpmcounter29.COUNT` does not increment; when 0, `hpmcounter29.COUNT` increments normally. + When set, `hpmcounter29.COUNT` does not increment; when 0, `hpmcounter29.COUNT` increments normally. - id: unimplemented-hpmcounter29 normative: false when: @@ -1103,7 +1103,7 @@ fields: index: 30 value: true text: | - When bit is set `hpmcounter30.COUNT` does not increment; when 0, `hpmcounter30.COUNT` increments normally. + When set, `hpmcounter30.COUNT` does not increment; when 0, `hpmcounter30.COUNT` increments normally. - id: unimplemented-hpmcounter30 normative: false when: @@ -1141,7 +1141,7 @@ fields: index: 31 value: true text: | - When bit is set `hpmcounter31.COUNT` does not increment; when 0, `hpmcounter31.COUNT` increments normally. + When set, `hpmcounter31.COUNT` does not increment; when 0, `hpmcounter31.COUNT` increments normally. - id: unimplemented-hpmcounter31 normative: false when: From 43c2940aaa23f6f1c327756ca33fb49eb0427b62 Mon Sep 17 00:00:00 2001 From: sudo-apt-Abdullah Date: Mon, 8 Sep 2025 09:33:44 +0000 Subject: [PATCH 3/3] tried to address the concerns --- spec/std/isa/csr/scountinhibit.layout | 84 ++-- spec/std/isa/csr/scountinhibit.yaml | 644 +++++++++++++++++--------- spec/std/isa/csr/sie.yaml | 20 +- 3 files changed, 486 insertions(+), 262 deletions(-) diff --git a/spec/std/isa/csr/scountinhibit.layout b/spec/std/isa/csr/scountinhibit.layout index ed778bb266..52591b5818 100644 --- a/spec/std/isa/csr/scountinhibit.layout +++ b/spec/std/isa/csr/scountinhibit.layout @@ -1,4 +1,4 @@ -# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# Copyright (c) Muhammad Abdullah — 10xEngineers # SPDX-License-Identifier: BSD-3-Clause-Clear # yaml-language-server: $schema=../../../schemas/csr_schema.json @@ -31,14 +31,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[0] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].CY = csr_value.CY; return csr_value.CY; @@ -53,14 +59,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[2] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].IR = csr_value.IR; return csr_value.IR; @@ -92,27 +104,39 @@ fields: reset_value(): | return COUNTINHIBIT_EN[<%= hpm_num %>] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM<%= hpm_num %> = csr_value.HPM<%= hpm_num %>; return csr_value.HPM<%= hpm_num %>; <%- end -%> sw_read(): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } - return ($bits(CSR[mcountinhibit]) & ($bits(CSR[scounteren]) & ~32'd2)) ; + return $bits(CSR[mcountinhibit]) & $bits(CSR[mcounteren]); diff --git a/spec/std/isa/csr/scountinhibit.yaml b/spec/std/isa/csr/scountinhibit.yaml index 5786bdebb6..c7cb11c5e8 100644 --- a/spec/std/isa/csr/scountinhibit.yaml +++ b/spec/std/isa/csr/scountinhibit.yaml @@ -1,4 +1,4 @@ -# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# Copyright (c) Muhammad Abdullah — 10xEngineers # WARNING: This file is auto-generated from spec/std/isa/csr/scountinhibit.layout# SPDX-License-Identifier: BSD-3-Clause-Clear @@ -32,14 +32,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[0] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].CY = csr_value.CY; return csr_value.CY; @@ -54,14 +60,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[2] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].IR = csr_value.IR; return csr_value.IR; @@ -92,14 +104,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[3] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM3 = csr_value.HPM3; return csr_value.HPM3; @@ -130,14 +148,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[4] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM4 = csr_value.HPM4; return csr_value.HPM4; @@ -168,14 +192,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[5] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM5 = csr_value.HPM5; return csr_value.HPM5; @@ -206,14 +236,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[6] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM6 = csr_value.HPM6; return csr_value.HPM6; @@ -244,14 +280,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[7] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM7 = csr_value.HPM7; return csr_value.HPM7; @@ -282,14 +324,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[8] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM8 = csr_value.HPM8; return csr_value.HPM8; @@ -320,14 +368,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[9] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM9 = csr_value.HPM9; return csr_value.HPM9; @@ -358,14 +412,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[10] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM10 = csr_value.HPM10; return csr_value.HPM10; @@ -396,14 +456,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[11] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM11 = csr_value.HPM11; return csr_value.HPM11; @@ -434,14 +500,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[12] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM12 = csr_value.HPM12; return csr_value.HPM12; @@ -472,14 +544,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[13] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM13 = csr_value.HPM13; return csr_value.HPM13; @@ -510,14 +588,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[14] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM14 = csr_value.HPM14; return csr_value.HPM14; @@ -548,14 +632,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[15] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM15 = csr_value.HPM15; return csr_value.HPM15; @@ -586,14 +676,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[16] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM16 = csr_value.HPM16; return csr_value.HPM16; @@ -624,14 +720,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[17] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM17 = csr_value.HPM17; return csr_value.HPM17; @@ -662,14 +764,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[18] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM18 = csr_value.HPM18; return csr_value.HPM18; @@ -700,14 +808,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[19] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM19 = csr_value.HPM19; return csr_value.HPM19; @@ -738,14 +852,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[20] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM20 = csr_value.HPM20; return csr_value.HPM20; @@ -776,14 +896,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[21] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM21 = csr_value.HPM21; return csr_value.HPM21; @@ -814,14 +940,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[22] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM22 = csr_value.HPM22; return csr_value.HPM22; @@ -852,14 +984,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[23] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM23 = csr_value.HPM23; return csr_value.HPM23; @@ -890,14 +1028,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[24] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM24 = csr_value.HPM24; return csr_value.HPM24; @@ -928,14 +1072,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[25] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM25 = csr_value.HPM25; return csr_value.HPM25; @@ -966,14 +1116,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[26] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM26 = csr_value.HPM26; return csr_value.HPM26; @@ -1004,14 +1160,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[27] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM27 = csr_value.HPM27; return csr_value.HPM27; @@ -1042,14 +1204,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[28] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM28 = csr_value.HPM28; return csr_value.HPM28; @@ -1080,14 +1248,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[29] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM29 = csr_value.HPM29; return csr_value.HPM29; @@ -1118,14 +1292,20 @@ fields: reset_value(): | return COUNTINHIBIT_EN[30] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM30 = csr_value.HPM30; return csr_value.HPM30; @@ -1156,26 +1336,38 @@ fields: reset_value(): | return COUNTINHIBIT_EN[31] ? UNDEFINED_LEGAL : 0; sw_write(csr_value): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } CSR[mcountinhibit].HPM31 = csr_value.HPM31; return csr_value.HPM31; sw_read(): | - if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b0) { - if (mode() == PrivilegeMode::M) { - raise(ExceptionCode::IllegalInstruction, mode(), $encoding); - } - } else if (implemented_csr?(CsrName::menvcfg) && CSR[menvcfg].CDE == 1'b1) { - if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { - raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + if (implemented_version?(ExtensionName::Sm, ">=1.12")) { + if (CSR[menvcfg].CDE == 1'b0) { + if ((mode() == PrivilegeMode::M) || (mode() == PrivilegeMode::S)) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + } else if (CSR[menvcfg].CDE == 1'b1) { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } + } else { + if ((mode() == PrivilegeMode::VS) || (mode() == PrivilegeMode::VU)) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } } - return ($bits(CSR[mcountinhibit]) & ($bits(CSR[scounteren]) & ~32'd2)) ; + return $bits(CSR[mcountinhibit]) & $bits(CSR[mcounteren]); diff --git a/spec/std/isa/csr/sie.yaml b/spec/std/isa/csr/sie.yaml index 0d95a58d5e..b11314986f 100644 --- a/spec/std/isa/csr/sie.yaml +++ b/spec/std/isa/csr/sie.yaml @@ -1,4 +1,4 @@ -# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# Copyright (c) Muhammad Abdullah — 10xEngineers # SPDX-License-Identifier: BSD-3-Clause-Clear # yaml-language-server: $schema=../../../schemas/csr_schema.json @@ -52,7 +52,9 @@ fields: description: | sie.SSIE is the interrupt-enable bit for supervisor-level software interrupts. sw_write(csr_value): | - CSR[mie].SSIE = csr_value.SSIE; + if (CSR[mideleg].SSI == 1'b1) { + CSR[mie].SSIE = csr_value.SSIE; + } return csr_value.SSIE; STIE: location: 5 @@ -64,7 +66,9 @@ fields: description: | sie.STIE is the interrupt-enable bit for supervisor-level timer interrupts. sw_write(csr_value): | - CSR[mie].STIE = csr_value.STIE; + if (CSR[mideleg].STI == 1'b1) { + CSR[mie].STIE = csr_value.STIE; + } return csr_value.STIE; SEIE: location: 9 @@ -76,7 +80,9 @@ fields: description: | sie.SEIE is the interrupt-enable bit for supervisor-level external interrupts. sw_write(csr_value): | - CSR[mie].SEIE = csr_value.SEIE; + if (CSR[mideleg].SEI == 1'b1) { + CSR[mie].SEIE = csr_value.SEIE; + } return csr_value.SEIE; LCOFIE: location: 13 @@ -90,7 +96,9 @@ fields: bit for local-counter-overflow interrupts. If the Sscofpmf extension is not implemented, sie.LCOFIE is read-only zeros. sw_write(csr_value): | - CSR[mie].LCOFIE = csr_value.LCOFIE; + if (CSR[mideleg].LCOFI == 1'b1) { + CSR[mie].LCOFIE = csr_value.LCOFIE; + } return csr_value.LCOFIE; sw_read(): | - return $bits(CSR[mie]) & 0x2222; + return $bits(CSR[mie]) & $bits(CSR[mideleg]);