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
9 changes: 6 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: 3)
def wavedrom_desc(arch_def, effective_xlen, exclude_unimplemented: false, optional_type: 2)
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"
puts "#{name}.#{field.name} is OPTIONAL #{optional_type}"
desc["reg"] << { "bits" => field.location(arch_def, effective_xlen).size, "name" => field.name, type: optional_type }
else
puts "#{name}.#{field.name} is NOT OPTIONAL 3"
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
Expand Down Expand Up @@ -572,7 +573,9 @@ def optional_in_cfg?(arch_def)

exists_in_cfg?(arch_def) &&
arch_def.mandatory_extensions.all? do |ext_req|
ext_req.satisfying_versions(arch_def).none? { |ext_ver| defined_by?(ext_ver) }
ext_req.satisfying_versions(arch_def).none? do |ext_ver|
defined_by?(ext_ver)
end
end
end
end
13 changes: 9 additions & 4 deletions lib/arch_obj_models/csr_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,15 @@ def optional_in_cfg?(arch_def)

exists_in_cfg?(arch_def) &&
(
parent.optional_in_cfg?(arch_def) ||
(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)
if data["definedBy"].nil?
parent.optional_in_cfg?(arch_def)
else
arch_def.mandatory_extensions.all? do |ext_req|
ext_req.satisfying_versions(arch_def).none? do |ext_ver|
defined_by?(ext_ver)
end
end
end
)
end

Expand Down
Loading