Module: Origen::Pins::PinCommon

Extended by:
ActiveSupport::Concern
Included in:
Pin, PinCollection
Defined in:
lib/origen/pins/pin_common.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#add_configuration(id, options = {}) ⇒ Object

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


105
106
107
# File 'lib/origen/pins/pin_common.rb', line 105

def add_configuration(id, options = {})
  configurations[id] = options
end

#add_mode(id, options = {}) ⇒ Object

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


99
100
101
# File 'lib/origen/pins/pin_common.rb', line 99

def add_mode(id, options = {})
  modes[id] = options
end

#add_package(id, options = {}) ⇒ Object

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


90
91
92
93
94
95
# 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 = {}) ⇒ Boolean

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

Returns:

  • (Boolean)

48
49
50
# 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 = {}) ⇒ Boolean

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

Returns:

  • (Boolean)

78
79
80
81
82
83
84
85
86
# 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 = {}) ⇒ Boolean

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

Returns:

  • (Boolean)

67
68
69
70
71
72
73
74
75
# 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 = {}) ⇒ Boolean Also known as: present_in_package?

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

Returns:

  • (Boolean)

56
57
58
59
60
61
62
63
# 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

#finalizeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


43
44
45
# File 'lib/origen/pins/pin_common.rb', line 43

def finalize
  @finalized = true
end

#id=(val) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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


34
35
36
37
38
39
40
# 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

#to_symObject


26
27
28
# File 'lib/origen/pins/pin_common.rb', line 26

def to_sym
  id
end