X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fvisitor%2Fhdsd%2Fscd%2Fscd_simulator.h;fp=dol%2Fsrc%2Fdol%2Fvisitor%2Fhdsd%2Fscd%2Fscd_simulator.h;h=48b4b3ff9d78839505cc810cc66b15e7cc23ae63;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/visitor/hdsd/scd/scd_simulator.h b/dol/src/dol/visitor/hdsd/scd/scd_simulator.h new file mode 100644 index 0000000..48b4b3f --- /dev/null +++ b/dol/src/dol/visitor/hdsd/scd/scd_simulator.h @@ -0,0 +1,118 @@ +#ifndef SCD_SIMULATOR_H +#define SCD_SIMULATOR_H + +#include +#include + +#include "scd_sock_poller.h" +#include "scd_chan_man.h" +#include "scd_cont_man.h" + + +/* forward declaration */ +class scd_chan_man; +class scd_cont_man_if; + + +/** + * Simulator to run a distributed SystemC simulation. First the + * channel with remote endpoints, the slave controllers and the + * master controller have to be registered with the channel manager + * and the control manager. Second the simulation has to be + * initialized and third the simulation can be started. + */ +class scd_simulator +{ +public: + + /** + * Constructor. Binds the simulator to the specified TCP port + * only on the specified network interface. + * \param name the name of this simulator + * \param loc_host IP or domain name of the interface to bind to + * \param loc_port TCP port to bind to + * \bool master SCD_MASTER if this simulator is the master, else + * SCD_SLAVE + */ + scd_simulator(const std::string& name, const std::string &loc_host, + uint16_t loc_port, bool master); + + /** + * Constructor. Binds the simulator to the specified TCP port on all + * available network interfaces. + * \param name the name of this simulator + * \param loc_port TCP port to bind to + * \bool master SCD_MASTER if this simulator is the master, else + * SCD_SLAVE + */ + scd_simulator(const std::string& name, uint16_t loc_port, bool master); + + virtual ~scd_simulator(); + + + /** + * Returns the name of this simulator. + */ + const std::string& get_name() const; + + /** + * Returns the socket poller of this simulation. + */ + scd_sock_poller& get_poller(); + + /** + * Returns the channel manager of this simulation. + */ + scd_chan_man& get_chan_man(); + + /** + * Returns the control manager of this simulation. + */ + scd_cont_man& get_cont_man(); + + /** + * Initializes the distributed simulation. Connects all remote channels + * and the control infrastructure. The channels, the slaves and the master + * have to be registered before initializating. A simulation can only + * be initialized once. + */ + bool init(); + + /** + * Runs the simulation until an error occures or no more events + * exist globally. A simulation can only be started once. + */ + bool start(); + + +private: + scd_sock_poller* _poller; + scd_chan_man* _chan_man; + scd_cont_man* _cont_man; + + std::string _name; + std::string _loc_host; + uint16_t _loc_port; + + /* member functions */ + + /** + * Indicates if events exist for the current simulation time. + * \return true if events exist for the current time + */ + bool _pending_now(); + + /** + * Indicates if events exist in the event queues. + * \return true if events exist + */ + bool _pending(); + + /** + * Returns the absolute time of the next event in the queues. + * \retunrs the absoulte time of the next event or 0 if no such event exists + */ + const sc_core::sc_time _next_time(); +}; + +#endif