quic/qbox
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | List of all members
InitiatorTester Class Reference

A TLM initiator to do testing on a target. More...

#include <initiator-tester.h>

Inheritance diagram for InitiatorTester:
Inheritance graph
[legend]
Collaboration diagram for InitiatorTester:
Collaboration graph
[legend]

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)
 

Detailed Description

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.

Member Function Documentation

◆ do_b_transport()

TlmResponseStatus InitiatorTester::do_b_transport ( TlmGenericPayload &  txn)
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.

Parameters
[in,out]txnThe payload to use for the transaction
Returns
the tlm::tlm_response_status value of the transaction

◆ do_dmi_request()

bool InitiatorTester::do_dmi_request ( uint64_t  addr)
inline

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.

Returns
the value returned by the get_direct_mem_ptr call

◆ do_read()

template<class T >
TlmResponseStatus InitiatorTester::do_read ( uint64_t  addr,
T data,
bool  debug = false 
)
inline

Perform a simple read into data

Parameters
[in]addrAddress of the read
[out]dataWhere to retrieve the read value
[in]debugPerform a transport_dbg instead of a b_transport
Returns
the tlm::tlm_response_status value of the transaction

◆ do_read_with_ptr()

TlmResponseStatus InitiatorTester::do_read_with_ptr ( uint64_t  addr,
uint8_t data,
size_t  len,
bool  debug = false 
)
inline

Perform a simple read into the buffer pointed by data

Parameters
[in]addrAddress of the read
[out]dataPointer to the buffer where to store the read data
[in]lenLength of the read
[in]debugPerform a transport_dbg instead of a b_transport
Returns
the tlm::tlm_response_status value of the transaction

◆ do_read_with_txn()

template<class T >
TlmResponseStatus InitiatorTester::do_read_with_txn ( TlmGenericPayload &  txn,
uint64_t  addr,
T data,
bool  debug = false 
)
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).

Parameters
[in,out]txnThe payload to use for the transaction
[in]addrAddress of the read
[out]dataWhere to retrieve the read value
[in]debugPerform a transport_dbg instead of a b_transport
Returns
the tlm::tlm_response_status value of the transaction

◆ do_read_with_txn_and_ptr()

TlmResponseStatus InitiatorTester::do_read_with_txn_and_ptr ( TlmGenericPayload &  txn,
uint64_t  addr,
uint8_t data,
size_t  len,
bool  debug = false 
)
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).

Parameters
[in,out]txnThe payload to use for the transaction
[in]addrAddress of the read
[out]dataPointer to the buffer where to store the read data
[in]lenLength of the read
[in]debugPerform a transport_dbg instead of a b_transport
Returns
the tlm::tlm_response_status value of the transaction

◆ do_transaction()

TlmResponseStatus InitiatorTester::do_transaction ( TlmGenericPayload &  txn,
bool  debug = false 
)
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.

Parameters
[in,out]txnThe payload to use for the transaction
[in]debugPerform a transport_dbg instead of a b_transport
Returns
the tlm::tlm_response_status value of the transaction

◆ do_transport_dbg()

TlmResponseStatus InitiatorTester::do_transport_dbg ( TlmGenericPayload &  txn)
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.

Parameters
[in,out]txnThe payload to use for the transaction
Returns
the tlm::tlm_response_status value of the transaction

◆ do_write()

template<class T >
TlmResponseStatus InitiatorTester::do_write ( uint64_t  addr,
const T data,
bool  debug = false 
)
inline

Perform a simple write.

Parameters
[in]addrAddress of the write
[in]dataData 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]debugPerform a transport_dbg instead of a b_transport
Returns
the tlm::tlm_response_status value of the transaction

◆ do_write_with_ptr()

TlmResponseStatus InitiatorTester::do_write_with_ptr ( uint64_t  addr,
const uint8_t data,
size_t  len,
bool  debug = false 
)
inline

Perform a simple write with data pointed by data

Parameters
[in]addrAddress of the write
[in]dataPointer 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]lenLength of the write
[in]debugPerform a transport_dbg instead of a b_transport
Returns
the tlm::tlm_response_status value of the transaction

◆ do_write_with_txn()

template<class T >
TlmResponseStatus InitiatorTester::do_write_with_txn ( TlmGenericPayload &  txn,
uint64_t  addr,
const T data,
bool  debug = false 
)
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).

Parameters
[in,out]txnThe payload to use for the transaction
[in]addrAddress of the write
[in]dataThe 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]debugPerform a transport_dbg instead of a b_transport
Returns
the tlm::tlm_response_status value of the transaction

◆ do_write_with_txn_and_ptr()

TlmResponseStatus InitiatorTester::do_write_with_txn_and_ptr ( TlmGenericPayload &  txn,
uint64_t  addr,
const uint8_t data,
size_t  len,
bool  debug = false 
)
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).

Parameters
[in]addrAddress of the write
[in]dataPointer 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]lenLength of the write
[in]debugPerform a transport_dbg instead of a b_transport
Returns
the tlm::tlm_response_status value of the transaction

◆ get_last_dmi_data()

const TlmDmi & InitiatorTester::get_last_dmi_data ( ) const
inline

Get the DMI data returned by the last get_direct_mem_ptr call.

Returns
the DMI data returned by the last get_direct_mem_ptr call

◆ get_last_dmi_hint()

bool InitiatorTester::get_last_dmi_hint ( ) const
inline

Get the DMI hint value of the last transaction (the is_dmi_allowed() flag in the payload)

Returns
the DMI hint value of the last transaction

◆ get_last_transport_debug_ret()

unsigned int InitiatorTester::get_last_transport_debug_ret ( ) const
inline

Get the return value of the last transport_dbg call.

Returns
the return value of the last transport_dbg call

◆ get_last_txn_delay()

const sc_core::sc_time & InitiatorTester::get_last_txn_delay ( ) const
inline

Get the delay value resulting of the last b_transport call.

Returns
the delay value resulting of the last b_transport call

◆ set_next_txn_delay()

void InitiatorTester::set_next_txn_delay ( const sc_core::sc_time &  delay)
inline

Set the delay value to use for the next b_transport call.

Parameters
[in]delayThe delay value to use for the next b_transport call

The documentation for this class was generated from the following file: