scc 2026.07
SystemC components library
scc::tcp4tlm_bridge Struct Reference

Bidirectional bridge for tunneling loosely timed TLM traffic over a TCP connection. More...

#include <tcp4tlm_bridge.h>

Inheritance diagram for scc::tcp4tlm_bridge:
Collaboration diagram for scc::tcp4tlm_bridge:

Classes

struct  timed_task

Public Types

typedef tcp4tlm::connection< tcp4tlm::response_message, tcp4tlm::request_message > connection_type
typedef std::shared_ptr< connection_type > con_ptr

Public Member Functions

 SC_HAS_PROCESS (tcp4tlm_bridge)
 tcp4tlm_bridge (sc_core::sc_module_name name, size_t no_of_ports=0)
void server_send_completed (con_ptr &con, bool established=false) override
void server_receive_completed (con_ptr &con, const tcp4tlm::request_message *const result) override
void start_server ()
void wait4connection ()
bool is_connection_established ()
void end_connection ()
sc_core::sc_event const & get_shutdown_event () const

Public Attributes

cci::cci_param< bool > is_connection_server {"is_connection_server", false}
cci::cci_param< std::string > other_host_name {"other_host_name", ""}
cci::cci_param< unsigned > other_host_port {"other_host_port", 0}
cci::cci_param< unsigned > this_host_port {"this_host_port", 32000u}
cci::cci_param< bool > wall_time_simulation_speed {"wall_time_simulation_speed", false}
cci::cci_param< bool > write_no_response {"write_no_response", false}
cci::cci_param< bool > no_systemc_sync {"no_systemc_sync", false}
tlm_utils::simple_target_socket< tcp4tlm_bridge, ::scc::LT > tsckt
tlm_utils::simple_initiator_socket< tcp4tlm_bridge, ::scc::LT > isckt
sc_core::sc_vector< sc_core::sc_out< bool > > signals {"signals"}

Protected Types

using callback_task = std::packaged_task<bool(void)>

Protected Member Functions

void btransport_cb (tlm::tlm_generic_payload &, sc_core::sc_time &)
unsigned transport_dbg_cb (tlm::tlm_generic_payload &)
virtual void do_access (tlm::tlm_generic_payload &gp, sc_core::sc_time &delay, bool debug=false)
void timing_thread ()
void process_task_que ()
void process_timed_task_que ()
void end_of_elaboration () override
void start_of_simulation () override
void end_of_simulation () override
Protected Member Functions inherited from scc::tcp4tlm::server< tcp4tlm::request_message, tcp4tlm::response_message >
const connection< tcp4tlm::response_message, tcp4tlm::request_message >::acceptor_t & get_acceptor ()
 server (std::size_t thread_pool_size=4)
long set_acceptor_endpoint (std::shared_ptr< boost::asio::ip::tcp::acceptor > &a, unsigned short port)
void start_server (unsigned short port, char *name=NULL)
void request_shutdown ()
bool is_shutdown_requested ()
void shutdown_server ()
virtual boost::asio::io_context & get_io_service ()
bool is_server_running ()
void create_new_session ()
Protected Member Functions inherited from scc::tcp4tlm::i_server< tcp4tlm::request_message, tcp4tlm::response_message >
virtual void server_send_completed (std::shared_ptr< connection< tcp4tlm::response_message, tcp4tlm::request_message > > &con, bool established=false)=0
virtual void server_receive_completed (std::shared_ptr< connection< tcp4tlm::response_message, tcp4tlm::request_message > > &con, const tcp4tlm::request_message *const result)=0
Protected Member Functions inherited from scc::tcp4tlm::client< tcp4tlm::request_message, tcp4tlm::response_message >
void setup_endpoint (boost::asio::ip::tcp::endpoint &ep)
bool is_local_socket (boost::asio::ip::tcp::socket &socket)
void configure (std::string host, unsigned port_nr)
void connect ()
bool is_remote_connected ()
connection< tcp4tlm::request_message, tcp4tlm::response_message > & client_connection (unsigned short retry_count=0)

Protected Attributes

scc::async_queue< timed_tasktask_que
scc::peq< callback_task > timed_task_que
std::mutex con_est_mtx
std::condition_variable con_est_sig
std::atomic< bool > con_est {false}
sc_core::sc_event shutdown_evt
rigtorp::SPSCQueue< sc_core::sc_time > next_time_stamp
unsigned long long sync
std::shared_ptr< tcp4tlm::response_message > resp_msg
tlm_utils::tlm_quantumkeeper quantumkeeper
tlm::scc::tlm_mm< tlm::tlm_base_protocol_types, false > mm
Protected Attributes inherited from scc::tcp4tlm::client< tcp4tlm::request_message, tcp4tlm::response_message >
std::string host
unsigned short port
unsigned short retry_count
boost::asio::io_context io_service
connection< tcp4tlm::request_message, tcp4tlm::response_message >::ptr trace_conn
std::atomic< bool > is_connected
bool local_connection

Detailed Description

