Class: Udb::PortfolioDesign

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

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)


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

Returns The RISC-V architecture.

Returns:



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

def cfg_arch
  @cfg_arch
end

#nameString (readonly)

Returns Name of design.

Returns:

  • (String)

    Name of design



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

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



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

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.



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

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



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

def portfolio_kind
  @portfolio_kind
end

Class Method Details

.portfolio_design_typesObject



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

def self.portfolio_design_types = [profile_release_type]

.profile_release_typeObject

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.

Parameters:

Returns:

  • (Array<Extension>)

    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.

Parameters:

Returns:

  • (Array<Extension>)

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



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

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.



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

def all_out_of_scope_params = @portfolio_grp.all_out_of_scope_params

#archObject

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

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



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.

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)


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

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



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.

Returns:

  • (Boolean)

    True if all parameters are fully-constrained in the design



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

def fully_configured? = false

#implemented_ext_versObject



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



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

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.



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

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.



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

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.



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

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.



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

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.



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.

Parameters:

Returns:

  • (Array<InScopeParameter>)

    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.

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



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.

Raises:

  • (ArgumentError)


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

#inspectString

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

Returns:

  • (String)

    A string representation of the object.



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

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



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

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

#mandatory_ext_reqsArray<ExtensionRequirement>

Returns List of all mandatory extension requirements.

Returns:



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.

Parameters:

  • ext_name (String)

    Extension name

Returns:

  • (Array<Parameter>)

    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_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).



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

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



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.

Returns:

  • (Boolean)

    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.

Returns:

  • (Boolean)

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



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

def unconfigured? = false