Sha256: 9810ba9d707d2d61b8a83c0b3b5bc1266479e3c715b6143bb4338e14c13c677f

Contents?: true

Size: 812 Bytes

Versions: 2

Compression:

Stored size: 812 Bytes

Contents

require 'origen'
require_relative '../config/application.rb'
require_relative '../config/environment.rb'

module OrigenMemoryImage
  def self.new(file, options = {})
    unless options[:source] == String
      file = Origen.file_handler.clean_path_to(file)
    end
    find_type(file, options).new(file, options)
  end

  # Returns the class of the image manager for the given file
  def self.find_type(file, options = {})
    # Read first 10 lines
    if options[:source] == String
      snippet = file.split("\n")
    else
      snippet = File.foreach(file.to_s).first(1)
    end
    case
    when options[:type] == :srecord || SRecord.match?(snippet)
      SRecord
    when options[:type] == :hex || Hex.match?(snippet)
      Hex
    else
      fail "Unknown format for image file: #{file}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
origen_memory_image-0.5.2 lib/origen_memory_image.rb
origen_memory_image-0.5.0 lib/origen_memory_image.rb