Class: OrigenARMDebug::DAP

Inherits:
Object
  • Object
show all
Includes:
Origen::Model
Defined in:
lib/origen_arm_debug/dap.rb

Overview

This is the top-level model that instantiates the DP and APs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ DAP

Returns a new instance of DAP.



8
9
10
11
12
13
14
15
# File 'lib/origen_arm_debug/dap.rb', line 8

def initialize(options = {})
  @dps = []
  @mem_aps = []         # Array of MEM-APs
  @jtag_aps = []        # Array of JTAG-APs
  @ext_aps = []         # Array of 'extension' APs

  instantiate_subblocks(options)
end

Instance Attribute Details

#dpsObject (readonly)

Returns the value of attribute dps.



6
7
8
# File 'lib/origen_arm_debug/dap.rb', line 6

def dps
  @dps
end

#ext_apsObject (readonly)

Returns the value of attribute ext_aps.



6
7
8
# File 'lib/origen_arm_debug/dap.rb', line 6

def ext_aps
  @ext_aps
end

#jtag_apsObject (readonly)

Returns the value of attribute jtag_aps.



6
7
8
# File 'lib/origen_arm_debug/dap.rb', line 6

def jtag_aps
  @jtag_aps
end

#mem_apsObject (readonly)

Returns the value of attribute mem_aps.



6
7
8
# File 'lib/origen_arm_debug/dap.rb', line 6

def mem_aps
  @mem_aps
end

Instance Method Details

#add_ap(name, options) ⇒ Object

Method to add additional Access Ports (MEM-AP)

Parameters:

  • name (Integer)

    Short name for mem_ap that is being created

  • options (Hash)

    Implemenation specific details



75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/origen_arm_debug/dap.rb', line 75

def add_ap(name, options)
  domain name.to_sym
  # class name is deleted from options in sub_block call
  class_name = options[:class_name]
  ap = sub_block(name.to_sym, options)

  if class_name == 'MemAP'
    mem_aps << ap
  elsif class_name == 'JTAGAP'
    jtag_aps << ap
  else
    ext_aps << ap
  end
end

#apsObject

Returns an array containing all APs



91
92
93
# File 'lib/origen_arm_debug/dap.rb', line 91

def aps
  mem_aps + jtag_aps + ext_aps
end

#instantiate_subblocks(options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/origen_arm_debug/dap.rb', line 17

def instantiate_subblocks(options = {})
  if options[:swd] || parent.respond_to?(:swd)
    dps << sub_block(:sw_dp, class_name: 'SW_DP')
  end

  if options[:jtag] || parent.respond_to?(:jtag)
    if options[:dapv6]
      options[:class_name] = 'JTAG_DPV6'
    else
      options[:class_name] = 'JTAG_DP'
    end
    dps << sub_block(:jtag_dp, options)
  end

  Array(options[:mem_aps]).each do |name, base_address|
    if base_address.is_a?(Hash)
      ap_opts = { class_name: 'MemAP' }.merge(base_address)
    else
      ap_opts = { class_name: 'MemAP', base_address: base_address }
    end

    add_ap(name, ap_opts)
  end

  Array(options[:jtag_aps]).each do |name, base_address|
    if base_address.is_a?(Hash)
      ap_opts = { class_name: 'JTAGAP' }.merge(base_address)
    else
      ap_opts = { class_name: 'JTAGAP', base_address: base_address }
    end

    add_ap(name, ap_opts)
  end

  Array(options[:aps]).each do |name, opts|
    if opts.is_a?(Hash)
      klass = opts.delete(:class_name)
      addr = opts.delete(:base_address)
      if klass.nil? || addr.nil?
        fail "[ARM DEBUG] Error: Must specify class_name and base_address if using 'aps' hash to define APs"
      end
      ap_opts = { class_name: klass, base_address: addr }.merge(opts)
    else
      fail "[ARM DEBUG] Error: Must specify class_name and base_address if using 'aps' hash to define APs"
    end

    add_ap(name, ap_opts)
  end
end