<<
ユーザー定義のデータ型を SystemC チャネル テンプレートに渡すには、これらのデータ型を、さまざまな種類の演算子も実装するクラスとして定義する必要があり=
ます==
。
sc_fifo
次のように定義する必要があります。
sc_fifo<route_t>
これを正しく行うには、route_t
データ型を次の例のように記述する必要があります。
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
- SystemC がそのような実装を必要とするのはなぜですか?
operator=
オブジェクト自体への参照を返す必要があるのはなぜですか? 内部メンバーを更新するだけです。struct
必要な演算子を実装する内部メソッドを使用して、代わりにデータ型を a として定義できますか?- なぜ
inline
この文脈で使われるのですか? - メソッドの宣言で期待されるように、返すことはオブジェクトへの参照を返すこととどのよう
*this
に同等でしょうか?