Class: Udb::ProcCertDesign

Inherits:
PortfolioDesign show all
Defined in:
lib/udb/proc_cert_design.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, cfg_arch, portfolio_design_type, proc_cert_model, proc_cert_class) ⇒ ProcCertDesign

Returns a new instance of ProcCertDesign.

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)


25
26
27
28
29
30
31
# File 'lib/udb/proc_cert_design.rb', line 25

def initialize(name, cfg_arch, portfolio_design_type, proc_cert_model, proc_cert_class)
  raise ArgumentError, "proc_cert_model must be a ProcCertModel" unless proc_cert_model.is_a?(ProcCertModel)
  raise ArgumentError, "proc_cert_class must be a ProcCertClass" unless proc_cert_class.is_a?(ProcCertClass)
  @proc_cert_model = proc_cert_model
  @proc_cert_class = proc_cert_class
  super(name, cfg_arch, portfolio_design_type, [proc_cert_model], proc_cert_class)
end

Instance Attribute Details

#proc_cert_classProcCertClass (readonly)

Returns The processor certificate class object from the architecture database.

Returns:

  • (ProcCertClass)

    The processor certificate class object from the architecture database



18
19
20
# File 'lib/udb/proc_cert_design.rb', line 18

def proc_cert_class
  @proc_cert_class
end

#proc_cert_modelProcCertModel (readonly)

Returns The processor certificate model object from the architecture database.

Returns:

  • (ProcCertModel)

    The processor certificate model object from the architecture database



15
16
17
# File 'lib/udb/proc_cert_design.rb', line 15

def proc_cert_model
  @proc_cert_model
end

Instance Method Details

#erb_env(*extra_inputs) ⇒ Hash<String, Object>

Add certificate-specific objects to the parent hash.

Parameters:

  • extra_inputs (Array<Hash>)

    Any extra inputs to be passed to ERB template.

Returns:

  • (Hash<String, Object>)

    Hash of objects to be used in ERB templates

Raises:

  • (ArgumentError)


40
41
42
43
44
45
46
47
48
49
50
# File 'lib/udb/proc_cert_design.rb', line 40

def erb_env(*extra_inputs)
  raise ArgumentError, "extra_inputs must be an Array but is a #{extra_inputs.class}" unless extra_inputs.is_a?(Array)

  h = super   # Call parent method with whatever args I got

  h[:proc_cert_design] = self
  h[:proc_cert_model] = proc_cert_model
  h[:proc_cert_class] = proc_cert_class

  h
end

#include_erb(template_name, extra_inputs = {}) ⇒ String

Include a partial ERB template into a full ERB template. Can be either in the portfolio or proc_cert backends (but not both).

Parameters:

  • template_path (String)

    Name of template file located in backends/portfolio/templates or in backends/proc_cert/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



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/udb/proc_cert_design.rb', line 59

def include_erb(template_name, extra_inputs = {})
  proc_cert_template_pname = "proc_cert/templates/#{template_name}"
  proc_cert_template_path = Pathname.new($root / "backends" / proc_cert_template_pname)

  portfolio_template_pname = "portfolio/templates/#{template_name}"
  portfolio_template_path = Pathname.new($root / "backends" / portfolio_template_pname)

  if proc_cert_template_path.exist? && portfolio_template_path.exist?
    raise "Both #{proc_cert_template_pname} and #{portfolio_template_pname} exist. Need unique names."
  elsif proc_cert_template_path.exist?
    partial(proc_cert_template_pname, erb_env(extra_inputs))
  elsif portfolio_template_path.exist?
    partial(portfolio_template_pname, erb_env(extra_inputs))
  else
    raise "Can't find file #{template_name} in either #{proc_cert_template_pname} or #{portfolio_template_pname}."
  end
end

#inspectString

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

Returns:

  • (String)

    A string representation of the object.



35
# File 'lib/udb/proc_cert_design.rb', line 35

def inspect = "ProcCertDesign##{name}"