Skip to content

Commit 86ff955

Browse files
Merge pull request #202 from riscv-software-src/192-crds-no-longer-have-any-green-csr-fields
Fix optional calc
2 parents 1273886 + eb171c0 commit 86ff955

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

lib/arch_obj_models/csr.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ def pruned_sw_read_ast(arch_def)
512512
# @param exclude_unimplemented [Boolean] If true, do not create include unimplemented fields in the figure
513513
# @param optional_type [Integer] Wavedrom type (Fill color) for fields that are optional (not mandatory) in a partially-specified arch_def
514514
# @return [Hash] A representation of the WaveDrom drawing for the CSR (should be turned into JSON for wavedrom)
515-
def wavedrom_desc(arch_def, effective_xlen, exclude_unimplemented: false, optional_type: 3)
515+
def wavedrom_desc(arch_def, effective_xlen, exclude_unimplemented: false, optional_type: 2)
516516
desc = {
517517
"reg" => []
518518
}
@@ -536,9 +536,10 @@ def wavedrom_desc(arch_def, effective_xlen, exclude_unimplemented: false, option
536536
desc["reg"] << { "bits" => n, type: 1 }
537537
end
538538
if arch_def.partially_configured? && field.optional_in_cfg?(arch_def)
539-
puts "#{name}.#{field.name} is OPTIONAL"
539+
puts "#{name}.#{field.name} is OPTIONAL #{optional_type}"
540540
desc["reg"] << { "bits" => field.location(arch_def, effective_xlen).size, "name" => field.name, type: optional_type }
541541
else
542+
puts "#{name}.#{field.name} is NOT OPTIONAL 3"
542543
desc["reg"] << { "bits" => field.location(arch_def, effective_xlen).size, "name" => field.name, type: 3 }
543544
end
544545
last_idx = field.location(arch_def, effective_xlen).max
@@ -572,7 +573,9 @@ def optional_in_cfg?(arch_def)
572573

573574
exists_in_cfg?(arch_def) &&
574575
arch_def.mandatory_extensions.all? do |ext_req|
575-
ext_req.satisfying_versions(arch_def).none? { |ext_ver| defined_by?(ext_ver) }
576+
ext_req.satisfying_versions(arch_def).none? do |ext_ver|
577+
defined_by?(ext_ver)
578+
end
576579
end
577580
end
578581
end

lib/arch_obj_models/csr_field.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,15 @@ def optional_in_cfg?(arch_def)
5151

5252
exists_in_cfg?(arch_def) &&
5353
(
54-
parent.optional_in_cfg?(arch_def) ||
55-
(data["definedBy"].nil? || arch_def.mandatory_extensions.all? do |ext_req|
56-
ext_req.satisfying_versions(arch_def).none? { |ext_ver| defined_by?(ext_ver) }
57-
end)
54+
if data["definedBy"].nil?
55+
parent.optional_in_cfg?(arch_def)
56+
else
57+
arch_def.mandatory_extensions.all? do |ext_req|
58+
ext_req.satisfying_versions(arch_def).none? do |ext_ver|
59+
defined_by?(ext_ver)
60+
end
61+
end
62+
end
5863
)
5964
end
6065

0 commit comments

Comments
 (0)