DS1701 Posted June 14, 2018 Report Share Posted June 14, 2018 Can you explain the difference between sc_spawn and another process (SC_METHOD, SC_THREAD, SC_CTHREAD )? How to use sc_spawn? Thanks all Quote Link to comment Share on other sites More sharing options...
Roman Popov Posted June 14, 2018 Report Share Posted June 14, 2018 sc_spawn allows to create process during simulation runtime. SC_* macro can be used only at elaboration time. Please read more details in IEEE SystemC standard. Here is small usage example: #define SC_INCLUDE_DYNAMIC_PROCESSES #include <systemc.h> SC_MODULE(spawn_demo) { SC_CTOR(spawn_demo) { SC_THREAD(static_thread); } void static_thread() { sc_spawn_options opts; sc_spawn([&]() { wait(1, SC_NS); cout << "spawned @ " << sc_time_stamp() << "\n"; }, "spawned_thread", &opts); wait(1, SC_NS); cout << "static @ " << sc_time_stamp() << "\n"; } }; int sc_main(int argc, char **argv) { spawn_demo demo0{"demo0"}; sc_start(); return 0; } veeresh k 1 Quote Link to comment Share on other sites More sharing options...
David Black Posted June 16, 2018 Report Share Posted June 16, 2018 sc_spawn creates same kind of processes as sC_METHOD, SC_THREAD, etc, but is not limited to the elaboration phase. Please either read the official documentation for IEEE-1666 (available as pdf free via Accellera) or get a good book on SystemC or take a class. Shashank V M 1 Quote Link to comment Share on other sites More sharing options...
DS1701 Posted June 22, 2018 Author Report Share Posted June 22, 2018 On 6/15/2018 at 12:56 AM, Roman Popov said: sc_spawn allows to create process during simulation runtime. SC_* macro can be used only at elaboration time. Please read more details in IEEE SystemC standard. Here is small usage example: #define SC_INCLUDE_DYNAMIC_PROCESSES #include <systemc.h> SC_MODULE(spawn_demo) { SC_CTOR(spawn_demo) { SC_THREAD(static_thread); } void static_thread() { sc_spawn_options opts; sc_spawn([&]() { wait(1, SC_NS); cout<< "spawned @ " << sc_time_stamp() << "\n"; }, "spawned_thread", &opts); wait(1, SC_NS); cout<< "static @ " << sc_time_stamp() << "\n"; } }; int sc_main(int argc, char **argv) { spawn_demo demo0{"demo0"}; sc_start(); return 0; } This is it means: sc_spawn can use for function have parameter and SC_* it not. Right or wrong? Quote Link to comment Share on other sites More sharing options...
Roman Popov Posted June 22, 2018 Report Share Posted June 22, 2018 41 minutes ago, Hook said: This is it means: sc_spawn can use for function have parameter and SC_* it not. Right or wrong? If you want to pass a parameter to process, then you can use sc_spawn and std::bind to bind parameters. DS1701 1 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.