Search the Community
Showing results for tags 'tlm_extension'.
-
I am looking for a way to serialize / de-serialize tlm_generic_payload objects, particularly tlm_generic_payload extensions (TLM 2.0) without using uvm_objects Example of setting the generic payload extension: class my_extension : public tlm::tlm_extension<my_extension>{ ... // class implementation (including copy_from and clone, has operator <<) } tlm_generic_payload* gp = new tlm_generic_payload; trans->set_extension(&my_extension); Desired serialization example (just an example, anything that serializes will do): cout << *trans.get_extension(0);
-
Dear all, I am new to payload extensions and I would appreciate a feedback on whether I am doing things right.. I need to declare a simple payload extension, including two additional fields: a reset value a 16 bit bit vector representing the value of a register In the header, I simply declare the clone/copy from functions, plus my additional fields: class reg_extension : public tlm::tlm_extension<reg_extension>{ public: reg_extension(); tlm::tlm_extension_base* clone() const ; void copy_from(tlm::tlm_extension_base const &); bool reset; sc_bv<16> value; }; And then I implemented the functions, by taking care of the additional reset and value fields: reg_extension::reg_extension(){ reset = false; value = sc_bv<16>(0); } tlm::tlm_extension_base * reg_extension::clone() const{ cout<<"Executing clone!"<<endl; reg_extension * ext = new reg_extension(); ext->reset = this->reset; ext->value = this->value; return ext; } void reg_extension::copy_from(tlm::tlm_extension_base const & ext){ reset = static_cast<reg_extension const &>(ext).reset; value = static_cast<reg_extension const &>(ext).value; } Is this enough for the extension to work? Best regards, S.
- 1 reply
-
- tlm_extension
- payload extension
-
(and 1 more)
Tagged with:
-
Dear all, is it possible to apply standard SystemC tracing to tlm_extensions? I defined my own tlm extension to add a reset and a value fields to the standard payload: class reg_extension : public tlm::tlm_extension<reg_extension>{ public: reg_extension(); tlm::tlm_extension_base* clone() const ; void copy_from(tlm::tlm_extension_base const &); bool reset; sc_bv<16> value; }; Then, my testbench declares and uses it to carry data to/from the target: class testbench : public sc_module , public virtual tlm::tlm_bw_transport_if<> { public: tlm::tlm_initiator_socket<> initiator_socket; reg_extension * payload_data; ... } void testbench::run() { tlm::tlm_generic_payload * trans; sc_time time; mem = new mem_manager(); trans = mem->allocate(); payload_data = new reg_extension; payload_data->value = sc_bv<16>("00001111"); payload_data->reset = 1; trans->set_data_length(sizeof(register_data_t)); trans->set_auto_extension(payload_data); trans->set_address(0); trans->set_write(); initiator_socket->b_transport(*trans, time); ... } In my main, I try to apply standard tracing: int main(int argc, char* argv[]) { toplevel top("top"); sc_trace_file* fp = sc_create_vcd_trace_file("wave"); fp->set_time_unit(1, SC_NS); sc_trace(fp, top.tb.payload_data->reset, "reset" ); sc_trace(fp, top.tb.payload_data->value, "value" ); sc_start(); sc_close_vcd_trace_file(fp); return 0; } The code compiles correctly, but: with SystemC 2.2.0, the generated trace is weird (see attached - I truncated the value as it had far too many digits) things get worse when compiling with SystemC 2.3.0, as the execution returns this error: My impression is that memory is somehow not managed - this would explain the wrong size for the value field, the huge correponding value, and the bad_alloc. Please note that I forced some wait invocations to advance simulation time, so that write operations onto the extension fields occur at different simulation times. Thank you in advance, Regards, S. wave.vcd
- 1 reply
-
- sc_trace
- tlm_extension
-
(and 1 more)
Tagged with:
-
Dear all, I am new to payload extensions and I would appreciate a feedback on whether I am doing things right.. I need to declare a simple payload extension, including two additional fields: a reset value a 16 bit bit vector representing the value of a register In the header, I simply declare the clone/copy from functions, plus my additional fields: class reg_extension : public tlm::tlm_extension<reg_extension>{ public: reg_extension(); tlm::tlm_extension_base* clone() const ; void copy_from(tlm::tlm_extension_base const &); bool reset; sc_bv<16> value; }; And then I implemented the functions, by taking care of the additional reset and value fields: reg_extension::reg_extension(){ reset = false; value = sc_bv<16>(0); } tlm::tlm_extension_base * reg_extension::clone() const{ cout<<"Executing clone!"<<endl; reg_extension * ext = new reg_extension(); ext->reset = this->reset; ext->value = this->value; return ext; } void reg_extension::copy_from(tlm::tlm_extension_base const & ext){ reset = static_cast<reg_extension const &>(ext).reset; value = static_cast<reg_extension const &>(ext).value; } Is this enough for the extension to work? Best regards, S.
-
- tlm_extension
- payload extension
-
(and 1 more)
Tagged with:
-
Dear all, to define extensions of the generic payload, I defined also a memory manager class, implementing the tlm_mm_interface. I googled and tried almost all implementations available out there - they all generate memory leaks (as bad as 80 bytes in 2 blocks, according to Valgrind). Can anybody help me? The issue seems to be caused by the allocate method. Header file: class mem_manager : public tlm::tlm_mm_interface{ public: std::vector<tlm::tlm_generic_payload *> free_list; tlm::tlm_generic_payload * allocate(); void free(tlm::tlm_generic_payload *); tlm::tlm_generic_payload * ptr; private: ~mem_manager(); }; Implementation: mem_manager::~mem_manager(){ } tlm::tlm_generic_payload * mem_manager::allocate(){ if (!free_list.empty()) { ptr = free_list.back(); free_list.pop_back(); cout<<"free list not empty"<<endl; } else { ptr = new tlm::tlm_generic_payload(this); cout<<"free list empty"<<endl; } return ptr; } void mem_manager::free(tlm::tlm_generic_payload * trans){ free_list.push_back((tlm::tlm_generic_payload *)trans); } Example of code using the memory manager: tlm::tlm_generic_payload * trans; sc_time time; mem = new mem_manager(); trans = mem->allocate(); payload_data = new reg_extension; payload_data->value = sc_bv<16>("01"); payload_data->reset = 1; trans->set_data_length(sizeof(register_data_t)); trans->set_auto_extension(payload_data); trans->set_address(0); trans->set_write(); initiator_socket->b_transport(*trans, time); if(trans->is_response_ok()){ } else{ cout<<"Error!"<<endl; } Regards, S.
- 1 reply
-
- tlm_mm_interface
- tlm_extension
-
(and 2 more)
Tagged with: