quic/qbox
|
A TLM initiator to do testing on a target. More...
#include <initiator-tester.h>
Public Types | |
using | TlmGenericPayload = tlm::tlm_generic_payload |
using | TlmResponseStatus = tlm::tlm_response_status |
using | TlmDmi = tlm::tlm_dmi |
using | InvalidateDirectMemPtrFn = std::function< void(uint64_t, uint64_t)> |
Public Member Functions | |
InitiatorTester (const sc_core::sc_module_name &n) | |
TlmResponseStatus | do_b_transport (TlmGenericPayload &txn) |
Perform a b_transport TLM transaction using the txn TLM payload. | |
TlmResponseStatus | do_transport_dbg (TlmGenericPayload &txn) |
Perform a transport_dbg TLM transaction using the txn TLM payload. | |
TlmResponseStatus | do_transaction (TlmGenericPayload &txn, bool debug=false) |
Perform a TLM transaction using the txn TLM payload. | |
TlmResponseStatus | do_read_with_txn_and_ptr (TlmGenericPayload &txn, uint64_t addr, uint8_t *data, size_t len, bool debug=false) |
Perform a simple read into the buffer pointed by data with a pre-set payload. | |
TlmResponseStatus | do_write_with_txn_and_ptr (TlmGenericPayload &txn, uint64_t addr, const uint8_t *data, size_t len, bool debug=false) |
Perform a simple write with data pointed by data with a pre-set payload. | |
TlmResponseStatus | do_read_with_ptr (uint64_t addr, uint8_t *data, size_t len, bool debug=false) |
Perform a simple read into the buffer pointed by data | |
TlmResponseStatus | do_write_with_ptr (uint64_t addr, const uint8_t *data, size_t len, bool debug=false) |
Perform a simple write with data pointed by data | |
template<class T > | |
TlmResponseStatus | do_read_with_txn (TlmGenericPayload &txn, uint64_t addr, T &data, bool debug=false) |
Perform a simple read with a pre-set payload. | |
template<class T > | |
TlmResponseStatus | do_write_with_txn (TlmGenericPayload &txn, uint64_t addr, const T &data, bool debug=false) |
Perform a simple write with a pre-set payload. | |
template<class T > | |
TlmResponseStatus | do_read (uint64_t addr, T &data, bool debug=false) |
Perform a simple read into data | |
template<class T > | |
TlmResponseStatus | do_write (uint64_t addr, const T &data, bool debug=false) |
Perform a simple write. | |
void | set_next_txn_delay (const sc_core::sc_time &delay) |
Set the delay value to use for the next b_transport call. | |
const sc_core::sc_time & | get_last_txn_delay () const |
Get the delay value resulting of the last b_transport call. | |
unsigned int | get_last_transport_debug_ret () const |
Get the return value of the last transport_dbg call. | |
bool | get_last_dmi_hint () const |
Get the DMI hint value of the last transaction (the is_dmi_allowed() flag in the payload) | |
bool | do_dmi_request (uint64_t addr) |
Perform a get_direct_mem_ptr call by specifying an address. | |
const TlmDmi & | get_last_dmi_data () const |
Get the DMI data returned by the last get_direct_mem_ptr call. | |
void | register_invalidate_direct_mem_ptr (InvalidateDirectMemPtrFn cb) |
Register a callback on invalidate_direct_mem_ptr event. | |
Public Attributes | |
tlm_utils::simple_initiator_socket< InitiatorTester, DEFAULT_TLM_BUSWIDTH > | socket |
Protected Member Functions | |
virtual void | prepare_txn (TlmGenericPayload &txn, bool is_read, uint64_t addr, uint8_t *data, size_t len) |
A TLM initiator to do testing on a target.
This class allows to test a target by providing helpers to standard TLM operations. Those helpers rangs from the most generic to the most simplified one. The idea is to provide simple helpers for the most common cases, while still allowing full flexibility if needed.
The prepare_txn
method can be overriden if needed when inheriting this class, to customize the way payloads are filled before a transaction. One can also use the *_with_txn helpers and provide an already filled payload with e.g. an extension. Please note however that prepare_txn
is still called on the payload to fill compulsory fields (namely the address, data pointer, data length and TLM command).
Read/write helpers return the tlm::tlm_response_status
value of the resulting transaction. The DMI hint value of the last transaction (the is_dmi_allowed()
flag) can be retrieved using the get_last_dmi_hint
method.
When using standard read/write helpers, one can specify the value of the b_transport delay
parameter, using the set_next_txn_delay
method. This delay value can then be retrieved after the transaction using the get_last_txn_delay
method (to check the value written back by the target).
Some helpers have a debug
argument defaulting to false
, when set to true, transport_dbg is called instead of b_transport on the socket. The transport_dbg return value is accessible through the get_last_transport_debug_ret
method.
Regarding DMI requests, one can use the do_dmi_request
helper to do a simple get_direct_mem_ptr call with only an address. The resulting tlm::tlm_dmi data can be retrieved using the get_last_dmi_data
method.
One can also register a callback to catch DMI invalidations on the backward path of the socket, using the register_invalidate_direct_mem_ptr
method.
|
inline |
Perform a b_transport TLM transaction using the txn
TLM payload.
This method performs a b_transport transaction using the txn
pre-filled payload. The transaction is not altered by this method so it should be completely filled prior to calling this method.
[in,out] | txn | The payload to use for the transaction |
Perform a get_direct_mem_ptr call by specifying an address.
Perform a DMI request by specifying an address for the request. The DMI data can be retrieved using the get_last_dmi_data
method.
Perform a simple read into data
[in] | addr | Address of the read |
[out] | data | Where to retrieve the read value |
[in] | debug | Perform a transport_dbg instead of a b_transport |
|
inline |
Perform a simple read into the buffer pointed by data
[in] | addr | Address of the read |
[out] | data | Pointer to the buffer where to store the read data |
[in] | len | Length of the read |
[in] | debug | Perform a transport_dbg instead of a b_transport |
|
inline |
Perform a simple read with a pre-set payload.
This method reads data into data
. It uses the txn
payload for the transaction, by overwriting the address, data pointer, data lenght and command fields of it. Other field are left untouched by this initiator (they could be altered by the target).
[in,out] | txn | The payload to use for the transaction |
[in] | addr | Address of the read |
[out] | data | Where to retrieve the read value |
[in] | debug | Perform a transport_dbg instead of a b_transport |
|
inline |
Perform a simple read into the buffer pointed by data
with a pre-set payload.
This method performs a read into the buffer pointed by data
. It uses the txn
payload for the transaction, by overwriting the address, data pointer, data lenght and command fields of it. Other field are left untouched by this initiator (they could be altered by the target).
[in,out] | txn | The payload to use for the transaction |
[in] | addr | Address of the read |
[out] | data | Pointer to the buffer where to store the read data |
[in] | len | Length of the read |
[in] | debug | Perform a transport_dbg instead of a b_transport |
|
inline |
Perform a TLM transaction using the txn
TLM payload.
This method performs a transaction using the txn
pre-filled payload. The transaction is not altered by this method so it should be completely filled prior to calling this method.
[in,out] | txn | The payload to use for the transaction |
[in] | debug | Perform a transport_dbg instead of a b_transport |
|
inline |
Perform a transport_dbg TLM transaction using the txn
TLM payload.
This method performs a transport_dbg transaction using the txn
pre-filled payload. The transaction is not altered by this method so it should be completely filled prior to calling this method.
[in,out] | txn | The payload to use for the transaction |
|
inline |
Perform a simple write.
[in] | addr | Address of the write |
[in] | data | Data to write (note that this method does not guarantee data won't be modified by the target. It does not perform a prior copy to enforce this) |
[in] | debug | Perform a transport_dbg instead of a b_transport |
|
inline |
Perform a simple write with data pointed by data
[in] | addr | Address of the write |
[in] | data | Pointer to the data to write (note that this method does not guarantee data won't be modified by the target. It does not perform a prior copy to enforce this) |
[in] | len | Length of the write |
[in] | debug | Perform a transport_dbg instead of a b_transport |
|
inline |
Perform a simple write with a pre-set payload.
This method performs a write from data
. It uses the txn
payload for the transaction, by overwriting the address, data pointer, data lenght and command fields of it. Other field are left untouched by this initiator (they could be altered by the target).
[in,out] | txn | The payload to use for the transaction |
[in] | addr | Address of the write |
[in] | data | The value to write (note that this method does not guarantee data won't be modified by the target. It does not perform a prior copy to enforce this) |
[in] | debug | Perform a transport_dbg instead of a b_transport |
|
inline |
Perform a simple write with data pointed by data
with a pre-set payload.
This method performs a write from the buffer pointed by data
. It uses the txn
payload for the transaction, by overwriting the address, data pointer, data lenght and command fields of it. Other field are left untouched by this initiator (they could be altered by the target).
[in] | addr | Address of the write |
[in] | data | Pointer to the data to write (note that this method does not guarantee data won't be modified by the target. It does not perform a prior copy to enforce this) |
[in] | len | Length of the write |
[in] | debug | Perform a transport_dbg instead of a b_transport |
|
inline |
Get the DMI data returned by the last get_direct_mem_ptr call.
|
inline |
Get the DMI hint value of the last transaction (the is_dmi_allowed() flag in the payload)
Get the return value of the last transport_dbg call.
|
inline |
Get the delay value resulting of the last b_transport call.
Set the delay value to use for the next b_transport call.
[in] | delay | The delay value to use for the next b_transport call |