feron_jb Posted February 24, 2014 Report Share Posted February 24, 2014 Hello everyone, I have a runtime error when trying to simulate the top level of a system containing 2 sc_threads. An example of my code architecture is presented hereunder, do you see any problem? Here is my error : 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:166 In process: Test_top.th1.Thread_test @ 0 s TB_test_top.cpp: #include "Test_top.h" int sc_main(int argc, char* argv[]) { Test_top topLevel("topLevel"); sc_start(70, SC_NS); }; Test_top.h: #include <systemc> #include "Thread.h" class Test_top { Test_top(); }; Test_top.cpp: #include "Test_top.h" Test_top::Test_top(){ Thread th1("th1"); Thread th2("th2"); }; Thread.h: #include <systemc> SC_MODULE (Thread){ void Thread_test(); SC_HAS_PROCESS(Thread); Thread(sc_module_name instanceName) : sc_module(instanceName){ SC_THREAD(Thread_test); } }; Thread.cpp #include "Thread.h" void Thread::Thread_test(){ ... wait(...); ... }; Thank you for your comments! Quote Link to comment Share on other sites More sharing options...
ralph.goergen Posted February 24, 2014 Report Share Posted February 24, 2014 Hi. I had no problems running your code (with SystemC 2.3.0). Only compiler errors: Test_top topLevel("topLevel"); This constructor doesn't exist. After fixing this, the example ran without errors. But there is a big problem in your code: You declare the two 'Thread' instances as local variables in the Test_top constructor. Since they are local variables, they will be created in the constructor and destroyed when the constructor exits. Hence, when you start the simulation, no SC_MODULE is available anymore. In older SystemC releases, this may lead to the observed error because of some internal clean up issues. Greetings Ralph David Black 1 Quote Link to comment Share on other sites More sharing options...
feron_jb Posted February 27, 2014 Author Report Share Posted February 27, 2014 You are right, declaring my two threads in my class definition and then instanciating it in the constructor fixed my problem. A stupid basic C++ error... Thank you for your solution! 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.