1 #include "scd_command.h"
7 scd_command::scd_command(): _type(0), _subtype(0), _msglen(0)
13 scd_command::scd_command(uint16_t type, uint16_t subtype):
14 _type(type), _subtype(subtype), _msglen(0)
20 scd_command::scd_command(uint16_t type, uint16_t subtype,
21 const std::string& msg):
22 _type(type), _subtype(subtype)
26 _msglen = msg.length()+1;
27 _msg = new char[_msglen];
28 strncpy(_msg, msg.c_str(), _msglen);
39 scd_command::scd_command(uint16_t type, uint16_t subtype,
40 const sc_core::sc_time& time) : _type(type), _subtype(subtype)
46 _msg = new char[_msglen];
48 // obtain high and low words
50 lo = value & 0xFFFFFFFF;
52 hi = value & 0xFFFFFFFF;
54 // do network conversion
60 memcpy(_msg + 4, &lo, 4);
65 scd_command::~scd_command()
72 uint16_t scd_command::get_type() const { return _type; }
75 uint16_t scd_command::get_subtype() const { return _subtype; }
78 std::string scd_command::get_string() const
83 return std::string(_msg, _msglen-1);
87 sc_core::sc_time scd_command::get_time() const
90 return sc_core::SC_ZERO_TIME;
95 // get value from buffer
97 memcpy(&lo, _msg+4, 4);
99 // do network conversion
104 return sc_core::sc_time(value, false);