amitk3553 7 Report post Posted May 3, 2013 Hello all, What is the difference between static and dynamic processes? Regards Amit Share this post Link to post Share on other sites
David Long 20 Report post Posted May 3, 2013 Hi Amit, Static processes are created before the start of simulation, by calling e.g. SC_THREAD macro or sc_spawn in the constructor or end_elaboration callback. Dynamic processes are created by calling sc_spawn within another process (which will not be executed until the simulation is running). Regards, Dave 1 amitk3553 reacted to this Share this post Link to post Share on other sites
amitk3553 7 Report post Posted May 3, 2013 Hi Amit, Static processes are created before the start of simulation, by calling e.g. SC_THREAD macro or sc_spawn in the constructor or end_elaboration callback. Dynamic processes are created by calling sc_spawn within another process (which will not be executed until the simulation is running). Regards, Dave Hello Dave Here is my understanding as below.Please correct this e.g. processs A() { ----- ----- process B() { --------}; }; SC_CTOR(){ sc_thread(A); sensitive<<a<<b; } here process a is static?? then implementation of B in A is dynamic process as done above??? or something else??? and what does mean by sc_spawn?? Share this post Link to post Share on other sites
apfitch 201 Report post Posted May 3, 2013 Have a look at the example on p66 of the 1666-2011 IEEE SystemC standard - that shows at example of using sc_spawn to create a dynamic process. In the code you've shown above, there are no dynamic processes. Your code doesn't seem to be valid C++ code, there's no keyword "process", you have to declare a void function to create a static process, e.g. void e() { cout << "this is a dynamic process" << endl; } SC_MODULE(M) { void f() { cout << "This is a static process" << endl; wait(10, SC_NS); sc_spawn (&e); } SC_CTOR(M) { SC_THREAD(f) } }; regards Alan Share this post Link to post Share on other sites
karandeep963 8 Report post Posted May 6, 2013 Hi Amit, Static processes are created before the start of simulation, by calling e.g. SC_THREAD macro or sc_spawn in the constructor or end_elaboration callback. Dynamic processes are created by calling sc_spawn within another process (which will not be executed until the simulation is running). Regards, Dave Hello Dave , Correct me , If I would say the process using static/dynamic sensitivity are static/dynamic process respectively , would be correct statement?????? If above is true then what would be called for a process implementing both static and dynamic events in the same ??? Regards, KS Share this post Link to post Share on other sites
amitk3553 7 Report post Posted May 6, 2013 Have a look at the example on p66 of the 1666-2011 IEEE SystemC standard - that shows at example of using sc_spawn to create a dynamic process. In the code you've shown above, there are no dynamic processes. Your code doesn't seem to be valid C++ code, there's no keyword "process", you have to declare a void function to create a static process, e.g. void e() { cout << "this is a dynamic process" << endl; } SC_MODULE(M) { void f() { cout << "This is a static process" << endl; wait(10, SC_NS); sc_spawn (&e); } SC_CTOR(M) { SC_THREAD(f) } }; regards Alan Hello Alan, Would you please explain the meaning of following line: sc_spawn (&e); Regards Amit Share this post Link to post Share on other sites
apfitch 201 Report post Posted May 6, 2013 It launches the function e() as a dynamic process, Alan 1 amitk3553 reacted to this Share this post Link to post Share on other sites
amitk3553 7 Report post Posted May 7, 2013 Hello alan, What is event finder used in case of static process? Regards Amit Share this post Link to post Share on other sites
David Long 20 Report post Posted May 7, 2013 Hi KS, Hello Dave , Correct me , If I would say the process using static/dynamic sensitivity are static/dynamic process respectively , would be correct statement?????? If above is true then what would be called for a process implementing both static and dynamic events in the same ??? Regards, KS No, you are mixing up static/dynamic sensitivity with static/dynamic processes. You can for example have a static process (e.g SC_THREAD) that makes use of dynamic sensitivity (e.g wait(x) ) or a dynamic process (sc_spawn) with static sensitivity (using sc_spawn_options - see section 5.5 of the LRM)). Regards, Dave Share this post Link to post Share on other sites
amitk3553 7 Report post Posted May 8, 2013 hello all, Would dynamic process(as in above example) enter in initialisation phase ? Regards cam Share this post Link to post Share on other sites
mohitnegi 4 Report post Posted May 8, 2013 Hi Amit, Static processes are created before the start of simulation, by calling e.g. SC_THREAD macro or sc_spawn in the constructor or end_elaboration callback. Dynamic processes are created by calling sc_spawn within another process (which will not be executed until the simulation is running). Regards, Dave Hi David , Is sc_spawn only way to create a dynamic process ... Share this post Link to post Share on other sites
David Long 20 Report post Posted May 8, 2013 Is sc_spawn only way to create a dynamic process ... Yes. Regards, Dave Share this post Link to post Share on other sites
apfitch 201 Report post Posted May 8, 2013 In the above example, the dynamic process e() would not get executed during the initialisation phase. Alan Share this post Link to post Share on other sites
karandeep963 8 Report post Posted May 14, 2013 Have a look at the example on p66 of the 1666-2011 IEEE SystemC standard - that shows at example of using sc_spawn to create a dynamic process. In the code you've shown above, there are no dynamic processes. Your code doesn't seem to be valid C++ code, there's no keyword "process", you have to declare a void function to create a static process, e.g. void e() { cout << "this is a dynamic process" << endl; } SC_MODULE(M) { void f() { cout << "This is a static process" << endl; wait(10, SC_NS); sc_spawn (&e); } SC_CTOR(M) { SC_THREAD(f) } }; regards Alan Hello Alan, Simulating the above code generates me the following errors: 1.cpp: In member function ‘void M::f()’: 1.cpp:13:20: error: ‘sc_spawn’ was not declared in this scope make: *** [1.o] Error 1 using "systemc-2.3.0" library. Please help. Regards, KS Share this post Link to post Share on other sites
Philipp A Hartmann 220 Report post Posted May 14, 2013 In order to use sc_spawn and dynamic processes in general with the Accellera SystemC implementation, please define SC_INCLUDE_DYNAMIC_PROCESSES before including SystemC: #define SC_INCLUDE_DYNAMIC_PROCESSES #include <systemc> // or <systemc.h> hth, Philipp 2 karandeep963 and faras.dewal reacted to this Share this post Link to post Share on other sites
dakupoto 33 Report post Posted May 15, 2013 The SystemC simulation engine performs two major tasks - 'elaboration' and 'simulation'. In the elaboration step, the internal data structures to used for the simulation are initialized. This corresponds to static process. sc_spawn, sc_join etc., correspond to dynamic process. Share this post Link to post Share on other sites
apfitch 201 Report post Posted May 15, 2013 Hi Dakupoto, that's not strictly correct, have a look at p6 of the standard: using sc_spawn during elaboration creates a static process, regards Alan 1 karandeep963 reacted to this Share this post Link to post Share on other sites
rahuljn 5 Report post Posted June 2, 2014 Is it possible to emulate SC_THREAD by calling sc_spawn ? Share this post Link to post Share on other sites
rahuljn 5 Report post Posted June 2, 2014 As Dave said "Static processes are created before the start of simulation, by calling e.g. SC_THREAD macro or sc_spawn in the constructor or end_elaboration callback." Any example to create static process using sc_spawn (no SC_THREAD) ? Share this post Link to post Share on other sites
rahuljn 5 Report post Posted June 2, 2014 Finally I am able to create process using sc_spawn() instead of SC_THREAD. My question is in the following code, is the process process1 is static or dynamic process ? class spawn_test : public sc_module { public: void process1(); SC_HAS_PROCESS(spawn_test); spawn_test(sc_module_name name){ //SC_THREAD(process1); sc_process_handle h1=sc_spawn(sc_bind(&spawn_test::process1,this)); }}; void spawn_test::process1(){ cout<<"Hello1\n"; wait(1,SC_NS); cout<<"Hello11\n";} int sc_main(int argc, char*argv[]){ spawn_test* st = new spawn_test("st"); sc_start(10,SC_NS); return 0;} 2 deepakj and manjunath angadi reacted to this Share this post Link to post Share on other sites
Philipp A Hartmann 220 Report post Posted June 2, 2014 My question is in the following code, is the process process1 is static or dynamic process ? Why don't you ask the process itself? std::cout << std::boolalpha << h1.dynamic() << std::endl; Short answer: Processes created from the process macros SC_THREAD,... are called "unspawned" processes, whereas processes created by sc_spawn are called (surprise!) spawned processes. Unspawned processes are by definition static processes, as the macros can't be used during simulation. On the other hand, spawned processes can be either static or dynamic processes: A dynamic process is created during simulation, whereas a static process is created during elaboration. hth, Philipp Share this post Link to post Share on other sites
rahuljn 5 Report post Posted April 8, 2016 Hi In the following example I am creating a process in end_of_elaboration method. Alan mentioned above that process created in end_of_elaboration method are static but when I call dynamic(), it return 1. So it is dynamic. #include "systemc.h"class test : public sc_module { public: sc_process_handle h; SC_HAS_PROCESS(test); test(sc_module_name name){ } void end_of_elaboration(){ SC_THREAD(fun); } void fun(){ h = sc_get_current_process_handle(); cout<<h.dynamic()<<endl; }};int sc_main(int, char**){ test t("t"); sc_start(); return 0;} Thanks Rahul Share this post Link to post Share on other sites
apfitch 201 Report post Posted April 10, 2016 Hi Rahul, I think I said "during elaboration" rather than "in the end_of elaboration callback". Anyway, the standard says on page 6 "A static process is a process created during the construction of the module hierarchy or from thebefore_end_of_elaboration callback.A dynamic process is a process created from the end_of_elaboration callback or during simulation." So I was wrong to say "elaboration" (which includes the end_of_elaboration callback according to section 4 of the standard), I should have referred to page 6, kind regards Alan P.S. Have you really been thinking about this for 2 years? :-) Share this post Link to post Share on other sites