1 #ifndef SCD_CONT_SLAVE_WRAPPER_H
2 #define SCD_CONT_SLAVE_WRAPPER_H
4 #include "scd_simulator.h"
5 #include "scd_socket.h"
6 #include "scd_command_writer.h"
7 #include "scd_command_reader.h"
8 #include "scd_cont_man.h"
9 #include "scd_sock_poller.h"
10 #include "fsm/scd_cont_fsm.h"
11 #include "fsm/scd_cont_wrapper_if.h"
13 #include "fsm/scd_stsw_init.h"
14 #include "fsm/scd_stsw_busy.h"
15 #include "fsm/scd_stsw_idle.h"
16 #include "fsm/scd_stsw_done.h"
17 #include "fsm/scd_stsw_time_req.h"
18 #include "fsm/scd_stsw_time_ack.h"
19 #include "fsm/scd_stsw_term_req.h"
20 #include "fsm/scd_stsw_term_ack.h"
21 #include "fsm/scd_stsw_terminate.h"
22 #include "fsm/scd_stsw_terminated.h"
23 #include "fsm/scd_stsw_fail.h"
24 #include "fsm/scd_stsw_failed.h"
27 * Control manager wrapper for a slave. Reflects the masters view of the
30 class scd_cont_slave_wrapper : public scd_cont_fsm_if, public scd_cont_fsm,
31 public scd_cont_wrapper_if, public scd_sock_ev_handler_if
33 friend class scd_stsw_base;
38 * \param sim the simulation environment
39 * \param name the name of the slave
41 scd_cont_slave_wrapper(scd_simulator& sim, const std::string& name);
43 virtual ~scd_cont_slave_wrapper();
46 * Returns the name of the slave.
48 const std::string& get_name() const;
51 * Sets the socket of the slave.
52 * \param sock the connection to the slave
54 void connect(scd_socket* sock);
57 * Sends a command to the slave.
59 void send_command(scd_command* cmd);
62 * Indicates if a command is being sent to the slave.
63 * \return true if a command is still being sent
65 bool is_sending() const;
68 * Closes the connection to the slave.
72 /* scd_cont_slave_wrapper_if */
74 { return static_cast<scd_stsw_base*>(_state)->send_time_req(); }
76 { return static_cast<scd_stsw_base*>(_state)->send_time_nack(); }
77 void send_time(const sc_core::sc_time& time)
78 { return static_cast<scd_stsw_base*>(_state)->send_time(time); }
80 { return static_cast<scd_stsw_base*>(_state)->send_term_req(); }
82 { return static_cast<scd_stsw_base*>(_state)->send_term_nack(); }
84 { return static_cast<scd_stsw_base*>(_state)->send_term(); }
86 { return static_cast<scd_stsw_base*>(_state)->time_req(); }
88 { return static_cast<scd_stsw_base*>(_state)->time_ack(); }
90 { return static_cast<scd_stsw_base*>(_state)->term_req(); }
92 { return static_cast<scd_stsw_base*>(_state)->term_ack(); }
94 { return static_cast<scd_stsw_base*>(_state)->idle(); }
96 { return static_cast<scd_stsw_base*>(_state)->done(); }
99 void set_busy() { return _state->set_busy(); }
100 void set_idle(const sc_core::sc_time& t) { return _state->set_idle(t); }
101 void set_done() { return _state->set_done(); }
102 void set_fail() { return _state->set_fail(); }
103 void process() { return _state->process(); }
104 bool active() const { return _state->active(); }
105 bool busy() const { return _state->busy(); }
106 bool failed() const { return _state->failed(); }
107 bool advance_time() const { return _state->advance_time(); }
108 const sc_core::sc_time& get_time_step() { return _state->get_time_step(); }
110 /* scd_sock_ev_handler_if */
111 void handle_sock_ev(sock_ev events);
112 const scd_socket& get_sock();
120 scd_command_writer _writer;
121 scd_command_reader _reader;
122 sc_core::sc_time _time_step;
125 scd_stsw_init _st_init;
126 scd_stsw_busy _st_busy;
127 scd_stsw_idle _st_idle;
128 scd_stsw_done _st_done;
129 scd_stsw_time_req _st_time_req;
130 scd_stsw_time_ack _st_time_ack;
131 scd_stsw_term_req _st_term_req;
132 scd_stsw_term_ack _st_term_ack;
133 scd_stsw_terminate _st_terminate;
134 scd_stsw_terminated _st_terminated;
135 scd_stsw_fail _st_fail;
136 scd_stsw_failed _st_failed;
138 /* member functions */
139 void _process_cmd(const scd_command& cmd);