class Origen::SubBlock

A simple class that will be instantiated by default when a sub block is defined without another class name specified

This class includes support for registers, pins, etc.

Public Instance Methods

app() click to toggle source

Since no application defined this sub-block class, consider its parent’s app to be the owning application

# File lib/origen/sub_blocks.rb, line 602
def app
  parent.app
end
method_missing(method, *args, &block) click to toggle source

Used to create attribute accessors on the fly.

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 Origen::Model#method_missing
# File lib/origen/sub_blocks.rb, line 610
def method_missing(method, *args, &block)
  super
rescue NoMethodError
  return regs(method) if has_reg?(method)
  return ports(method) if has_port?(method)

  if method.to_s =~ /=$/
    define_singleton_method(method) do |val|
      instance_variable_set("@#{method.to_s.sub('=', '')}", val)
    end
  else
    define_singleton_method(method) do
      instance_variable_get("@#{method}")
    end
  end
  send(method, *args, &block)
end