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.



19
20
21
22
23
24
# File 'lib/origen/chip_mode.rb', line 19

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?


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

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.



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

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

Returns the value of attribute data_rate.



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

def data_rate
  @data_rate
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



26
27
28
# File 'lib/origen/chip_mode.rb', line 26

def name
  @name || @id
end

#ownerObject

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



15
16
17
# File 'lib/origen/chip_mode.rb', line 15

def owner
  @owner
end

#typical_voltageObject Also known as: typ_voltage

Returns the value of attribute typical_voltage.



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

def typical_voltage
  @typical_voltage
end

Instance Method Details

#idObject



31
32
33
# File 'lib/origen/chip_mode.rb', line 31

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

#id=(val) ⇒ Object



35
36
37
# File 'lib/origen/chip_mode.rb', line 35

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

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

Returns:

  • (Boolean)


62
63
64
# File 'lib/origen/chip_mode.rb', line 62

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

#to_sObject



88
89
90
# File 'lib/origen/chip_mode.rb', line 88

def to_s
  id.to_s
end

#to_symObject



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

def to_sym
  to_s.to_sym
end