jelicicm Posted April 5, 2019 Report Share Posted April 5, 2019 (edited) 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. Code: class Chiplet : public sc_core::sc_module { public: // 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 ); ~Chiplet(); void recvTransfer(int id, tlm::tlm_generic_payload &payload, sc_core::sc_time &delay); //callback for receiving b_transfer private: 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) : _name(name) { SC_HAS_PROCESS(Chiplet); 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"); SC_THREAD(doit_send); } SEND_ERR_CODES Chiplet::prepareFrame(/*all parameters needed for payload fields*/ ) tlm::tlm_generic_payload *payload = new tlm::tlm_generic_payload; payload->set_address(offset); payload->set_command(tlm::TLM_WRITE_COMMAND); payload->set_data_ptr(send_ptr); 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) { wait(startSendTransfer_ev); 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 April 5, 2019 by jelicicm Found solution Quote Link to comment Share on other sites More sharing options...
David Black Posted April 6, 2019 Report Share Posted April 6, 2019 Where do you set send_ptr? What with : cout << "send_ptr: " << hex << send_ptr << endl; Quote Link to comment Share on other sites More sharing options...
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.