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
- #delay(cycles) ⇒ Object
- #extract_address(reg_or_val, options = {}) ⇒ Object private
- #extract_data(reg_or_val, options = {}) ⇒ Object private
- #extract_size(reg_or_val, options = {}) ⇒ Object private
- #read(reg_or_val, options = {}) ⇒ Object (also: #read_register)
-
#read16(data, options = {}) ⇒ Object
(also: #read_word, #read_16)
Read 16 bits of data to the given byte address.
-
#read32(data, options = {}) ⇒ Object
(also: #read_longword, #read_32)
Read 32 bits of data to the given byte address.
-
#read8(data, options = {}) ⇒ Object
(also: #read_byte, #read_8)
Read 8 bits of data to the given byte address.
- #write(reg_or_val, options = {}) ⇒ Object (also: #write_register)
-
#write16(data, options = {}) ⇒ Object
(also: #write_word, #write_16)
Write 16 bits of data to the given byte address.
-
#write32(data, options = {}) ⇒ Object
(also: #write_longword, #write_32)
Write 32 bits of data to the given byte address.
-
#write8(data, options = {}) ⇒ Object
(also: #write_byte, #write_8)
Write 8 bits of data to the given byte address.
Instance Method Details
#delay(cycles) ⇒ Object
212 213 214 |
# File 'lib/origen_debuggers/j_link.rb', line 212 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.
323 324 325 326 327 328 329 |
# File 'lib/origen_debuggers/j_link.rb', line 323 def extract_address(reg_or_val, = {}) addr = [:addr] || [: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.
316 317 318 319 320 |
# File 'lib/origen_debuggers/j_link.rb', line 316 def extract_data(reg_or_val, = {}) return [:data] if [: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.
301 302 303 304 305 306 307 308 309 310 311 312 313 |
# File 'lib/origen_debuggers/j_link.rb', line 301 def extract_size(reg_or_val, = {}) size = [:size] if [: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
224 225 226 227 228 229 |
# File 'lib/origen_debuggers/j_link.rb', line 224 def read(reg_or_val, = {}) if reg_or_val.respond_to?(:data) cc("[JLink] Read #{reg_or_val.name.upcase} register, address: 0x%06X, expect value: 0x%08X" % [reg_or_val.address, reg_or_val.data]) end send("read#{extract_size(reg_or_val, )}".to_sym, reg_or_val, ) end |
#read16(data, options = {}) ⇒ Object Also known as: read_word, read_16
Read 16 bits of data to the given byte address
240 241 242 |
# File 'lib/origen_debuggers/j_link.rb', line 240 def read16(data, = {}) read_memory(extract_address(data, ), number: 2) end |
#read32(data, options = {}) ⇒ Object Also known as: read_longword, read_32
Read 32 bits of data to the given byte address
data can be array of registers, if array of data then will auto-incrememnt address
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/origen_debuggers/j_link.rb', line 249 def read32(data, = {}) = { optimize: false, # whether to use a single command to do the read # user may care regarding endianness size: 32, # size of each item in bits number: 1, # default number of items }.merge() [:optimize] = [:optimized] if [:optimized] if data.is_a?(Array) if [:optimize] # for optimized option assume single starting address for data in array read_memory(extract_address(data, ), size: [:size], number: data.length) else data.each_index do |i| data_item = data[i] # do separate writes for each 32-bit word read_memory(extract_address(data_item, ) + i * ([:size] / 8), size: [:size]) end end else if [:optimize] read_memory(extract_address(data, ), size: [:size], number: [:number]) else read_memory(extract_address(data, ), number: ([:size] / 8)) end end end |
#read8(data, options = {}) ⇒ Object Also known as: read_byte, read_8
Read 8 bits of data to the given byte address
233 234 235 |
# File 'lib/origen_debuggers/j_link.rb', line 233 def read8(data, = {}) read_memory(extract_address(data, ), number: 1) end |
#write(reg_or_val, options = {}) ⇒ Object Also known as: write_register
216 217 218 219 220 221 |
# File 'lib/origen_debuggers/j_link.rb', line 216 def write(reg_or_val, = {}) if reg_or_val.respond_to?(:data) cc("[JLink] Write #{reg_or_val.name.upcase} register, address: 0x%06X with value: 0x%08X" % [reg_or_val.address, reg_or_val.data]) end send("write#{extract_size(reg_or_val, )}".to_sym, reg_or_val, ) end |
#write16(data, options = {}) ⇒ Object Also known as: write_word, write_16
Write 16 bits of data to the given byte address
287 288 289 |
# File 'lib/origen_debuggers/j_link.rb', line 287 def write16(data, = {}) dw "w2 0x#{extract_address(data, ).to_s(16).upcase}, 0x#{extract_data(data, ).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
294 295 296 |
# File 'lib/origen_debuggers/j_link.rb', line 294 def write32(data, = {}) dw "w4 0x#{extract_address(data, ).to_s(16).upcase}, 0x#{extract_data(data, ).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
280 281 282 |
# File 'lib/origen_debuggers/j_link.rb', line 280 def write8(data, = {}) dw "w1 0x#{extract_address(data, ).to_s(16).upcase}, 0x#{extract_data(data, ).to_s(16).upcase}" end |