class Origen::Pins::Pin

Constants

FUNCTION_SCOPED_ATTRIBUTES

Any attributes listed here will be looked up for the current function defined by the current mode and configuration context before falling back to a default

ORG_FILE_INTERCEPTED_METHODS

Don’t include the ! method in here, the cycle will be captured at the tester level and it would cause a double cycle in the org file if also captured at the pin

PACKAGE_SCOPED_ATTRIBUTES

Any attributes listed here will be looked up for the current package context before falling back to a default

TYPES

Pin Types, ‘digital’ and ‘analog’ are legacy types kept for backwards compatibility

Attributes

aliases[R]

Returns a hash containing the aliases associated with the given pin

description[RW]
ext_pulldown[R]

Boolean on whether pin has external pull-down

ext_pullup[R]

Boolean on whether pin has external pull-up

force[RW]

Value to be forced on the pin, e.g. during simulation

functions[R]

Returns a hash containing the functions associated with the given pin

invert[RW]

Inverts pin states for drive and compare, can be useful if a timing set change requires clocks to drive low for example when all pattern logic has been set up to drive them high.

notes[RW]
open_drain[R]

Boolean on whether pin is open drain

order[RW]
owner[R]
repeat_previous[R]

Attribute used to generate vectors where the pin state is assigned the repeat_previous opcode, used by Tester#repeat_previous

rtl_name[W]

Pin RTL name

size[R]
state_meta[R]

Returns a hash containing any meta data associated with the current pin state

my_pin.read!(1, meta: { position: 10 })
my_pin.state_meta    # => { position: 10 }
my_pin.dont_care
my_pin.state_meta    # => {}
supply[RW]

Internal power supply pin is connected to

supply_str[RW]
type[R]

Pin type, either :analog or :digital

Public Instance Methods

<=>(other_pin) click to toggle source

When sorting pins do it by ID

# File lib/origen/pins/pin.rb, line 193
def <=>(other_pin)
  @id <=> other_pin.id
end
add_alias(id, options = {}) click to toggle source

Add an alias to the given pin.

If the options contain a package, mode or configuration reference then the alias will only work under that context.

# File lib/origen/pins/pin.rb, line 574
def add_alias(id, options = {})
  obj = options.delete(:obj) || myself
  if aliases[id]
    aliases[id][:packages] += resolve_packages(options)
    aliases[id][:modes] += resolve_modes(options)
    aliases[id][:configurations] += resolve_configurations(options)
    aliases[id][:packages].uniq!
    aliases[id][:modes].uniq!
    aliases[id][:configurations].uniq!
  else
    aliases[id] = {
      packages:       resolve_packages(options),
      modes:          resolve_modes(options),
      configurations: resolve_configurations(options)
    }
    Origen.pin_bank.register_alias(id, obj, options)
  end
end
add_channel(str, options = {})
Alias for: add_dib_assignment
add_dib_assignment(str, options = {}) click to toggle source

Add a Device Interface Board (e.g. probecard at wafer probe or loadboard at final package test) assignment to the pin. Some refer to this as a channel but API name is meant to be generic.

# File lib/origen/pins/pin.rb, line 466
def add_dib_assignment(str, options = {})
  options = {
    site: 0
  }.merge(options)
  packages = resolve_packages(options)
  if packages.empty?
    @dib_assignment[options[:site]] = str
    add_alias str.to_s.symbolize, package: :all, mode: :all, configuration: :all
  else
    packages.each do |package_id|
      package_id = package_id.respond_to?(:id) ? package_id.id : package_id
      myself.packages[package_id] ||= {}
      myself.packages[package_id][:dib_assignment] ||= []
      myself.packages[package_id][:dib_assignment][options[:site]] = str
      add_alias str.to_s.symbolize, package: package_id, mode: :all, configuration: :all
    end
  end
end
Also aliased as: add_dib_info, add_channel
add_dib_info(str, options = {})
Alias for: add_dib_assignment
add_dib_meta(pkg, options) click to toggle source
# File lib/origen/pins/pin.rb, line 487
def add_dib_meta(pkg, options)
  unless Origen.top_level.packages.include? pkg
    Origen.log.error("Cannot add DIB metadata for package '#{pkg}', that package has not been added yet!")
    fail
  end
  options.each do |attr, attr_value|
    packages[pkg][:dib_meta] ||= {}
    packages[pkg][:dib_meta][attr] = attr_value
    add_alias attr_value.to_s.symbolize, package: pkg, mode: :all, configuration: :all
  end
end
add_function(id, options = {}) click to toggle source

Add a function to the pin.

@example Adding a mode-specific function

pin.add_function :tdi, :direction => :input
pin.add_function :nvm_fail, :mode => :nvmbist, :direction => :output
# File lib/origen/pins/pin.rb, line 530
def add_function(id, options = {})
  id = id.to_sym
  add_function_attributes(options.merge(name: id, id: id.to_sym))
  f = FunctionProxy.new(id, myself)
  add_alias id, packages: :all, obj: f
end
add_function_attributes(options = {}) click to toggle source
# File lib/origen/pins/pin.rb, line 537
def add_function_attributes(options = {})
  id = options.delete(:id)
  modes = resolve_modes(options)
  configurations = resolve_configurations(options)
  options[:direction] = sanitize_direction(options[:direction]) if options[:direction]
  if modes.empty?
    modes = [:all]
  end
  if configurations.empty?
    configurations = [:all]
  end
  # Supports newer attribute lookup by function ID
  if id
    functions[:ids] ||= {}
    if functions[:ids][id]
      functions[:ids][id] = functions[:ids][id].merge!(options)
    else
      functions[:ids][id] = options.dup
    end
  end
  # Supports older attribute lookup by mode context
  modes.each do |mode|
    configurations.each do |configuration|
      functions[mode.to_sym] ||= {}
      if functions[mode.to_sym][configuration.to_sym]
        functions[mode.to_sym][configuration.to_sym] = functions[mode.to_sym][configuration.to_sym].merge!(options)
      else
        functions[mode.to_sym][configuration.to_sym] = options
      end
    end
  end
end
add_location(str, options = {}) click to toggle source

Add a location identifier to the pin, this is a free format field which can be a pin number or BGA co-ordinate for example.

@example Adding a location by package

$dut.pin(:pin3).add_location "B3", :package => :p1
$dut.pin(:pin3).add_location "B2", :package => :p2
# File lib/origen/pins/pin.rb, line 430
def add_location(str, options = {})
  packages = resolve_packages(options)
  if packages.empty?
    @location = str
    add_alias str.to_s.symbolize, package: :all, mode: :all, configuration: :all
  else
    packages.each do |package_id|
      package_id = package_id.respond_to?(:id) ? package_id.id : package_id
      myself.packages[package_id] ||= {}
      myself.packages[package_id][:location] = str
      add_alias str.to_s.symbolize, package: package_id, mode: :all, configuration: :all
    end
  end
end
Also aliased as: add_locn
add_locn(str, options = {})
Alias for: add_location
assert(value, options = {}) click to toggle source

Pass in 0 or 1 to have the pin expect_lo or expect_hi respectively. This is useful when programatically setting the pin state.

Example

[0,1,1,0].each do |level|
    $pin(:d_in).assert(level)
end
# File lib/origen/pins/pin.rb, line 861
def assert(value, options = {})
  set_state_with_options(:compare, options)
  set_value(value)
end
Also aliased as: compare, expect, read
assert!(*args) click to toggle source
# File lib/origen/pins/pin.rb, line 869
def assert!(*args)
  assert(*args)
  cycle
end
Also aliased as: compare!, expect!, read!
assert_hi(options = {}) click to toggle source

Set the pin to expect a 1 on future cycles

# File lib/origen/pins/pin.rb, line 786
def assert_hi(options = {})
  set_state_with_options(:compare, options)
  set_value(1)
end
Also aliased as: expect_hi, compare_hi, read_hi
assert_hi!(options = {}) click to toggle source
# File lib/origen/pins/pin.rb, line 794
def assert_hi!(options = {})
  assert_hi(options)
  cycle
end
Also aliased as: expect_hi!, compare_hi!, read_hi!
assert_lo(options = {}) click to toggle source

Set the pin to expect a 0 on future cycles

# File lib/origen/pins/pin.rb, line 803
def assert_lo(options = {})
  set_state_with_options(:compare, options)
  set_value(0)
  # Planning to add the active load logic to the tester instead...
  # options = { :active => false    #if active true means to take tester active load capability into account
  #          }.merge(options)
  # unless state_to_be_inverted?
  #  myself.state = ($tester.active_loads || !options[:active]) ? $tester.pin_state(:expect_lo) : $tester.pin_state(:dont_care)
  # else
  #  myself.state = ($tester.active_loads || !options[:active]) ? $tester.pin_state(:expect_hi) : $tester.pin_state(:dont_care)
  # end
end
Also aliased as: expect_lo, compare_lo, read_lo
assert_lo!(options = {}) click to toggle source
# File lib/origen/pins/pin.rb, line 819
def assert_lo!(options = {})
  assert_lo(options)
  cycle
end
Also aliased as: expect_lo!, compare_lo!, read_lo!
assert_midband(options = {}) click to toggle source
# File lib/origen/pins/pin.rb, line 877
def assert_midband(options = {})
  set_state_with_options(:compare_midband, options)
end
assert_midband!(options = {}) click to toggle source
# File lib/origen/pins/pin.rb, line 884
def assert_midband!(options = {})
  assert_midband(options)
  cycle
end
belongs_to_a_pin_group?() click to toggle source

Returns true if the pin belongs to a pin group.

add_pins :jtag, size: 6
add_pin  :done
add_pin_alias :fail, :jtag, pin: 4

pin(:done).belongs_to_a_pin_group?  # => false
pin(:fail).belongs_to_a_pin_group?  # => true
# File lib/origen/pins/pin.rb, line 635
def belongs_to_a_pin_group?
  !groups.empty?
end
capture(options = {}) click to toggle source

Mark the (data) from the pin to be captured

# File lib/origen/pins/pin.rb, line 945
def capture(options = {})
  set_state_with_options(:capture, options)
end
Also aliased as: store
capture!(options = {}) click to toggle source

Mark the (data) from the pin to be captured and trigger a cycle

# File lib/origen/pins/pin.rb, line 951
def capture!(options = {})
  capture(options)
  cycle
end
Also aliased as: store!
clear_mask(options = { context: nil, size: nil }) click to toggle source
# File lib/origen/pins/pin.rb, line 1136
def clear_mask(options = { context: nil, size: nil })
  context = options[:context]
  size = options[:size]

  index = context.is_a?(Integer) ? context : self.index(context: context)

  if index.nil? && context.nil?
    # If the index is nil and no context was given, no implicit index could be resolved
    fail("Could not discern pin :#{name}'s implicit index!")
  elsif index.nil?
    # If the index is nil and some context was given, then the pin is not in the given context
    fail("Pin :#{name} is not a member of the given context!")
  end

  if size && context && !context.is_a?(Integer)
    # A context was given, that was not just an Integer, and size was given
    # Raise an exception as these two conflict.
    fail('Both a sized context (e.g. pin group) and a :size option cannot be used simultaneously!')
  elsif size
    # A size option was given. Use that.
    ((2**size) - 1) ^ (1 << index)
  elsif context.is_a?(Symbol)
    ((2**groups[context].instance_variable_get(:@store).size) - 1) ^ (1 << index)
  elsif context.respond_to?(:size) && !context.is_a?(Integer)
    # PinCollection or Array
    ((2**context.size) - 1) ^ (1 << index)
  else
    # No size option was given. Use the implicit index instead.
    (2**index) - 1
  end
end
Also aliased as: clr_mask, cmask
clr_mask(options = { context: nil, size: nil })
Alias for: clear_mask
cmask(options = { context: nil, size: nil })
Alias for: clear_mask
compare(value, options = {})
Alias for: assert
compare!(*args)
Alias for: assert!
compare_hi(options = {})
Alias for: assert_hi
compare_hi!(options = {})
Alias for: assert_hi!
compare_lo(options = {})
Alias for: assert_lo
compare_lo!(options = {})
Alias for: assert_lo!
compare_midband(options = {})
Alias for: assert_midband
compare_midband!(options = {})
Alias for: assert_midband!
compare_wave(code = nil) click to toggle source

Returns the compare cycle wave assigned to the pin based on the currently enabled timeset, or nil if none is set Note that if a timeset is set then all pins will always return a wave as they will pick up a default waveform if none is explicitly assigned to it.

# File lib/origen/pins/pin.rb, line 137
def compare_wave(code = nil)
  if t = dut.current_timeset
    # Cache this for performance since potentially this is something that could be called on
    # every cycle in some applications
    @compare_waves ||= {}
    @compare_waves[t.id] ||= {}
    @compare_waves[t.id][code] ||= dut.current_timeset.send(:wave_for, myself, type: :compare, code: code)
  end
end
comparing?() click to toggle source

Returns true if the pin is currently in a compare state

# File lib/origen/pins/pin.rb, line 898
def comparing?
  !@suspend &&
    state == :compare
end
comparing_mem?() click to toggle source

Returns true if the pin is currently in a compare mem state

# File lib/origen/pins/pin.rb, line 904
def comparing_mem?
  !@suspend &&
    state == :expect_mem
end
comparing_midband?() click to toggle source

Returns true if the pin is currently in a compare state

# File lib/origen/pins/pin.rb, line 910
def comparing_midband?
  !@suspend &&
    state == :compare_midband
end
data()
Alias for: value
data=(val)
Alias for: set_value
delete!() click to toggle source

Delete this pin (myself). Used bang in method name to keep same for pins and pin collections. Pin collections already had a delete method which deletes a pin from the collection. Needed delete! to indicate it is deleting the actual pin or pin group calling the method.

# File lib/origen/pins/pin.rb, line 1058
def delete!
  owner.delete_pin(myself)
