Jump to content

b_transport in class derived from simple_initiator_socket


Recommended Posts

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.

Link to comment
Share on other sites

This is a C++ issue and not SystemC/TLM itself.

A few suggestions, which may help with further issues:

  1. Consider trying JetBrains CLion as an IDE
  2. If asking for help with code that you can share, put it on EDAplayground and share the link (totally free)
  3. 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...

Link to comment
Share on other sites

  • 2 weeks later...

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

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...