Jump to content

Count number of SC_THREAD and/or SC_METHOD

Recommended Posts

25 minutes ago, Khushi said:

How can I count the number of SC_THREAD/SC_METHOD in a given simulation of a SystemC platform ?

Is it possible ?

    int n_methods = 0;
    int n_threads = 0;
    int n_cthreads = 0;

    void count_procs_recursive(sc_object * parent) {
        if (std::string ( parent->kind() ) == "sc_method_process" )
        if (std::string(parent->kind()) == "sc_thread_process")
        if (std::string(parent->kind()) == "sc_cthread_process")

        for (sc_object * child : parent->get_child_objects()) {

    void before_end_of_elaboration() override {
        for (sc_object * obj : sc_get_top_level_objects()) {

        cout << "n_methods = " << n_methods << "\n";
        cout << "n_threads = " << n_threads << "\n";
        cout << "n_cthreads = " << n_cthreads << "\n";

( Not tested. )

Share this post

Link to post
Share on other sites

Caveat: That is the number of statically allocated processes. It does not account for dynamic threads or processes (i.e. sc_spawn'ed), which would be more difficult to track. Mind you, it is pretty complete and most likely static is what you are after.

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