Skip to content

Commit

Permalink
Change raise to puts
Browse files Browse the repository at this point in the history
  • Loading branch information
james-ball-qualcomm committed Dec 27, 2024
1 parent a962e90 commit f6dc761
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 10 deletions.
22 changes: 15 additions & 7 deletions backends/certificate_doc/tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,28 @@ Dir.glob("#{$root}/arch/certificate_model/*.yaml") do |f|
"#{CERT_DOC_DIR}/templates/certificate.adoc.erb",
__FILE__
] do |t|
puts "UPDATE: Creating bootstrap objects for #{cert_model_name}"

# Create bootstrap ConfiguredArchitecture object which also creates and contains
# a PartialConfig object for the rv32/rv64 configuration.
base_cfg_arch = cfg_arch_for("rv#{base}")
bootstrap_cfg_arch = cfg_arch_for("rv#{base}")

# Creates CertModel object for every certificate model in database
# Creates CertModel object for every certificate model in the database
# using rv32/rv64 PartialConfig object and then returns named CertModel object.
base_cert_model = base_cfg_arch.cert_model(cert_model_name)
raise "No certificate model named '#{cert_model_name}'" if base_cert_model.nil?
bootstrap_cert_model = bootstrap_cfg_arch.cert_model(cert_model_name)
raise "No certificate model named '#{cert_model_name}'" if bootstrap_cert_model.nil?

# Ask base certification model to create an in-memory ConfiguredArchitecture for this model.
cfg_arch = base_cert_model.to_cfg_arch
puts "UPDATE: Creating real objects for #{cert_model_name}"

# Set globals for ERB template.
# Use bootstrap CertModel to create a ConfiguredArchitecture for this CertModel
# to use instead of the the bootstrap one created based on the rv32/rv64 configuration.
cfg_arch = bootstrap_cert_model.to_cfg_arch

# Use model-specific ConfiguredArchitecture to create CertModel objects again
# for every certificate model in the database and then return named CertModel object.
cert_model = cfg_arch.cert_model(cert_model_name)

# Set globals for ERB template.
portfolio = cert_model
cert_class = cert_model.cert_class
portfolio = cert_model
Expand Down
66 changes: 64 additions & 2 deletions cert_flow.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
backends/certificate_doc/tasks.rake
base_cfg_arch = cfg_arch_for("rv#{base}") # rv32 or rv64
bootstrap_cfg_arch = cfg_arch_for("rv#{base}") # rv32 or rv64
Rakefile
Calls ConfiguredArchitecture.new("gen/resolved_arch/rv32")
Calls Architecture.new # Parent class
Expand All @@ -8,7 +8,7 @@ base_cfg_arch = cfg_arch_for("rv#{base}") # rv32 or rv64
Calls PartialConfig.new(cfg path, @data) # Uses Ruby send() method
@mxlen = @data["params"].xlen
@name = "rv32"
base_cert_model = base_cfg_arch.cert_model(cert_model_name = "MC100-32")
bootstrap_cert_model = bootstrap_cfg_arch.cert_model(cert_model_name = "MC100-32")
Calls self.generate_obj_methods("cert_model", "certificate_model", CertModel) in Architecture # Magic
Calls define_method("cert_model")
Calls define_method("cert_models")
Expand All @@ -19,3 +19,65 @@ base_cert_model = base_cfg_arch.cert_model(cert_model_name = "MC100-32")
@data = yaml
@cfg_arch = arch # rv32 (nil if Architecture object provided)
@specification = arch # rv32
cfg_arch = bootstrap_cert_model.to_cfg_arch # In Portfolio class
Creates hash with mandatory extensions (with version requirement) and params
Uses in_scope_ext_reqs() and all_in_scope_ext_params() in Portfolio
Writes hash to yaml file in /tmp/.../MC100-32/cfg.yaml
Passes yaml file to ConfiguredArchitecture.new()
Creates Architecture (base class), Config, and PartialConfig again (see above)
cert_model = cfg_arch.cert_model(cert_model_name)
Creates CertModel for every model in the database and stores it in the real ConfiguredArchitecture object
Calls ERB template
Converts ERB result to ASCIIDOC


==============================================================================================
Actual rv32/cfg.yaml
---
$schema: config_schema.json#
kind: architecture configuration
type: partially configured
name: rv32
description: A generic RV32 system; only MXLEN is known
params:
XLEN: 32
mandatory_extensions:
- name: "I"
version: ">= 0"
- name: "Sm"
version: ">= 0"
===============================================================================================
Example of /tmp/.../MC100-32/cfg.yaml
---
"$schema": config_schema.json
type: partially configured
kind: architecture configuration
name: MC100-32
description: A partially configured architecture definition corresponding to the MC100-32
portfolio.
mandatory_extensions:
- name: I
version:
- "~> 2.1"
- name: C
version:
- "~> 2.2"
- name: M
version:
- "~> 2.0"
- name: Zicsr
version:
- "~> 2.0"
- name: Zicntr
version:
- "~> 2.0"
- name: Sm
version:
- "~> 1.11.0"
params:
MISALIGNED_SPLIT_STRATEGY: by_byte
PRECISE_SYNCHRONOUS_EXCEPTIONS: true
TRAP_ON_ECALL_FROM_M: true
TRAP_ON_EBREAK: true
M_MODE_ENDIANESS: little
XLEN: 32
2 changes: 2 additions & 0 deletions lib/arch_obj_models/certificate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def initialize(obj_yaml, yaml_path, arch: nil)
unless arch.is_a?(ConfiguredArchitecture)
raise ArgumentError, "For #{name} arch is a #{arch.class} but must be a ConfiguredArchitecture"
end

puts "UPDATE: Creating CertModel object for #{name} using cfg #{cfg_arch.name}"
end

def unpriv_isa_manual_revision = @data["unpriv_isa_manual_revision"]
Expand Down
2 changes: 1 addition & 1 deletion lib/arch_obj_models/portfolio.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def initialize(obj_yaml, yaml_path, arch: nil)

if (obj_yaml["base"] != arch.mxlen)
bad_base = obj_yaml["base"]
raise "For #{name} called with ConfigureArchitecture #{arch.name} with mxlen=#{arch.mxlen} but my base is #{bad_base}"
#puts "UPDATE: ConfigureArchitecture #{arch.name} has mxlen=#{arch.mxlen} but base for #{name} is #{bad_base}"
end
end

Expand Down

0 comments on commit f6dc761

Please sign in to comment.