Class: Origen::PowerDomains::PowerDomain

Inherits:
Object
  • Object
show all
Includes:
Specs
Defined in:
lib/origen/power_domains/power_domain.rb

Constant Summary

Constants included from Specs

Specs::FEATURE_TYPES, Specs::NOTE_TYPES, Specs::SPEC_TYPES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Specs

#creation_info, #delete_all_doc_resources, #delete_all_documentation, #delete_all_exhibits, #delete_all_mode_selects, #delete_all_notes, #delete_all_overrides, #delete_all_power_supplies, #delete_all_specs, #delete_all_version_history, #delete_creation_info, #delete_spec_features, #doc_resource, #doc_resources, #documentation, #documentations, #exhibit, #exhibits, #get_creation_info, #get_modes, #has_spec?, #has_specs?, #info, #mode_select, #mode_selects, #note, #notes, #override, #overrides, #power_supplies, #power_supply, #spec, #spec_feature, #spec_features, #specs, #version_histories, #version_history, #versions

Methods included from Specs::Checkers

#evaluate_limit, #get_mode, #limits_ok?, #name_audit

Constructor Details

#initialize(id, options = {}, &block) ⇒ PowerDomain

Returns a new instance of PowerDomain



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/origen/power_domains/power_domain.rb', line 32

def initialize(id, options = {}, &block)
  @id = id
  @description = ''
  @display_name = {}
  @id = @id.symbolize unless @id.is_a? Symbol
  options.each { |k, v| instance_variable_set("@#{k}", v) }
  (block.arity < 1 ? (instance_eval(&block)) : block.call(self)) if block_given?
  @unit_voltage_range = :fixed if @unit_voltage_range.nil?
  fail unless attrs_ok?
  create_dut_spec unless @min.nil? || @max.nil?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/origen/power_domains/power_domain.rb', line 173

def method_missing(m, *args, &block)
  ivar = "@#{m.to_s.gsub('=', '')}"
  ivar_sym = ":#{ivar}"
  if m.to_s =~ /=$/
    define_singleton_method(m) do |val|
      instance_variable_set(ivar, val)
    end
  elsif instance_variables.include? ivar_sym
    instance_variable_get(ivar)
  else
    define_singleton_method(m) do
      instance_variable_get(ivar)
    end
  end
  send(m, *args, &block)
end

Instance Attribute Details

#actual_nameObject

Actual Power Domain Name



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

def actual_name
  @actual_name
end

#descriptionObject

Returns the value of attribute description



6
7
8
# File 'lib/origen/power_domains/power_domain.rb', line 6

def description
  @description
end

#display_nameObject

