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

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

#include <target-tester.h>

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

Public Types

using TlmGenericPayload = tlm::tlm_generic_payload
 
using TlmResponseStatus = tlm::tlm_response_status
 
using TlmDmi = tlm::tlm_dmi
 
using AccessCallbackFn = std::function< TlmResponseStatus(uint64_t addr, uint8_t *data, size_t len)>
 
using DebugAccessCallbackFn = std::function< int(uint64_t addr, uint8_t *data, size_t len)>
 
using GetDirectMemPtrCallbackFn = std::function< bool(uint64_t addr, TlmDmi &)>
 

Public Member Functions

 TargetTester (const sc_core::sc_module_name &n, size_t mmio_size)
 Construct a TargetTester object with a name and an MMIO size.
 
void register_read_cb (AccessCallbackFn cb)
 Register callback called on b_tranport read transaction.
 
void register_write_cb (AccessCallbackFn cb)
 Register callback called on b_tranport write transaction.
 
void register_debug_read_cb (DebugAccessCallbackFn cb)
 Register callback called on transport_dbg read transaction.
 
void register_debug_write_cb (DebugAccessCallbackFn cb)
 Register callback called on transport_dbg write transaction.
 
void register_get_direct_mem_ptr_cb (GetDirectMemPtrCallbackFn cb)
 Register a callback called on a get_direct_mem_ptr call.
 
bool last_txn_is_valid () const
 Return true if the copy of the last transaction is valid.
 
const TlmGenericPayload & get_last_txn ()
 Return a copy of the last transaction payload.
 
const sc_core::sc_time & get_last_txn_delay ()
 Return a copy of the last transaction delay value.
 
TlmGenericPayload & get_cur_txn ()
 Get the current transaction payload.
 
sc_core::sc_time & get_cur_txn_delay ()
 Get the current transaction delay.
 

Public Attributes

tlm_utils::simple_target_socket< TargetTester, DEFAULT_TLM_BUSWIDTH > socket
 

Protected Member Functions

virtual void b_transport (TlmGenericPayload &txn, sc_core::sc_time &delay)
 
virtual unsigned int transport_dbg (TlmGenericPayload &txn)
 
virtual bool get_direct_mem_ptr (TlmGenericPayload &txn, TlmDmi &dmi_data)
 

Detailed Description

A TLM target to do testing on an initiator.

This class allows to test an initiator by providing helpers to standard TLM operations. The class user can register various callbacks for classical TLM forward path calls. The goal of those callback is to provide an easy mean of accessing most often used data in the callback parameters directly. The complete payload of the current transaction is still accessible using the get_cur_txn(_delay) method.

When not registering any callbacks, this class behaves as a dummy target, responding correctly to transactions with the following behaviour:

Regular TLM forward calls can be overriden when inheriting this class if one need fine control over the transaction. However, Be aware that by doing so, you'll loose the helpers functionnality of this class.

Constructor & Destructor Documentation

◆ TargetTester()

TargetTester::TargetTester ( const sc_core::sc_module_name &  n,
size_t  mmio_size 
)
inline

Construct a TargetTester object with a name and an MMIO size.

Parameters
[in]nThe name of the SystemC module
[in]mmio_sizeThe size of the memory mapped I/O region of this component

Member Function Documentation

◆ get_cur_txn()

TlmGenericPayload & TargetTester::get_cur_txn ( )
inline

Get the current transaction payload.

This method returns the payload of the transaction in progress. It must be could from within a transaction callback only. The transaction payload can be altered if needed.

Returns
the current transaction payload

◆ get_cur_txn_delay()

sc_core::sc_time & TargetTester::get_cur_txn_delay ( )
inline

Get the current transaction delay.

This method returns the delay value of the transaction in progress. It must be could from within a transaction callback only. The transaction delay can be altered if needed.

Returns
the current transaction delay

◆ get_last_txn()

const TlmGenericPayload & TargetTester::get_last_txn ( )
inline

Return a copy of the last transaction payload.

@detail This method returns an internal copy of the last transaction payload. An internal flag checks whether the payload is valid or not. Calling this method actually reset the flag so calling it two time in a row will trigger a test failure. This ensures that you actually got the transaction you expected to get.

◆ get_last_txn_delay()

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

Return a copy of the last transaction delay value.

@detail This method returns an internal copy of the last transaction delay value. An internal flag checks whether the delay value is valid or not. Calling this method actually reset the flag so calling it two time in a row will trigger a test failure. This ensures that you actually got the transaction you expected to get.

◆ last_txn_is_valid()

bool TargetTester::last_txn_is_valid ( ) const
inline

Return true if the copy of the last transaction is valid.

@detail This method can be used to check whether this target effectively received a transaction or not. It will return true if the internal copy of the last transaction is valid. Note that this flag is reset when calling the get_last_txn method.

Returns
true if the copy of the last transaction is valid

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