Class: Origen::ChipMode

Inherits:
Object show all
Defined in:
lib/origen/chip_mode.rb

Overview

Represents an SoC DFT/Operating mode - e.g. SCAN, RAMBIST, etc.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ ChipMode

Returns a new instance of ChipMode.



21
22
23
24
25
26
# File 'lib/origen/chip_mode.rb', line 21

def initialize(name, options = {})
  options.each { |k, v| instance_variable_set("@#{k}", v) }
  (block.arity < 1 ? (instance_eval(&block)) : block.call(self)) if block_given?
  @name = name
  validate_args
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *arguments, &block) ⇒ Object

Implements methods like:

if $dut.mode.rambist?


71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/origen/chip_mode.rb', line 71

def method_missing(method_name, *arguments, &block)
  ivar = "@#{method_name.to_s.gsub('=', '')}"
  ivar_sym = ":#{ivar}"
  if method_name[-1] == '?'
    return id == method_name[0..-2].to_sym
  elsif method_name[-1] == '='
    define_singleton_method(method_name) do |val|
      instance_variable_set(ivar, val)
    end
  elsif instance_variables.include? ivar_sym
    instance_variable_get(ivar)
  else
    define_singleton_method(method_name) do
      instance_variable_get(ivar)
    end
  end

  send(method_name, *arguments, &block)
end

Instance Attribute Details

#audienceObject

Returns the value of attribute audience.



13
14
15
# File 'lib/origen/chip_mode.rb', line 13

def audience
  @audience
end

#brief_descriptionObject

Returns the value of attribute brief_description.



4
5
6
# File 'lib/origen/chip_mode.rb', line 4

def brief_description
  @brief_description
end

#data_rate(options = {}) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/origen/chip_mode.rb', line 41

def data_rate(options = {})
  options = {
    absolute_number: true
  }.update(options)
  # Convert the data rate to a number
  if !!@data_rate && !!@data_rate_unit
    if options[:absolute_number]
      # The data rate unit was validated on init so it is good to go
      # in theory but should still check if it returns a numeric
      value = @data_rate.send(@data_rate_unit.to_sym)
      if value.is_a?(Numeric)
        value
      else
        Origen.log.error "@data_rate '#{@data_rate}' conversion using @data_rate_unit '#{@data_rate_unit}' did not product a Numeric, exiting..."
      end
    else
      @data_rate
    end
  else
    @data_rate
  end
end

#data_rate_unitObject

Returns the value of attribute data_rate_unit.



8
9
10
# File 'lib/origen/chip_mode.rb', line 8

def data_rate_unit
  @data_rate_unit
end

#descriptionObject

Returns the value of attribute description.



5
6
7
# File 'lib/origen/chip_mode.rb', line 5

def description
  @description
end

#minimum_version_enabledObject

Returns the value of attribute minimum_version_enabled.



9
10
11
# File 'lib/origen/chip_mode.rb', line 9

def minimum_version_enabled
  @minimum_version_enabled
end

#nameObject Also known as: full_name



28
29
30
# File 'lib/origen/chip_mode.rb', line 28

def name
  @name || @id
end

#ownerObject

Returns the object that owns the mode (the SoC instance usually)



17
18
19
# File 'lib/origen/chip_mode.rb', line 17

def owner
  @owner
end

#typical_voltageObject Also known as: typ_voltage

Returns the value of attribute typical_voltage.



18
19
20
# File 'lib/origen/chip_mode.rb', line 18

def typical_voltage
  @typical_voltage
end

Instance Method Details

#idObject



33
34
35
# File 'lib/origen/chip_mode.rb', line 33

def id
  @id || name.to_s.downcase.gsub(/(\s|-)+/, '_').to_sym
end

#id=(val) ⇒ Object



37
38
39
# File 'lib/origen/chip_mode.rb', line 37

def id=(val)
  @id = val.to_s.gsub(/(\s|-)+/, '_').downcase.to_sym
end

#respond_to_missing?(method_name, _include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/origen/chip_mode.rb', line 64

def respond_to_missing?(method_name, _include_private = false)
  method_name[-1] == '?'
end

#to_sObject



91
92
93
# File 'lib/origen/chip_mode.rb', line 91

def to_s
  id.to_s
end

#to_symObject



95
96
97
# File 'lib/origen/chip_mode.rb', line 95

def to_sym
  to_s.to_sym
end