Method: Origen::Pins::PinBank#add_pin

Defined in:
lib/origen/pins/pin_bank.rb

#add_pin(pin, _owner, _options = {}) ⇒ Origen::Pins::Pin

Add the given pin to the bank

Returns:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/origen/pins/pin_bank.rb', line 21

def add_pin(pin, _owner, _options = {})
  if pin.is_a?(PowerPin)
    bank = all_power_pins
  elsif pin.is_a?(GroundPin)
    bank = all_ground_pins
  elsif pin.is_a?(VirtualPin)
    bank = all_virtual_pins
  elsif pin.is_a?(OtherPin)
    bank = all_other_pins
  else
    bank = all_pins
  end
  if bank[pin.id]
    fail "A pin with id #{pin.id} already exists!"
  end

  all_ids << pin.id
  bank[pin.id] = pin
  # If ends in a number
  # if !options[:dont_create_group] && pin.id.to_s =~ /(.*?)(\d+)$/
  #  # Create a new group if one with the given name doesn't already exist
  #  unless group = all_pin_groups[$1.to_sym]
  #    group = PinCollection.new(owner, options)
  #    group.id = $1.to_sym
  #    all_pin_groups[$1.to_sym] = group
  #  end
  #  group.add_pin(pin)
  # end
  pin
end