40struct tcp4tlm_server :
public sc_core::sc_module,
protected tcp4tlm::server<tcp4tlm::request_message, tcp4tlm::response_message> {
41 SC_HAS_PROCESS(tcp4tlm_server);
43 cci::cci_param<unsigned> this_host_port{
"this_host_port", 32000u};
44 cci::cci_param<bool> wall_time_simulation_speed{
"wall_time_simulation_speed",
false};
45 cci::cci_param<bool> write_no_response{
"write_no_response",
false};
46 cci::cci_param<bool> no_systemc_sync{
"no_systemc_sync",
false};
48 tlm_utils::simple_initiator_socket<tcp4tlm_server, ::scc::LT> isckt;
50 sc_core::sc_vector<sc_core::sc_out<bool>> signals{
"signals"};
52 tcp4tlm_server(sc_core::sc_module_name name,
size_t no_of_ports = 0);
54 virtual ~tcp4tlm_server();
57 typedef std::shared_ptr<connection_type> con_ptr;
59 void server_send_completed(con_ptr& con,
bool established =
false)
override {
65 void server_receive_completed(con_ptr& con,
const tcp4tlm::request_message*
const result)
override;
68 using namespace std::chrono_literals;
69 server::start_server(this_host_port.get_value());
72 void wait4connection() {
73 using namespace std::chrono_literals;
75 std::unique_lock<std::mutex> lock(con_est_mtx);
76 while(!con_est.load())
77 con_est_sig.wait_for(lock, 100ms, [
this]() {
return con_est.load(); });
80 bool is_connection_established() {
return con_est; }
82 sc_core::sc_event
const& get_shutdown_event()
const {
return shutdown_evt; }
85 using callback_task = std::packaged_task<bool(
void)>;
88 sc_core::sc_time timepoint;
92 std::mutex con_est_mtx;
93 std::condition_variable con_est_sig;
94 std::atomic<bool> con_est{
false};
95 sc_core::sc_event shutdown_evt;
97 unsigned long long sync;
99 void process_task_que();
100 void process_timed_task_que();
101 void start_of_simulation()
override;
102 void end_of_simulation()
override;
103 std::shared_ptr<tcp4tlm::response_message> resp_msg;
104 tlm_utils::tlm_quantumkeeper quantumkeeper;
108 tlm::scc::tlm_gp_shared_ptr init_gp(
const tcp4tlm::BusOpMsg*
const msg);
109#ifdef BOOST_ASIO_HAS_LOCAL_SOCKETS
110 tcp4tlm::request_message get_notify_endpoint_msg(boost::asio::local::stream_protocol::endpoint& ep) {
111 return tcp4tlm::make_notify_endpoint_msg(ep.path(), 0);
114 tcp4tlm::request_message get_notify_endpoint_msg(boost::asio::ip::tcp::endpoint& ep) {
115 boost::asio::ip::address addr = ep.address();
116 return tcp4tlm::make_notify_endpoint_msg(addr.is_unspecified() ? boost::asio::ip::host_name() : addr.to_string(), ep.port());
118#ifdef GENERATE_STATISTICS
119 std::vector<unsigned long> rtto, txt, rxt;
123 std::vector<unsigned long> histogram;
124 unsigned long min, max;
125 unsigned long long sum;
126 tlm_genip::addr_decoder_if& indexer;
128 bool print_histogram;
129 statistics(tlm_genip::addr_decoder_if& indexer_,
size_t hsize,
unsigned long initval)
130 : histogram(hsize, 0)
136 , print_histogram(false) {}
137 void updateStat(
unsigned long rt);