class Origen::Registers::Placeholder
Instantiating registers can be quite expensive, this object is a placeholder for a register and will transform into one automatically when it is required to (i.e. whenever a register method is called on it).
Attributes
Public Class Methods
Source
# File lib/origen/registers.rb, line 136 def initialize(owner, name, attributes) @owner = owner @name = name @attributes = attributes @feature = attributes[:_feature] if attributes.key?(:_feature) # Give reg.new a way to tell if coming from Placeholder if attributes[:bit_info].is_a? Hash attributes[:bit_info][:from_placeholder] = true end end
Public Instance Methods
Source
# File lib/origen/registers.rb, line 155 def enabled? if feature value = false current_owner = self if feature.class == Array feature.each do |f| current_owner = self loop do if current_owner.respond_to?(:owner) current_owner = current_owner.owner if current_owner.respond_to?(:has_feature?) if current_owner.has_feature?(f) value = true break end end else # if current owner does not have a owner value = false break end end # loop end unless value if Origen.top_level && \ Origen.top_level.respond_to?(:has_feature?) && \ Origen.top_level.has_feature?(f) value = true unless value break end end end unless value break # break if feature not found and return false end end # iterated through all features in array value else # if feature.class != Array loop do if current_owner.respond_to?(:owner) current_owner = current_owner.owner if current_owner.respond_to?(:has_feature?) if current_owner.has_feature?(feature) value = true break end end else # if current owner does not have a owner value = false break end end # loop end unless value if Origen.top_level && \ Origen.top_level.respond_to?(:has_feature?) && \ Origen.top_level.has_feature?(feature) value = true end end value end else true end end
Returns true if the register is enabled by a feature of owner.
Source
# File lib/origen/registers.rb, line 221 def enabled_by_feature?(name = nil) if !name !!feature else if feature.class == Array feature.each do |f| if f == name return true end end false else feature == name end end end
Returns true if the register is constrained by the given/any feature
Also aliased as: has_feature_constraint?
Source
# File lib/origen/registers.rb, line 240 def inspect materialize.inspect end
Make it look like a reg in the console to avoid confusion
Source
# File lib/origen/registers.rb, line 149 def is_a?(klass) klass == Origen::Registers::Reg || klass == self.class end
Make this appear like a reg to any application code
Source
# File lib/origen/registers.rb, line 260 def materialize owner.instantiate_reg(name, attributes) end
Source
# File lib/origen/registers.rb, line 252 def method_missing(method, *args, &block) materialize.send(method, *args, &block) end
Source
# File lib/origen/registers.rb, line 245 def reset end
Don’t need to act on reset, an un-materialized reg is by default already reset
Source
# File lib/origen/registers.rb, line 256 def respond_to?(method, include_private = false) materialize.respond_to?(method, include_private) end
Source
# File lib/origen/registers.rb, line 276 def to_json(*args) materialize.to_json(*args) end