Allen yang Posted November 14, 2023 Report Share Posted November 14, 2023 Here is my code. I set my own extension and use new to create an object, but I don't know when to call delete operator to free it. https://www.edaplayground.com/x/8ur8 Quote Link to comment Share on other sites More sharing options...
Allen yang Posted November 14, 2023 Author Report Share Posted November 14, 2023 I really need your help when tlm_extension_base call free function to release the new memory. Thanks! Quote Link to comment Share on other sites More sharing options...
Allen yang Posted November 14, 2023 Author Report Share Posted November 14, 2023 OK. I have read the source code of systemc. And I found that ~tlm_generic_payload will call extension free. Quote //-------------- // Destructor //-------------- tlm_generic_payload::~tlm_generic_payload() { for(unsigned int i=0; i<m_extensions.size(); i++) if(m_extensions[i]) m_extensions[i]->free(); } Quote Link to comment Share on other sites More sharing options...
David Black Posted November 14, 2023 Report Share Posted November 14, 2023 This depends slightly on the coding style (Loosely timed (LT) vs Approximately Timed (AT)) and the extension classification. For AT, if you use the auto-extension mechanism, then the memory manager can do this for you. For sticky extensions, you don't remove the extension at all because it gets reused. For LT, it should be done in the component that creates the extension when the transaction is closing. This is a relatively complex topic, which is covered in the Doulos TLM Adopter course, among other places. [Note: I work as an instructor at Doulos.] Quote Link to comment Share on other sites More sharing options...
Allen yang Posted November 15, 2023 Author Report Share Posted November 15, 2023 I'm very appreciate your advice. Do you have any links about the Doulos TLM Adopter course? Quote Link to comment Share on other sites More sharing options...
David Black Posted November 16, 2023 Report Share Posted November 16, 2023 https://www.doulos.com/training/soc-design-and-verification/systemc-tlm-20/ 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.