origen_memory_image 0.5.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dbd9fff5f4d4a999086de046e0c99a016a475f15
4
- data.tar.gz: a06173b18adeab5d1ce72f919cfa6b239bc04712
3
+ metadata.gz: caf8c439a35b5f220e8274b6626673ee7525271a
4
+ data.tar.gz: ec7fbf5149451f4ec2f92f4f9e9cbb4757ffd897
5
5
  SHA512:
6
- metadata.gz: 549bd0444aa5942e410d5ceece65c21bed5d4561932e1632e9ca605838f8599eafeb4dd50cf6b24616564645b90b3eaf67550e6a6ea86d07fb2f2b6be38f7298
7
- data.tar.gz: cb109a9dc9fa36c486e8026ea5804ce7dd721882ecb2da6e76e63e915c6a07fcb6abd3ef3973632d1a8b766a4050ef0e94702135f669c5e7226bda6c1ce4b308
6
+ metadata.gz: 94959863f2afed01b3300650b793209631118c11fca988b89b30bdc162497974a53423c87c2538c84569448f98f1ed7ba77f198983c24b11e67f27fc5e0b929d
7
+ data.tar.gz: feb360c36844b949e4463956ab81d69e5e0dfee76b094fee1acf149ef946cb27b3f0c79ec77748dc6003be23bbe918d7bb35fa77665a7e40a7c0eb528a7f2553
data/config/boot.rb ADDED
@@ -0,0 +1 @@
1
+ require "origen_memory_image"
data/config/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module OrigenMemoryImage
2
2
  MAJOR = 0
3
- MINOR = 5
4
- BUGFIX = 2
3
+ MINOR = 6
4
+ BUGFIX = 0
5
5
  DEV = nil
6
6
 
7
7
  VERSION = [MAJOR, MINOR, BUGFIX].join(".") + (DEV ? ".pre#{DEV}" : '')
@@ -1,8 +1,12 @@
1
1
  require 'origen'
2
2
  require_relative '../config/application.rb'
3
- require_relative '../config/environment.rb'
4
3
 
5
4
  module OrigenMemoryImage
5
+ autoload :Base, 'origen_memory_image/base'
6
+ autoload :SRecord, 'origen_memory_image/s_record'
7
+ autoload :Hex, 'origen_memory_image/hex'
8
+ autoload :Binary, 'origen_memory_image/binary'
9
+
6
10
  def self.new(file, options = {})
7
11
  unless options[:source] == String
8
12
  file = Origen.file_handler.clean_path_to(file)
@@ -19,6 +23,12 @@ module OrigenMemoryImage
19
23
  snippet = File.foreach(file.to_s).first(1)
20
24
  end
21
25
  case
26
+ # Always do the binary first since the others won't be able to process
27
+ # a binary snippet
28
+ when options[:type] == :binary || (options[:source] != String && Binary.match?(file))
29
+ Binary
30
+ when options[:source] == String && Binary.match?(snippet, true)
31
+ Binary
22
32
  when options[:type] == :srecord || SRecord.match?(snippet)
23
33
  SRecord
24
34
  when options[:type] == :hex || Hex.match?(snippet)
@@ -0,0 +1,69 @@
1
+ require 'ptools'
2
+
3
+ module OrigenMemoryImage
4
+ class Binary < Base
5
+ def self.match?(file, snippet = false)
6
+ if snippet
7
+ file.all? { |l| l.strip =~ /^[01]*$/ }
8
+ else
9
+ File.binary?(file)
10
+ end
11
+ end
12
+
13
+ # Always returns 0 since binary files do not contain addresses
14
+ def start_address
15
+ 0
16
+ end
17
+
18
+ def create_test_file
19
+ data = [
20
+ 0x1EE0021C, 0x22401BE0, 0x021C2243,
21
+ 0x18E0021C, 0x5A780A43, 0x03E0034B,
22
+ 0xF7215A78, 0x0A400020, 0x22E08442,
23
+ 0x22D31FE0, 0x84421FD9, 0x1CE08442,
24
+ 0x002B20D1, 0x03E0012A, 0x01D1002B,
25
+ 0x1BD00223, 0x2340022A, 0x02D1002B,
26
+ 0x15D103E0, 0x032A01D1, 0x78000018,
27
+ 0x7C000018, 0x82000018, 0x88000018
28
+ ]
29
+ data = data.map { |d| d.to_s(2).rjust(32, '0') }.join
30
+ File.open('examples/bin1.bin', 'wb') do |output|
31
+ output.write [data].pack('B*')
32
+ end
33
+ end
34
+
35
+ private
36
+
37
+ # Returns an array containing all address/data from the given s-record
38
+ # No address manipulation is performed, that is left to the caller to apply
39
+ # any scrambling as required by the target system
40
+ def extract_addr_data(options = {})
41
+ options = {
42
+ data_width_in_bytes: 4
43
+ }.merge(options)
44
+
45
+ result = []
46
+ width = options[:data_width_in_bytes]
47
+ address = 0
48
+
49
+ if file
50
+ raw = File.binread(file)
51
+ bytes = raw.unpack('C*')
52
+ else
53
+ raw = lines.map(&:strip).join
54
+ bytes = raw.scan(/.{1,8}/).map { |s| s.to_i(2) }
55
+ end
56
+
57
+ bytes.each_slice(width) do |d|
58
+ v = 0
59
+ width.times do |i|
60
+ v |= d[i] << ((width - 1 - i) * 8) if d[i]
61
+ end
62
+ result << [address, v]
63
+ address += width
64
+ end
65
+
66
+ result
67
+ end
68
+ end
69
+ end
@@ -135,6 +135,17 @@ The data lines can be grouped into any size:
135
135
  780000187C0000188200001888000018
