sdressler Posted March 23, 2015 Report Posted March 23, 2015 Hi, I'm working on a TL-Model in SystemC. Due to some internal necessarities, it is important to re-instantiate the model before a new simulation. I do not want to re-start the whole program. However, I get the following warning: Warning: (W505) object already exists: ast-sink.processSink. Latter declaration will be renamed to ast-sink.processSink_0In file: ../../../../src/sysc/kernel/sc_object_manager.cpp:149 This obviously comes from re-instantiation, since the instantiated module always uses the same name. However, this does not really makes sense to me, since between instantiations, the destructor is called and therefore, also sc_module_registry::remove gets called from which I'd assume, that it removes the module properly. This feels like a SystemC bug to me. Cheers, Sebastian Quote
ralph.goergen Posted March 23, 2015 Report Posted March 23, 2015 Hi, unfortunatelly you are moving in the area of undefined behaviour. During the running simulation (exactly after the completion of the elaboration phase), you are not allowed to instantiate modules, signal, etc. AFAIK, SystemC (or at least the Accellera PoC simulator) does not support resetting of the simulation kernel and restarting the evaluation phase. A possible 'solution' might be re-initialising the simulation kernel by instantiating a new one. But please take care: The following is dangerous and not conforming to the standard. Its a hack that uses implementation details and will not work in all SystemC simulators. There are two global variables called sc_curr_simcontext and sc_default_global_context When your simulation run is over, do sc_curr_simcontext = new sc_simcontext(); sc_default_global_context = sc_curr_simcontext; After that, the elaboration and simulation can be started again by calling sc_start again (after you instantiated your model again). Greetings Ralph Quote
sdressler Posted March 24, 2015 Author Report Posted March 24, 2015 Thank you for the reply. Dou you know, whether sc_curr_simcontext = new sc_simcontext(); also takes care about destructing the old context? That is, otherwise I would assume the simulation leaks memory with every new instantiated context. Cheers, Sebastian Quote
ralph.goergen Posted March 24, 2015 Report Posted March 24, 2015 You are right here. The old simcontext object is not deleted in the proposed hack and that results in memory leaks. But so what. We are living in the 64-bit-and-tons-of-memory era. You can try to delete the old simcontext, but I am not sure what happens than. It may result in errors. Actually, the simcontext object is not meant to be deleted. Greetings Ralph Quote
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.