Jump to content

sc_spawn and anthoer process


DS1701

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:

#define SC_INCLUDE_DYNAMIC_PROCESSES
#include <systemc.h>

SC_MODULE(spawn_demo) {

    SC_CTOR(spawn_demo) {
        SC_THREAD(static_thread);
    }

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

 

Link to comment
Share on other sites

On 6/15/2018 at 12:56 AM, Roman Popov said:

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:


#define SC_INCLUDE_DYNAMIC_PROCESSES
#include <systemc.h>

SC_MODULE(spawn_demo) {

    SC_CTOR(spawn_demo) {
        SC_THREAD(static_thread);
    }

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

 

This is it means: sc_spawn can use for function have parameter and SC_* it not. Right or wrong?

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...