Jump to content

Problem with re-instatiation of modules


Recommended Posts

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_0
In 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


gets called from which I'd assume, that it removes the module properly. This feels like a SystemC bug to me.




Link to comment
Share on other sites



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





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).




Link to comment
Share on other sites

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.




Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...