Class: OrigenARMDebug::SW_DPController

Inherits:
Object
  • Object
show all
Includes:
Origen::Controller, DPController, Helpers
Defined in:
lib/origen_arm_debug/sw_dp_controller.rb

Instance Method Summary collapse

Methods included from DPController

#ctrl_stat, #select_ap_reg

Methods included from Helpers

#extract_address, #extract_data, #log

Instance Method Details

#read_register(reg, options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/origen_arm_debug/sw_dp_controller.rb', line 26

def read_register(reg, options = {})
  unless reg.readable?
    fail "The :#{reg.name} register is not readable!"
  end

  if reg.owner == model
    log "Read SW-DP register #{reg.name.to_s.upcase}: #{Origen::Utility.read_hex(reg)}" do
      dut.swd.read_dp(reg)
    end
  else
    unless reg.owner.is_a?(AP)
      fail 'The SW-DP can only write to DP or AP registers!'
    end

    select_ap_reg(reg)
    dut.swd.read_ap(address: reg.address)

    # Add any extra delay needed in between selecting the AP state, initiating and completing a dummy read, and
    # starting the actual read.
    if options[:apacc_wait_states]
      options[:apacc_wait_states].cycles
    end

    dut.swd.read_dp(reg, options.merge(address: rdbuff.address))
  end
end

#write_register(reg, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/origen_arm_debug/sw_dp_controller.rb', line 7

def write_register(reg, options = {})
  unless reg.writable?
    fail "The :#{reg.name} register is not writeable!"
  end

  if reg.owner == model
    log "Write SW-DP register #{reg.name.to_s.upcase}: #{reg.data.to_hex}" do
      dut.swd.write_dp(reg)
    end
  else
    unless reg.owner.is_a?(AP)
      fail 'The SW-DP can only write to DP or AP registers!'
    end

    select_ap_reg(reg)
    dut.swd.write_ap(reg, options)
  end
end