X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fvisitor%2Fhdsd%2Fscd%2Fscd_cont_slave_wrapper.h;fp=dol%2Fsrc%2Fdol%2Fvisitor%2Fhdsd%2Fscd%2Fscd_cont_slave_wrapper.h;h=882f9ac87fc4d0586f850fb46141e01ff2f8dc6c;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/visitor/hdsd/scd/scd_cont_slave_wrapper.h b/dol/src/dol/visitor/hdsd/scd/scd_cont_slave_wrapper.h new file mode 100644 index 0000000..882f9ac --- /dev/null +++ b/dol/src/dol/visitor/hdsd/scd/scd_cont_slave_wrapper.h @@ -0,0 +1,142 @@ +#ifndef SCD_CONT_SLAVE_WRAPPER_H +#define SCD_CONT_SLAVE_WRAPPER_H + +#include "scd_simulator.h" +#include "scd_socket.h" +#include "scd_command_writer.h" +#include "scd_command_reader.h" +#include "scd_cont_man.h" +#include "scd_sock_poller.h" +#include "fsm/scd_cont_fsm.h" +#include "fsm/scd_cont_wrapper_if.h" + +#include "fsm/scd_stsw_init.h" +#include "fsm/scd_stsw_busy.h" +#include "fsm/scd_stsw_idle.h" +#include "fsm/scd_stsw_done.h" +#include "fsm/scd_stsw_time_req.h" +#include "fsm/scd_stsw_time_ack.h" +#include "fsm/scd_stsw_term_req.h" +#include "fsm/scd_stsw_term_ack.h" +#include "fsm/scd_stsw_terminate.h" +#include "fsm/scd_stsw_terminated.h" +#include "fsm/scd_stsw_fail.h" +#include "fsm/scd_stsw_failed.h" + +/** + * Control manager wrapper for a slave. Reflects the masters view of the + * slaves state. + */ +class scd_cont_slave_wrapper : public scd_cont_fsm_if, public scd_cont_fsm, + public scd_cont_wrapper_if, public scd_sock_ev_handler_if +{ + friend class scd_stsw_base; + +public: + /** + * Constructor. + * \param sim the simulation environment + * \param name the name of the slave + */ + scd_cont_slave_wrapper(scd_simulator& sim, const std::string& name); + + virtual ~scd_cont_slave_wrapper(); + + /** + * Returns the name of the slave. + */ + const std::string& get_name() const; + + /** + * Sets the socket of the slave. + * \param sock the connection to the slave + */ + void connect(scd_socket* sock); + + /** + * Sends a command to the slave. + */ + void send_command(scd_command* cmd); + + /** + * Indicates if a command is being sent to the slave. + * \return true if a command is still being sent + */ + bool is_sending() const; + + /** + * Closes the connection to the slave. + */ + void close(); + + /* scd_cont_slave_wrapper_if */ + void send_time_req() + { return static_cast(_state)->send_time_req(); } + void send_time_nack() + { return static_cast(_state)->send_time_nack(); } + void send_time(const sc_core::sc_time& time) + { return static_cast(_state)->send_time(time); } + void send_term_req() + { return static_cast(_state)->send_term_req(); } + void send_term_nack() + { return static_cast(_state)->send_term_nack(); } + void send_term() + { return static_cast(_state)->send_term(); } + bool time_req() const + { return static_cast(_state)->time_req(); } + bool time_ack() const + { return static_cast(_state)->time_ack(); } + bool term_req() const + { return static_cast(_state)->term_req(); } + bool term_ack() const + { return static_cast(_state)->term_ack(); } + bool idle() const + { return static_cast(_state)->idle(); } + bool done() const + { return static_cast(_state)->done(); } + + /* scd_cont_fsm_if */ + void set_busy() { return _state->set_busy(); } + void set_idle(const sc_core::sc_time& t) { return _state->set_idle(t); } + void set_done() { return _state->set_done(); } + void set_fail() { return _state->set_fail(); } + void process() { return _state->process(); } + bool active() const { return _state->active(); } + bool busy() const { return _state->busy(); } + bool failed() const { return _state->failed(); } + bool advance_time() const { return _state->advance_time(); } + const sc_core::sc_time& get_time_step() { return _state->get_time_step(); } + + /* scd_sock_ev_handler_if */ + void handle_sock_ev(sock_ev events); + const scd_socket& get_sock(); + +private: + scd_simulator& _sim; + std::string _name; + bool _is_connected; + + scd_socket* _socket; + scd_command_writer _writer; + scd_command_reader _reader; + sc_core::sc_time _time_step; + + /* states */ + scd_stsw_init _st_init; + scd_stsw_busy _st_busy; + scd_stsw_idle _st_idle; + scd_stsw_done _st_done; + scd_stsw_time_req _st_time_req; + scd_stsw_time_ack _st_time_ack; + scd_stsw_term_req _st_term_req; + scd_stsw_term_ack _st_term_ack; + scd_stsw_terminate _st_terminate; + scd_stsw_terminated _st_terminated; + scd_stsw_fail _st_fail; + scd_stsw_failed _st_failed; + + /* member functions */ + void _process_cmd(const scd_command& cmd); +}; + +#endif