Class: Udb::ProcCertModel

Inherits:
Portfolio show all
Defined in:
lib/udb/obj/certificate.rb

Overview

Holds information about a processor certificate model YAML file. The inherited “data” member is the database of extensions, instructions, CSRs, etc.

Defined Under Namespace

Classes: Requirement, RequirementGroup

Instance Method Summary collapse

Constructor Details

#initialize(obj_yaml, yaml_path, arch) ⇒ ProcCertModel

Returns a new instance of ProcCertModel.

Parameters:

  • obj_yaml (Hash<String, Object>)

    Contains contents of Certificate Model yaml file (put in @data)

  • data_path (String)

    Path to yaml file

  • arch (Architecture)

    Database of RISC-V standards



32
33
34
# File 'lib/udb/obj/certificate.rb', line 32

def initialize(obj_yaml, yaml_path, arch)
  super # Calls parent class with the same args I got
end

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.

Raises:

  • (ArgumentError)


246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# File 'lib/udb/obj/certificate.rb', line 246

def all_in_scope_exts_with_param(param)
  raise ArgumentError, "Expecting Parameter" unless param.is_a?(Parameter)

  exts = []

  # Iterate through all the extensions in the architecture database that define this parameter.
  param.exts.each do |ext|
    found = false

    in_scope_extensions.each do |potential_ext|
      if ext.name == potential_ext.name
        found = true
        next
      end
    end

    if found
      # Only add extensions that exist in this certificate model.
      exts << ext
    end
  end

  # Return intersection of extension names
  exts.sort_by!(&:name)
end

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

Raises:

  • (ArgumentError)


275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/udb/obj/certificate.rb', line 275

def all_in_scope_exts_without_param(param)
  raise ArgumentError, "Expecting Parameter" unless param.is_a?(Parameter)

  exts = []   # Local variable, no caching

  # Iterate through all the extensions in the architecture database that define this parameter.
  param.exts.each do |ext|
    found = false

    in_scope_extensions.each do |potential_ext|
      if ext.name == potential_ext.name
        found = true
        next
      end
    end

    if found
        # Only add extensions that are in-scope (i.e., exist in this certificate model).
        exts << ext
    end
  end

  # Return intersection of extension names
  exts.sort_by!(&:name)
end

#all_in_scope_paramsArray<InScopeParameter>

These are always IN-SCOPE by definition (since they are listed in the portfolio). Can have multiple array entries with the same parameter name since multiple extensions may define the same parameter.

Returns:

  • (Array<InScopeParameter>)

    Sorted list of parameters specified by any extension in portfolio.



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/udb/obj/certificate.rb', line 163

def all_in_scope_params
  return @all_in_scope_params unless @all_in_scope_params.nil?

  @all_in_scope_params = []

  @data["extensions"].each do |ext_name, ext_data|
    next if ext_name[0] == "$"

    # Find Extension object from database
    ext = @arch.extension(ext_name)
    if ext.nil?
      raise "Cannot find extension named #{ext_name}"
    end

    ext_data["param_constraints"]&.each do |param_name, param_data|
      param = ext.params.find { |p| p.name == param_name }
      raise "There is no param '#{param_name}' in extension '#{ext_name}" if param.nil?

      next unless param.when.could_be_satisfied_by_ext_reqs?(in_scope_ext_reqs)

      @all_in_scope_params << InScopeParameter.new(param, param_data["schema"], param_data["note"])
    end
  end
  @all_in_scope_params.sort!
end

#all_out_of_scope_paramsArray<Parameter>

Returns Sorted list of parameters out of scope across all in scope extensions (those listed as mandatory or optional in the certificate model).

Returns:

  • (Array<Parameter>)

    Sorted list of parameters out of scope across all in scope extensions (those listed as mandatory or optional in the certificate model).



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

def all_out_of_scope_params
  return @all_out_of_scope_params unless @all_out_of_scope_params.nil?

  @all_out_of_scope_params = []
  in_scope_ext_reqs.each do |ext_req|
    ext = @arch.extension(ext_req.name)
    ext.params.each do |param|
      next if all_in_scope_params.any? { |c| c.param.name == param.name }

      @all_out_of_scope_params << param
    end
  end
  @all_out_of_scope_params.sort!
