Jump to content

sc_spawn and anthoer process

Recommended Posts

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:

#include <systemc.h>

SC_MODULE(spawn_demo) {

    SC_CTOR(spawn_demo) {

    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"};
    return 0;


Share this post

Link to post
Share on other sites

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.


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