Class: Udb::PartialConfig

Inherits:
AbstractConfig show all
Defined in:
lib/udb/config.rb

Overview

This class represents a configuration that is “partially-configured” (e.g., portfolio or configurable IP). # It only lists mandatory & prohibited extensions and fully-constrained parameters (single value).

Constant Summary

Constants inherited from AbstractConfig

AbstractConfig::ParamValueType

Instance Attribute Summary

Attributes inherited from AbstractConfig

#info, #type

Instance Method Summary collapse

Methods inherited from AbstractConfig

#arch_overlay, #arch_overlay_abs, #compatible, #configured?, create, create_from_data, #description, #name, #overlay?

Constructor Details

#initialize(data, info) ⇒ PartialConfig

Returns a new instance of PartialConfig.



238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/udb/config.rb', line 238

def initialize(data, info)
  super(data, info)

  @param_values = @data.key?("params") ? @data["params"] : [].freeze

  @mxlen = @data.dig("params", "MXLEN")

  if @mxlen.nil?
    # Infer MXLEN from subordinate mode XLENs: if any of UXLEN/SXLEN/VSXLEN/VUXLEN
    # can be 64, then MXLEN must be 64 (lower modes cannot exceed machine-mode width).
    MODE_XLEN_PARAMS.each do |param|
      val = @data.dig("params", param)
      if val == 64 || (val.is_a?(Array) && val.include?(64))
        @mxlen = 64
        break
      end
    end

    if @mxlen.nil?
      param_req = @data.dig("requirements", "param")
      @mxlen = 64 if !param_req.nil? && param_req_implies_64?(param_req)
    end
  end

  @mxlen.freeze unless @mxlen.nil?
end

Instance Method Details

#additional_extensions_allowed?Boolean

Returns:

  • (Boolean)


334
# File 'lib/udb/config.rb', line 334

def additional_extensions_allowed? = @data.key?("additional_extensions") ? @data["additional_extensions"] : true

#fully_configured?Boolean

Returns:

  • (Boolean)


276
# File 'lib/udb/config.rb', line 276

def fully_configured? = false

#mandatory_extensionsObject



285
286
287
288
289
290
291
292
293
294
295
# File 'lib/udb/config.rb', line 285

def mandatory_extensions
  @mandatory_extensions ||=
    if @data["mandatory_extensions"].nil?
      []
    else
      @data["mandatory_extensions"].map do |e|
        # convert the requirement to always be an array
        { "name" => e["name"], "version" => e["version"].is_a?(String) ? [e["version"]] : e["version"] }
      end
    end
end

#mxlenObject



273
# File 'lib/udb/config.rb', line 273

def mxlen = @mxlen

#non_mandatory_extensionsObject



298
299
300
301
302
303
304
305
306
307
308
# File 'lib/udb/config.rb', line 298

def non_mandatory_extensions
  @non_mandatory_extensions ||=
    if @data["non_mandatory_extensions"].nil?
      []
    else
      @data["non_mandatory_extensions"].map do |e|
        # convert the requirement to always be an array
        { "name" => e["name"], "version" => e["version"].is_a?(String) ? [e["version"]] : e["version"] }
      end
    end
end

#param_valuesObject



270
# File 'lib/udb/config.rb', line 270

def param_values = @param_values

#partially_configured?Boolean

Returns:

  • (Boolean)


279
# File 'lib/udb/config.rb', line 279

def partially_configured? = true

#prohibited_extensionsObject



311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# File 'lib/udb/config.rb', line 311

def prohibited_extensions
  @prohibited_extensions ||=
    if @data["prohibited_extensions"].nil?
      []
    else
      @data["prohibited_extensions"].map do |e|
        # convert the requirement to always be an array
        {
          "name" => e["name"],
          "version" =>
            if e.key?("version")
              e["version"].is_a?(String) ? [e["version"]] : e["version"]
            else
              ">=0"
            end
        }
      end
    end
end

#requirementsObject



337
# File 'lib/udb/config.rb', line 337

def requirements = @data["requirements"]

#unconfigured?Boolean

Returns:

  • (Boolean)


282
# File 'lib/udb/config.rb', line 282

def unconfigured? = false