Skip to content

Commit 2c36e82

Browse files
Fix bug in display of parameter values and add values to extension appendix. Other minors fixes/improvements.
1 parent 174d1cf commit 2c36e82

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

arch/crd/MC-1.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ MC-1:
88
# semantic version within the CRD family
99
version: "1.0"
1010

11+
# XLEN used by rakefile
12+
base: 32
13+
1114
description: |
1215
MC-1 can be though of as a minimal 32-bit RISC-V processor with M-mode support:
1316

arch/crd/MockCRD-1.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ MockCRD-1:
66

77
family: MockCRDFamily
88

9+
# XLEN used by rakefile
10+
base: 64
11+
912
# semantic version within the CRD family
1013
version: "1.0"
1114

@@ -124,7 +127,7 @@ MockCRD-1:
124127
const: little
125128
XLEN:
126129
schema:
127-
const: 32
130+
const: 64
128131
CONFIG_PTR_ADDRESS:
129132
schema:
130133
const: 0xdeadbeef

backends/crd_doc/tasks.rake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@ Dir.glob("#{$root}/arch/crd/*.yaml") do |f|
1313
crd_name = File.basename(f, ".yaml")
1414
crd_obj = YAML.load_file(f, permitted_classes: [Date])
1515
raise "Ill-formed CRD file #{f}: missing 'family' field" if crd_obj.dig(crd_name, 'family').nil?
16+
17+
base = crd_obj[crd_name]["base"]
18+
raise "Missing CRD base" if base.nil?
1619

1720
file "#{$root}/gen/crd_doc/adoc/#{crd_name}.adoc" => [
1821
"#{$root}/arch/crd/#{crd_name}.yaml",
1922
"#{$root}/arch/crd_family/#{crd_obj[crd_name]['family']}.yaml",
2023
"#{CRD_DOC_DIR}/templates/crd.adoc.erb",
2124
__FILE__,
22-
"#{$root}/.stamps/arch-gen-_64.stamp"
25+
"#{$root}/.stamps/arch-gen-_#{base}.stamp"
2326
] do |t|
2427
# TODO: schema validation
25-
arch_def = arch_def_for("_64")
28+
arch_def = arch_def_for("_#{base}")
2629
crd = arch_def.crd(crd_name)
2730
raise "No CRD defined for #{crd_name}" if crd.nil?
2831

backends/crd_doc/templates/crd.adoc.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ If the "Allowed Value(s)" is "Any" then any value allowed by the type is accepta
117117
<% if crd.all_in_scope_ext_params.empty? -%>
118118
None
119119
<% else -%>
120-
[cols="4,2,1,1,3"]
120+
[cols="4,2,1,1,2"]
121121
|===
122122
| Parameter | Type | Allowed Value(s) | Extension(s) | Note
123123
@@ -316,7 +316,7 @@ The following instructions are added by this extension:
316316
317317
<% crd.in_scope_ext_params(ext_req).sort.each do |ext_param| -%>
318318
[[ext-<%= ext_req.name %>-param-<%= ext_param.name %>-def]]
319-
<%= ext_param.name %>::
319+
<%= ext_param.name %> &#8658; <%= ext_param.param_db.schema_type %>::
320320
+
321321
--
322322
<%= ext_param.param_db.desc %>
@@ -329,7 +329,7 @@ The following instructions are added by this extension:
329329
330330
<% crd.out_of_scope_params(ext_req.name).sort.each do |param_db| -%>
331331
[[ext-<%= ext_req.name %>-param-<%= param_db.name %>-def]]
332-
<%= param_db.name %>::
332+
<%= param_db.name %> &#8658; <%= param_db.schema_type %>::
333333
+
334334
--
335335
<%= param_db.desc %>

lib/arch_obj_models/crd.rb

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,6 @@ def value
222222
end
223223

224224
# @return [String] - # What parameter values are allowed by the CRD.
225-
#
226-
# Old implementation:
227-
# def schema_pretty_crd_merged_with_param_db
228-
# Schema.new(@param_db.schema).merge!(@schema_crd).to_pretty_s
229-
# end
230225
def allowed_values
231226
if (@schema_crd.empty?)
232227
# CRD doesn't add any constraints on parameter's value.
@@ -236,11 +231,9 @@ def allowed_values
236231
# Create a Schema object just using information in the parameter database.
237232
schema_obj = @param_db.schema
238233

239-
# Merge in constraints imposed by the CRD on the parameter.
240-
schema_obj.merge!(@schema_crd)
241-
242-
# Create string showing allowed values of parameter with CRD constraints added
243-
schema_obj.to_pretty_s
234+
# Merge in constraints imposed by the CRD on the parameter and then
235+
# create string showing allowed values of parameter with CRD constraints added
236+
schema_obj.merge(@schema_crd).to_pretty_s
244237
end
245238

246239
# sorts by name

lib/arch_obj_models/schema.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,12 @@ def large2hex(value)
117117
end
118118
end
119119

120-
def merge!(other_schema)
120+
def merge(other_schema)
121121
raise ArgumentError, "Expecting Schema" unless (other_schema.is_a?(Schema) || other_schema.is_a?(Hash))
122122

123-
hash = other_schema.is_a?(Schema) ? other_schema.instance_variable_get(:@schema_hash) : other_schema
123+
other_hash = other_schema.is_a?(Schema) ? other_schema.instance_variable_get(:@schema_hash) : other_schema
124124

125-
@schema_hash.merge!(hash)
126-
127-
self
125+
Schema.new(@schema_hash.merge(other_hash))
128126
end
129127

130128
def empty?

0 commit comments

Comments
 (0)