Class: OrigenSWD::Driver
- Inherits:
-
Object
- Object
- OrigenSWD::Driver
- Includes:
- Origen::Registers
- Defined in:
- lib/origen_swd/driver.rb
Overview
To use this driver the owner model must define the following pins (an alias is fine):
:swd_clk
:swd_dio
Constant Summary collapse
- REQUIRED_PINS =
[:swd_clk, :swd_dio]
Instance Attribute Summary collapse
-
#owner ⇒ Object
readonly
Returns the parent object that instantiated the driver, could be either a DUT object or a protocol abstraction.
-
#posedge_clk ⇒ Object
Returns the value of attribute posedge_clk.
-
#trn ⇒ Object
Customiz-ible ‘turn-round cycle’ (TRN) parameter (in cycles).
Instance Method Summary collapse
-
#initialize(owner, options = {}) ⇒ Driver
constructor
Initialize class variables.
-
#read(ap_dp, reg_or_val, options = {}) ⇒ Object
Read data from Debug Port or Access Port.
-
#read_ap(reg_or_val, options = {}) ⇒ Object
Write data from Access Port.
-
#read_dp(reg_or_val, options = {}) ⇒ Object
Write data from Debug Port.
-
#write(ap_dp, reg_or_val, deprecated_wdata = nil, options = {}) ⇒ Object
Write data to Debug Port or Access Port.
-
#write_ap(reg_or_val, options = {}) ⇒ Object
Write data to Access Port.
-
#write_dp(reg_or_val, options = {}) ⇒ Object
Write data to Debug Port.
Constructor Details
#initialize(owner, options = {}) ⇒ Driver
Initialize class variables
28 29 30 31 32 33 34 35 |
# File 'lib/origen_swd/driver.rb', line 28 def initialize(owner, = {}) @owner = owner @current_apaddr = 0 @orundetect = 0 @trn = 0 @posedge_clk = '1' end |
Instance Attribute Details
#owner ⇒ Object (readonly)
Returns the parent object that instantiated the driver, could be either a DUT object or a protocol abstraction
13 14 15 |
# File 'lib/origen_swd/driver.rb', line 13 def owner @owner end |
#posedge_clk ⇒ Object
Returns the value of attribute posedge_clk.
17 18 19 |
# File 'lib/origen_swd/driver.rb', line 17 def posedge_clk @posedge_clk end |
#trn ⇒ Object
Customiz-ible ‘turn-round cycle’ (TRN) parameter (in cycles)
16 17 18 |
# File 'lib/origen_swd/driver.rb', line 16 def trn @trn end |
Instance Method Details
#read(ap_dp, reg_or_val, options = {}) ⇒ Object
Read data from Debug Port or Access Port
70 71 72 73 74 75 76 |
# File 'lib/origen_swd/driver.rb', line 70 def read(ap_dp, reg_or_val, = {}) addr = extract_address(reg_or_val, .merge(use_reg_or_val_if_you_must: true)) send_header(ap_dp, 1, addr) # send read-specific header (rnw = 1) receive_acknowledgement() receive_payload(reg_or_val, ) swd_dio.drive(0) end |
#read_ap(reg_or_val, options = {}) ⇒ Object
Write data from Access Port
56 57 58 59 |
# File 'lib/origen_swd/driver.rb', line 56 def read_ap(reg_or_val, = {}) reg_or_val, = nil, reg_or_val if reg_or_val.is_a?(Hash) read(1, reg_or_val, .merge(compare_data: reg_or_val.is_a?(Numeric))) end |
#read_dp(reg_or_val, options = {}) ⇒ Object
Write data from Debug Port
44 45 46 47 |
# File 'lib/origen_swd/driver.rb', line 44 def read_dp(reg_or_val, = {}) reg_or_val, = nil, reg_or_val if reg_or_val.is_a?(Hash) read(0, reg_or_val, .merge(compare_data: reg_or_val.is_a?(Numeric))) end |
#write(ap_dp, reg_or_val, deprecated_wdata = nil, options = {}) ⇒ Object
Write data to Debug Port or Access Port
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/origen_swd/driver.rb', line 109 def write(ap_dp, reg_or_val, deprecated_wdata = nil, = {}) deprecated_wdata, = nil, deprecated_wdata if deprecated_wdata.is_a?(Hash) if deprecated_wdata addr = reg_or_val.respond_to?(:address) ? reg_or_val.address : reg_or_val else addr = extract_address(reg_or_val, ) end send_header(ap_dp, 0, addr) # send write-specific header (rnw = 0) receive_acknowledgement if deprecated_wdata if reg_or_val.respond_to?(:data) reg_or_val.data = deprecated_wdata else reg_or_val = deprecated_wdata end end send_payload(reg_or_val, ) swd_dio.drive(0) end |
#write_ap(reg_or_val, options = {}) ⇒ Object
Write data to Access Port
96 97 98 |
# File 'lib/origen_swd/driver.rb', line 96 def write_ap(reg_or_val, = {}) write(1, reg_or_val, ) end |
#write_dp(reg_or_val, options = {}) ⇒ Object
Write data to Debug Port
85 86 87 |
# File 'lib/origen_swd/driver.rb', line 85 def write_dp(reg_or_val, = {}) write(0, reg_or_val, ) end |