aarone Posted September 6, 2015 Report Share Posted September 6, 2015 Hi, the code below throws the exception: Error: (E519)wait() is only allowed in SC_THREADs and SC_CTHREADs : in SC_METHODs use next_trigger() instead In file : ..\..\src\sysc\kernel\sc_wait.cpp:92 Although I understand that a spawned method qualifies as a thread, I tried to replace the wait call with next_trigger and still get the same exception at runtime. Thanks in advance, Aaron // main.cpp #include <systemc> #include "my_module.h" using namespace sc_core; int sc_main(int argc, char* argv[]) { my_module my_module_i("my_module_i"); sc_start(); return 0; } // my_module.h #ifndef MY_MODULE_H #define MY_MODULE_H #include <systemc> SC_MODULE(my_module) { my_module(sc_core::sc_module_name nm); void my_thread(void); }; #endif // my_module.cpp #include <iostream> using std::cout; using std::endl; #define SC_INCLUDE_DYNAMIC_PROCESSES #include <systemc> using namespace sc_core; #include "my_module.h" SC_HAS_PROCESS(my_module); my_module::my_module(sc_module_name nm) : sc_module(nm) { try { SC_FORK sc_spawn(sc_bind(&my_module::my_thread, this), "my-thread") SC_JOIN } catch (const sc_report& x){ cout << "Ooppss..." << endl; cout << x.what() << endl; throw; } } void my_module::my_thread(void) { cout << "INFO: spawned thread " << sc_get_current_process_handle().name() << " @ " << sc_time_stamp() << endl; wait(10, SC_NS); // next_trigger(10, SC_NS); } Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted September 6, 2015 Report Share Posted September 6, 2015 SC_FORK/SC_JOIN can be used only within an already started process, not within the constructor of your module (SC_JOIN involves a wait as well). You can register the thread via SC_THREAD(my_thread); hth,Philipp Quote Link to comment Share on other sites More sharing options...
aarone Posted September 6, 2015 Author Report Share Posted September 6, 2015 I see... I couldn't figure out where that 'wait' came form... Thanks Philipp! 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.