Sha256: 468a4e99a20ecb9adbf6f1d653c1518c678d52fc40038a3daaa567c53ba8388c

Contents?: true

Size: 1.91 KB

Versions: 2

Compression:

Stored size: 1.91 KB

Contents

module OrigenTesters
  module IGXLBasedTester
    class Base
      class Patsubr
        attr_accessor :index

        # Specify multiple patterns by passing an array of attributes
        # as the 2nd argument:
        #
        #   Patset.new("mrd1_pset", :pattern => "nvm_mrd1.PAT")
        #
        #   Patset.new("mrd1_pset", [{:pattern => "nvm_mrd1.PAT"},
        #                            {:pattern => "nvm_global_subs.PAT, :start_label => "subr"}
        #                           ])
        def initialize(name, attrs = {})
          attrs = [attrs] unless attrs.is_a? Array
          attrs.each do |pattrs|
            if pattrs[:pattern]
              pat = Pathname.new(pattrs[:pattern].gsub('\\', '/')).basename('.*').to_s
              Origen.interface.referenced_patterns << pat
            end
            lines << platform::PatsubrPattern.new(name, pattrs)
          end
          self.name = name
        end

        def ==(other_patset)
          self.class == other_patset.class &&
            name.to_s == other_patset.name.to_s &&
            sorted_pattern_files == other_patset.sorted_pattern_files
        end

        def name
          @name
        end

        def name=(n)
          @name = n
          lines.each { |l| l.pattern_set = n }
          n
        end

        # Returns all lines in the pattern set
        def lines
          @lines ||= []
        end

        # Returns all pattern files in the pattern set in alphabetical order
        def sorted_pattern_files
          @lines.map(&:file_name).sort
        end

        # Returns the fully formatted pattern set for insertion into a patset sheet
        def to_s
          l = ''
          lines.each do |line|
            l += "#{line}\r\n"
          end
          l.chomp
        end

        def platform
          Origen.interface.platform
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
origen_testers-0.13.2 lib/origen_testers/igxl_based_tester/base/patsubr.rb
origen_testers-0.10.0 lib/origen_testers/igxl_based_tester/base/patsubr.rb