Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions arch/csr/misa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ misa:
Writing 0 to this field will cause all atomic instructions to raise an `IllegalInstruction` exception.
type(): |
return (implemented?(ExtensionName::A) && MUTABLE_MISA_A) ? CsrFieldType::RW : CsrFieldType::RO;
reset_value(): |
return implemented?(ExtensionName::A) ? 1 : 0;
definedBy: A
reset_value: 1
B:
location: 1
description: |
Expand All @@ -34,8 +34,8 @@ misa:
Writing 0 to this field will cause all bitmanip instructions to raise an `IllegalInstruction` exception.
type(): |
return (implemented?(ExtensionName::B) && MUTABLE_MISA_B) ? CsrFieldType::RW : CsrFieldType::RO;
reset_value(): |
return implemented?(ExtensionName::B) ? 1 : 0;
definedBy: B
reset_value: 1
C:
location: 2
description: |
Expand All @@ -46,8 +46,8 @@ misa:
Additionally, IALIGN becomes 32.
type(): |
return (implemented?(ExtensionName::C) && MUTABLE_MISA_C) ? CsrFieldType::RW : CsrFieldType::RO;
reset_value(): |
return implemented?(ExtensionName::C) ? 1 : 0;
definedBy: C
reset_value: 1
D:
location: 3
description: |
Expand All @@ -61,8 +61,8 @@ misa:
--
type(): |
return (implemented?(ExtensionName::D) && MUTABLE_MISA_D) ? CsrFieldType::RW : CsrFieldType::RO;
reset_value(): |
return implemented?(ExtensionName::D) ? 1 : 0;
definedBy: D
reset_value: 1
F:
location: 5
description: |
Expand All @@ -76,8 +76,8 @@ misa:
--
type(): |
return (implemented?(ExtensionName::F) && MUTABLE_MISA_F) ? CsrFieldType::RW : CsrFieldType::RO;
reset_value(): |
return implemented?(ExtensionName::F) ? 1 : 0;
definedBy: F
reset_value: 1
sw_write(csr_value): |
if (csr_value.F == 0 && csr_value.D == 1) {
return UNDEFINED_LEGAL_DETERMINISTIC;
Expand Down Expand Up @@ -115,13 +115,14 @@ misa:
Writing 0 to this field will cause all attempts to enter VS- or VU- mode, execute a hypervisor instruction, or access a hypervisor CSR to raise an `IllegalInstruction` fault.
type(): |
return (implemented?(ExtensionName::H) && MUTABLE_MISA_H) ? CsrFieldType::RW : CsrFieldType::RO;
reset_value(): |
return implemented?(ExtensionName::H) ? 1 : 0;
definedBy: H
reset_value: 1
I:
location: 8
description: |
Indicates support for the `I` (base) extension.
type: RO
definedBy: I
reset_value: 1
M:
location: 13
Expand All @@ -132,8 +133,8 @@ misa:
Writing 0 to this field will cause all attempts to execute an integer multiply or divide instruction to raise an `IllegalInstruction` exception.
type(): |
return (implemented?(ExtensionName::M) && MUTABLE_MISA_M) ? CsrFieldType::RW : CsrFieldType::RO;
reset_value(): |
return implemented?(ExtensionName::M) ? 1 : 0;
definedBy: M
reset_value: 1
S:
location: 19
description: |
Expand All @@ -143,8 +144,8 @@ misa:
Writing 0 to this field will cause all attempts to enter S-mode or access S-mode state to raise an exception.
type(): |
return (implemented?(ExtensionName::S) && MUTABLE_MISA_S) ? CsrFieldType::RW : CsrFieldType::RO;
reset_value(): |
return implemented?(ExtensionName::S) ? 1 : 0;
definedBy: S
reset_value: 1
U:
location: 21
description: |
Expand All @@ -154,19 +155,18 @@ misa:
Writing 0 to this field will cause all attempts to enter U-mode to raise an exception.
type(): |
return (implemented?(ExtensionName::U) && MUTABLE_MISA_U) ? CsrFieldType::RW : CsrFieldType::RO;
reset_value(): |
return implemented?(ExtensionName::U) ? 1 : 0;
definedBy: U
reset_value: 1
V:
location: 22
description: |
Indicates support for the `V` (vector) extension.

[when,"MUTABLE_MISA_S == true"]
[when,"MUTABLE_MISA_V == true"]
Writing 0 to this field will cause all attempts to execute a vector instruction to raise an `IllegalInstruction` trap.
type: RO
reset_value: 0 # TODO
# reset_value(): |
# return implemented?(ExtensionName::V) ? 1 : 0;
definedBy: V
reset_value: 1
sw_read(): |
return (
(CSR[misa].MXL << 62) |
Expand Down
6 changes: 3 additions & 3 deletions backends/crd_doc/templates/crd.adoc.erb
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ h| Privilege Mode | <%= csr.priv_mode %>
.<%= csr.name %> format
[wavedrom, ,svg,subs='attributes',width="100%"]
....
<%= JSON.dump csr.wavedrom_desc(arch_def, csr.base.nil? ? 32 : csr.base, optional_type: 3) %>
<%= JSON.dump csr.wavedrom_desc(arch_def, csr.base.nil? ? 32 : csr.base, optional_type: 2) %>
....
<% else -%>
<%# CSR has a dynamic length, or a field has a dynamic location,
Expand All @@ -552,13 +552,13 @@ This CSR format changes dynamically with XLEN.
.<%= csr.name %> Format when <%= csr.length_cond32 %>
[wavedrom, ,svg,subs='attributes',width="100%"]
....
<%= JSON.dump csr.wavedrom_desc(arch_def, 32, optional_type: 3) %>
<%= JSON.dump csr.wavedrom_desc(arch_def, 32, optional_type: 2) %>
....

.<%= csr.name %> Format when <%= csr.length_cond64 %>
[wavedrom, ,svg,subs='attributes',width="100%"]
....
<%= JSON.dump csr.wavedrom_desc(arch_def, 64, optional_type: 3) %>
<%= JSON.dump csr.wavedrom_desc(arch_def, 64, optional_type: 2) %>
....


Expand Down
7 changes: 4 additions & 3 deletions lib/arch_obj_models/csr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ def pruned_sw_read_ast(arch_def)
# @param exclude_unimplemented [Boolean] If true, do not create include unimplemented fields in the figure
# @param optional_type [Integer] Wavedrom type (Fill color) for fields that are optional (not mandatory) in a partially-specified arch_def
# @return [Hash] A representation of the WaveDrom drawing for the CSR (should be turned into JSON for wavedrom)
def wavedrom_desc(arch_def, effective_xlen, exclude_unimplemented: false, optional_type: 2)
def wavedrom_desc(arch_def, effective_xlen, exclude_unimplemented: false, optional_type: 3)
desc = {
"reg" => []
}
Expand All @@ -536,9 +536,10 @@ def wavedrom_desc(arch_def, effective_xlen, exclude_unimplemented: false, option
desc["reg"] << { "bits" => n, type: 1 }
end
if arch_def.partially_configured? && field.optional_in_cfg?(arch_def)
puts "#{name}.#{field.name} is OPTIONAL"
desc["reg"] << { "bits" => field.location(arch_def, effective_xlen).size, "name" => field.name, type: optional_type }
else
desc["reg"] << { "bits" => field.location(arch_def, effective_xlen).size, "name" => field.name, type: 2 }
desc["reg"] << { "bits" => field.location(arch_def, effective_xlen).size, "name" => field.name, type: 3 }
end
last_idx = field.location(arch_def, effective_xlen).max
end
Expand Down Expand Up @@ -570,7 +571,7 @@ def optional_in_cfg?(arch_def)
raise "optional_in_cfg? should only be used by a partially-specified arch def" unless arch_def.partially_configured?

exists_in_cfg?(arch_def) &&
arch_def.mandatory_extensions.none? do |ext_req|
arch_def.mandatory_extensions.all? do |ext_req|
ext_req.satisfying_versions(arch_def).none? { |ext_ver| defined_by?(ext_ver) }
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/arch_obj_models/csr_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def optional_in_cfg?(arch_def)
exists_in_cfg?(arch_def) &&
(
parent.optional_in_cfg?(arch_def) ||
(data["definedBy"].nil? || arch_def.mandatory_extensions.none? do |ext_req|
(data["definedBy"].nil? || arch_def.mandatory_extensions.all? do |ext_req|
ext_req.satisfying_versions(arch_def).none? { |ext_ver| defined_by?(ext_ver) }
end)
)
Expand Down
4 changes: 4 additions & 0 deletions lib/arch_obj_models/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ def params(arch_def)
ext(arch_def).params.select { |p| p.defined_in_extension_version?(@version) }
end

def to_s
"#{name}@#{version}"
end

# @overload ==(other)
# @param other [String] An extension name
# @return [Boolean] whether or not this ExtensionVersion is named 'other'
Expand Down
Loading