Display Names Hash of display names display_name = {

input:  Input voltage name, e.g. V<sub>IN</sub>
output:  Output voltage name, e.g. V<sub>OUT</sub>
default: Regular Voltage name, e.g. V<sub>DD</sub>


30
31
32
# File 'lib/origen/power_domains/power_domain.rb', line 30

def display_name
  @display_name
end

#generic_nameObject

Generic Power Domain Name This is the power supply that can be blocked off to multiple power supplies For example, Power Domain for DDR blocks could be GVDD, then the actual power supplies can be different for each DDR block.

DDR1 --> G1VDD
DDR2 --> G2VDD


14
15
16
# File 'lib/origen/power_domains/power_domain.rb', line 14

def generic_name
  @generic_name
end

#idObject

Returns the value of attribute id



6
7
8
# File 'lib/origen/power_domains/power_domain.rb', line 6

def id
  @id
end

#maxObject

Returns the value of attribute max



6
7
8
# File 'lib/origen/power_domains/power_domain.rb', line 6

def max
  @max
end

#maximum_voltage_ratingObject Also known as: mvr

Maximum Voltage Rating



61
62
63
# File 'lib/origen/power_domains/power_domain.rb', line 61

def maximum_voltage_rating
  @maximum_voltage_rating
end

#minObject

Returns the value of attribute min



6
7
8
# File 'lib/origen/power_domains/power_domain.rb', line 6

def min
  @min
end

#nominal_voltageObject Also known as: nominal, nom

Nominal voltage



123
124
125
# File 'lib/origen/power_domains/power_domain.rb', line 123

def nominal_voltage
  @nominal_voltage
end

#setpointObject Also known as: curr_value, value

Current setpoint, defaults top nil on init



130
131
132
# File 'lib/origen/power_domains/power_domain.rb', line 130

def setpoint
  @setpoint
end

#unit_voltage_rangeObject Also known as: unit_range

Power domain can allow either a variable or fixed unit voltage range (Range or :fixed)



138
139
140
# File 'lib/origen/power_domains/power_domain.rb', line 138

def unit_voltage_range
  @unit_voltage_range
end

#voltagesObject

Allowed Voltage Points Some power supplies can be at different levels, e.g. 1.8V or 3.3V Could be a signal voltage or an array of voltages



22
23
24
# File 'lib/origen/power_domains/power_domain.rb', line 22

def voltages
  @voltages
end

Instance Method Details

#create_dut_specObject

Create DUT specs for the power supply



49
50
51
52
53
54
55
56
57
58
# File 'lib/origen/power_domains/power_domain.rb', line 49

def create_dut_spec
  if Origen.top_level.specs.nil?
    set_specs
  elsif Origen.top_level.specs.include? name
    Origen.log.error("Cannot create power domain spec '#{name}', it already exists!")
    fail
  else
    set_specs
  end
end

#display_names(default_name) ⇒ Object



167
168
169
170
171
# File 'lib/origen/power_domains/power_domain.rb', line 167

def display_names(default_name)
  @display_name[:default] = default_name
  @display_name[:input] = change_subscript('IN')
  @display_name[:output] = change_subscript('OUT')
end

#ground_pinsObject

Returns an Array of ground pin IDs that match the power domain ID



82
83
84
# File 'lib/origen/power_domains/power_domain.rb', line 82

def ground_pins
  Origen.top_level.ground_pins.select { |_pin_id, p| p.supply == id }.keys
end

#has_ground_pin?(pin) ⇒ Boolean

Checks for the existence of a signal pin that references the power domain

Returns:

  • (Boolean)


97
98
99
# File 'lib/origen/power_domains/power_domain.rb', line 97

def has_ground_pin?(pin)
  ground_pins.include?(pin) ? true : false
end

#has_pin?(pin) ⇒ Boolean

Checks if a pin references the power domain, regardless of type

Returns:

  • (Boolean)


107
108
109
# File 'lib/origen/power_domains/power_domain.rb', line 107

def has_pin?(pin)
  pins.include? pin
end

#has_power_pin?(pin) ⇒ Boolean

Checks for the existence of a signal pin that references the power domain

Returns:

  • (Boolean)


102
103
104
# File 'lib/origen/power_domains/power_domain.rb', line 102

def has_power_pin?(pin)
  power_pins.include?(pin) ? true : false
end

#has_signal_pin?(pin) ⇒ Boolean

Checks for the existence of a signal pin that references the power domain

Returns:

  • (Boolean)


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

def has_signal_pin?(pin)
  signal_pins.include?(pin) ? true : false
end

#nameObject



44
45
46
# File 'lib/origen/power_domains/power_domain.rb', line 44

def name
  @id
end

#pin_type(pin) ⇒ Object

Checks for a pin type, returns nil if it is not found



112
113
114
115
116
117
118
119
120
# File 'lib/origen/power_domains/power_domain.rb', line 112

def pin_type(pin)
  if self.has_pin?(pin) == false
    nil
  else
    [:signal, :ground, :power].each do |pintype|
      return pintype if send("has_#{pintype}_pin?", pin)
    end
  end
end

#pinsObject

Returns an Array of all pins that reference the power domain



72
73
74
# File 'lib/origen/power_domains/power_domain.rb', line 72

def pins
  signal_pins + ground_pins + power_pins
end

#power_pinsObject

Returns an Array of ground pin IDs that match the power domain ID



87
88
89
# File 'lib/origen/power_domains/power_domain.rb', line 87

def power_pins
  Origen.top_level.power_pins.select { |_pin_id, p| p.supply == id }.keys
end

#setpoint_ok?(val = nil) ⇒ Boolean Also known as: value_ok?, val_ok?

Checks if the setpoint is valid This will need rework once the class has spec limits added

Returns:

  • (Boolean)


153
154
155
156
157
158
159
160
161
162
163
# File 'lib/origen/power_domains/power_domain.rb', line 153

def setpoint_ok?(val = nil)
  return true if maximum_voltage_rating.nil?
  compare_val = val.nil? ? setpoint : val
  if compare_val.nil?
    false
  elsif compare_val <= maximum_voltage_rating
    true
  else
    false
  end
end

#setpoint_to_nominalObject

Sets setpoint equal to nominal_voltage



67
68
69
# File 'lib/origen/power_domains/power_domain.rb', line 67

def setpoint_to_nominal
  @setpoint = @nominal_voltage
end

#signal_pinsObject

Returns an Array of signal pin IDs that match the power domain ID



77
78
79
# File 'lib/origen/power_domains/power_domain.rb', line 77

def signal_pins
  Origen.top_level.pins.select { |_pin_id, p| p.supply == id }.keys
end