Christian Posted June 21, 2023 Report Posted June 21, 2023 Hello, I tried to write a wrapper for a simple_initiator_socket. Therefore I derived from simple_initiator_socket. #ifndef SRC_MODELS_INC_INITIATORSOCKETWRAPPER_HPP_ #define SRC_MODELS_INC_INITIATORSOCKETWRAPPER_HPP_ #include "tlm.h" #include "tlm_utils/simple_initiator_socket.h" #include "tlm_utils/simple_target_socket.h" #include "SpdSyscLog.h" #include "addressSpace.hpp" using namespace sc_core; template<typename MODULE, unsigned int BUSWIDTH> class initiatorSocketWrapper: public tlm_utils::simple_initiator_socket<MODULE, BUSWIDTH>, public SpdSyscLog { private: bool initiate(tlm::tlm_command direction, uint16_t length, uint16_t addr, uint8_t* data) { sc_time delay(SC_ZERO_TIME); tlm::tlm_generic_payload trans; trans.set_command(direction); trans.set_data_length(length); trans.set_byte_enable_ptr(0); trans.set_streaming_width(trans.get_data_length()); // Streaming unused trans.set_address(addr); trans.set_data_ptr(data); trans.set_dmi_allowed(false); trans.set_response_status(tlm::TLM_INCOMPLETE_RESPONSE); this->b_transport(trans, delay); if (trans.is_response_error()) { LOG_ERROR("response: {}", trans.get_response_string().c_str()); return false; } return true; } public: initiatorSocketWrapper(const char* name) : tlm_utils::simple_initiator_socket<MODULE, BUSWIDTH>(name), SpdSyscLog(this->name()) { } bool write(int16_t length, uint16_t addr, uint16_t* data) { return initiate(tlm::TLM_WRITE_COMMAND, length, addr, reinterpret_cast<uint8_t*> (data)); } bool write(int16_t length, uint16_t addr, uint8_t* data) { return initiate(tlm::TLM_WRITE_COMMAND, length, addr, data); } bool read(int16_t length, uint16_t addr, uint16_t* data) { return initiate(tlm::TLM_READ_COMMAND, length, addr, reinterpret_cast<uint8_t*> (data)); } bool read(int16_t length, uint16_t addr, uint8_t* data) { return initiate(tlm::TLM_READ_COMMAND, length, addr, data); } }; #endif /* SRC_MODELS_INC_INITIATORSOCKETWRAPPER_HPP_ */ But now, I'm not able to call b_transport inside a method of this new class. The following error is shown: b_transport is not a member of initiatorSocketWrapper<..>::base_type {aka tlm_utils::simple_initiator_socket<..>} Any hint is highly appreciated. Many thanks in advance and kind regards. Quote
David Black Posted June 23, 2023 Report Posted June 23, 2023 This is a C++ issue and not SystemC/TLM itself. A few suggestions, which may help with further issues: Consider trying JetBrains CLion as an IDE If asking for help with code that you can share, put it on EDAplayground and share the link (totally free) Obtain more training in C++ Generally, C++ template classes can be trickier to debug than non-template classes. I always recommend developing at least one non-templated version before converting to templated. It often saves a ton of time. Something like: struct TestModule; //< forward declaration using MODULENAME = TestModule; static constexpr const int BUSWIDTH = 32; class initiatorSocketWrapper: public tlm_utils::simple_initiator_socket<MODULE, BUSWIDTH>, public SpdSyscLog { ... }; Once you work out the bugs there, convert back to templated... Quote
Christian Posted July 7, 2023 Author Report Posted July 7, 2023 Hello, many thanks for your answer. I'm anyway wondering, why b_transport should not be a member of initiatorSocketWrapper, since initiatorSocketWrapper is derived from simple_initiator_socket and should therefore inherit this method. But maybe b_transport is something else than a method, which I have overseen? Kind regards, Christian Quote
David Black Posted July 7, 2023 Report Posted July 7, 2023 b_transport is a fundamental method of TLM-2.0. Simple sockets implement this indirectly and require that you register your implementation. So you have to declare something with a similar interface in the class using them. Quote
Christian Posted July 7, 2023 Author Report Posted July 7, 2023 Hello, many thanks for the clarification. Kind regards, Christian Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.