Class: Udb::PortfolioDesign

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/udb/portfolio_design.rb

Direct Known Subclasses

ProcCertDesign

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, cfg_arch, portfolio_design_type, portfolios, portfolio_class) ⇒ PortfolioDesign

Returns a new instance of PortfolioDesign.

Parameters:

  • name (#to_s)

    The name of the portfolio design (i.e., backend filename without a suffix)

  • cfg_arch (ConfiguredArchitecture)

    The database of RISC-V standards for a particular configuration

  • portfolio_design_type (String)

    Type of portfolio design associated with this design

  • portfolios (Array<Portfolio>)

    Portfolios being converted to adoc

  • portfolio_class (PortfolioClass)

    PortfolioClass for all the Portfolios

Raises:

  • (ArgumentError)


78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/udb/portfolio_design.rb', line 78

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_archConfiguredArchitecture (readonly)

Returns The RISC-V architecture.

Returns:



62
63
64
# File 'lib/udb/portfolio_design.rb', line 62

def cfg_arch
  @cfg_arch
end

#nameString (readonly)

Returns Name of design.

Returns:

  • (String)

    Name of design



50
51
52
# File 'lib/udb/portfolio_design.rb', line 50

def name
  @name
end

#portfolio_classPortfolioClass (readonly)

Returns Portfolio class for all the portfolios in this design.

Returns:

  • (PortfolioClass)

    Portfolio class for all the portfolios in this design



53
54
55
# File 'lib/udb/portfolio_design.rb', line 53

def portfolio_class
  @portfolio_class
end

#portfolio_design_typeString (readonly)

Returns Type of design suitable for human readers.

Returns:

  • (String)

    Type of design suitable for human readers.



59
60
61
# File 'lib/udb/portfolio_design.rb', line 59

def portfolio_design_type
  @portfolio_design_type
end

#portfolio_kindString (readonly)

Returns Kind of portfolio for all portfolios in this design.

Returns:

  • (String)

    Kind of portfolio for all portfolios in this design



56
57
58
# File 'lib/udb/portfolio_design.rb', line 56

def portfolio_kind
  @portfolio_kind
end

Class Method Details

.portfolio_design_typesObject



71
# File 'lib/udb/portfolio_design.rb', line 71

def self.portfolio_design_types = [profile_release_type, proc_crd_type, proc_ctp_type]

.proc_crd_typeObject



69
# File 'lib/udb/portfolio_design.rb', line 69

def self.proc_crd_type = "Certification Requirements Document"

.proc_ctp_typeObject



70
# File 'lib/udb/portfolio_design.rb', line 70

def self.proc_ctp_type = "Certification Test Plan"

.profile_release_typeObject

Class methods



68
# File 'lib/udb/portfolio_design.rb', line 68

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.

Parameters:

Returns:

  • (Array<Extension>)

    Sorted list of all in-scope extensions that define this parameter in the database and the parameter is in-scope.



206
# File 'lib/udb/portfolio_design.rb', line 206

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.

Parameters:

Returns:

  • (Array<Extension>)

    List of all in-scope extensions that define this parameter in the database but the parameter is out-of-scope.



211
# File 'lib/udb/portfolio_design.rb', line 211

def all_in_scope_exts_without_param(param) = @portfolio_grp.all_in_scope_exts_without_param(param)

#all_in_scope_paramsArray<InScopeParameter>

Returns Sorted list of parameters specified by any extension in portfolio.

Returns:

  • (Array<InScopeParameter>)

    Sorted list of parameters specified by any extension in portfolio.



190
# File 'lib/udb/portfolio_design.rb', line 190

def all_in_scope_params = @portfolio_grp.all_in_scope_params

#all_out_of_scope_paramsArray<Parameter>

Returns Sorted list of parameters out of scope across all in scope extensions.

Returns:

  • (Array<Parameter>)

    Sorted list of parameters out of scope across all in scope extensions.



197
# File 'lib/udb/portfolio_design.rb', line 197

def all_out_of_scope_params = @portfolio_grp.all_out_of_scope_params

#archObject

Provided for backwards-compatibility



65
# File 'lib/udb/portfolio_design.rb', line 65

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 “-”.

Returns:

  • (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 “-”.



187
# File 'lib/udb/portfolio_design.rb', line 187

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.

Parameters:

  • extra_inputs (Hash<String, Object>) (defaults to: {})

    Any extra inputs to be passed to ERB template.

Returns:

  • (Hash<String, Object>)

    Hash of objects available to ERB templates and ERB fragments included in the main ERB template.

Raises:

  • (ArgumentError)


221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/udb/portfolio_design.rb', line 221

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 “-”.

Returns:

  • (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 “-”.



177
# File 'lib/udb/portfolio_design.rb', line 177

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.

Returns:

  • (Boolean)

    True if all parameters are fully-constrained in the design



132
# File 'lib/udb/portfolio_design.rb', line 132

def fully_configured? = false

#implemented_ext_versObject



122
123
124
125
126
# File 'lib/udb/portfolio_design.rb', line 122

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_csrsArray<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.

Returns:

  • (Array<Csr>)

    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.



166
# File 'lib/udb/portfolio_design.rb', line 166

def in_scope_csrs = @portfolio_grp.in_scope_csrs(self)

#in_scope_exception_codesArray<ExceptionCode>

Returns Unsorted list of all in-scope exception codes.

Returns:

  • (Array<ExceptionCode>)

    Unsorted list of all in-scope exception codes.



169
# File 'lib/udb/portfolio_design.rb', line 169

def in_scope_exception_codes = @portfolio_grp.in_scope_exception_codes(self)

#in_scope_ext_reqsArray<ExtensionRequirement>

Returns List of all mandatory or optional extension requirements referenced by this design.

Returns:

  • (Array<ExtensionRequirement>)

    List of all mandatory or optional extension requirements referenced by this design.



154
# File 'lib/udb/portfolio_design.rb', line 154

def in_scope_ext_reqs = @portfolio_grp.in_scope_ext_reqs

#in_scope_extensionsArray<Extension>

Returns List of all mandatory or optional extensions referenced by this design.

Returns:

  • (Array<Extension>)

    List of all mandatory or optional extensions referenced by this design.



151
# File 'lib/udb/portfolio_design.rb', line 151

def in_scope_extensions = @portfolio_grp.in_scope_extensions

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

Returns:

  • (Array<Instruction>)

    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.



160
# File 'lib/udb/portfolio_design.rb', line 160

def in_scope_instructions = @portfolio_grp.in_scope_instructions(self)

#in_scope_interrupt_codesArray<ExceptionCode>

Returns Unsorted list of all in-scope interrupt codes.

Returns:

  • (Array<ExceptionCode>)

    Unsorted list of all in-scope interrupt codes.



172
# File 'lib/udb/portfolio_design.rb', line 172

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.

Parameters:

Returns:

  • (Array<InScopeParameter>)

    Sorted list of extension parameters from portfolio for given extension.



194
# File 'lib/udb/portfolio_design.rb', line 194

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.

Parameters:

  • template_path (String)

    Name of template file located in backends/portfolio/templates

  • extra_inputs (Hash<String, Object>) (defaults to: {})

    Any extra inputs to be passed to ERB template.

Returns:

  • (String)

    Result of ERB evaluation of the template file



251
252
253
254
# File 'lib/udb/portfolio_design.rb', line 251

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.

Raises:

  • (ArgumentError)


238
239
240
241
242
243
244
# File 'lib/udb/portfolio_design.rb', line 238

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

#inspectString

Returns a string representation of the object, suitable for debugging.

Returns:

  • (String)

    A string representation of the object.



99
# File 'lib/udb/portfolio_design.rb', line 99

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 “-”.

Returns:

  • (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 “-”.



182
# File 'lib/udb/portfolio_design.rb', line 182

def instruction_presence(inst_name) = @portfolio_grp.instruction_presence(inst_name)

#mandatory_ext_reqsArray<ExtensionRequirement>

Returns List of all mandatory extension requirements.

Returns:



145
# File 'lib/udb/portfolio_design.rb', line 145

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.

Parameters:

  • ext_name (String)

    Extension name

Returns:

  • (Array<Parameter>)

    Sorted list of parameters that are out of scope for named extension.



201
# File 'lib/udb/portfolio_design.rb', line 201

def out_of_scope_params(ext_name) = @portfolio_grp.out_of_scope_params(ext_name)

#param_valuesHash<String, String>

Returns Fully-constrained parameter values (those with just one possible value for this design).

Returns:

  • (Hash<String, String>)

    Fully-constrained parameter values (those with just one possible value for this design).



148
# File 'lib/udb/portfolio_design.rb', line 148

def param_values = @portfolio_grp.param_values

#params_with_valueArray<ParameterWithValue>

Returns List of all parameters fully-constrained to one specific value.

Returns:

  • (Array<ParameterWithValue>)

    List of all parameters fully-constrained to one specific value



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/udb/portfolio_design.rb', line 106

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.

Returns:

  • (Boolean)

    True if some parameters aren’t fully-constrained yet in the design



135
# File 'lib/udb/portfolio_design.rb', line 135

def partially_configured? = true

#unconfigured?Boolean

Returns True if all parameters aren’t constrained at all in the design.

Returns:

  • (Boolean)

    True if all parameters aren’t constrained at all in the design



138
# File 'lib/udb/portfolio_design.rb', line 138

def unconfigured? = false