diff --git a/arch/crd/MC-1.yaml b/arch/crd/MC-1.yaml index b6a576993..6ea41b60d 100644 --- a/arch/crd/MC-1.yaml +++ b/arch/crd/MC-1.yaml @@ -8,6 +8,9 @@ MC-1: # semantic version within the CRD family version: "1.0" + # XLEN used by rakefile + base: 32 + description: | MC-1 can be though of as a minimal 32-bit RISC-V processor with M-mode support: diff --git a/arch/crd/MockCRD-1.yaml b/arch/crd/MockCRD-1.yaml index 65f803fa0..3d7042712 100644 --- a/arch/crd/MockCRD-1.yaml +++ b/arch/crd/MockCRD-1.yaml @@ -6,6 +6,9 @@ MockCRD-1: family: MockCRDFamily + # XLEN used by rakefile + base: 64 + # semantic version within the CRD family version: "1.0" @@ -124,7 +127,7 @@ MockCRD-1: const: little XLEN: schema: - const: 32 + const: 64 CONFIG_PTR_ADDRESS: schema: const: 0xdeadbeef diff --git a/backends/crd_doc/tasks.rake b/backends/crd_doc/tasks.rake index 0d5821872..b97a69bea 100644 --- a/backends/crd_doc/tasks.rake +++ b/backends/crd_doc/tasks.rake @@ -13,16 +13,19 @@ Dir.glob("#{$root}/arch/crd/*.yaml") do |f| crd_name = File.basename(f, ".yaml") crd_obj = YAML.load_file(f, permitted_classes: [Date]) raise "Ill-formed CRD file #{f}: missing 'family' field" if crd_obj.dig(crd_name, 'family').nil? + + base = crd_obj[crd_name]["base"] + raise "Missing CRD base" if base.nil? file "#{$root}/gen/crd_doc/adoc/#{crd_name}.adoc" => [ "#{$root}/arch/crd/#{crd_name}.yaml", "#{$root}/arch/crd_family/#{crd_obj[crd_name]['family']}.yaml", "#{CRD_DOC_DIR}/templates/crd.adoc.erb", __FILE__, - "#{$root}/.stamps/arch-gen-_64.stamp" + "#{$root}/.stamps/arch-gen-_#{base}.stamp" ] do |t| # TODO: schema validation - arch_def = arch_def_for("_64") + arch_def = arch_def_for("_#{base}") crd = arch_def.crd(crd_name) raise "No CRD defined for #{crd_name}" if crd.nil? diff --git a/backends/crd_doc/templates/crd.adoc.erb b/backends/crd_doc/templates/crd.adoc.erb index 78768ad09..eedea90dc 100644 --- a/backends/crd_doc/templates/crd.adoc.erb +++ b/backends/crd_doc/templates/crd.adoc.erb @@ -117,7 +117,7 @@ If the "Allowed Value(s)" is "Any" then any value allowed by the type is accepta <% if crd.all_in_scope_ext_params.empty? -%> None <% else -%> -[cols="4,2,1,1,3"] +[cols="4,2,1,1,2"] |=== | Parameter | Type | Allowed Value(s) | Extension(s) | Note @@ -316,7 +316,7 @@ The following instructions are added by this extension: <% crd.in_scope_ext_params(ext_req).sort.each do |ext_param| -%> [[ext-<%= ext_req.name %>-param-<%= ext_param.name %>-def]] -<%= ext_param.name %>:: +<%= ext_param.name %> ⇒ <%= ext_param.param_db.schema_type %>:: + -- <%= ext_param.param_db.desc %> @@ -329,7 +329,7 @@ The following instructions are added by this extension: <% crd.out_of_scope_params(ext_req.name).sort.each do |param_db| -%> [[ext-<%= ext_req.name %>-param-<%= param_db.name %>-def]] -<%= param_db.name %>:: +<%= param_db.name %> ⇒ <%= param_db.schema_type %>:: + -- <%= param_db.desc %> diff --git a/lib/arch_obj_models/crd.rb b/lib/arch_obj_models/crd.rb index 0be657a2a..2936e8707 100644 --- a/lib/arch_obj_models/crd.rb +++ b/lib/arch_obj_models/crd.rb @@ -222,11 +222,6 @@ def value end # @return [String] - # What parameter values are allowed by the CRD. - # - # Old implementation: - # def schema_pretty_crd_merged_with_param_db - # Schema.new(@param_db.schema).merge!(@schema_crd).to_pretty_s - # end def allowed_values if (@schema_crd.empty?) # CRD doesn't add any constraints on parameter's value. @@ -236,11 +231,9 @@ def allowed_values # Create a Schema object just using information in the parameter database. schema_obj = @param_db.schema - # Merge in constraints imposed by the CRD on the parameter. - schema_obj.merge!(@schema_crd) - - # Create string showing allowed values of parameter with CRD constraints added - schema_obj.to_pretty_s + # Merge in constraints imposed by the CRD on the parameter and then + # create string showing allowed values of parameter with CRD constraints added + schema_obj.merge(@schema_crd).to_pretty_s end # sorts by name diff --git a/lib/arch_obj_models/schema.rb b/lib/arch_obj_models/schema.rb index 48f38ebdf..c5cbbc998 100644 --- a/lib/arch_obj_models/schema.rb +++ b/lib/arch_obj_models/schema.rb @@ -122,14 +122,12 @@ def large2hex(value) end end - def merge!(other_schema) + def merge(other_schema) raise ArgumentError, "Expecting Schema" unless (other_schema.is_a?(Schema) || other_schema.is_a?(Hash)) - hash = other_schema.is_a?(Schema) ? other_schema.instance_variable_get(:@schema_hash) : other_schema + other_hash = other_schema.is_a?(Schema) ? other_schema.instance_variable_get(:@schema_hash) : other_schema - @schema_hash.merge!(hash) - - self + Schema.new(@schema_hash.merge(other_hash)) end def empty?