end
describe(options = {}) click to toggle source
# File lib/origen/pins/pin.rb, line 322
def describe(options = {})
  desc = ['********************']
  desc << "Pin id: #{id}"
  func_aliases = []
  unless functions.empty?
    desc << ''
    desc << 'Functions'
    desc << '---------'
    functions.each do |mode, configurations|
      unless mode == :ids
        configurations.each do |configuration, attrs|
          a = ":#{attrs[:name]}".ljust(30)
          func_aliases << attrs[:name]
          unless mode == :all
            a += ":modes => [#{[mode].flatten.map { |id| ':' + id.to_s }.join(', ')}]"
            prev = true
          end
          unless configuration == :all
            a += ' ; ' if prev
            a += ":configurations => [#{[configuration].flatten.map { |id| ':' + id.to_s }.join(', ')}]"
          end
          desc << a
        end
      end
    end
  end
  unless aliases.empty?
    desc << ''
    desc << 'Aliases'
    desc << '-------'
    aliases.each do |name, context|
      unless func_aliases.include?(name)
        a = ":#{name}".ljust(30)
        unless context[:packages].empty? || context[:packages] == [:all]
          a += ":packages => [#{context[:packages].map { |id| ':' + id.to_s }.join(', ')}]"
          prev = true
        end
        unless context[:modes].empty? || context[:modes] == [:all]
          a += ' ; ' if prev
          a += ":modes => [#{context[:modes].map { |id| ':' + id.to_s }.join(', ')}]"
          prev = true
        end
        unless context[:configurations].empty? || context[:configurations] == [:all]
          a += ' ; ' if prev
          a += ":configurations => [#{context[:configurations].map { |id| ':' + id.to_s }.join(', ')}]"
        end
        desc << a
      end
    end
  end
  unless Origen.top_level.modes.empty?
    desc << ''
    desc << 'Modes'
    desc << '-------'
    Origen.top_level.modes.each do |name|
      unless option(mode: name).nil?
        a = ":#{name}".ljust(30) + ":mode => #{option(mode: name)}"
        desc << a
      end
    end
  end
  unless groups.empty?
    desc << ''
    desc << 'Groups'
    desc << '------'
    desc << groups.map { |name, _group| ':' + name.to_s }.join(', ')
  end
  desc << '********************'
  if options[:return]
    desc
  else
    puts desc.join("\n")
  end
end
direction=(val) click to toggle source

Sets the default direction of the pin, :input, :output or :io (default). If a function specific direction has been specified that will override this value.

# File lib/origen/pins/pin.rb, line 521
def direction=(val)
  @direction = sanitize_direction(val)
end
disable_clock(options = {}) click to toggle source
# File lib/origen/pins/pin.rb, line 1016
def disable_clock(options = {})
  @clock.stop_clock(options)
  @clock = nil
end
dont_care(options = {}) click to toggle source

Set the pin to X on future cycles

# File lib/origen/pins/pin.rb, line 828
def dont_care(options = {})
  set_state_with_options(:dont_care, options)
end
dont_care!(options = {}) click to toggle source
# File lib/origen/pins/pin.rb, line 832
def dont_care!(options = {})
  dont_care(options)
  cycle
end
drive(value, options = {}) click to toggle source

Pass in 0 or 1 to have the pin drive_lo or drive_hi respectively. This is useful when programatically setting the pin state.

Example

[0,1,1,0].each do |level|
    $pin(:d_in).drive(level)
end
# File lib/origen/pins/pin.rb, line 843
def drive(value, options = {})
  set_state_with_options(:drive, options)
  set_value(value)
end
Also aliased as: write
drive!(value, options = {}) click to toggle source
# File lib/origen/pins/pin.rb, line 849
def drive!(value, options = {})
  drive(value, options)
  cycle
end
Also aliased as: write!
drive_hi(options = {}) click to toggle source

Set the pin to drive a 1 on future cycles

# File lib/origen/pins/pin.rb, line 730
def drive_hi(options = {})
  set_state_with_options(:drive, options)
  set_value(1)
end
Also aliased as: write_hi
drive_hi!(options = {}) click to toggle source
# File lib/origen/pins/pin.rb, line 736
def drive_hi!(options = {})
  drive_hi(options)
  cycle
end
Also aliased as: write_hi!
drive_lo(options = {}) click to toggle source

Set the pin to drive a 0 on future cycles

# File lib/origen/pins/pin.rb, line 755
def drive_lo(options = {})
  set_state_with_options(:drive, options)
  set_value(0)
end
Also aliased as: write_lo
drive_lo!(options = {}) click to toggle source
# File lib/origen/pins/pin.rb, line 761
def drive_lo!(options = {})
  drive_lo(options)
  cycle
end
Also aliased as: write_lo!
drive_mem(options = {}) click to toggle source
# File lib/origen/pins/pin.rb, line 767
def drive_mem(options = {})
  set_state_with_options(:drive_mem, options)
end
drive_mem!(options = {}) click to toggle source
# File lib/origen/pins/pin.rb, line 771
def drive_mem!(options = {})
  drive_mem(options)
  cycle
end
drive_very_hi(options = {}) click to toggle source

Set the pin to drive a high voltage on future cycles (if the tester supports it). For example on a J750 high-voltage channel the pin state would be set to “2”

# File lib/origen/pins/pin.rb, line 744
def drive_very_hi(options = {})
  set_state_with_options(:drive_very_hi, options)
  set_value(1)
end
drive_very_hi!(options = {}) click to toggle source
# File lib/origen/pins/pin.rb, line 749
def drive_very_hi!(options = {})
  drive_very_hi(options)
  cycle
end
drive_wave(code = nil) click to toggle source

Returns the drive cycle wave assigned to the pin based on the currently enabled timeset, or nil if none is set. Note that if a timeset is set then all pins will always return a wave as they will pick up a default waveform if none is explicitly assigned to it.

# File lib/origen/pins/pin.rb, line 123
def drive_wave(code = nil)
  if t = dut.current_timeset
    # Cache this for performance since potentially this is something that could be called on
    # every cycle in some applications
    @drive_waves ||= {}
    @drive_waves[t.id] ||= {}
    @drive_waves[t.id][code] ||= dut.current_timeset.send(:wave_for, myself, type: :drive, code: code)
  end
end
driving?() click to toggle source

Returns true if the pin is currently in a drive state

# File lib/origen/pins/pin.rb, line 916
def driving?
  !@suspend &&
    (state == :drive || state == :drive_very_hi)
end
driving_mem?() click to toggle source

Returns true if the pin is currently in a drive mem state

# File lib/origen/pins/pin.rb, line 922
def driving_mem?
  !@suspend &&
    state == :drive_mem
end
duty_cycles() click to toggle source
# File lib/origen/pins/pin.rb, line 1040
def duty_cycles
  @clock.cycles_per_duty
end
enable_clock(options = {}) click to toggle source
# File lib/origen/pins/pin.rb, line 1012
def enable_clock(options = {})
  @clock = PinClock.new(myself, options)
end
expect(value, options = {})
Alias for: assert
expect!(*args)
Alias for: assert!
expect_hi(options = {})
Alias for: assert_hi
expect_hi!(options = {})
Alias for: assert_hi!
expect_lo(options = {})
Alias for: assert_lo
expect_lo!(options = {})
Alias for: assert_lo!
expect_mem(options = {}) click to toggle source
# File lib/origen/pins/pin.rb, line 776
def expect_mem(options = {})
  set_state_with_options(:expect_mem, options)
end
expect_mem!(options = {}) click to toggle source
# File lib/origen/pins/pin.rb, line 780
def expect_mem!(options = {})
  expect_mem(options)
  cycle
end
expect_midband(options = {})
Alias for: assert_midband
expect_midband!(options = {})
Alias for: assert_midband!
ext_pulldown=(value) click to toggle source
# File lib/origen/pins/pin.rb, line 1086
def ext_pulldown=(value)
  if [true, false].include? value
    @ext_pulldown = value
  else
    fail "Pin ext_pulldown  attribute '#{value}' must be either true or false"
  end
end
ext_pullup=(value) click to toggle source
# File lib/origen/pins/pin.rb, line 1078
def ext_pullup=(value)
  if [true, false].include? value
    @ext_pullup = value
  else
    fail "Pin ext_pullup  attribute '#{value}' must be either true or false"
  end
end
function_scoped_name(options = {})
Alias for: name
functions=(val) click to toggle source
# File lib/origen/pins/pin.rb, line 201
def functions=(val)
  if val.is_a? Hash
    val.each do |name, _whatever|
      add_function name
    end
  else
    fail "Attempt to set the functions hash on pin #{@name}.  Argument must be a Hash."
  end
end
global_path_to() click to toggle source
# File lib/origen/pins/pin.rb, line 111
def global_path_to
  "dut.pins(:#{id})"
end
goodbye() click to toggle source

See Pin#hello

# File lib/origen/pins/pin.rb, line 187
def goodbye
  @@hello_pins.delete(myself)
  puts "Pin #{name} has stopped toggling"
end
group() click to toggle source

If the pin was defined initially as part of a group then this will return that group, otherwise it will return nil

# File lib/origen/pins/pin.rb, line 399
def group
  @primary_group
end
Also aliased as: primary_group
group_index() click to toggle source

If the pin is a member of a primary group, this returns its index number within that group, otherwise returns nil

# File lib/origen/pins/pin.rb, line 406
def group_index
  @primary_group_index
end
Also aliased as: primary_group_index
groups() click to toggle source

Returns a hash containing the pin groups that the given pin is a member of

# File lib/origen/pins/pin.rb, line 412
def groups
  # Origen.pin_bank.all_pin_groups.select do |name, group|
  @groups ||= Origen.pin_bank.pin_groups.select do |_name, group|
    group.include?(myself)
  end
end
Also aliased as: pin_groups
half_period() click to toggle source
# File lib/origen/pins/pin.rb, line 1044
def half_period
  @clock.cycles_per_half_period
end
has_alias?(id, options = {}) click to toggle source

Returns true if the pin has the given alias within the given or current context

# File lib/origen/pins/pin.rb, line 594
def has_alias?(id, options = {})
  if aliases[id]
    if options[:ignore_context]
      true
    else
      packages = resolve_packages(options)
      modes = resolve_modes(options)
      configurations = resolve_configurations(options)
      begin
        aliases[id][:packages].include?(:all) || aliases[id][:packages].empty? ||
          packages.any? { |package| aliases[id][:packages].include?(package) }
      end && begin
        aliases[id][:modes].include?(:all) || aliases[id][:modes].empty? ||
          modes.any? { |mode| aliases[id][:modes].include?(mode) }
      end && begin
        aliases[id][:configurations].include?(:all) || aliases[id][:configurations].empty? ||
          configurations.any? { |config| aliases[id][:configurations].include?(config) }
      end
    end
  else
    false
  end
end
hello() click to toggle source

Causes the pin to continuously drive 1 for 2 seconds and then drive 0 for 2 seconds.

This is not an API that is intended to be used within a pattern. Rather it is a debug aid when setting up something like a bench test environment that uses Origen Link. For example you would call this method on a pin from a console session, then confirm with a multimeter that the pin is toggling on the relevant hardware.

