Jump to content
biplab77

Any method of stopping simulation without sc_start(time) and sc_stop

Recommended Posts

Hi All,

 

I have built a simulator which uses system C library. Its a network simulator and i am planning to run some traces. Well earlier when i was running my own generated traffic i was specifying the simulation time in cycles and used to achieve results. Now when i am running traces, i am not sure how much time will be enough. i want to ask that is there any way to stop the simulation at any part of the code apart from main(). If yes then how??

I will like to stop the simulation as soon as i am finished processing the last line of my trace file OR i don't receive any more packets in the receiving module designed in my network simulator in a certain time.

Well to be honest i am a novice in system C. I took an introductory class and started building this as it ensured parallel processing.

 

Thank You

Regards

Biplab

Share this post


Link to post
Share on other sites

@Sumit :- Thank you very much !!! 
Well i had another question. Whats the way to suspend a method for some time?? Like equivalent to sleep(). i mean i want to suspend the execution of that specific module(or if process) for some time. And then start executing from there after itself.
I cant use sleep as it will take system time into account rather than the simulation time. Next_trigger() starts executing the whole process again. and wait() is used in threads... So i am in a fix. 
Sorry for asking such basic questions... In a learning phase..

Share this post


Link to post
Share on other sites

Hi All,

 

I have built a simulator which uses system C library. Its a network simulator and i am planning to run some traces. Well earlier when i was running my own generated traffic i was specifying the simulation time in cycles and used to achieve results. Now when i am running traces, i am not sure how much time will be enough. i want to ask that is there any way to stop the simulation at any part of the code apart from main(). If yes then how??

I will like to stop the simulation as soon as i am finished processing the last line of my trace file OR i don't receive any more packets in the receiving module designed in my network simulator in a certain time.

Well to be honest i am a novice in system C. I took an introductory class and started building this as it ensured parallel processing.

 

Thank You

Regards

Biplab

 

Hello Sir,

While there is no substitute for sc_start(), sc_stop(), "pausing" a simulation to

to change input parameters to see their effect, can easily be achieved.

in sc_main:

/* set parameters/conditions to some values */

use sc_start, sc_stop combination to run simulation

for a fixed time period.

/* change parameters/conditions to different values */

use sc_start, sc_stop combination to run simulation

And so on ....

There is no mention of which SystemC version you

are using, but this technique can be used for older

versions as well.

Hope that helps.

Share this post


Link to post
Share on other sites

Technically, you are not supposed to call sc_stop() more than once during a given simulation. Since version 2.3, you now have the option of using sc_pause() if you wish to go back and forth. But there is a more fundamental issue that should be observed:

 

There is no way to pause an SC_METHOD as Biplab is requesting. You simply must re-enter the method. This is a strong reason for using SC_THREAD, which allows the use of wait(). If for some strange reason you insist on using SC_METHOD, then your only alternative is to create a state machine implementation in combination with using next_trigger(). These comments also apply to using suspend()/resume(), disable()/enable(), or sc_pause()/sc_start().

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×