Bidirectional bridge for tunneling loosely timed TLM traffic over a TCP connection.

The bridge is both a SystemC/TLM component and a TCP endpoint. Its target socket accepts local TLM generic payloads and serializes them into tcp4tlm FlatBuffer messages which are sent to a peer bridge. Conversely, incoming BusOpMsg requests are converted back into TLM generic payloads, scheduled in SystemC time, and forwarded through the initiator socket to the local model.

Two bridge instances form a bidirectional connection. Depending on the is_connection_server parameter, an instance either waits for a peer endpoint notification or actively connects to the configured peer and sends its own listening endpoint via NotifyEndpointMsg. Once connected, the bridge exchanges BusOpMsg, BusDataMsg, response, SyncMsg, SigOpMsg, and NotifyShutdownMsg messages to carry bus accesses, read data, status responses, simulation time synchronization, signal updates, and orderly shutdown.

TLM reads wait for a BusDataMsg response and copy the returned data into the original payload. TLM writes send the payload data and either wait for a status response or complete immediately when write_no_response is enabled. Debug transport is represented as a BusOpMsg with debug access type.

The timing threads coordinate message execution with SystemC simulation time. In simulated-time mode, remote timestamps drive local advancement. In wall-time mode, the bridge can pace simulation against elapsed wall clock time. The no_systemc_sync parameter bypasses timestamp-based task scheduling.

Definition at line 69 of file tcp4tlm_bridge.h.

Member Typedef Documentation

◆ callback_task

using scc::tcp4tlm_bridge::callback_task = std::packaged_task<bool(void)>
protected

Definition at line 127 of file tcp4tlm_bridge.h.

◆ con_ptr

typedef std::shared_ptr<connection_type> scc::tcp4tlm_bridge::con_ptr

Definition at line 97 of file tcp4tlm_bridge.h.

◆ connection_type

typedef tcp4tlm::connection<tcp4tlm::response_message, tcp4tlm::request_message> scc::tcp4tlm_bridge::connection_type

Definition at line 96 of file tcp4tlm_bridge.h.

Constructor & Destructor Documentation

◆ tcp4tlm_bridge()

scc::tcp4tlm_bridge::tcp4tlm_bridge ( sc_core::sc_module_name name,
size_t no_of_ports = 0 )

Definition at line 40 of file tcp4tlm_bridge.cpp.

◆ ~tcp4tlm_bridge()

scc::tcp4tlm_bridge::~tcp4tlm_bridge ( )
virtual

Definition at line 90 of file tcp4tlm_bridge.cpp.

Member Function Documentation

◆ btransport_cb()

void scc::tcp4tlm_bridge::btransport_cb ( tlm::tlm_generic_payload & gp,
sc_core::sc_time & delay )
protected

Definition at line 175 of file tcp4tlm_bridge.cpp.

◆ do_access()

void scc::tcp4tlm_bridge::do_access ( tlm::tlm_generic_payload & gp,
sc_core::sc_time & delay,
bool debug = false )
protectedvirtual

Definition at line 177 of file tcp4tlm_bridge.cpp.

◆ end_connection()

void scc::tcp4tlm_bridge::end_connection ( )
inline

Definition at line 200 of file tcp4tlm_bridge.h.

◆ end_of_elaboration()

void scc::tcp4tlm_bridge::end_of_elaboration ( )
overrideprotected

Definition at line 101 of file tcp4tlm_bridge.cpp.

◆ end_of_simulation()

void scc::tcp4tlm_bridge::end_of_simulation ( )
overrideprotected

Definition at line 128 of file tcp4tlm_bridge.cpp.

◆ get_shutdown_event()

sc_core::sc_event const & scc::tcp4tlm_bridge::get_shutdown_event ( ) const
inline

Definition at line 124 of file tcp4tlm_bridge.h.

◆ is_connection_established()

bool scc::tcp4tlm_bridge::is_connection_established ( )
inline

Definition at line 120 of file tcp4tlm_bridge.h.

◆ process_task_que()

void scc::tcp4tlm_bridge::process_task_que ( )
protected

Definition at line 457 of file tcp4tlm_bridge.cpp.

◆ process_timed_task_que()

void scc::tcp4tlm_bridge::process_timed_task_que ( )
protected

Definition at line 473 of file tcp4tlm_bridge.cpp.

◆ server_receive_completed()

void scc::tcp4tlm_bridge::server_receive_completed ( con_ptr & con,
const tcp4tlm::request_message *const result )
override

Definition at line 343 of file tcp4tlm_bridge.cpp.

◆ server_send_completed()

void scc::tcp4tlm_bridge::server_send_completed ( con_ptr & con,
bool established = false )
inlineoverride

Definition at line 99 of file tcp4tlm_bridge.h.

◆ start_of_simulation()

void scc::tcp4tlm_bridge::start_of_simulation ( )
overrideprotected

Definition at line 106 of file tcp4tlm_bridge.cpp.

◆ start_server()

void scc::tcp4tlm_bridge::start_server ( )
inline