Call Pin#goodbye to stop it.

@example Call from an origen console like this

dut.pin(:tdi).hello
# File lib/origen/pins/pin.rb, line 167
def hello
  drive_hi
  @@hello_pins ||= []
  @@hello_pins << myself unless @@hello_pins.include?(myself)
  @@hello_loop ||= Thread.new do
    loop do
      @@hello_pins.each(&:toggle)
      if $tester
        # Add a dummy timeset if one is not set yet, doesn't really matter what it is in this case
        # and better not to force the user to setup a debug workaround due to running outside of a pattern
        $tester.set_timeset('hello_world', 40) unless $tester.timeset
        $tester.cycle
      end
      sleep 2
    end
  end
  puts "Pin #{name} is toggling with a period of 2 seconds"
end
high_voltage?() click to toggle source

Returns true if pin is in high voltage state

# File lib/origen/pins/pin.rb, line 928
def high_voltage?
  !@suspend &&
    state == :drive_very_hi
end
index(options = { context: nil }) click to toggle source
# File lib/origen/pins/pin.rb, line 1098
def index(options = { context: nil })
  context = options[:context]
  if context.is_a?(Symbol)
    # Context pin group provided
    group = groups[context].instance_variable_get(:@store)
    if group
      group.index(self)
    end
  elsif context.is_a?(Array)
    # Anonymous pin group given
    context.map { |p| p.is_a?(Symbol) ? owner.pin(p) : p }.index(self)
  else
    # Try an index based off of the pin name.
    # Only works if the pin ends in a decimal. Otherwise, returns nil.
    i = name.to_s.index(/\d+$/)
    if i
      name.to_s[i..-1].to_i
    end
  end
end
index?(options = { context: nil }) click to toggle source
# File lib/origen/pins/pin.rb, line 1094
def index?(options = { context: nil })
  !!index(options).nil?
end
inspect() click to toggle source
# File lib/origen/pins/pin.rb, line 318
def inspect
  "<#{myself.class}:#{object_id}>"
end
invalidate_group_cache() click to toggle source
# File lib/origen/pins/pin.rb, line 420
def invalidate_group_cache
  @groups = nil
end
invalidate_vector_cache() click to toggle source

@api private

# File lib/origen/pins/pin.rb, line 295
def invalidate_vector_cache
  @vector_formatted_value = nil
  groups.each { |_name, group| group.invalidate_vector_cache }
end
inverted?() click to toggle source

Returns the state of invert

# File lib/origen/pins/pin.rb, line 893
def inverted?
  @invert
end
is_a_clock?() click to toggle source
# File lib/origen/pins/pin.rb, line 1004
def is_a_clock?
  !(@clock.nil?)
end
is_a_running_clock?() click to toggle source
# File lib/origen/pins/pin.rb, line 1008
def is_a_running_clock?
  @clock.running?
end
is_alias_of?(name) click to toggle source

Returns true if the pin is an alias of the given pin name

# File lib/origen/pins/pin.rb, line 619
def is_alias_of?(name)
  if Origen.pin_bank.find(name)
    Origen.pin_bank.find(name).id == Origen.pin_bank.find(myself).id
  else
    false
  end
end
is_not_a_clock?() click to toggle source
# File lib/origen/pins/pin.rb, line 1000
def is_not_a_clock?
  @clock.nil?
end
is_to_be_captured?()
Alias for: to_be_captured?
is_to_be_stored?()
Alias for: to_be_captured?
mask(options = { context: nil }) click to toggle source
# File lib/origen/pins/pin.rb, line 1119
def mask(options = { context: nil })
  context = options[:context]
  index = context.is_a?(Integer) ? context : self.index(context: context)

  if index.nil? && context.nil?
    # If the index is nil and no context was given, no implicit index could be resolved
    fail("Could not discern pin :#{name}'s implicit index!")
  elsif index.nil?
    # If the index is nil and some context was given, then the pin is not in the given context
    fail("Pin :#{name} is not a member of the given context!")
  end

  2**index
end
Also aliased as: set_mask, smask
method_missing(m, *args, &block) click to toggle source
Calls superclass method
# File lib/origen/pins/pin.rb, line 1178
def method_missing(m, *args, &block)
  if meta.include? m
    meta[m]
  else
    super
  end
end
name(options = {}) click to toggle source

Returns the name of the pin, if a name has been specifically assigned by the application (via name=) then this will be returned, otherwise the name of the current function if present will be returned, and then as a last resort the ID of the pin

# File lib/origen/pins/pin.rb, line 277
def name(options = {})
  # Return a specifically assigned name in preference to a function name
  (options.empty? ? @name : nil) || function_scoped_name(options) || @id
end
Also aliased as: function_scoped_name
name=(val) click to toggle source
# File lib/origen/pins/pin.rb, line 197
def name=(val)
  @name = val
end
named?(n) click to toggle source
# File lib/origen/pins/pin.rb, line 1170
def named?(n)
  if n.is_a?(Regexp)
    [name.to_s, *aliases.keys].any? { |na| na =~ n }
  else
    [name.to_s, *aliases.keys.map(&:to_s)].include?(n.to_s)
  end
end
next_edge() click to toggle source
# File lib/origen/pins/pin.rb, line 1036
def next_edge
  @clock.next_edge
end
open_drain=(value) click to toggle source
# File lib/origen/pins/pin.rb, line 1070
def open_drain=(value)
  if [true, false].include? value
    @open_drain = value
  else
    fail "Pin open_drain  attribute '#{value}' must be either true or false"
  end
end
org_file_intercepted_methods() click to toggle source
# File lib/origen/pins/pin.rb, line 115
def org_file_intercepted_methods
  ORG_FILE_INTERCEPTED_METHODS
end
pause_clock(options = {})
Alias for: stop_clock
pin_groups()
Alias for: groups
primary_group()
Alias for: group
primary_group_index()
Alias for: group_index
read(value, options = {})
Alias for: assert
read!(*args)
Alias for: assert!
read_hi(options = {})
Alias for: assert_hi
read_hi!(options = {})
Alias for: assert_hi!
read_lo(options = {})
Alias for: assert_lo
read_lo!(options = {})
Alias for: assert_lo!
read_midband(options = {})
Alias for: assert_midband
read_midband!(options = {})
Alias for: assert_midband!
repeat_previous=(bool) click to toggle source
# File lib/origen/pins/pin.rb, line 659
def repeat_previous=(bool)
  invalidate_vector_cache
  @repeat_previous = bool
end
repeat_previous?() click to toggle source
# File lib/origen/pins/pin.rb, line 664
def repeat_previous?
  @repeat_previous
end
respond_to_missing?(m, include_private = false) click to toggle source
Calls superclass method
# File lib/origen/pins/pin.rb, line 1186
def respond_to_missing?(m, include_private = false)
  meta[m] || super
end
restore() click to toggle source

Restores the state of the pin to the last time save was called

# File lib/origen/pins/pin.rb, line 991
def restore
  invalidate_vector_cache
  @state = @_saved_state.pop
  @value = @_saved_value.pop
  @suspend = @_saved_suspend.pop
  @invert = @_saved_invert.pop
  @repeat_previous = @_saved_repeat_previous.pop
end
restore_state() { || ... } click to toggle source

Restores the state of the pin at the end of the given block to the state it was in at the start of the block

pin(:invoke).driving?  # => true
pin(:invoke).restore_state do
  pin(:invoke).dont_care
  pin(:invoke).driving?  # => false
end
pin(:invoke).driving?  # => true
# File lib/origen/pins/pin.rb, line 974
def restore_state
  save
  yield
  restore
end
resume() click to toggle source

Will resume compares on this pin

# File lib/origen/pins/pin.rb, line 654
def resume
  invalidate_vector_cache
  @suspend = false
end
resume_clock(options = {})
Alias for: start_clock
rtl_name() click to toggle source
# File lib/origen/pins/pin.rb, line 147
def rtl_name
  if primary_group
    (@rtl_name || "#{primary_group.id}#{primary_group_index}").to_s
  else
    (@rtl_name || id).to_s
  end
