To pass user-defined datatypes into SystemC channels templates requires these datatypes to be defined as a class that implements also different kind of operators <<
, =
, ==
.
I need to define a sc_fifo
such as:
sc_fifo<route_t>
For this to be correct, route_t
datatype has to be written as in the below example.
class route_t
{
public:
route_dir_t route_dir;
unsigned int vc_index;
// methods allowing the structure to be passed into SystemC channels
// constructor
route_t(route_dir_t _route_dir, unsigned int _vc_index) {
route_dir = _route_dir;
vc_index = _vc_index;
}
inline bool operator == (const route_t& _route) const {
return (route_dir == _route.route_dir && vc_index == _route.vc_index);
}
inline route_t& operator = (const route_t& _route) {
route_dir = _route.route_dir;
vc_index = _route.vc_index;
return *this;
}
}; // end class route_t
- Why does SystemC require such an implementation?
- Why does the
operator=
need to return a reference to the object itself? It just updates the internal members. - Can the datatype be defined as a
struct
instead with internal methods implementing the required operators? - Why is
inline
used in this context? - How can returning
*this
be equivalent to returning a reference to the object as expected in the declaration of the method?