Definition at line 107 of file tcp4tlm_bridge.h.

◆ timing_thread()

void scc::tcp4tlm_bridge::timing_thread ( )
protected

Definition at line 263 of file tcp4tlm_bridge.cpp.

◆ transport_dbg_cb()

unsigned scc::tcp4tlm_bridge::transport_dbg_cb ( tlm::tlm_generic_payload & gp)
protected

Definition at line 169 of file tcp4tlm_bridge.cpp.

◆ wait4connection()

void scc::tcp4tlm_bridge::wait4connection ( )
inline

Definition at line 112 of file tcp4tlm_bridge.h.

Member Data Documentation

◆ con_est

std::atomic<bool> scc::tcp4tlm_bridge::con_est {false}
protected

Definition at line 136 of file tcp4tlm_bridge.h.

◆ con_est_mtx

std::mutex scc::tcp4tlm_bridge::con_est_mtx
protected

Definition at line 134 of file tcp4tlm_bridge.h.

◆ con_est_sig

std::condition_variable scc::tcp4tlm_bridge::con_est_sig
protected

Definition at line 135 of file tcp4tlm_bridge.h.

◆ is_connection_server

cci::cci_param<bool> scc::tcp4tlm_bridge::is_connection_server {"is_connection_server", false}

this governs the sequence of connection:

  • if false: it first starts the server, connects to remote and sends a NotifyEndpointMsg
  • if true: it starts the server, waits for a NotifyEndpointMsg and then connects the client

Definition at line 78 of file tcp4tlm_bridge.h.

◆ isckt

tlm_utils::simple_initiator_socket<tcp4tlm_bridge, ::scc::LT> scc::tcp4tlm_bridge::isckt

Definition at line 88 of file tcp4tlm_bridge.h.

◆ mm

tlm::scc::tlm_mm<tlm::tlm_base_protocol_types, false> scc::tcp4tlm_bridge::mm
protected

Definition at line 151 of file tcp4tlm_bridge.h.

◆ next_time_stamp

rigtorp::SPSCQueue<sc_core::sc_time> scc::tcp4tlm_bridge::next_time_stamp
protected

Definition at line 138 of file tcp4tlm_bridge.h.

◆ no_systemc_sync

cci::cci_param<bool> scc::tcp4tlm_bridge::no_systemc_sync {"no_systemc_sync", false}

Definition at line 84 of file tcp4tlm_bridge.h.

◆ other_host_name

cci::cci_param<std::string> scc::tcp4tlm_bridge::other_host_name {"other_host_name", ""}

Definition at line 79 of file tcp4tlm_bridge.h.

◆ other_host_port

cci::cci_param<unsigned> scc::tcp4tlm_bridge::other_host_port {"other_host_port", 0}

Definition at line 80 of file tcp4tlm_bridge.h.

◆ quantumkeeper

tlm_utils::tlm_quantumkeeper scc::tcp4tlm_bridge::quantumkeeper
protected

Definition at line 150 of file tcp4tlm_bridge.h.

◆ resp_msg

std::shared_ptr<tcp4tlm::response_message> scc::tcp4tlm_bridge::resp_msg
protected

Definition at line 149 of file tcp4tlm_bridge.h.

◆ shutdown_evt

sc_core::sc_event scc::tcp4tlm_bridge::shutdown_evt
protected

Definition at line 137 of file tcp4tlm_bridge.h.

◆ signals

sc_core::sc_vector<sc_core::sc_out<bool> > scc::tcp4tlm_bridge::signals {"signals"}

Definition at line 90 of file tcp4tlm_bridge.h.

◆ sync

unsigned long long scc::tcp4tlm_bridge::sync
protected

Definition at line 139 of file tcp4tlm_bridge.h.

◆ task_que

scc::async_queue<timed_task> scc::tcp4tlm_bridge::task_que
protected

Definition at line 132 of file tcp4tlm_bridge.h.

◆ this_host_port

cci::cci_param<unsigned> scc::tcp4tlm_bridge::this_host_port {"this_host_port", 32000u}

Definition at line 81 of file tcp4tlm_bridge.h.

◆ timed_task_que

scc::peq<callback_task> scc::tcp4tlm_bridge::timed_task_que
protected

Definition at line 133 of file tcp4tlm_bridge.h.

◆ tsckt

tlm_utils::simple_target_socket<tcp4tlm_bridge, ::scc::LT> scc::tcp4tlm_bridge::tsckt

Definition at line 86 of file tcp4tlm_bridge.h.

◆ wall_time_simulation_speed

cci::cci_param<bool> scc::tcp4tlm_bridge::wall_time_simulation_speed {"wall_time_simulation_speed", false}

Definition at line 82 of file tcp4tlm_bridge.h.

◆ write_no_response

cci::cci_param<bool> scc::tcp4tlm_bridge::write_no_response {"write_no_response", false}

Definition at line 83 of file tcp4tlm_bridge.h.


The documentation for this struct was generated from the following files: