diff --git a/lib/arch_obj_models/csr.rb b/lib/arch_obj_models/csr.rb index 3071dc9d91..7dc5ee7a9a 100644 --- a/lib/arch_obj_models/csr.rb +++ b/lib/arch_obj_models/csr.rb @@ -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" => [] } @@ -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 @@ -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 diff --git a/lib/arch_obj_models/csr_field.rb b/lib/arch_obj_models/csr_field.rb index ed1d0bfe52..8ee73555e9 100644 --- a/lib/arch_obj_models/csr_field.rb +++ b/lib/arch_obj_models/csr_field.rb @@ -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