end
sanitize_direction(val) click to toggle source
# File lib/origen/pins/pin.rb, line 504
def sanitize_direction(val)
  if val
    val = val.to_s.downcase.gsub(/\//, '')
    if val =~ /i.*o/
      :io
    elsif val =~ /^i/
      :input
    elsif val =~ /^o/
      :output
    else
      fail "Unknown pin direction: #{val}"
    end
  end
end
save() click to toggle source

Saves the current state of the pin, allowing it to be restored to the current state by calling the restore method

# File lib/origen/pins/pin.rb, line 982
def save
  @_saved_state << @state
  @_saved_value << @value
  @_saved_suspend << @suspend
  @_saved_invert << @invert
  @_saved_repeat_previous << @repeat_previous
end
set_mask(options = { context: nil })
Alias for: mask
set_state(state) click to toggle source
# File lib/origen/pins/pin.rb, line 673
def set_state(state)
  invalidate_vector_cache
  @repeat_previous = false
  @state = state
end
set_state_with_options(state, options = {}) click to toggle source
# File lib/origen/pins/pin.rb, line 668
def set_state_with_options(state, options = {})
  @state_meta = options[:meta] || {}
  set_state(state)
end
set_value(val) click to toggle source
# File lib/origen/pins/pin.rb, line 679
def set_value(val)
  orig = val
  invalidate_vector_cache
  if val.is_a?(String) || val.is_a?(Symbol)
    val = val.to_s
    if val =~ /^(b|h).+/
      val = Origen::Value.new(val)
    else
      @vector_formatted_value = val
      return
    end
  end
  if val.is_a?(Origen::Value)
    val = val[0]
  else
    # If val is a data bit extract the value of it
    val = val.respond_to?(:data) ? val.data : val
    # Assume driving/asserting a nil value means 0
    val ||= 0
    if !val.x_or_z? && val > 1
      fail "Attempt to set a value of #{val} on pin #{name}"
    end
  end
  @repeat_previous = false
  if val.x_or_z?
    dont_care
  else
    if inverted?
      @value = val == 0 ? 1 : 0
    else
      @value = val
    end
  end
end
Also aliased as: data=
sites() click to toggle source

Returns the number of test sites enabled for the pin

# File lib/origen/pins/pin.rb, line 500
def sites
  dib_assignment.size
end
smask(options = { context: nil })
Alias for: mask
start_clock(options = {}) click to toggle source
# File lib/origen/pins/pin.rb, line 1025
def start_clock(options = {})
  enable_clock(options) if myself.is_not_a_clock?
  @clock.start_clock(options)
end
Also aliased as: resume_clock
state() click to toggle source
# File lib/origen/pins/pin.rb, line 719
def state
  @state
end
state=(value) click to toggle source
# File lib/origen/pins/pin.rb, line 723
def state=(value)
  invalidate_vector_cache
  @state_meta = {}
  @state = value
end
stop_clock(options = {}) click to toggle source
# File lib/origen/pins/pin.rb, line 1031
def stop_clock(options = {})
  @clock.stop_clock(options)
end
Also aliased as: pause_clock
store(options = {})
Alias for: capture
store!(options = {})
Alias for: capture!
suspend() click to toggle source
# File lib/origen/pins/pin.rb, line 644
def suspend
  invalidate_vector_cache
  @suspend = true
end
suspended?() click to toggle source
# File lib/origen/pins/pin.rb, line 649
def suspended?
  @suspend
end
to_be_captured?() click to toggle source

Returns true if the (data) from the pin is marked to be captured

# File lib/origen/pins/pin.rb, line 958
def to_be_captured?
  state == :capture
end
to_be_stored?()
Alias for: to_be_captured?
to_vector() click to toggle source

Returns the value held by the pin as a string formatted to the current tester’s pattern syntax

@example

pin.drive_hi
pin.to_vector   # => "1"
pin.expect_lo
pin.to_vector   # => "L"
# File lib/origen/pins/pin.rb, line 290
def to_vector
  @vector_formatted_value ||= Origen.tester.format_pin_state(myself)
end
toggle() click to toggle source
# File lib/origen/pins/pin.rb, line 933
def toggle
  unless state == :dont_care
    set_value(value == 0 ? 1 : 0)
  end
end
toggle!() click to toggle source
# File lib/origen/pins/pin.rb, line 939
def toggle!
  toggle
  cycle
end
toggle_clock() click to toggle source
# File lib/origen/pins/pin.rb, line 1048
def toggle_clock
  fail "ERROR: Clock on #{@owner.name} not running." unless is_a_running_clock?

  @clock.toggle
end
type=(value) click to toggle source
# File lib/origen/pins/pin.rb, line 1062
def type=(value)
  if TYPES.include? value
    @type = value
  else
    fail "Pin type '#{value}' must be set to one of the following: #{TYPES.join(', ')}"
  end
end
update_clock() click to toggle source
# File lib/origen/pins/pin.rb, line 1021
def update_clock
  @clock.update_clock
end
update_package(options = {})
Alias for: update_packages
update_packages(options = {}) click to toggle source

Add a way to update packages for the pins after the pins have been added.

@example Updating a package after the pin has been added dut.add_pin :p1 dut.add_package: package1 dut.add_package: package2 dut.pin(:p1).packages # => {} dut.pin(:p1).update_packages :packages # => [:package1, :package2] dut.pin(:p1).packages # => {:package1=>{}, :package2=>{}}

# File lib/origen/pins/pin.rb, line 455
def update_packages(options = {})
  packages = resolve_packages(options)
  packages.each do |package_id|
    package_id = package_id.respond_to?(:id) ? package_id.id : package_id
    myself.packages[package_id] ||= {}
  end
end
Also aliased as: update_package
value() click to toggle source
# File lib/origen/pins/pin.rb, line 639
def value
  @value
end
Also aliased as: data
vector_formatted_value=(val) click to toggle source

Set the pin value and state from a string formatted to the current tester’s pattern syntax, this is the opposite of the to_vector method

@example

pin.vector_formatted_value = "L"
pin.driving?                      # => false
pin.value                         # => 0
pin.vector_formatted_value = "1"
pin.driving?                      # => true
pin.value                         # => 1
# File lib/origen/pins/pin.rb, line 311
def vector_formatted_value=(val)
  unless @vector_formatted_value == val
    Origen.tester.update_pin_from_formatted_state(myself, val)
    @vector_formatted_value = val
  end
end
write(value, options = {})
Alias for: drive
write!(value, options = {})
Alias for: drive!
write_hi(options = {})
Alias for: drive_hi
write_hi!(options = {})
Alias for: drive_hi!
write_lo(options = {})
Alias for: drive_lo
write_lo!(options = {})
Alias for: drive_lo!

Private Instance Methods

primary_group=(group) click to toggle source
# File lib/origen/pins/pin.rb, line 1192
def primary_group=(group)
  @primary_group = group
end
primary_group_index=(number) click to toggle source
# File lib/origen/pins/pin.rb, line 1196
def primary_group_index=(number)
  @primary_group_index = number
end