Jump to content
aarone

Runtime sc_spawn exception

Recommended Posts

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);
}

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×