X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fvisitor%2Fhdsd%2Fscd%2Fscd_command.h;fp=dol%2Fsrc%2Fdol%2Fvisitor%2Fhdsd%2Fscd%2Fscd_command.h;h=cbb3bedfa24294591e97b6ce02dea986dd00c0bf;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/visitor/hdsd/scd/scd_command.h b/dol/src/dol/visitor/hdsd/scd/scd_command.h new file mode 100644 index 0000000..cbb3bed --- /dev/null +++ b/dol/src/dol/visitor/hdsd/scd/scd_command.h @@ -0,0 +1,108 @@ +#ifndef SCD_COMMAND_H +#define SCD_COMMAND_H + +#include +#include +#include + +#include "systemc" + + +const size_t SCD_CM_MAXLEN = 512; +const size_t SCD_CM_HEADER = 3*2; + +/* command types */ +const uint16_t SCD_CM_REGISTER = 1; +const uint16_t SCD_CM_CONFIG = 2; +const uint16_t SCD_CM_CONTROL = 3; + +/* command subtypes */ +// register +const uint16_t SCD_CM_NETSIM = 1; +const uint16_t SCD_CM_CHANNEL = 2; +// control +const uint16_t SCD_CM_BUSY = 1; +const uint16_t SCD_CM_IDLE = 2; +const uint16_t SCD_CM_DONE = 3; +const uint16_t SCD_CM_FAILED = 4; +const uint16_t SCD_CM_TIME_REQ = 5; +const uint16_t SCD_CM_TIME_ACK = 6; +const uint16_t SCD_CM_TIME_NACK = 7; +const uint16_t SCD_CM_TIME = 8; +const uint16_t SCD_CM_TERM_REQ = 9; +const uint16_t SCD_CM_TERM_ACK = 10; +const uint16_t SCD_CM_TERM_NACK = 11; +const uint16_t SCD_CM_TERM = 12; + +/* forward declarations */ +class scd_command_reader; +class scd_command_writer; + + +/** + * Command class. Commands are control messages that are sent between + * the different simulators. A command has a type, a subtype and a potential + * message part. + */ +class scd_command +{ +friend class scd_command_reader; +friend class scd_command_writer; + +public: + /** + * Default constructor. Creates an empty command. + */ + scd_command(); + + /* + * Constructor. Creates a command with no message part. + * \param type the type of this command + * \param subtype the subtype of this command + */ + scd_command(uint16_t type, uint16_t subtype); + + /** + * Constructor. Creates a new command with a string as message + * part. + */ + scd_command(uint16_t type, uint16_t subtype, const std::string& msg); + + /** + * Constructor. Creates a new command with a SystemC time value as + * message part. + */ + scd_command(uint16_t type, uint16_t subtype, const sc_core::sc_time& time); + + virtual ~scd_command(); + + /** + * Returns the type of the command. + */ + uint16_t get_type() const; + + /** + * Returns the subtype of the command. + */ + uint16_t get_subtype() const; + + /** + * Returns the message part interpreted as a string. + */ + std::string get_string() const; + + /** + * Returns the message part interpreted as a SystemC time. + * If the message part does not have the correct size SC_ZERO_TIME + * is returned instead. + */ + sc_core::sc_time get_time() const; + +private: + uint16_t _type; + uint16_t _subtype; + uint16_t _msglen; + char* _msg; +}; + +#endif