8 using sc_core::sc_prim_channel;
10 #include "scd_simulator.h"
11 #include "scd_command.h"
12 #include "scd_chan_wrapper.h"
13 #include "scd_out_connector.h"
16 /* forward declaration */
17 class scd_out_connector;
18 class scd_chan_wrapper;
22 * The channel manager holds all remote channels. The channels have
23 * to be registered before the simulator is initiated. The channel
24 * manager will then initiate connections to other simulators
25 * and will handle channels from incomming connections.
26 * During simulation data is sent from the channel output buffers
27 * to remote hosts and data is received and stored in the input buffers.
28 * The channel implementation will then generate events to resume
29 * simulation processes.
36 * \param sim the simulator
38 scd_chan_man(scd_simulator &sim);
40 virtual ~scd_chan_man();
43 * Registers a remote channel with master endpoint on this host.
44 * Another host will initiate the connection and the channel will
45 * be connected by an in-connector calling connect_channel().
46 * \param name the name of the remote channel
47 * \param mchan the SystemC channel implementing the
48 * remote-in and/or the remote-out interface.
50 void register_channel(const std::string &name, sc_prim_channel& mchan);
53 * Registers a remote channel with slave endpoint on this host.
54 * This host will initiate the connection to the host with the
55 * master endpoint. To drive this process init_process() has to
56 * be called periodically.
57 * \param name the name of the remote channel
58 * \param mchan the SystemC channel implementing the
59 * remote-in and/or the remote-out interface.
60 * \param host the FQDN or IP address of the remote simulator
61 * with the master endpoint of the channel
62 * \param port TCP port of the remote simulator
64 void register_channel(const std::string &name, sc_prim_channel& schan,
65 const std::string &host, const uint16_t port);
67 * Drives the initialization process. Restarts outgoing connection
68 * attempts to connect channels to other simulators if previous
69 * attempts have timed out. ready() indicates the end of the
75 * Connects a channel from an incomming connection. Is intended to be
76 * called from an in-connector.
77 * \param c the register command received by the in-connector (contains
79 * \param sock the socket of the incoming connection that is used
82 void connect_channel(const scd_command &c, scd_socket* sock);
85 * Indicates if all clients have been connected.
86 * \return true if the channel manager completed initialization
91 * Checks if channels have data in the output buffers and activates
92 * the transmission if necessary. Receiption is resumed if the input
93 * buffer can accept data again. Call this function after each
94 * simulation step (which might fill data into the buffers that has
100 * Closes all channels.
105 /* member variables */
107 std::list<scd_chan_wrapper*> _channels;
108 std::list<scd_out_connector*> _connectors;
112 /* member functions */
114 scd_chan_wrapper* _get_channel(const std::string& name);