end

#debug_manual_revisionObject



38
# File 'lib/udb/obj/certificate.rb', line 38

def debug_manual_revision = @data["debug_manual_revision"]

#in_scope_params(ext_req) ⇒ Array<InScopeParameter>

These are always IN SCOPE by definition (since they are listed in the portfolio).

Parameters:

Returns:

  • (Array<InScopeParameter>)

    Sorted list of extension parameters from portfolio for given extension.

Raises:

  • (ArgumentError)


192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/udb/obj/certificate.rb', line 192

def in_scope_params(ext_req)
  raise ArgumentError, "Expecting ExtensionRequirement" unless ext_req.is_a?(ExtensionRequirement)

  params = []    # Local variable, no caching

  # Get extension information from portfolio YAML for passed in extension requirement.
  ext_data = @data["extensions"][ext_req.name]
  raise "Cannot find extension named #{ext_req.name}" if ext_data.nil?

  # Find Extension object from database
  ext = @arch.extension(ext_req.name)
  raise "Cannot find extension named #{ext_req.name}" if ext.nil?

  # Loop through an extension's parameter constraints (hash) from the certificate model.
  # Note that "&" is the Ruby safe navigation operator (i.e., skip do loop if nil).
  ext_data["param_constraints"]&.each do |param_name, param_data|
    # Find Parameter object from database
    param = ext.params.find { |p| p.name == param_name }
    raise "There is no param '#{param_name}' in extension '#{ext_req.name}" if param.nil?

    next unless param.when.could_be_satisfied_by_ext_reqs?(in_scope_ext_reqs)

    params << InScopeParameter.new(param, param_data["schema"], param_data["note"])
  end

  params.sort!
end

#in_scope_priv_modesObject



50
# File 'lib/udb/obj/certificate.rb', line 50

def in_scope_priv_modes = @data["in_scope_priv_modes"]

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



239
240
241
# File 'lib/udb/obj/certificate.rb', line 239

def out_of_scope_params(ext_name)
  all_out_of_scope_params.select{ |param| param.exts.any? { |ext| ext.name == ext_name } }.sort
end

#priv_isa_manual_revisionObject



37
# File 'lib/udb/obj/certificate.rb', line 37

def priv_isa_manual_revision = @data["priv_isa_manual_revision"]

#proc_cert_classProcCertClass

Returns The certification class that this model belongs to.

Returns:

  • (ProcCertClass)

    The certification class that this model belongs to.



53
54
55
56
57
58
# File 'lib/udb/obj/certificate.rb', line 53

def proc_cert_class
  proc_cert_class = @arch.ref(@data["class"]['$ref'])
  raise "No processor certificate class named '#{@data["class"]}'" if proc_cert_class.nil?

  proc_cert_class
end

#requirement_groupsArray<RequirementGroup>

Returns The list of requirement groups.

Returns:



145
146
147
148
149
150
151
152
153
# File 'lib/udb/obj/certificate.rb', line 145

def requirement_groups
  return @requirement_groups unless @requirement_groups.nil?

  @requirement_groups = []
  @data["requirement_groups"]&.each do |req_key, req_group|
    @requirement_groups << RequirementGroup.new(req_group, @arch) unless req_key == "$child_of" || req_key == "$parent_of"
  end
  @requirement_groups
end

#tsc_profile_releaseObject



40
41
42
43
44
45
46
47
48
# File 'lib/udb/obj/certificate.rb', line 40

def tsc_profile_release
  return nil if @data["tsc_profile_release"].nil?

  profile_release = @arch.ref(@data["tsc_profile_release"]['$ref'])

  raise "No profile release called '#{@data["tsc_profile_release"]}' exists" if profile_release.nil?

  profile_release
end

#unpriv_isa_manual_revisionObject



36
# File 'lib/udb/obj/certificate.rb', line 36

def unpriv_isa_manual_revision = @data["unpriv_isa_manual_revision"]