module Origen::Controller
Public Instance Methods
==(obj, options = {})
click to toggle source
When compared to another object, a controller will consider itself equal if either the controller or its model match the given object
Calls superclass method
# File lib/origen/controller.rb, line 93 def ==(obj, options = {}) if obj.is_a?(Origen::SubBlocks::Placeholder) obj = obj.materialize end if options[:called_from_model] super(obj) else super(obj) || model == obj end end
Also aliased as: equal?
controller()
click to toggle source
Means that when dealing with a controller/model pair, you can always call obj.model and obj.controller to get the one you want, regardless of the one you currently have.
# File lib/origen/controller.rb, line 108 def controller self end
display()
click to toggle source
Workaround due to reserved keywords in Ruby, Display in the case below.
Calls superclass method
# File lib/origen/controller.rb, line 6 def display # If the DUT responds to a sub_block "display" return the sub_block if model.sub_blocks.include? 'display' Origen.log.debug "Found a sub_block \'display\', passing control to the #{model.class}..." model.sub_blocks['display'] else # Else, pass control to the ruby core. super end end
inspect()
click to toggle source
# File lib/origen/controller.rb, line 60 def inspect if model "<Model/Controller: #{model.class}:#{model.object_id}/#{self.class}:#{object_id}>" else "<Controller: #{self.class}:#{object_id}>" end end
is_a?(*args)
click to toggle source
Calls superclass method
# File lib/origen/controller.rb, line 68 def is_a?(*args) if model super(*args) || model.is_a?(*args) else super(*args) end end
method_missing(method, *args, &block)
click to toggle source
Used to proxy all method and attribute requests not implemented on the controller to the model.
On first call of a missing method a method is generated to avoid the missing lookup next time, this should be faster for repeated lookups of the same method, e.g. reg
Calls superclass method
# File lib/origen/controller.rb, line 132 def method_missing(method, *args, &block) if model.respond_to?(method) # This method is handled separately since it is important to produce a proxy method # that takes no arguments, otherwise the register address lookup system mistakes it # for a legacy way of calculating the base address whereby the register itself was # given as an argument. if method.to_sym == :base_address define_singleton_method(method) do model.send(method) end base_address else define_singleton_method(method) do |*args, &block| model.send(method, *args, &block) end send(method, *args, &block) end else super end end
model()
click to toggle source
Returns the controller’s model
# File lib/origen/controller.rb, line 77 def model @model ||= if self.class.path_to_model m = eval(self.class.path_to_model) if m if m.respond_to?(:_controller=) m.send(:_controller=, self) end else fail "No model object found at path: #{self.class.path_to_model}" end m end end
respond_to?(*args)
click to toggle source
Calls superclass method
# File lib/origen/controller.rb, line 112 def respond_to?(*args) super || !!(!@respond_directly && model && model.respond_to_directly?(*args)) end
respond_to_directly?(*args)
click to toggle source
# File lib/origen/controller.rb, line 116 def respond_to_directly?(*args) @respond_directly = true result = respond_to?(*args) @respond_directly = false result end
to_json(*args)
click to toggle source
# File lib/origen/controller.rb, line 123 def to_json(*args) model.to_json(*args) end
Private Instance Methods
_model=(model)
click to toggle source
# File lib/origen/controller.rb, line 156 def _model=(model) @model = model end