51 using TlmGenericPayload = tlm::tlm_generic_payload;
52 using TlmResponseStatus = tlm::tlm_response_status;
53 using TlmDmi = tlm::tlm_dmi;
57 using GetDirectMemPtrCallbackFn = std::function<
bool(
uint64_t addr, TlmDmi&)>;
63 TlmGenericPayload* m_cur_txn =
nullptr;
64 sc_core::sc_time* m_cur_txn_delay =
nullptr;
66 bool m_last_txn_valid =
false;
67 TlmGenericPayload m_last_txn;
69 bool m_last_txn_delay_valid =
false;
70 sc_core::sc_time m_last_txn_delay;
72 AccessCallbackFn m_read_cb;
73 AccessCallbackFn m_write_cb;
75 DebugAccessCallbackFn m_debug_read_cb;
76 DebugAccessCallbackFn m_debug_write_cb;
78 GetDirectMemPtrCallbackFn m_dmi_cb;
81 template <
class RET, RET DEFAULT_RET, RET ADDRESS_ERROR_RET, RET DEFAULT_CB_RET,
class CB_FN>
97 if (txn.get_address() + txn.get_data_length() >= m_mmio_size) {
102 addr = txn.get_address();
103 ptr = txn.get_data_ptr();
104 len = txn.get_data_length();
106 switch (txn.get_command()) {
132 m_last_txn.deep_copy_from(txn);
133 m_last_txn_valid =
true;
139 virtual void b_transport(TlmGenericPayload& txn, sc_core::sc_time& delay)
143 TlmResponseStatus
ret;
145 m_cur_txn_delay = &delay;
147 AccessCallbackFn>(txn, m_read_cb, m_write_cb);
148 m_cur_txn_delay =
nullptr;
150 txn.set_response_status(
ret);
152 m_last_txn_delay = delay;
153 m_last_txn_delay_valid =
true;
156 virtual unsigned int transport_dbg(TlmGenericPayload& txn)
160 ret = generic_access<
int, 0, 0, -1, DebugAccessCallbackFn>(txn, m_debug_read_cb, m_debug_write_cb);
163 ret = txn.get_data_length();
169 virtual bool get_direct_mem_ptr(TlmGenericPayload& txn, TlmDmi& dmi_data)
173 m_last_txn.deep_copy_from(m_last_txn);
175 addr = txn.get_address();
178 return m_dmi_cb(
addr, dmi_data);
185 tlm_utils::simple_target_socket<TargetTester, DEFAULT_TLM_BUSWIDTH> socket;
195 socket.register_b_transport(
this, &TargetTester::b_transport);
196 socket.register_transport_dbg(
this, &TargetTester::transport_dbg);
197 socket.register_get_direct_mem_ptr(
this, &TargetTester::get_direct_mem_ptr);
251 m_last_txn_valid =
false;
268 m_last_txn_delay_valid =
false;
270 return m_last_txn_delay;
300 return *m_cur_txn_delay;
TargetTester(const sc_core::sc_module_name &n, size_t mmio_size)
Construct a TargetTester object with a name and an MMIO size.
Definition target-tester.h:193