0

I am trying to use TLM2 for a simulation project but for some reason I can't use b_transport the same way I see it used in other projects, here is the code snippet that doesn't build due to this error(error C2039 : 'b_transport' : is not a member of 'tlm_utils::simple_initiator_socket<Initiator,32,tlm::tlm_base_protocol_types>')

#include <systemc.h>
#include <tlm_utils/simple_target_socket.h>
#include <tlm_utils/simple_initiator_socket.h>

SC_MODULE(Memory) {
    tlm_utils::simple_target_socket<Memory> targetSocket;

    SC_CTOR(Memory) {
        targetSocket.register_b_transport(this, &BTransportCallback);
    }

    void BTransportCallback(tlm::tlm_generic_payload& payload, sc_time& delay) {
        // ...
    }
};

SC_MODULE(Initiator) {
    tlm_utils::simple_initiator_socket<Initiator> initiatorSocket;

    SC_CTOR(Initiator) {
    }
};

SC_MODULE(TopLevel) {
    Memory* memory;
    Initiator* initiator;

    SC_CTOR(TopLevel) {
        memory = new Memory("Memory");
        initiator = new Initiator("Initiator");

        initiator->initiatorSocket.bind(memory->targetSocket);

        // this is just an example for build test, obviously this isn't a correct call
        tlm::tlm_generic_payload p; 
        initiator->initiatorSocket.b_transport(p, SC_ZERO);
    }
};

I know what this error implies, but I don't understand why the systemc includes with tlm2 doesn't find this method.

I use SystemC 2.3.3 (Includes TLM), and there are no issues at includes, since I can use other systemc things normally.

Please let me know if you encountered something similar or what I might've overlooked(maybe I am using the wrong headers ?).

Eric Postpischil
  • 195,579
  • 13
  • 168
  • 312
hades
  • 1
  • please include full error message. – apple apple Aug 17 '22 at 08:22
  • In the description there is already the full error message (```error C2039: 'b_transport': is not a member of 'tlm_utils::simple_initiator_socket'```) There are no other errors from the compiler – hades Aug 17 '22 at 08:25

1 Answers1

0

I found the issue. I had to use the arrow (->) operator, so this is the correct usage

SC_MODULE(TopLevel) {
    Memory* memory;
    Initiator* initiator;

    SC_CTOR(TopLevel) {
        memory = new Memory("Memory");
        initiator = new Initiator("Initiator");

        sc_time delay = SC_ZERO_TIME;
        tlm::tlm_generic_payload p; 
        initiator->initiatorSocket.bind(memory->targetSocket);

        initiator->initiatorSocket->b_transport(p, delay);
    }
};
toolic
  • 57,801
  • 17
  • 75
  • 117
hades
  • 1