Skip to content

Commit

Permalink
Back out code to attempt to ensure required extension versions are in…
Browse files Browse the repository at this point in the history
… the DB.
  • Loading branch information
james-ball-qualcomm committed Dec 4, 2024
1 parent db874da commit c59841d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 30 deletions.
3 changes: 2 additions & 1 deletion arch/csr/menvcfg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ name: menvcfg
address: 0x30A
long_name: Machine Environment Configuration
description: |
Contains bits to enable/disable extensions
Contains fields that control certain characteristics of the execution environment
for modes less privileged than M-mode.
The `menvcfg` CSR controls
certain characteristics of the execution environment for modes less
Expand Down
7 changes: 4 additions & 3 deletions arch/csr/senvcfg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ kind: csr
name: senvcfg
address: 0x10A
long_name: Supervisor Environment Configuration
description: Contains bits to enable/disable extensions
description: |
Contains fields that control certain characteristics of the U-mode execution environment.
priv_mode: S
length: 64
definedBy:
allOf:
- name: Sm
version: ">=1.12"
- name: S
version: ">=1.12"
- name: U
fields:
CBZE:
location: 7
Expand Down
8 changes: 7 additions & 1 deletion arch/ext/S.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ name: S
type: privileged
long_name: Supervisor mode
versions:
- version: "1.11.0"
state: ratified
ratification_date: 2019-06
requires:
name: U
version: ">= 1.0.0"
- version: "1.12.0"
state: ratified
ratification_date: 2021-12
requires:
name: U
version: "= 1.12.0"
version: ">= 1.0.0"
description: |
This chapter describes the RISC-V supervisor-level architecture, which
contains a common core that is used with various supervisor-level
Expand Down
1 change: 1 addition & 0 deletions arch/ext/Sm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ params:
schema:
type: string
enum: [little, big, dynamic]
# TODO: Only little available in Sm 1.11
MISA_CSR_IMPLEMENTED:
description: |
Whether or not the `misa` CSR returns zero or a non-zero value.
Expand Down
8 changes: 0 additions & 8 deletions lib/arch_obj_models/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -637,14 +637,6 @@ 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
Expand Down
26 changes: 9 additions & 17 deletions lib/arch_obj_models/portfolio.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,31 +136,23 @@ def in_scope_ext_reqs(desired_presence = nil)
missing_ext = false

@data["extensions"]&.each do |ext_name, ext_data|
# 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
end

actual_presence = ext_data["presence"] # Could be a String or Hash
raise "Missing extension presence for extension #{ext_name}" if actual_presence.nil?

# Convert presence String or Hash to object.
actual_presence_obj = ExtensionPresence.new(actual_presence)

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,
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)

# 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
# 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

in_scope_ext_reqs << ext_req
end
end

Expand Down

0 comments on commit c59841d

Please sign in to comment.