lib/origen/registers/reg.rb
# Returns true if the register owner matches the given name. A match will be detected
# if the class names of the register's owner contains the given name.
#
# Alternatively if the register owner implements a method called reg_owner_alias
# then the value that this returns instead will also be considered when checking if the given
# name matches. This method can return an array of names if multiple aliases are required.
#
# Aliases can be useful for de-coupling the commonly used name, e.g. "NVM" from the actual
# class name.
#
# @example
#   class C90NVM
#     include Origen::Registers
#
#     def initialize
#       add_reg :clkdiv, 0x3, 16, :div => {:bits => 8}
#     end
#
#   end
#
#   reg = C90NVM.new.reg(:clkdiv)
#   reg.owned_by?(:ram)      # => false
#   reg.owned_by?(:nvm)      # => true
#   reg.owned_by?(:c90nvm)   # => true
#   reg.owned_by?(:c40nvm)   # => false
#   reg.owned_by?(:flash)    # => false
#
# @example Using an alias
#   class C90NVM
#     include Origen::Registers
#
#     def initialize
#       add_reg :clkdiv, 0x3, 16, :div => {:bits => 8}
#     end
#
#     def reg_owner_alias
#       "flash"
#     end
#
#   end
#
#   reg = C90NVM.new.reg(:clkdiv)
#   reg.owned_by?(:ram)      # => false
#   reg.owned_by?(:nvm)      # => true
#   reg.owned_by?(:c90nvm)   # => true
#   reg.owned_by?(:c40nvm)   # => false
#   reg.owned_by?(:flash)    # => true
Returns true if the register owner matches the given name. A match will be detected
if the class names of the register's owner contains the given name.

Alternatively if the register owner implements a method called reg_owner_alias
then the value that this returns instead will also be considered when checking if the given
name matches. This method can return an array of names if multiple aliases are required.

Aliases can be useful for de-coupling the commonly used name, e.g. "NVM" from the actual
class name.
Returns true if the register owner matches the given name . A match will be detected if the class names of the register ' s owner contains the given name . Alternatively if the register owner implements a method called reg_owner_alias then the value that this returns instead will also be considered when checking if the given name matches . This method can return an array of names if multiple aliases are required . Aliases can be useful for de - coupling the commonly used name e . g . " NVM " from the actual class name .
def owned_by?(name)
        !!(owner.class.to_s =~ /#{name}/i) || begin
          if owner.respond_to?(:reg_owner_alias)
            [owner.reg_owner_alias].flatten.any? do |al|
              al.to_s =~ /#{name}/i
            end
          else
            false
          end
        end
      end
def owned_by? ( name ) ! ! ( owner . class . to_s =~ / #{ name } /i ) || begin if owner . respond_to? ( :reg_owner_alias ) [ owner . reg_owner_alias ] . flatten . any? do | al | al . to_s =~ / #{ name } /i end else false end end end
Returns true if the register owner matches the given name.
Returns true if the register owner matches the given name .
name
<not_specific>
example
class C90NVM include Origen::Registers def initialize add_reg :clkdiv, 0x3, 16, :div => {:bits => 8} end end reg = C90NVM.new.reg(:clkdiv) reg.owned_by?(:ram) # => false reg.owned_by?(:nvm) # => true reg.owned_by?(:c90nvm) # => true reg.owned_by?(:c40nvm) # => false reg.owned_by?(:flash) # => false
class C90NVM include Origen :: Registers def initialize add_reg : clkdiv 0x3 16 : div = > { : bits = > 8 } end end reg = C90NVM . new . reg ( : clkdiv ) reg . owned_by? ( : ram ) # = > false reg . owned_by? ( : nvm ) # = > true reg . owned_by? ( : c90nvm ) # = > true reg . owned_by? ( : c40nvm ) # = > false reg . owned_by? ( : flash ) # = > false
example
Using an alias class C90NVM include Origen::Registers def initialize add_reg :clkdiv, 0x3, 16, :div => {:bits => 8} end def reg_owner_alias "flash" end end reg = C90NVM.new.reg(:clkdiv) reg.owned_by?(:ram) # => false reg.owned_by?(:nvm) # => true reg.owned_by?(:c90nvm) # => true reg.owned_by?(:c40nvm) # => false reg.owned_by?(:flash) # => true
Using an alias class C90NVM include Origen :: Registers def initialize add_reg : clkdiv 0x3 16 : div = > { : bits = > 8 } end def reg_owner_alias " flash " end end reg = C90NVM . new . reg ( : clkdiv ) reg . owned_by? ( : ram ) # = > false reg . owned_by? ( : nvm ) # = > true reg . owned_by? ( : c90nvm ) # = > true reg . owned_by? ( : c40nvm ) # = > false reg . owned_by? ( : flash ) # = > true