Jump to content

Sending tlm_generic_payload over peq_with_get

Recommended Posts

So I'm trying to send tlm_generic_payload over peq_with_get, and it's not really working as it should. I have three functions that I need to "pass" with this, and when I prinout the address of pointer to tlm_generic_payload, its always the same, which seems like a good thing, but when I print out address of payload->get_data_ptr() its always rubbish, and not constant.


class Chiplet : public sc_core::sc_module
        // The TLM socket to send bus traffic.
        tlm_utils::simple_initiator_socket<Chiplet> chipletWLSocketMaster[WAVELINK_SOCKETS];
        // The TLM socket to receive bus traffic.
        tlm_utils::simple_target_socket_tagged<Chiplet> chipletWLSocketSlave[WAVELINK_SOCKETS];
        Chiplet( sc_core::sc_module_name name, sc_in_clk* systemClock );
        void recvTransfer(int id, tlm::tlm_generic_payload &payload, sc_core::sc_time &delay); //callback for receiving b_transfer

        void doit_send( void );

        SEND_ERR_CODES sendTransferSpawn(tlm::tlm_generic_payload* payload);
        tlm_utils::peq_with_get<tlm::tlm_generic_payload>* send_peq;

        sc_event startSendTransfer_ev;
Chiplet::Chiplet(sc_core::sc_module_name name, sc_in_clk* systemClock) : 

    for(int i = 0; i < WAVELINK_SOCKETS; i++) {
        chipletWLSocketSlave[i].register_b_transport( this, &Chiplet::recvTransfer, i );
    send_peq = new tlm_utils::peq_with_get<tlm::tlm_generic_payload>("send_queue");


SEND_ERR_CODES Chiplet::prepareFrame(/*all parameters needed for payload fields*/ )
    tlm::tlm_generic_payload *payload = new tlm::tlm_generic_payload;

    payload->set_data_length(sizeof(EthernetFrame) + length);
    cout << "payload addr 1 " << payload/*->get_data_ptr()*/ << endl;

    send_peq->notify(*payload, (ZERO_DELAY, dummy_delay));

//after N of these payloads has been added to send_peq, startSendTransfer_ev is triggered and we move on to the next function


void Chiplet::doit_send( void ) {
    tlm::tlm_generic_payload *payload;
    while(1) {

        while(payload = send_peq->get_next_transaction()) {
            cout << "payload addr 2 " << payload/*->get_data_ptr()*/ << endl;
            sc_spawn( sc_bind(&Chiplet::sendTransferSpawn, this, payload) );

SEND_ERR_CODES Chiplet::sendTransferSpawn(tlm::tlm_generic_payload* payload)
    cout << "payload addr 3 " << payload/*->get_data_ptr()*/ << endl;

//b_transfer would be invoked from here

So, as I said, these printouts always give the same address for 1st payload (payload addr 1 = payload addr 2 = payload addr 3), and same address for 2nd payload, and same address for N-th payload. But, if I try to print with payload->get_data_ptr() all I get is rubbish.

What am I missing?



EDIT> Found an error, on part of code not shown here there was some static memory allocation that had to be dynamic. Feel free to delete / not approve this thread. 

Edited by jelicicm
Found solution

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now