Module: OrigenDebuggers::PEmicro::Common_API

Included in:
OrigenDebuggers::PEmicro
Defined in:
lib/origen_debuggers/p_and_e.rb

Overview

All debuggers should try and support these methods

Instance Method Summary collapse

Instance Method Details

#delay(cycles) ⇒ Object



120
121
122
123
124
# File 'lib/origen_debuggers/p_and_e.rb', line 120

def delay(cycles)
  dw 'jtag_end' if @in_jtag
  @in_jtag = false
  dw "delay #{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.



217
218
219
220
221
222
223
# File 'lib/origen_debuggers/p_and_e.rb', line 217

def extract_address(reg_or_val, options = {})
  addr = options[:addr] || options[: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.



210
211
212
213
214
# File 'lib/origen_debuggers/p_and_e.rb', line 210

def extract_data(reg_or_val, options = {})
  return options[:data] if options[: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.



195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/origen_debuggers/p_and_e.rb', line 195

def extract_size(reg_or_val, options = {})
  size = options[:size] if options[: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



133
134
135
136
137
# File 'lib/origen_debuggers/p_and_e.rb', line 133

def read(reg_or_val, options = {})
  dw 'jtag_end' if @in_jtag
  @in_jtag = false
  send("read#{extract_size(reg_or_val, options)}".to_sym, reg_or_val, options)
end

#read16(data, options = {}) ⇒ Object Also known as: read_word, read_16

Read 16 bits of data to the given byte address



150
151
152
153
154
# File 'lib/origen_debuggers/p_and_e.rb', line 150

def read16(data, options = {})
  dw 'jtag_end' if @in_jtag
  @in_jtag = false
  dw "DUMP.W #{extract_address(data, options)} #{(extract_address(data, options))}"
end

#read32(data, options = {}) ⇒ Object Also known as: read_longword, read_32

Read 32 bits of data to the given byte address



159
160
161
162
163
# File 'lib/origen_debuggers/p_and_e.rb', line 159

def read32(data, options = {})
  dw 'jtag_end' if @in_jtag
  @in_jtag = false
  dw "DUMP.L #{(extract_address(data, options))} #{(extract_address(data, options))}"
end

#read8(data, options = {}) ⇒ Object Also known as: read_byte, read_8

Read 8 bits of data to the given byte address



141
142
143
144
145
# File 'lib/origen_debuggers/p_and_e.rb', line 141

def read8(data, options = {})
  dw 'jtag_end' if @in_jtag
  @in_jtag = false
  dw "DUMP.B #{(extract_address(data, options))} #{(extract_address(data, options))}"
end

#write(reg_or_val, options = {}) ⇒ Object Also known as: write_register



126
127
128
129
130
# File 'lib/origen_debuggers/p_and_e.rb', line 126

def write(reg_or_val, options = {})
  dw 'jtag_end' if @in_jtag
  @in_jtag = false
  send("write#{extract_size(reg_or_val, options)}".to_sym, reg_or_val, options)
end

#write16(data, options = {}) ⇒ Object Also known as: write_word, write_16

Write 16 bits of data to the given byte address



177
178
179
180
181
# File 'lib/origen_debuggers/p_and_e.rb', line 177

def write16(data, options = {})
  dw 'jtag_end' if @in_jtag
  @in_jtag = false
  dw "MM.W #{extract_address(data, options).to_s(16).upcase} #{extract_data(data, options).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



186
187
188
189
190
# File 'lib/origen_debuggers/p_and_e.rb', line 186

def write32(data, options = {})
  dw 'jtag_end' if @in_jtag
  @in_jtag = false
  dw "MM.L #{extract_address(data, options).to_s(16).upcase} #{extract_data(data, options).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



168
169
170
171
172
# File 'lib/origen_debuggers/p_and_e.rb', line 168

def write8(data, options = {})
  dw 'jtag_end' if @in_jtag
  @in_jtag = false
  dw "MM.B #{extract_address(data, options).to_s(16).upcase} #{extract_data(data, options).to_s(16).upcase}"
end