module Origen::Pins::PinCommon

Methods and attributes that are common to both pins and pin groups

Attributes

configuration[RW]

Override the chip-level configuration attribute for the given pin

configurations[R]

Returns a hash containing the chip configurations that the given pin is present in and a metadata hash for storing any information specific to the operation of the given pin in that configuration

description[RW]

Free format field to store an description of the pin or pin group function

id[R]
modes[R]

Returns a hash containing the chip modes that the given pin is present in and a metadata hash for storing any information specific to the operation of the given pin in that mode

owner[R]
packages[R]

Returns a hash containing the chip packages that the given pin is present in and a metadata hash for each package option containing information like the location or pin number for the given in pin in the given package.

Public Instance Methods

add_configuration(id, options = {}) click to toggle source

Make the pin or pin group available in the given configuration, any options that are supplied will be saved as metadata associated with the given pin in that configuration

# File lib/origen/pins/pin_common.rb, line 105
def add_configuration(id, options = {})
  configurations[id] = options
end
add_mode(id, options = {}) click to toggle source

Make the pin or pin group available in the given mode, any options that are supplied will be saved as metadata associated with the given pin in that mode

# File lib/origen/pins/pin_common.rb, line 99
def add_mode(id, options = {})
  modes[id] = options
end
add_package(id, options = {}) click to toggle source

Make the pin available in the given package, any options that are supplied will be saved as metadata associated with the given pin in that package

# File lib/origen/pins/pin_common.rb, line 90
def add_package(id, options = {})
  packages[id] = options
  if is_a?(Pin)
    add_location(options[:location], package: id) if options[:location]
  end
end
enabled?(options = {}) click to toggle source

Returns true if the pin is enabled by the current or given context

# File lib/origen/pins/pin_common.rb, line 48
def enabled?(options = {})
  present_in_package?(options) # && enabled_in_mode?(options) && enabled_in_configuration?(options)
end
enabled_in_configuration?(options = {}) click to toggle source

Returns true if the pin or pin group is present in the current configuration context.

# File lib/origen/pins/pin_common.rb, line 78
def enabled_in_configuration?(options = {})
  config = options[:configuration] || current_configuration
  if config
    !!(configurations[:all] || configurations.empty? || configurations[config])
  # If no configuration is specified a pin is only available if it does not have a configuration constraint
  else
    !!(configurations[:all] || configurations.empty?)
  end
end
enabled_in_mode?(options = {}) click to toggle source

Returns true if the pin or pin group is present in the current mode context.

# File lib/origen/pins/pin_common.rb, line 67
def enabled_in_mode?(options = {})
  mode = options[:mode] || current_mode_id
  if mode
    !!(modes[:all] || modes.empty? || modes[mode])
  # If no mode is specified a pin is only available if it does not have a mode constraint
  else
    !!(modes[:all] || modes.empty?)
  end
end
enabled_in_package?(options = {}) click to toggle source

Returns true if the pin or pin group is present in the current package context.

A pin is considered enabled when either no package context is set (all pins available at die level), or when a package context is set and it matches one attached to the pin

# File lib/origen/pins/pin_common.rb, line 56
def enabled_in_package?(options = {})
  package = options[:package] || current_package_id
  if package
    !!(packages[:all] || packages[package])
  else
    true
  end
end
Also aliased as: present_in_package?
finalize() click to toggle source

@api private

# File lib/origen/pins/pin_common.rb, line 43
def finalize
  @finalized = true
end
id=(val) click to toggle source

The ID of a pin should be considered immutable, however internally it may be neccessary to change the initial ID as the pins are initially setup

@api private

# File lib/origen/pins/pin_common.rb, line 34
def id=(val)
  if @id && @finalized
    fail 'The ID of a pin cannot be changed once it has been set!'
  else
    @id = val
  end
end
present_in_package?(options = {})
Alias for: enabled_in_package?
to_sym() click to toggle source
# File lib/origen/pins/pin_common.rb, line 26
def to_sym
  id
end

Private Instance Methods

add_initial_configurations(options) click to toggle source
# File lib/origen/pins/pin_common.rb, line 193
def add_initial_configurations(options)
  resolve_configurations(options).each do |config|
    if config.is_a?(Hash)
      config.each do |id, attributes|
        add_configuration(id, attributes)
      end
    else
      add_configuration(config)
    end
  end
end
add_initial_modes(options) click to toggle source
# File lib/origen/pins/pin_common.rb, line 181
def add_initial_modes(options)
  resolve_modes(options).each do |mode|
    if mode.is_a?(Hash)
      mode.each do |id, attributes|
        add_mode(id, attributes)
      end
    else
      add_mode(mode)
    end
  end
end
add_initial_packages(options) click to toggle source
# File lib/origen/pins/pin_common.rb, line 169
def add_initial_packages(options)
  resolve_packages(options).each do |package|
    if package.is_a?(Hash)
      package.each do |id, attributes|
        add_package(id, attributes)
      end
    else
      add_package(package)
    end
  end
end
apply_initial_scope(options) click to toggle source
# File lib/origen/pins/pin_common.rb, line 142
def apply_initial_scope(options)
  @packages = {}
  @modes = {}
  @configurations = {}
  add_initial_packages(options)
  add_initial_modes(options)
  add_initial_configurations(options)
end
current_configuration() click to toggle source

Returns the current configuration context for this pin/pin group, if a configuration has been explicitly set on this pin that will be returned, otherwise the current chip-level configuration context will be returned (nil if none is set)

# File lib/origen/pins/pin_common.rb, line 120
def current_configuration
  configuration || begin
    if Origen.top_level
      Origen.top_level.current_configuration
    end
  end
end
current_mode_id() click to toggle source

Returns the current top-level mode ID, nil if none is set.

# File lib/origen/pins/pin_common.rb, line 136
def current_mode_id
  if Origen.top_level && Origen.top_level.current_mode
    Origen.top_level.current_mode.id
  end
end
current_package_id() click to toggle source

Returns the current top-level package ID, nil if none is set.

# File lib/origen/pins/pin_common.rb, line 129
def current_package_id
  if Origen.top_level && Origen.top_level.current_package
    Origen.top_level.current_package.id
  end
end
on_init(owner, options = {}) click to toggle source
# File lib/origen/pins/pin_common.rb, line 111
def on_init(owner, options = {})
  @owner = owner
  @description = options[:description]
  apply_initial_scope(options)
end
resolve_configurations(options = {}) click to toggle source

Returns an array containing the configuration ids resolved from the given options or the current top-level context

# File lib/origen/pins/pin_common.rb, line 165
def resolve_configurations(options = {})
  [options.delete(:configuration) || options.delete(:configurations) || current_configuration].flatten.compact
end
resolve_modes(options = {}) click to toggle source

Returns an array containing the mode ids resolved from the given options or the current top-level context

# File lib/origen/pins/pin_common.rb, line 159
def resolve_modes(options = {})
  [options.delete(:mode) || options.delete(:modes) || current_mode_id].flatten.compact
end
resolve_packages(options = {}) click to toggle source

Returns an array containing the package ids resolved from the given options or the current top-level context

# File lib/origen/pins/pin_common.rb, line 153
def resolve_packages(options = {})
  [options.delete(:package) || options.delete(:packages) || current_package_id].flatten.compact
end