Jump to content

Runtime sc_spawn exception


aarone

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

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...