biplab77 Posted May 12, 2015 Report Share Posted May 12, 2015 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 biplab77 1 Quote Link to comment Share on other sites More sharing options...
sumit_tuwien Posted May 13, 2015 Report Share Posted May 13, 2015 Hi Biplab, Please consider using sc_core::sc_stop() from the place where you want to stop the simulation. Regards, Sumit maehne and Mudong 2 Quote Link to comment Share on other sites More sharing options...
biplab77 Posted May 15, 2015 Author Report Share Posted May 15, 2015 @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.. Quote Link to comment Share on other sites More sharing options...
sumit_tuwien Posted May 16, 2015 Report Share Posted May 16, 2015 Hi Biplab, From SystemC 2.3.1 you can suspend/resume or enable/disable any process. Please check the latest LRM. Regards, Sumit Quote Link to comment Share on other sites More sharing options...
dakupoto Posted May 17, 2015 Report Share Posted May 17, 2015 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. Quote Link to comment Share on other sites More sharing options...
David Black Posted May 18, 2015 Report Share Posted May 18, 2015 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(). Mudong 1 Quote Link to comment Share on other sites More sharing options...
biplab77 Posted May 24, 2015 Author Report Share Posted May 24, 2015 I will be using SC_THREAD and will let you know.. Than you very much. You guys have been of much help 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.