Class: Udb::PortfolioDesign
- Inherits:
-
Object
- Object
- Udb::PortfolioDesign
- Extended by:
- Forwardable
- Defined in:
- lib/udb/portfolio_design.rb
Instance Attribute Summary collapse
-
#cfg_arch ⇒ ConfiguredArchitecture
readonly
The RISC-V architecture.
-
#name ⇒ String
readonly
Name of design.
-
#portfolio_class ⇒ PortfolioClass
readonly
Portfolio class for all the portfolios in this design.
-
#portfolio_design_type ⇒ String
readonly
Type of design suitable for human readers.
-
#portfolio_kind ⇒ String
readonly
Kind of portfolio for all portfolios in this design.
Class Method Summary collapse
- .portfolio_design_types ⇒ Object
-
.profile_release_type ⇒ Object
Class methods.
Instance Method Summary collapse
-
#all_in_scope_exts_with_param(param) ⇒ Array<Extension>
Sorted list of all in-scope extensions that define this parameter in the database and the parameter is in-scope.
-
#all_in_scope_exts_without_param(param) ⇒ Array<Extension>
List of all in-scope extensions that define this parameter in the database but the parameter is out-of-scope.
-
#all_in_scope_params ⇒ Array<InScopeParameter>
Sorted list of parameters specified by any extension in portfolio.
-
#all_out_of_scope_params ⇒ Array<Parameter>
Sorted list of parameters out of scope across all in scope extensions.
-
#arch ⇒ Object
Provided for backwards-compatibility.
-
#csr_presence(csr_name) ⇒ String
Given an CSR
ext_name, return the presence as a string. -
#erb_env(extra_inputs = {}) ⇒ Hash<String, Object>
Put this in a method so it can be easily overridden by subclasses.
-
#extension_presence(ext_name) ⇒ String
Given an extension
ext_name, return the presence as a string. -
#fully_configured? ⇒ Boolean
A Portfolio corresponds to a partially-configured design.
- #implemented_ext_vers ⇒ Object
-
#in_scope_csrs ⇒ Array<Csr>
Unsorted list of all CSRs associated with extensions listed as mandatory or optional in portfolio.
-
#in_scope_exception_codes ⇒ Array<ExceptionCode>
Unsorted list of all in-scope exception codes.
-
#in_scope_ext_reqs ⇒ Array<ExtensionRequirement>
List of all mandatory or optional extension requirements referenced by this design.
-
#in_scope_extensions ⇒ Array<Extension>
List of all mandatory or optional extensions referenced by this design.
-
#in_scope_instructions ⇒ Array<Instruction>
Sorted list of all instructions associated with extensions listed as mandatory or optional in portfolio.
-
#in_scope_interrupt_codes ⇒ Array<ExceptionCode>
Unsorted list of all in-scope interrupt codes.
-
#in_scope_params(ext_req) ⇒ Array<InScopeParameter>
Sorted list of extension parameters from portfolio for given extension.
-
#include_erb(template_name, extra_inputs = {}) ⇒ String
Include a partial ERB template into a full ERB template.
-
#init_erb_binding(erb_binding) ⇒ Object
Called from tasks.rake file to add standard set of objects available to ERB templates.
-
#initialize(name, cfg_arch, portfolio_design_type, portfolios, portfolio_class) ⇒ PortfolioDesign
constructor
A new instance of PortfolioDesign.
-
#inspect ⇒ String
Returns a string representation of the object, suitable for debugging.
-
#instruction_presence(inst_name) ⇒ String
Given an instruction
ext_name, return the presence as a string. -
#mandatory_ext_reqs ⇒ Array<ExtensionRequirement>
List of all mandatory extension requirements.
-
#out_of_scope_params(ext_name) ⇒ Array<Parameter>
Sorted list of parameters that are out of scope for named extension.
-
#param_values ⇒ Hash<String, String>
Fully-constrained parameter values (those with just one possible value for this design).
-
#params_with_value ⇒ Array<ParameterWithValue>
List of all parameters fully-constrained to one specific value.
-
#partially_configured? ⇒ Boolean
True if some parameters aren’t fully-constrained yet in the design.
-
#unconfigured? ⇒ Boolean
True if all parameters aren’t constrained at all in the design.
Constructor Details
#initialize(name, cfg_arch, portfolio_design_type, portfolios, portfolio_class) ⇒ PortfolioDesign
Returns a new instance of PortfolioDesign.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/udb/portfolio_design.rb', line 75 def initialize(name, cfg_arch, portfolio_design_type, portfolios, portfolio_class) raise ArgumentError, "cfg_arch must be an ConfiguredArchitecture but is a #{cfg_arch.class}" unless cfg_arch.is_a?(ConfiguredArchitecture) raise ArgumentError, "portfolio_design_type of #{portfolio_design_type} unknown" unless PortfolioDesign.portfolio_design_types.include?(portfolio_design_type) raise ArgumentError, "portfolios must be an Array<Portfolio> but is a #{portfolios.class}" unless portfolios.is_a?(Array) raise ArgumentError, "portfolio_class must be a PortfolioClass but is a #{portfolio_class.class}" unless portfolio_class.is_a?(PortfolioClass) @name = name.to_s.freeze @name_sym = @name.to_sym.freeze @cfg_arch = cfg_arch @portfolio_design_type = portfolio_design_type # The PortfolioGroup has an Array<Portfolio> inside it and forwards common Array methods to its internal Array. # Can call @portfolio_grp.each or @portfolio_grp.map and they are handled by the normal Array methods. @portfolio_grp = PortfolioGroup.new(name, portfolios) @portfolio_class = portfolio_class @portfolio_kind = portfolios[0].kind end |
Instance Attribute Details
#cfg_arch ⇒ ConfiguredArchitecture (readonly)
Returns The RISC-V architecture.
61 62 63 |
# File 'lib/udb/portfolio_design.rb', line 61 def cfg_arch @cfg_arch end |
#name ⇒ String (readonly)
Returns Name of design.
49 50 51 |
# File 'lib/udb/portfolio_design.rb', line 49 def name @name end |
#portfolio_class ⇒ PortfolioClass (readonly)
Returns Portfolio class for all the portfolios in this design.
52 53 54 |
# File 'lib/udb/portfolio_design.rb', line 52 def portfolio_class @portfolio_class end |
#portfolio_design_type ⇒ String (readonly)
Returns Type of design suitable for human readers.
58 59 60 |
# File 'lib/udb/portfolio_design.rb', line 58 def portfolio_design_type @portfolio_design_type end |
#portfolio_kind ⇒ String (readonly)
Returns Kind of portfolio for all portfolios in this design.
55 56 57 |
# File 'lib/udb/portfolio_design.rb', line 55 def portfolio_kind @portfolio_kind end |
Class Method Details
.portfolio_design_types ⇒ Object
68 |
# File 'lib/udb/portfolio_design.rb', line 68 def self.portfolio_design_types = [profile_release_type] |
.profile_release_type ⇒ Object
Class methods
67 |
# File 'lib/udb/portfolio_design.rb', line 67 def self.profile_release_type = "Profile Release" |
Instance Method Details
#all_in_scope_exts_with_param(param) ⇒ Array<Extension>
Returns Sorted list of all in-scope extensions that define this parameter in the database and the parameter is in-scope.
203 |
# File 'lib/udb/portfolio_design.rb', line 203 def all_in_scope_exts_with_param(param) = @portfolio_grp.all_in_scope_exts_with_param(param) |
#all_in_scope_exts_without_param(param) ⇒ Array<Extension>
Returns List of all in-scope extensions that define this parameter in the database but the parameter is out-of-scope.
208 |
# File 'lib/udb/portfolio_design.rb', line 208 def all_in_scope_exts_without_param(param) = @portfolio_grp.all_in_scope_exts_without_param(param) |
#all_in_scope_params ⇒ Array<InScopeParameter>
Returns Sorted list of parameters specified by any extension in portfolio.
187 |
# File 'lib/udb/portfolio_design.rb', line 187 def all_in_scope_params = @portfolio_grp.all_in_scope_params |
#all_out_of_scope_params ⇒ Array<Parameter>
Returns Sorted list of parameters out of scope across all in scope extensions.
194 |
# File 'lib/udb/portfolio_design.rb', line 194 def all_out_of_scope_params = @portfolio_grp.all_out_of_scope_params |
#arch ⇒ Object
Provided for backwards-compatibility
64 |
# File 'lib/udb/portfolio_design.rb', line 64 def arch = @cfg_arch |
#csr_presence(csr_name) ⇒ String
Given an CSR ext_name, return the presence as a string. Returns the greatest presence string across all portfolios in this design. If the CSR name isn’t found in this design, return “-”.
184 |
# File 'lib/udb/portfolio_design.rb', line 184 def csr_presence(csr_name) = @portfolio_grp.csr_presence(csr_name) |
#erb_env(extra_inputs = {}) ⇒ Hash<String, Object>
Put this in a method so it can be easily overridden by subclasses.
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/udb/portfolio_design.rb', line 218 def erb_env(extra_inputs = {}) raise ArgumentError, "extra_inputs must be an Hash but is a #{extra_inputs.class}" unless extra_inputs.is_a?(Hash) h = { arch: cfg_arch, design: self, portfolio_design: self, portfolio_design_type: @portfolio_design_type, portfolio_class: @portfolio_class, portfolio_kind: @portfolio_kind, portfolios: @portfolio_grp.portfolios } h.merge!(extra_inputs) end |
#extension_presence(ext_name) ⇒ String
Given an extension ext_name, return the presence as a string. Returns the greatest presence string across all portfolios in this design. If the extension name isn’t found in this design, return “-”.
174 |
# File 'lib/udb/portfolio_design.rb', line 174 def extension_presence(ext_name) = @portfolio_grp.extension_presence(ext_name) |
#fully_configured? ⇒ Boolean
A Portfolio corresponds to a partially-configured design. See the AbstractConfig class for details.
129 |
# File 'lib/udb/portfolio_design.rb', line 129 def fully_configured? = false |
#implemented_ext_vers ⇒ Object
119 120 121 122 123 |
# File 'lib/udb/portfolio_design.rb', line 119 def implemented_ext_vers # Only supported by fully-configured configurations and a portfolio corresponds to a # partially-configured configuration. See the AbstractConfig class for details. raise "Not supported for portfolio #{name}" end |
#in_scope_csrs ⇒ Array<Csr>
Returns Unsorted list of all CSRs associated with extensions listed as mandatory or optional in portfolio. Uses CSRs provided by the minimum version of the extension that meets the extension requirement. Factors in things like XLEN in design.
163 |
# File 'lib/udb/portfolio_design.rb', line 163 def in_scope_csrs = @portfolio_grp.in_scope_csrs(self) |
#in_scope_exception_codes ⇒ Array<ExceptionCode>
Returns Unsorted list of all in-scope exception codes.
166 |
# File 'lib/udb/portfolio_design.rb', line 166 def in_scope_exception_codes = @portfolio_grp.in_scope_exception_codes(self) |
#in_scope_ext_reqs ⇒ Array<ExtensionRequirement>
Returns List of all mandatory or optional extension requirements referenced by this design.
151 |
# File 'lib/udb/portfolio_design.rb', line 151 def in_scope_ext_reqs = @portfolio_grp.in_scope_ext_reqs |
#in_scope_extensions ⇒ Array<Extension>
Returns List of all mandatory or optional extensions referenced by this design.
148 |
# File 'lib/udb/portfolio_design.rb', line 148 def in_scope_extensions = @portfolio_grp.in_scope_extensions |
#in_scope_instructions ⇒ Array<Instruction>
Returns Sorted list of all instructions associated with extensions listed as mandatory or optional in portfolio. Uses instructions provided by the minimum version of the extension that meets the extension requirement. Factors in things like XLEN in design.
157 |
# File 'lib/udb/portfolio_design.rb', line 157 def in_scope_instructions = @portfolio_grp.in_scope_instructions(self) |
#in_scope_interrupt_codes ⇒ Array<ExceptionCode>
Returns Unsorted list of all in-scope interrupt codes.
169 |
# File 'lib/udb/portfolio_design.rb', line 169 def in_scope_interrupt_codes = @portfolio_grp.in_scope_interrupt_codes(self) |
#in_scope_params(ext_req) ⇒ Array<InScopeParameter>
Returns Sorted list of extension parameters from portfolio for given extension.
191 |
# File 'lib/udb/portfolio_design.rb', line 191 def in_scope_params(ext_req) = @portfolio_grp.in_scope_params(ext_req) |
#include_erb(template_name, extra_inputs = {}) ⇒ String
Include a partial ERB template into a full ERB template.
248 249 250 251 |
# File 'lib/udb/portfolio_design.rb', line 248 def include_erb(template_name, extra_inputs = {}) template_pname = "portfolio/templates/#{template_name}" partial(template_pname, erb_env(extra_inputs)) end |
#init_erb_binding(erb_binding) ⇒ Object
Called from tasks.rake file to add standard set of objects available to ERB templates.
235 236 237 238 239 240 241 |
# File 'lib/udb/portfolio_design.rb', line 235 def init_erb_binding(erb_binding) raise ArgumentError, "Expected Binding object but got #{erb_binding.class}" unless erb_binding.is_a?(Binding) erb_env.each do |key, obj| erb_binding.local_variable_set(key, obj) end end |
#inspect ⇒ String
Returns a string representation of the object, suitable for debugging.
96 |
# File 'lib/udb/portfolio_design.rb', line 96 def inspect = "PortfolioDesign##{name}" |
#instruction_presence(inst_name) ⇒ String
Given an instruction ext_name, return the presence as a string. Returns the greatest presence string across all portfolios in this design. If the instruction name isn’t found in this design, return “-”.
179 |
# File 'lib/udb/portfolio_design.rb', line 179 def instruction_presence(inst_name) = @portfolio_grp.instruction_presence(inst_name) |
#mandatory_ext_reqs ⇒ Array<ExtensionRequirement>
Returns List of all mandatory extension requirements.
142 |
# File 'lib/udb/portfolio_design.rb', line 142 def mandatory_ext_reqs = @portfolio_grp.mandatory_ext_reqs |
#out_of_scope_params(ext_name) ⇒ Array<Parameter>
Returns Sorted list of parameters that are out of scope for named extension.
198 |
# File 'lib/udb/portfolio_design.rb', line 198 def out_of_scope_params(ext_name) = @portfolio_grp.out_of_scope_params(ext_name) |
#param_values ⇒ Hash<String, String>
Returns Fully-constrained parameter values (those with just one possible value for this design).
145 |
# File 'lib/udb/portfolio_design.rb', line 145 def param_values = @portfolio_grp.param_values |
#params_with_value ⇒ Array<ParameterWithValue>
Returns List of all parameters fully-constrained to one specific value.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/udb/portfolio_design.rb', line 103 def params_with_value return @params_with_value unless @params_with_value.nil? @params_with_value = [] in_scope_ext_reqs.each do |ext_req| ext_req.extension.params.each do |param| next unless param_values.key?(param.name) @params_with_value << ParameterWithValue.new(param, param_values[param.name]) end end @params_with_value end |
#partially_configured? ⇒ Boolean
Returns True if some parameters aren’t fully-constrained yet in the design.
132 |
# File 'lib/udb/portfolio_design.rb', line 132 def partially_configured? = true |
#unconfigured? ⇒ Boolean
Returns True if all parameters aren’t constrained at all in the design.
135 |
# File 'lib/udb/portfolio_design.rb', line 135 def unconfigured? = false |