Jump to content

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


biplab77

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

Link to comment
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..

Link to comment
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.

Link to comment
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().

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.

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