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.
317 318 319 320 321 322 323 |
# File 'lib/origen_debuggers/j_link.rb', line 317 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.
310 311 312 313 314 |
# File 'lib/origen_debuggers/j_link.rb', line 310 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.
295 296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/origen_debuggers/j_link.rb', line 295 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
221 222 223 |
# File 'lib/origen_debuggers/j_link.rb', line 221 def read(reg_or_val, = {}) 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
234 235 236 |
# File 'lib/origen_debuggers/j_link.rb', line 234 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
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
# File 'lib/origen_debuggers/j_link.rb', line 243 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
227 228 229 |
# File 'lib/origen_debuggers/j_link.rb', line 227 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 |
# File 'lib/origen_debuggers/j_link.rb', line 216 def write(reg_or_val, = {}) 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
281 282 283 |
# File 'lib/origen_debuggers/j_link.rb', line 281 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
288 289 290 |
# File 'lib/origen_debuggers/j_link.rb', line 288 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
274 275 276 |
# File 'lib/origen_debuggers/j_link.rb', line 274 def write8(data, = {}) dw "w1 0x#{extract_address(data, ).to_s(16).upcase}, 0x#{extract_data(data, ).to_s(16).upcase}" end |