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.



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

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



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

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



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

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>


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

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


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

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



63
64
65
# File 'lib/origen/power_domains/power_domain.rb', line 63

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



125
126
127
# File 'lib/origen/power_domains/power_domain.rb', line 125

def nominal_voltage
  @nominal_voltage
end

#unit_voltage_rangeObject Also known as: unit_range

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



140
141
142
# File 'lib/origen/power_domains/power_domain.rb', line 140

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



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

def voltages
  @voltages
end

Instance Method Details

#create_dut_specObject

Create DUT specs for the power supply



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

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



170
171
172
173
174
# File 'lib/origen/power_domains/power_domain.rb', line 170

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



84
85
86
# File 'lib/origen/power_domains/power_domain.rb', line 84

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)


99
100
101
# File 'lib/origen/power_domains/power_domain.rb', line 99

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)


109
110
111
# File 'lib/origen/power_domains/power_domain.rb', line 109

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)


104
105
106
# File 'lib/origen/power_domains/power_domain.rb', line 104

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)


94
95
96
# File 'lib/origen/power_domains/power_domain.rb', line 94

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

#nameObject



46
47
48
# File 'lib/origen/power_domains/power_domain.rb', line 46

def name
  @id
end

#pin_type(pin) ⇒ Object

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



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

def pin_type(pin)
  if 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



74
75
76
# File 'lib/origen/power_domains/power_domain.rb', line 74

def pins
  signal_pins + ground_pins + power_pins
end

#power_pinsObject

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



89
90
91
# File 'lib/origen/power_domains/power_domain.rb', line 89

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

#setpointObject Also known as: curr_value, value

Current setpoint, defaults top nil on init



132
133
134
# File 'lib/origen/power_domains/power_domain.rb', line 132

def setpoint
  @setpoint
end

#setpoint=(val) ⇒ Object

Setter for setpoint



146
147
148
149
150
151
# File 'lib/origen/power_domains/power_domain.rb', line 146

def setpoint=(val)
  unless setpoint_ok?(val)
    Origen.log.warn("Setpoint (#{setpoint_string(val)}) for power domain '#{name}' is not within the voltage range (#{unit_voltage_range_string})!")
  end
  @setpoint = val
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)


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

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



69
70
71
# File 'lib/origen/power_domains/power_domain.rb', line 69

def setpoint_to_nominal
  @setpoint = @nominal_voltage
end

#signal_pinsObject

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



79
80
81
# File 'lib/origen/power_domains/power_domain.rb', line 79

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