diff --git a/arch/ext/Smcdeleg.yaml b/arch/ext/Smcdeleg.yaml index cf03c5253..6687479e0 100644 --- a/arch/ext/Smcdeleg.yaml +++ b/arch/ext/Smcdeleg.yaml @@ -16,7 +16,7 @@ doc_license: versions: - version: "1.0.0" state: ratified - ratification_date: null + ratification_date: unknown repositories: - url: https://github.com/riscvarchive/riscv-smcdeleg-ssccfg url: https://github.com/riscvarchive/riscv-smcdeleg-ssccfg/releases/download/v1.0.0/riscv-smcdeleg-ssccfg-v1.0.0.pdf diff --git a/arch/ext/Ssccfg.yaml b/arch/ext/Ssccfg.yaml index b19973dbc..67b94f42f 100644 --- a/arch/ext/Ssccfg.yaml +++ b/arch/ext/Ssccfg.yaml @@ -9,5 +9,5 @@ type: privileged versions: - version: "1.0.0" state: ratified - ratification_date: null + ratification_date: unknown url: https://docs.google.com/document/d/1s-GeH5XpHBLzbQZucA8DPA7vvF7Xvf_nrPbrU2YLBcE/edit#heading=h.yyrgtolcaczx diff --git a/arch/ext/Ssccptr.yaml b/arch/ext/Ssccptr.yaml index 247dc2b07..dcfc0aedc 100644 --- a/arch/ext/Ssccptr.yaml +++ b/arch/ext/Ssccptr.yaml @@ -13,7 +13,7 @@ type: privileged versions: - version: "1.0.0" state: ratified - ratification_date: null + ratification_date: unknown url: https://github.com/riscv/riscv-profiles/releases/tag/v1.0 repositories: - url: https://github.com/riscv/riscv-profiles diff --git a/arch/ext/Sstc.yaml b/arch/ext/Sstc.yaml index 435287d68..f55c454c8 100644 --- a/arch/ext/Sstc.yaml +++ b/arch/ext/Sstc.yaml @@ -3,11 +3,10 @@ $schema: "ext_schema.json#" kind: extension name: Sstc -long_name: Superivisor mode timer interrupts -description: Superivisor mode timer interrupts +long_name: Supervisor-mode timer interrupts +description: Supervisor-mode timer interrupts type: privileged versions: -- version: "0.9.0" +- version: "1.0.0" state: ratified - ratification_date: null - url: https://drive.google.com/file/d/1m84Re2yK8m_vbW7TspvevCDR82MOBaSX/view?usp=drive_link + ratification_date: unknown \ No newline at end of file diff --git a/arch/ext/Sstvala.yaml b/arch/ext/Sstvala.yaml index 118b7811d..46987c66a 100644 --- a/arch/ext/Sstvala.yaml +++ b/arch/ext/Sstvala.yaml @@ -19,7 +19,7 @@ type: privileged versions: - version: "1.0.0" state: ratified - ratification_date: null + ratification_date: unknown url: https://github.com/riscv/riscv-profiles/releases/tag/v1.0 repositories: - url: https://github.com/riscv/riscv-profiles diff --git a/arch/ext/Sstvecd.yaml b/arch/ext/Sstvecd.yaml index cbe35c0c1..e6e4f0f55 100644 --- a/arch/ext/Sstvecd.yaml +++ b/arch/ext/Sstvecd.yaml @@ -12,7 +12,7 @@ type: privileged versions: - version: "1.0.0" state: ratified - ratification_date: null + ratification_date: unknown url: https://github.com/riscv/riscv-profiles/releases/tag/v1.0 repositories: - url: https://github.com/riscv/riscv-profiles diff --git a/arch/ext/Ssu64xl.yaml b/arch/ext/Ssu64xl.yaml new file mode 100644 index 000000000..8f456c28b --- /dev/null +++ b/arch/ext/Ssu64xl.yaml @@ -0,0 +1,15 @@ +# yaml-language-server: $schema=../../schemas/ext_schema.json + +$schema: "ext_schema.json#" +kind: extension +name: Ssu64xl +long_name: UXLEN=64 must be supported +description: | + `sstatus.UXL` must be capable of holding the value 2 (i.e., UXLEN=64 must be supported). + + [NOTE] + This extension was ratified as part of the RVA20 profile. +versions: +- version: "1.0.0" + state: ratified + ratification_date: unknown \ No newline at end of file diff --git a/arch/ext/Svbare.yaml b/arch/ext/Svbare.yaml index afc684ac2..2bc7d6f80 100644 --- a/arch/ext/Svbare.yaml +++ b/arch/ext/Svbare.yaml @@ -13,7 +13,7 @@ description: | versions: - version: "1.0.0" state: ratified - ratification_date: null + ratification_date: unknown requires: name: S param_constraints: diff --git a/arch/ext/Svpbmt.yaml b/arch/ext/Svpbmt.yaml index 43db85e29..7b6719fd7 100644 --- a/arch/ext/Svpbmt.yaml +++ b/arch/ext/Svpbmt.yaml @@ -14,7 +14,7 @@ type: privileged versions: - version: "1.0.0" state: ratified - ratification_date: null + ratification_date: unknown requires: name: Sv39 param_constraints: diff --git a/arch/ext/U.yaml b/arch/ext/U.yaml index c7c4fc253..bd2cbcbd7 100644 --- a/arch/ext/U.yaml +++ b/arch/ext/U.yaml @@ -3,11 +3,13 @@ $schema: "ext_schema.json#" kind: extension name: U -long_name: User-level privilege mode -description: User-level privilege mode +long_name: User-mode privilege level +description: | + User-mode privilege level is supported by an implementation if the U extension is present. + Note that the RISC-V ISA doens't formally define a U extension and it is only discussed in the Privileged ISA manual. type: privileged versions: -- version: "1.12.0" +- version: "1.0.0" state: ratified ratification_date: 2019-12 params: diff --git a/arch/ext/V.yaml b/arch/ext/V.yaml index e40290605..c8e69a2aa 100644 --- a/arch/ext/V.yaml +++ b/arch/ext/V.yaml @@ -8,7 +8,7 @@ long_name: Variable-length vector versions: - version: "1.0.0" state: ratified - ratification_date: null + ratification_date: unknown description: | TODO params: diff --git a/arch/ext/Za128rs.yaml b/arch/ext/Za128rs.yaml index e78da5e68..dc0a059b8 100644 --- a/arch/ext/Za128rs.yaml +++ b/arch/ext/Za128rs.yaml @@ -16,7 +16,7 @@ description: | versions: - version: "1.0.0" state: ratified - ratification_date: null + ratification_date: unknown param_constraints: LRSC_RESERVATION_STRATEGY: schema: diff --git a/arch/ext/Zic64b.yaml b/arch/ext/Zic64b.yaml index 15395d5ec..9506f16bc 100644 --- a/arch/ext/Zic64b.yaml +++ b/arch/ext/Zic64b.yaml @@ -13,7 +13,7 @@ type: privileged versions: - version: "1.0.0" state: ratified - ratification_date: null + ratification_date: unknown url: https://github.com/riscv/riscv-profiles/releases/tag/v1.0 repositories: - url: https://github.com/riscv/riscv-profiles diff --git a/arch/ext/Ziccamoa.yaml b/arch/ext/Ziccamoa.yaml index 838438db1..a24f265d4 100644 --- a/arch/ext/Ziccamoa.yaml +++ b/arch/ext/Ziccamoa.yaml @@ -12,4 +12,4 @@ description: | versions: - version: "1.0.0" state: ratified - ratification_date: null + ratification_date: unknown diff --git a/arch/ext/Ziccif.yaml b/arch/ext/Ziccif.yaml index 4a35d7b00..70d5f10c4 100644 --- a/arch/ext/Ziccif.yaml +++ b/arch/ext/Ziccif.yaml @@ -14,4 +14,4 @@ description: | versions: - version: "1.0.0" state: ratified - ratification_date: null + ratification_date: unknown diff --git a/arch/ext/Zicclsm.yaml b/arch/ext/Zicclsm.yaml index 835e91223..c95bace89 100644 --- a/arch/ext/Zicclsm.yaml +++ b/arch/ext/Zicclsm.yaml @@ -20,7 +20,7 @@ description: | versions: - version: "1.0.0" state: ratified - ratification_date: null + ratification_date: unknown param_constraints: MISALIGNED_LDST: schema: diff --git a/arch/ext/Ziccrse.yaml b/arch/ext/Ziccrse.yaml index 93e7539b8..c03ff9bc6 100644 --- a/arch/ext/Ziccrse.yaml +++ b/arch/ext/Ziccrse.yaml @@ -12,4 +12,4 @@ description: | versions: - version: "1.0.0" state: ratified - ratification_date: null + ratification_date: unknown diff --git a/arch/ext/Zicsr.yaml b/arch/ext/Zicsr.yaml index 92689331a..e28539c64 100644 --- a/arch/ext/Zicsr.yaml +++ b/arch/ext/Zicsr.yaml @@ -9,4 +9,4 @@ type: unprivileged versions: - version: "2.0.0" state: ratified - ratification_date: null + ratification_date: unknown diff --git a/arch/ext/Zifencei.yaml b/arch/ext/Zifencei.yaml index 7b661769b..d9b7dc433 100644 --- a/arch/ext/Zifencei.yaml +++ b/arch/ext/Zifencei.yaml @@ -69,4 +69,4 @@ type: unprivileged versions: - version: "2.0.0" state: ratified - ratification_date: null + ratification_date: unknown diff --git a/arch/ext/Zihintpause.yaml b/arch/ext/Zihintpause.yaml index 06db29627..8c7c7c27d 100644 --- a/arch/ext/Zihintpause.yaml +++ b/arch/ext/Zihintpause.yaml @@ -70,4 +70,4 @@ type: unprivileged versions: - version: "2.0.0" state: ratified - ratification_date: null + ratification_date: unknown diff --git a/arch/ext/Zkt.yaml b/arch/ext/Zkt.yaml index df11a4e36..304e7b69e 100644 --- a/arch/ext/Zkt.yaml +++ b/arch/ext/Zkt.yaml @@ -354,7 +354,7 @@ versions: - name: Claire Wolf - version: 1.0.1 state: ratified - ratification_date: null + ratification_date: unknown changes: - Fix typos to show that `c.srli`, `c.srai`, and `c.slli` are Zkt instructions in RV64. company: diff --git a/arch/profile_release/RVA20.yaml b/arch/profile_release/RVA20.yaml index 279024c2c..28f37d993 100644 --- a/arch/profile_release/RVA20.yaml +++ b/arch/profile_release/RVA20.yaml @@ -55,13 +55,6 @@ RVA20: presence: mandatory M: presence: mandatory - U: - presence: mandatory - version: "~> 2.0" - param_constraints: - U_MODE_ENDIANESS: - schema: - const: little Zicntr: presence: mandatory Ziccif: @@ -138,6 +131,13 @@ RVA20: supervisor-mode execution environment in 64-bit applications processors. RVA20S64 is based on privileged architecture version 1.11. extensions: + U: + presence: mandatory + version: "~> 1.0" + param_constraints: + U_MODE_ENDIANESS: + schema: + const: little S: presence: mandatory version: "~> 1.11" diff --git a/backends/profile_doc/templates/profile.adoc.erb b/backends/profile_doc/templates/profile.adoc.erb index cee0ec4b2..74fa8f4ec 100644 --- a/backends/profile_doc/templates/profile.adoc.erb +++ b/backends/profile_doc/templates/profile.adoc.erb @@ -441,7 +441,7 @@ Extensions present in a profile are also present in higher-privileged profiles i === <%= ext.name %> Extension <%= ext.long_name %> -.Presence +.<%= ext.name %> Extension Presence |=== | Profile | v<%= ext.versions.map { |v| v.version }.join(" | v") %> @@ -453,8 +453,12 @@ Extensions present in a profile are also present in higher-privileged profiles i <% ext.versions.each do |v| -%> <%= v.version %>:: + State::: + <%= v.state %> + <% if v.state == "ratified" -%> Ratification date::: <%= v.ratification_date %> + <% end # if %> <% unless v.changes.empty? -%> Changes::: @@ -462,18 +466,18 @@ Extensions present in a profile are also present in higher-privileged profiles i * <%= c %> <% end -%> - <%- end -%> - <%- unless v.url.nil? -%> + <% end -%> + <% unless v.url.nil? -%> Ratification document::: <%= v.url %> - <%- end -%> - <%- unless v.implications -%> + <% end -%> + <% unless v.implications -%> Implies::: - <%- v.implications.each do |i| -%> + <% v.implications.each do |i| -%> * `<%= i.name %>` version <%= i.version %> - <%- end -%> - <%- end -%> -<%- end -%> + <% end -%> + <% end -%> +<% end -%> ==== Synopsis @@ -484,8 +488,8 @@ Extensions present in a profile are also present in higher-privileged profiles i :leveloffset: -3 // TODO: GitHub issue 92: Use version specified by each profile and add version info to inst table below. -<%- insts = arch_def.instructions.select { |i| i.defined_by?(ext.min_version) } -%> -<%- unless insts.empty? -%> +<% insts = arch_def.instructions.select { |i| i.defined_by?(ext.min_version) } -%> +<% unless insts.empty? -%> ==== Instructions The following instructions are added by this extension: diff --git a/cfgs/generic_rv64/arch_overlay/ext/Xcustom.yaml b/cfgs/generic_rv64/arch_overlay/ext/Xcustom.yaml index 80aa49d40..ca6771f9a 100644 --- a/cfgs/generic_rv64/arch_overlay/ext/Xcustom.yaml +++ b/cfgs/generic_rv64/arch_overlay/ext/Xcustom.yaml @@ -6,7 +6,7 @@ long_name: A new custom extension! type: unprivileged versions: - version: "0.1.0" - ratification_date: null + ratification_date: unknown state: development description: | A new custom extension! diff --git a/lib/arch_obj_models/certificate.rb b/lib/arch_obj_models/certificate.rb index 5b8f0552a..1a326fb6b 100644 --- a/lib/arch_obj_models/certificate.rb +++ b/lib/arch_obj_models/certificate.rb @@ -79,7 +79,7 @@ def when_pretty "Parameter #{param_name} == #{param_value}" end else - raise "TODO: when type #{key} not implemented" + raise "Type #{key} not implemented" end end.flatten.join(" and ") end @@ -111,7 +111,7 @@ def when_pretty "Parameter #{param_name} == #{param_value}" end else - raise "TODO: when type #{key} not implemented" + raise "Type #{key} not implemented" end end.flatten.join(" and ") end diff --git a/lib/arch_obj_models/extension.rb b/lib/arch_obj_models/extension.rb index 9cb10debd..8f652766a 100644 --- a/lib/arch_obj_models/extension.rb +++ b/lib/arch_obj_models/extension.rb @@ -448,7 +448,6 @@ def implemented_instructions(archdef) # Example => presence: # optional: development class ExtensionPresence - include Comparable # Creates <, >, <=, >= automatically since <=> is provided attr_reader :presence attr_reader :optional_type @@ -527,13 +526,6 @@ def to_s_concise "#{presence}" end - # - # Overloaded comparison operators following these rules: - # - "mandatory" is greater than "optional" - # - optional_types all have same rank - # - equals compares presence and then optional_type - # - # @overload ==(other) # @param other [String] A presence string # @return [Boolean] whether or not this ExtensionPresence has the same presence (ignores optional_type) @@ -551,35 +543,56 @@ def ==(other) end end + # @overload <=>(other) + # @param other [String] A presence string + # @return [Integer] Sort alphabetically by presence, then alphabetically by optional_type + def <=>(other) + raise ArgumentError, "ExtensionPresence is only comparable to other ExtensionPresence classes" unless other.is_a?(ExtensionPresence) + + if @presence != other.presence + @presence <=> other.presence + else + @optional_type <=> other.optional_type + end + end + + ###################################################### + # Following comparison operators follow these rules: + # - "mandatory" is greater than "optional" + # - optional_types all have same rank + # - equals compares presence and then optional_type + ###################################################### + # @overload >(other) # @param other [ExtensionPresence] An extension presence object # @return [Boolean] Whether or not this ExtensionPresence is greater-than the other - def >(other) = (self.mandatory? && other.optional?) + def >(other) + raise ArgumentError, "ExtensionPresence is only comparable to other ExtensionPresence classes" unless other.is_a?(ExtensionPresence) + (self.mandatory? && other.optional?) + end # @overload >=(other) # @param other [ExtensionPresence] An extension presence object # @return [Boolean] Whether or not this ExtensionPresence is greater-than or equal to the other - def >=(other) = (self > other) || (self == other) + def >=(other) + raise ArgumentError, "ExtensionPresence is only comparable to other ExtensionPresence classes" unless other.is_a?(ExtensionPresence) + (self > other) || (self == other) + end # @overload <(other) # @param other [ExtensionPresence] An extension presence object # @return [Boolean] Whether or not this ExtensionPresence is less-than the other - def <(other) = (self.optional? && other.mandatory?) + def <(other) + raise ArgumentError, "ExtensionPresence is only comparable to other ExtensionPresence classes" unless other.is_a?(ExtensionPresence) + (self.optional? && other.mandatory?) + end # @overload <=(other) # @param other [ExtensionPresence] An extension presence object # @return [Boolean] Whether or not this ExtensionPresence is less-than or equal to the other - def <=(other) = (self < other) || (self == other) - - # Sorts by presence, then by optional_type - def <=>(other) + def <=(other) raise ArgumentError, "ExtensionPresence is only comparable to other ExtensionPresence classes" unless other.is_a?(ExtensionPresence) - - if @presence != other.presence - @presence <=> other.presence - else - @optional_type <=> other.optional_type - end + (self < other) || (self == other) end end @@ -624,6 +637,14 @@ def satisfying_versions(archdef) ext.versions.select { |v| @requirement.satisfied_by?(v.version) } end + # @return [Boolean] True if any extension version satifies this requirement + # @param [Extension] The extension object that contains one or more versions + def satisfied_by_ext?(ext) + return false if ext.nil? + + ext.versions.any? { |v| @requirement.satisfied_by?(v.version) } + end + # @overload # @param extension_version [ExtensionVersion] A specific extension version # @return [Boolean] whether or not the extension_version meets this requirement @@ -644,14 +665,13 @@ def satisfied_by?(*args) satified_by?(ext_ver) end else - raise ArgumentError, "Single argument must be an ExtensionVersion or ExtensionRquirement" + raise ArgumentError, "Single argument must be an ExtensionVersion or ExtensionRequirement" end elsif args.size == 2 raise ArgumentError, "First parameter must be an extension name" unless args[0].respond_to?(:to_s) raise ArgumentError, "First parameter must be an extension version" unless args[1].respond_to?(:to_s) - args[0] == @name && - @requirement.satisfied_by?(Gem::Version.new(args[1])) + (args[0] == @name) && @requirement.satisfied_by?(Gem::Version.new(args[1])) else raise ArgumentError, "Wrong number of args (expecting 1 or 2)" end @@ -674,4 +694,4 @@ def <=>(other) @name <=> other.name end -end +end \ No newline at end of file diff --git a/lib/arch_obj_models/portfolio.rb b/lib/arch_obj_models/portfolio.rb index 7a2ad3a8b..701c57f4d 100644 --- a/lib/arch_obj_models/portfolio.rb +++ b/lib/arch_obj_models/portfolio.rb @@ -82,6 +82,7 @@ def extension_presence(ext_name) # @param ext_name [String] # @param ext_versions [Array] # @return [Array] + # JamesBall def version_greatest_presence(ext_name, ext_versions) presences = [] @@ -132,26 +133,41 @@ def in_scope_ext_reqs(desired_presence = nil) desired_presence.is_a?(ExtensionPresence) ? desired_presence : ExtensionPresence.new(desired_presence) + missing_ext = false + @data["extensions"]&.each do |ext_name, ext_data| actual_presence = ext_data["presence"] # Could be a String or Hash raise "Missing extension presence for extension #{ext_name}" if actual_presence.nil? - # Convert String or Hash to object. + # Convert presence String or Hash to object. actual_presence_obj = ExtensionPresence.new(actual_presence) - match = - if desired_presence.nil? - true # Always match + if desired_presence.nil? || (actual_presence_obj == desired_presence_converted) + version_data = ext_data["version"] + + ext_req = + ExtensionRequirement.new(ext_name, version_data, presence: actual_presence_obj, + note: ext_data["note"], req_id: "REQ-EXT-" + ext_name) + + # Does extension even exist? + # If not, don't raise an error right away so we can find all of the missing extensions and report them all. + ext = arch_def.extension(ext_name) + if ext.nil? + puts "Extension #{ext_name} for #{name} not found in database" + missing_ext = true else - actual_presence_obj == desired_presence_converted + # Okay, so extension exists. Can the extension requirement be met? + raise "No version of extension #{ext_name} in #{name} satifies the extension requirement #{version_data}" unless ext_req.satisfied_by_ext?(ext) end - if match - in_scope_ext_reqs << - ExtensionRequirement.new(ext_name, ext_data["version"], presence: actual_presence_obj, - note: ext_data["note"], req_id: "REQ-EXT-" + ext_name) + in_scope_ext_reqs << ext_req end end + + # TODO: Change to "raise" when missing extensions added to database so we can make progress until then. + # See https://github.com/riscv-software-src/riscv-unified-db/issues/320 + puts "One or more extensions referenced by #{name} missing in database" if missing_ext + in_scope_ext_reqs end @@ -163,15 +179,9 @@ def optional_type_ext_reqs = in_scope_ext_reqs(ExtensionPresence.optional) def in_scope_extensions return @in_scope_extensions unless @in_scope_extensions.nil? - @in_scope_extensions = in_scope_ext_reqs.map do |er| - obj = arch_def.extension(er.name) - - # @todo: change this to raise once all the profile extensions - # are defined - warn "Extension #{er.name} is not defined" if obj.nil? - - obj - end.reject(&:nil?) + @in_scope_extensions = in_scope_ext_reqs.map do |ext_req| + arch_def.extension(ext_req.name) + end.reject(&:nil?) # Filter out extensions that don't exist yet. @in_scope_extensions end diff --git a/lib/arch_obj_models/schema.rb b/lib/arch_obj_models/schema.rb index c5cbbc998..758c3251a 100644 --- a/lib/arch_obj_models/schema.rb +++ b/lib/arch_obj_models/schema.rb @@ -107,7 +107,7 @@ def to_pretty_s(schema_hash = @schema_hash) raise "to_pretty_s unknown type #{schema_hash["type"]} in #{schema_hash}" end else - raise "TODO: to_pretty_s schema for #{schema_hash}" + raise "Unsupported schema for #{schema_hash}" end end