origen_memory_image 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90f929c547d4a00df7450faf892f6f4ebed1c56d18b64e9315d810dd7774f55c
4
- data.tar.gz: e209715c41348a5975f549f27babdc1d4e2c0473f6e935fff12148d2f2e7a5f0
3
+ metadata.gz: 2d9b91a3a905b3801a9d96ee96fe7494baf3c201d1b3ee34107599923ff0763a
4
+ data.tar.gz: d66b83fcd77afac1ed13754871d9fab2952760f2ad5fc17b6709904ef6a48c6d
5
5
  SHA512:
6
- metadata.gz: 2319ac1964ce679181d45b9b79343604a90aad3149d3015ab1e8daf3e1edaf2045bf41aaba40680f371131f6278a363187caf2407b60fd7508cb4ecdc3792cdc
7
- data.tar.gz: c8dae0921e4490b7a108cfbbb0a1ef0d93585fe8191c8e61dd2ef3debf624bd6333771d2f7ee24de638cb265f33653729e8def0e7bcc6812eeac689470f89a90
6
+ metadata.gz: f6fedde88b97b4661fb9773d6780497ba995f07114661ba3c94b5ca842c818dc59592e40758c387ce7f8361b1cf68977c40aba88c0a864a3a3ab751a9a118e0b
7
+ data.tar.gz: 7a712d8374d57ae31dd11454cc7985084988ca90e3d883205b3738bc1ac48c2e45bb89054c6a9a816efd1b57096e17220da099508a634eb915af9760a7114a8d
data/config/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module OrigenMemoryImage
2
2
  MAJOR = 0
3
3
  MINOR = 8
4
- BUGFIX = 1
4
+ BUGFIX = 2
5
5
  DEV = nil
6
6
  VERSION = [MAJOR, MINOR, BUGFIX].join(".") + (DEV ? ".pre#{DEV}" : '')
7
7
  end
@@ -16,6 +16,13 @@ module OrigenMemoryImage
16
16
  fail "#{self.class} has not implemented the start_address method!"
17
17
  end
18
18
 
19
+ # Returns true if a start (jump address) record exists
20
+ def has_start_record
21
+ start_address unless @start_address
22
+ @start_record_found = false if @start_record_found.nil?
23
+ @start_record_found
24
+ end
25
+
19
26
  # Returns the s-record as an array of addresses and data
20
27
  #
21
28
  # @param [hash] options, allows the selection of endianness swapping - ie the output will have the endianness changed
@@ -156,9 +156,16 @@ module OrigenMemoryImage
156
156
  end
157
157
 
158
158
  def start_address
159
+ if @call_order_warn
160
+ Origen.log.warn 'Previously srec.start_address returned the lowest address when to_a was called first. Now the start record is always returned if present.'
161
+ @call_order_warn = false
162
+ end
163
+
164
+ lowest_address = nil
159
165
  @start_address ||= begin
160
166
  lines.each do |line|
161
167
  if line =~ /^S([789])(.*)/
168
+ @start_record_found = true
162
169
  type = Regexp.last_match[1]
163
170
  case type
164
171
  when '7'
@@ -169,7 +176,19 @@ module OrigenMemoryImage
169
176
  return line.slice(4, 4).to_i(16)
170
177
  end
171
178
  end
179
+ if line =~ /^S([1-3])/
180
+ type = Regexp.last_match[1].to_i(16) # S-record type, 1-3
181
+ # Set the matcher to capture x number of bytes dependent on the s-rec type
182
+ addr_matcher = '\w\w' * (1 + type)
183
+ line.strip =~ /^S\d\w\w(#{addr_matcher})(\w*)\w\w$/ # $1 = address, $2 = data
184
+ addr = Regexp.last_match[1].to_i(16)
185
+ lowest_address ||= addr
186
+ lowest_address = addr if addr < lowest_address
187
+ end
172
188
  end
189
+ # if no start_address record is found, return lowest address
190
+ @start_record_found = false
191
+ lowest_address
173
192
  end
174
193
  end
175
194
 
@@ -183,6 +202,12 @@ module OrigenMemoryImage
183
202
  data_width_in_bytes: 4
184
203
  }.merge(options)
185
204
 
205
+ # guarantee that the start_address will be the jump address if provided
206
+ if @start_address.nil?
207
+ start_address
208
+ @call_order_warn = @start_record_found ? true : false
209
+ end
210
+
186
211
  result = []
187
212
  lines.each do |line|
188
213
  # Only if the line is an s-record with data...
@@ -192,8 +217,6 @@ module OrigenMemoryImage
192
217
  addr_matcher = '\w\w' * (1 + type)
193
218
  line.strip =~ /^S\d\w\w(#{addr_matcher})(\w*)\w\w$/ # $1 = address, $2 = data
194
219
  addr = Regexp.last_match[1].to_i(16)
195
- @start_address ||= addr
196
- @start_address = addr if addr < @start_address
197
220
  data = Regexp.last_match[2]
198
221
  data_matcher = '\w\w' * options[:data_width_in_bytes]
199
222
  data.scan(/#{data_matcher}/).each do |data_packet|
@@ -91,10 +91,14 @@ my_hex = OrigenMemoryImage.new(str, source: String)
91
91
 
92
92
  Every memory image object then supports a common API.
93
93
 
94
- The <code>start_address</code> method returns the start (execution start) address:
94
+ The <code>start_address</code> method returns the start (execution start) address. If the memory image
95
+ contains an indication of the execution start address that record value will be returned. If there is
96
+ no start address record, the lowest address will be returned. The <code>has_start_record</code> method
97
+ indicates whether a start address record was found:
95
98
 
96
99
  ~~~ruby
97
- my_srec.start_address # => 0x3000_F000
100
+ my_srec.start_address # => 0x3000_F000
101
+ my_srec.has_start_record # => true
98
102
  ~~~
99
103
 
100
104
  The <code>to_a</code> method returns the file content as an array of address/data pairs,
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.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen McGinty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-28 00:00:00.000000000 Z
11
+ date: 2021-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: origen