Class: OrigenARMDebug::JTAG_DPV6Controller

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

Instance Method Summary collapse

Methods included from DPControllerV6

#ctrl_stat, #select_ap_reg

Methods included from Helpers

#extract_address, #extract_data, #log

Instance Method Details

#base_addressObject



164
165
166
# File 'lib/origen_arm_debug/jtag_dp_v6_controller.rb', line 164

def base_address
  model.base_address
end

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



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/origen_arm_debug/jtag_dp_v6_controller.rb', line 134

def dp_read(reg, options = {})
  # Part 1 - Request read from DP-Register by writing to DPACC with RnW=1
  dr.reset
  dr.overlay(nil)
  dr[0].write(1)
  dr[2..1].write(reg.offset >> 2)
  dr[34..3].write(0)
  ir.write!(dpacc_select)
  dut.jtag.write_dr(dr)

  # Part 2 - Now read real data from RDBUFF (DP-Reg)
  dr.reset
  dr.overlay(nil)
  dr[0].write(1)
  dr[2..1].write(rdbuff.offset >> 2)
  dr[34..3].copy_all(reg)
  options[:mask] = options[:mask] << 3 unless options[:mask].nil?
  dut.jtag.read_dr(dr, options)
end

#dp_write(reg) ⇒ Object



154
155
156
157
158
159
160
161
162
# File 'lib/origen_arm_debug/jtag_dp_v6_controller.rb', line 154

def dp_write(reg)
  dr.reset
  dr.overlay(nil)
  dr[0].write(0)
  dr[2..1].write(reg.offset >> 2)
  dr[34..3].copy_all(reg)
  ir.write!(dpacc_select)
  dut.jtag.write_dr(dr)
end

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



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/origen_arm_debug/jtag_dp_v6_controller.rb', line 64

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

  if reg.owner == model
    # Don't log this one, not really a DP reg and will be included
    # in the JTAG driver log anyway
    if reg.name == :ir
      dut.jtag.read_ir(reg)
    else

      log "Read JTAG-DP register #{reg.name.to_s.upcase}: #{Origen::Utility.read_hex(reg)}" do
        if reg.name == :idcode
          ir.write!(reg.offset)
          dut.jtag.read_dr(reg)

        # DPACC
        elsif reg.name == :select || reg.name == :rdbuff
          dp_read(reg, options)

        # Some other register
        elsif reg.meta.include?(:dpbanksel)
          # Part 1 - Set dpbanksel if required
          if model.reg(:select).bits(:dpbanksel).data != reg.meta[:dpbanksel]
            model.reg(:select).bits(:dpbanksel).write! reg.meta[:dpbanksel]
          end

          dp_read(reg, options)

        else
          fail "Can't read #{reg.name}"
        end
      end
    end

  # AP register read
  else
    unless reg.owner.is_a?(AP)
      fail 'The JTAG-DP can only write to DP or AP registers!'
    end

    # Part 1 - Request read from AP-Register by writing to APACC with RnW=1
    select_ap_reg(reg)
    dr.reset
    dr.overlay(nil)
    dr[0].write(1)
    dr[2..1].write(reg.offset >> 2)
    dr[34..3].write(0)
    ir.write!(apacc_select)
    dut.jtag.write_dr(dr)

    # Calling AP should provide any delay parameter for wait states between AP read request
    #   and when the data is available at the RDBUFF DP-Reg
    if options[:apacc_wait_states]
      options[:apacc_wait_states].cycles
    end

    # Part 2 - Now read real data from RDBUFF (DP-Reg)
    dr.reset
    dr.overlay(nil)
    dr[0].write(1)
    dr[2..1].write(rdbuff.offset >> 2)
    dr[34..3].copy_all(reg)
    options[:mask] = options[:mask] << 3 unless options[:mask].nil?
    ir.write!(dpacc_select)
    dut.jtag.read_dr(dr, options)
  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
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
# File 'lib/origen_arm_debug/jtag_dp_v6_controller.rb', line 7

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

  # DP register write
  if reg.owner == model
    # Don't log this one, not really a DP reg and will be included
    # in the JTAG driver log anyway
    if reg.name == :ir
      dut.jtag.write_ir(reg)
    else

      log "Write JTAG-DP register #{reg.name.to_s.upcase}: #{reg.data.to_hex}" do
        if reg.name == :abort
          ir.write!(reg.offset)
          dr.reset
          dr.overlay(nil)
          dr[2..0].write(0)
          dr[34..3].copy_all(reg)
          dut.jtag.write_dr(dr)

        # DPACC
        elsif reg.name == :select
          dp_write(reg)

        # Some other debug register
        elsif reg.meta.include?(:dpbanksel)
          if model.reg(:select).bits(:dpbanksel).data != reg.meta[:dpbanksel]
            model.reg(:select).bits(:dpbanksel).write! reg.meta[:dpbanksel]
          end
          dp_write(reg)

        else
          fail "Can't write #{reg.name}"
        end
      end
    end

  # AP register write
  else

    unless reg.owner.is_a?(AP)
      fail 'The JTAG-DP can only write to DP or AP registers!'
    end

    select_ap_reg(reg)
    dr.reset
    dr.overlay(nil)
    dr[0].write(0)
    dr[2..1].write(reg.offset >> 2)
    dr[34..3].copy_all(reg)
    ir.write!(apacc_select)
    dut.jtag.write_dr(dr, options)
  end
end