Module: OrigenDebuggers::JLink::Common_API

Included in:
OrigenDebuggers::JLink
Defined in:
lib/origen_debuggers/j_link.rb

Overview

All debuggers should try and support these methods

Instance Method Summary collapse

Instance Method Details

#delay(cycles) ⇒ Object



213
214
215
# File 'lib/origen_debuggers/j_link.rb', line 213

def delay(cycles)
  dw "Sleep #{cycles_to_ms(cycles)}"
end

#extract_address(reg_or_val, options = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



292
293
294
295
296
297
298
# File 'lib/origen_debuggers/j_link.rb', line 292

def extract_address(reg_or_val, options = {})
  addr = options[:addr] || options[:address]
  return addr if addr
  addr = reg_or_val.address if reg_or_val.respond_to?(:address)
  fail 'You must supply an :address option if not providing a register!' unless addr
  addr
end

#extract_data(reg_or_val, options = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



285
286
287
288
289
# File 'lib/origen_debuggers/j_link.rb', line 285

def extract_data(reg_or_val, options = {})
  return options[:data] if options[:data]
  return reg_or_val.data if reg_or_val.respond_to?(:data)
  reg_or_val
end

#extract_size(reg_or_val, options = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/origen_debuggers/j_link.rb', line 270

def extract_size(reg_or_val, options = {})
  size = options[:size] if options[:size]
  unless size
    if reg_or_val.respond_to?(:contains_bits?) && reg_or_val.contains_bits?
      size = reg_or_val.size
    end
  end
  fail 'You must supply an :size option if not providing a register!' unless size
  unless [8, 16, 32].include?(size)
    fail 'Only a size of 8, 16 or 32 is supported!'
  end
  size
end

#read(reg_or_val, options = {}) ⇒ Object Also known as: read_register



222
223
224
# File 'lib/origen_debuggers/j_link.rb', line 222

def read(reg_or_val, options = {})
  send("read#{extract_size(reg_or_val, options)}".to_sym, reg_or_val, options)
end

#read16(data, options = {}) ⇒ Object Also known as: read_word, read_16

Read 16 bits of data to the given byte address



235
236
237
# File 'lib/origen_debuggers/j_link.rb', line 235

def read16(data, options = {})
  read_memory(extract_address(data, options), number_of_bytes: 2)
end

#read32(data, options = {}) ⇒ Object Also known as: read_longword, read_32

Read 32 bits of data to the given byte address



242
243
244
# File 'lib/origen_debuggers/j_link.rb', line 242

def read32(data, options = {})
  read_memory(extract_address(data, options), number_of_bytes: 4)
end

#read8(data, options = {}) ⇒ Object Also known as: read_byte, read_8

Read 8 bits of data to the given byte address



228
229
230
# File 'lib/origen_debuggers/j_link.rb', line 228

def read8(data, options = {})
  read_memory(extract_address(data, options), number_of_bytes: 1)
end

#write(reg_or_val, options = {}) ⇒ Object Also known as: write_register



217
218
219
# File 'lib/origen_debuggers/j_link.rb', line 217

def write(reg_or_val, options = {})
  send("write#{extract_size(reg_or_val, options)}".to_sym, reg_or_val, options)
end

#write16(data, options = {}) ⇒ Object Also known as: write_word, write_16

Write 16 bits of data to the given byte address



256
257
258
# File 'lib/origen_debuggers/j_link.rb', line 256

def write16(data, options = {})
  dw "w2 0x#{extract_address(data, options).to_s(16).upcase}, 0x#{extract_data(data, options).to_s(16).upcase}"
end

#write32(data, options = {}) ⇒ Object Also known as: write_longword, write_32

Write 32 bits of data to the given byte address



263
264
265
# File 'lib/origen_debuggers/j_link.rb', line 263

def write32(data, options = {})
  dw "w4 0x#{extract_address(data, options).to_s(16).upcase}, 0x#{extract_data(data, options).to_s(16).upcase}"
end

#write8(data, options = {}) ⇒ Object Also known as: write_byte, write_8

Write 8 bits of data to the given byte address



249
250
251
# File 'lib/origen_debuggers/j_link.rb', line 249

def write8(data, options = {})
  dw "w1 0x#{extract_address(data, options).to_s(16).upcase}, 0x#{extract_data(data, options).to_s(16).upcase}"
end