Sha256: 637f44efe7b4c47e55197457b0455d4551b57edf031fb5dd605e00f5cd7e7967

Contents?: true

Size: 1.97 KB

Versions: 56

Compression:

Stored size: 1.97 KB

Contents

module OrigenTesters
  class MemoryStyle
    attr_reader :pin_id, :size, :bit_order, :format, :trigger, :mode, :data_type

    def initialize
      @pin_id = []
      @size = []
      @bit_order = []
      @format = []
      @trigger = []
      @mode = []
      @data_type = []
    end

    # Set memory style attributes for the given pin
    #
    # @example
    #   mem.pin :tdi, size: 8, trigger: :auto
    def pin(*pin_ids)
      options = pin_ids.last.is_a?(Hash) ? pin_ids.pop : {}
      pin_ids.each_index do |i|
        if pin_ids[i].is_a?(Symbol)
          pin_ids[i] = dut.pin(pin_ids[i]).name
        else
          pin_ids[i] = pin_ids[i].name
        end
      end
      @pin_id << pin_ids
      @size << options[:size]
      @bit_order << options[:bit_order]
      @format << options[:format]
      @trigger << options[:trigger]
      @mode << options[:mode]
      @data_type << options[:data_type]
    end

    # Get the chronologically last setting for the given pin's attributes
    #
    # @example
    #   mem.pin :tdi, size: 1
    #   mem.pin :tdi, size: 2
    #
    #   my_local_attribute_hash = mem.accumulate_attributes(:tdi)
    #   # my_local_attribute_hash now is
    #   # {pin_id: :tdi, size: 2, bit_order: nil, format: nil, trigger: nil}
    def accumulate_attributes(pin_id)
      a = { pin_id: pin_id }
      @pin_id.each_index do |i|
        if @pin_id[i].include?(pin_id)
          a[:size] = @size[i]
          a[:bit_order] = @bit_order[i]
          a[:format] = @format[i]
          a[:trigger] = @trigger[i]
          a[:mode] = @mode[i]
          a[:data_type] = @data_type[i]
        end
      end
      a
    end

    # Check to see if a given pin exists in this style container
    def contains_pin?(pin_id)
      contained_pins.include?(pin_id)
    end

    # Get an array of pins contained in this style container
    def contained_pins
      pins = []
      @pin_id.each do |a|
        a.each do |p|
          pins << p
        end
      end
      pins.uniq
    end
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
origen_testers-0.52.8 lib/origen_testers/memory_style.rb
origen_testers-0.52.7 lib/origen_testers/memory_style.rb
origen_testers-0.52.6 lib/origen_testers/memory_style.rb
origen_testers-0.52.5 lib/origen_testers/memory_style.rb
origen_testers-0.52.4 lib/origen_testers/memory_style.rb
origen_testers-0.52.3 lib/origen_testers/memory_style.rb
origen_testers-0.52.1 lib/origen_testers/memory_style.rb
origen_testers-0.52.0 lib/origen_testers/memory_style.rb
origen_testers-0.51.5 lib/origen_testers/memory_style.rb
origen_testers-0.51.4 lib/origen_testers/memory_style.rb
origen_testers-0.51.3 lib/origen_testers/memory_style.rb
origen_testers-0.51.2 lib/origen_testers/memory_style.rb
origen_testers-0.51.1 lib/origen_testers/memory_style.rb
origen_testers-0.51.0 lib/origen_testers/memory_style.rb
origen_testers-0.50.0 lib/origen_testers/memory_style.rb
origen_testers-0.49.4 lib/origen_testers/memory_style.rb
origen_testers-0.49.3 lib/origen_testers/memory_style.rb
origen_testers-0.49.2 lib/origen_testers/memory_style.rb
origen_testers-0.49.1 lib/origen_testers/memory_style.rb
origen_testers-0.49.0 lib/origen_testers/memory_style.rb