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
- #delay(cycles) ⇒ Object
- #extract_address(reg_or_val, options = {}) ⇒ Object private
- #extract_data(reg_or_val, options = {}) ⇒ Object private
- #extract_size(reg_or_val, options = {}) ⇒ Object private
- #read(reg_or_val, options = {}) ⇒ Object (also: #read_register)
-
#read16(data, options = {}) ⇒ Object
(also: #read_word, #read_16)
Read 16 bits of data to the given byte address.
-
#read32(data, options = {}) ⇒ Object
(also: #read_longword, #read_32)
Read 32 bits of data to the given byte address.
-
#read8(data, options = {}) ⇒ Object
(also: #read_byte, #read_8)
Read 8 bits of data to the given byte address.
- #write(reg_or_val, options = {}) ⇒ Object (also: #write_register)
-
#write16(data, options = {}) ⇒ Object
(also: #write_word, #write_16)
Write 16 bits of data to the given byte address.
-
#write32(data, options = {}) ⇒ Object
(also: #write_longword, #write_32)
Write 32 bits of data to the given byte address.
-
#write8(data, options = {}) ⇒ Object
(also: #write_byte, #write_8)
Write 8 bits of data to the given byte address.
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.
223 224 225 226 227 228 229 |
# File 'lib/origen_debuggers/p_and_e.rb', line 223 def extract_address(reg_or_val, = {}) addr = [:addr] || [: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.
216 217 218 219 220 |
# File 'lib/origen_debuggers/p_and_e.rb', line 216 def extract_data(reg_or_val, = {}) return [:data] if [: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.
201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/origen_debuggers/p_and_e.rb', line 201 def extract_size(reg_or_val, = {}) size = [:size] if [: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
136 137 138 139 140 141 142 143 |
# File 'lib/origen_debuggers/p_and_e.rb', line 136 def read(reg_or_val, = {}) dw 'jtag_end' if @in_jtag @in_jtag = false if reg_or_val.respond_to?(:data) cc("[P&E] Read #{reg_or_val.name.upcase} register, address: 0x%06X, expect value: 0x%08X" % [reg_or_val.address, reg_or_val.data]) end send("read#{extract_size(reg_or_val, )}".to_sym, reg_or_val, ) end |
#read16(data, options = {}) ⇒ Object Also known as: read_word, read_16
Read 16 bits of data to the given byte address
156 157 158 159 160 |
# File 'lib/origen_debuggers/p_and_e.rb', line 156 def read16(data, = {}) dw 'jtag_end' if @in_jtag @in_jtag = false dw "DUMP.W #{extract_address(data, )} #{(extract_address(data, ))}" end |
#read32(data, options = {}) ⇒ Object Also known as: read_longword, read_32
Read 32 bits of data to the given byte address
165 166 167 168 169 |
# File 'lib/origen_debuggers/p_and_e.rb', line 165 def read32(data, = {}) dw 'jtag_end' if @in_jtag @in_jtag = false dw "DUMP.L #{(extract_address(data, ))} #{(extract_address(data, ))}" end |
#read8(data, options = {}) ⇒ Object Also known as: read_byte, read_8
Read 8 bits of data to the given byte address
147 148 149 150 151 |
# File 'lib/origen_debuggers/p_and_e.rb', line 147 def read8(data, = {}) dw 'jtag_end' if @in_jtag @in_jtag = false dw "DUMP.B #{(extract_address(data, ))} #{(extract_address(data, ))}" end |
#write(reg_or_val, options = {}) ⇒ Object Also known as: write_register
126 127 128 129 130 131 132 133 |
# File 'lib/origen_debuggers/p_and_e.rb', line 126 def write(reg_or_val, = {}) dw 'jtag_end' if @in_jtag @in_jtag = false if reg_or_val.respond_to?(:data) cc("[P&E] Write #{reg_or_val.name.upcase} register, address: 0x%06X with value: 0x%08X" % [reg_or_val.address, reg_or_val.data]) end send("write#{extract_size(reg_or_val, )}".to_sym, reg_or_val, ) end |
#write16(data, options = {}) ⇒ Object Also known as: write_word, write_16
Write 16 bits of data to the given byte address
183 184 185 186 187 |
# File 'lib/origen_debuggers/p_and_e.rb', line 183 def write16(data, = {}) dw 'jtag_end' if @in_jtag @in_jtag = false dw "MM.W #{extract_address(data, ).to_s(16).upcase} #{extract_data(data, ).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
192 193 194 195 196 |
# File 'lib/origen_debuggers/p_and_e.rb', line 192 def write32(data, = {}) dw 'jtag_end' if @in_jtag @in_jtag = false dw "MM.L #{extract_address(data, ).to_s(16).upcase} #{extract_data(data, ).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
174 175 176 177 178 |
# File 'lib/origen_debuggers/p_and_e.rb', line 174 def write8(data, = {}) dw 'jtag_end' if @in_jtag @in_jtag = false dw "MM.B #{extract_address(data, ).to_s(16).upcase} #{extract_data(data, ).to_s(16).upcase}" end |