Module: OrigenARMDebug::Helpers

Included in:
APController, DAPController, JTAG_DPController, JTAG_DPV6Controller, SW_DPController
Defined in:
lib/origen_arm_debug/helpers.rb

Overview

Generic helper methods shared by the various controllers

Instance Method Summary collapse

Instance Method Details

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



12
13
14
15
16
17
18
# File 'lib/origen_arm_debug/helpers.rb', line 12

def extract_address(reg_or_val, options = {})
  addr = options[:address] || options[:addr]
  return addr if addr
  return reg_or_val.address if reg_or_val.respond_to?('address')
  return reg_or_val.addr if reg_or_val.respond_to?('addr')
  fail 'No address given, if supplying a data value instead of a register object, you must supply an :address option'
end

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



4
5
6
7
8
9
10
# File 'lib/origen_arm_debug/helpers.rb', line 4

def extract_data(reg_or_val, options = {})
  if reg_or_val.respond_to?('data')
    reg_or_val.data
  else
    reg_or_val
  end
end

#log(msg) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/origen_arm_debug/helpers.rb', line 20

def log(msg)
  cc "[ARM Debug] #{msg}"
  if block_given?
    yield
    cc "[ARM Debug] /#{msg}"
  end
end