136
136
  ~~~
137
137
 
138
+ #### Binary Files
139
+
140
+ A binary file:
141
+
142
+ ~~~text
143
+ 00001101000101010000111100010011
144
+ 00001110000101000001000000010010
145
+ 00000000000000000000010000010111
146
+ 00000100000000110000010100000110
147
+ ~~~
148
+
138
149
  ### How To Setup a Development Environment
139
150
 
140
151
  [Clone the repository from Github](https://github.com/Origen-SDK/origen_memory_image).
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: origen_memory_image
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen McGinty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-06 00:00:00.000000000 Z
11
+ date: 2017-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: origen
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.2.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: ptools
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: origen_doc_helpers
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -46,13 +60,12 @@ extensions: []
46
60
  extra_rdoc_files: []
47
61
  files:
48
62
  - config/application.rb
63
+ - config/boot.rb
49
64
  - config/commands.rb
50
- - config/development.rb
51
- - config/environment.rb
52
- - config/users.rb
53
65
  - config/version.rb
54
66
  - lib/origen_memory_image.rb
55
67
  - lib/origen_memory_image/base.rb
68
+ - lib/origen_memory_image/binary.rb
56
69
  - lib/origen_memory_image/hex.rb
57
70
  - lib/origen_memory_image/s_record.rb
58
71
  - templates/web/index.md.erb
@@ -78,10 +91,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
91
  version: 1.8.11
79
92
  requirements: []
80
93
  rubyforge_project:
81
- rubygems_version: 2.2.2
94
+ rubygems_version: 2.6.7
82
95
  signing_key:
83
96
  specification_version: 4
84
97
  summary: Provides a standard API for consuming memory image files in any format e.g.
85
98
  s-record, hex
86
99
  test_files: []
87
- has_rdoc:
@@ -1,12 +0,0 @@
1
- # This file is similar to environment.rb and will be loaded
2
- # automatically at the start of each invocation of Origen.
3
- #
4
- # However the major difference is that it will not be loaded
5
- # if the application is imported by a 3rd party app - in that
6
- # case only environment.rb is loaded.
7
- #
8
- # Therefore this file should be used to load anything you need
9
- # to setup a development environment for this app, normally
10
- # this would be used to load some dummy classes to instantiate
11
- # your objects so that they can be tested and/or interacted with
12
- # in the console.
@@ -1,40 +0,0 @@
1
- # This file will be required by Origen before your target is loaded, you
2
- # can use this to require all of your files, which is the easiest way
3
- # to get started. As your experience grows you may wish to require only the
4
- # minimum files required to allow the target to be initialized and let
5
- # each class require its own dependencies.
6
- #
7
- # It is recommended that you keep all of your application logic in lib/
8
- # The lib directory has already been added to the search path and so any files
9
- # in there can be referenced from here with a relative path.
10
- #
11
- # Note that pattern files do not need to be referenced from here and these
12
- # will be located automatically by origen.
13
- #
14
- # Examples
15
- # --------
16
- # This says load the file "lib/pioneer.rb" the first time anyone makes a
17
- # reference to the class name 'Pioneer'.
18
- #autoload :Pioneer, "pioneer"
19
- #
20
- # This is generally preferable to using require which will load the file
21
- # regardless of whether it is needed by the current target or not:
22
- #require "pioneer"
23
- #
24
- # Sometimes you have to use require however:-
25
- # 1. When defining a test program interface:
26
- #require "interfaces/j750"
27
- # 2. If you want to extend a class defined by an imported plugin, in
28
- # this case your must use required and supply a full path (to distinguish
29
- # it from the one in the parent application):
30
- #require "#{Origen.root}/c90_top_level/p2"
31
-
32
- # Plugins should not use a wildcard import of the lib directory to help
33
- # prevent long start up times, only require what is necessary to boot and
34
- # use autoload for everything else.
35
- module OrigenMemoryImage
36
- autoload :Base, "origen_memory_image/base"
37
- autoload :SRecord, "origen_memory_image/s_record"
38
- autoload :Hex, "origen_memory_image/hex"
39
- end
40
- require "origen_memory_image"
data/config/users.rb DELETED
@@ -1,18 +0,0 @@
1
- # This file defines the users associated with your project, it is basically the
2
- # mailing list for release notes.
3
- #
4
- # You can split your users into "admin" and "user" groups, the main difference
5
- # between the two is that admin users will get all tag emails, users will get
6
- # emails on external/official releases only.
7
- #
8
- # Users are also prohibited from running the "origen tag" task, but this is
9
- # really just to prevent a casual user from executing it inadvertently and is
10
- # not intended to be a serious security gate.
11
- module Origen
12
- module Users
13
- def users
14
- @users ||= [
15
- ]
16
- end
17
- end
18
- end