Jump to content
amitk3553

static and dynamic processes

Recommended Posts

Hi Amit,

 

Static processes are created before the start of simulation, by calling e.g. SC_THREAD macro or sc_spawn in the constructor or end_elaboration callback.

 

Dynamic processes are created by calling sc_spawn within another process (which will not be executed until the simulation is running).

 

Regards,

Dave

Share this post


Link to post
Share on other sites

Hi Amit,

 

Static processes are created before the start of simulation, by calling e.g. SC_THREAD macro or sc_spawn in the constructor or end_elaboration callback.

 

Dynamic processes are created by calling sc_spawn within another process (which will not be executed until the simulation is running).

 

Regards,

Dave

Hello Dave

 

Here is my understanding as below.Please correct this

 

e.g.

 

processs A()

{

-----

-----

process B()

{

--------};

};

 

SC_CTOR(){

sc_thread(A);

sensitive<<a<<b;

}

 

here process a is static??

 

then implementation of B in A is dynamic process as done above??? or something else???

 

and what does mean by sc_spawn??

Share this post


Link to post
Share on other sites

Have a look at the example on p66 of the 1666-2011 IEEE SystemC standard - that shows at example of using sc_spawn to create a dynamic process.

 

In the code you've shown above, there are no dynamic processes. Your code doesn't seem to be valid C++ code, there's no keyword "process", you have to declare a void function to create a static process, e.g.

 

void e() {

  cout << "this is a dynamic process" << endl;

}

 

SC_MODULE(M) {

 

  void f() {

    cout << "This is a static process" << endl;

    wait(10, SC_NS);

    sc_spawn (&e);

  }

 

  SC_CTOR(M) {

     SC_THREAD(f)

 }

 

};

 

regards

Alan

Share this post


Link to post
Share on other sites

Hi Amit,

 

Static processes are created before the start of simulation, by calling e.g. SC_THREAD macro or sc_spawn in the constructor or end_elaboration callback.

 

Dynamic processes are created by calling sc_spawn within another process (which will not be executed until the simulation is running).

 

Regards,

Dave

Hello Dave ,

 

Correct me ,

 

If I would say the process using static/dynamic sensitivity are static/dynamic process respectively , would be correct statement??????

 

If above is true then what would be called for a process implementing both static and dynamic events in the same ??? 

 

Regards,

KS

Share this post


Link to post
Share on other sites

Have a look at the example on p66 of the 1666-2011 IEEE SystemC standard - that shows at example of using sc_spawn to create a dynamic process.

 

In the code you've shown above, there are no dynamic processes. Your code doesn't seem to be valid C++ code, there's no keyword "process", you have to declare a void function to create a static process, e.g.

 

void e() {

  cout << "this is a dynamic process" << endl;

}

 

SC_MODULE(M) {

 

  void f() {

    cout << "This is a static process" << endl;

    wait(10, SC_NS);

    sc_spawn (&e);

  }

 

  SC_CTOR(M) {

     SC_THREAD(f)

 }

 

};

 

regards

Alan

Hello Alan,

 

  Would you please explain the meaning of  following line:

 

  sc_spawn (&e);

 

 

 

Regards

Amit

Share this post


Link to post
Share on other sites

Hi KS,

 

Hello Dave ,

 

Correct me ,

 

If I would say the process using static/dynamic sensitivity are static/dynamic process respectively , would be correct statement??????

 

If above is true then what would be called for a process implementing both static and dynamic events in the same ??? 

 

Regards,

KS

 

No, you are mixing up static/dynamic sensitivity with static/dynamic processes. You can for example have a static process (e.g SC_THREAD) that makes use of dynamic sensitivity (e.g wait(x) ) or a dynamic process (sc_spawn) with static sensitivity (using sc_spawn_options - see section 5.5 of the LRM)).

 

Regards,

Dave

Share this post


Link to post
Share on other sites

Hi Amit,

 

Static processes are created before the start of simulation, by calling e.g. SC_THREAD macro or sc_spawn in the constructor or end_elaboration callback.

 

Dynamic processes are created by calling sc_spawn within another process (which will not be executed until the simulation is running).

 

Regards,

Dave

Hi David ,

 

Is sc_spawn only way to create a dynamic process ...

Share this post


Link to post
Share on other sites

Have a look at the example on p66 of the 1666-2011 IEEE SystemC standard - that shows at example of using sc_spawn to create a dynamic process.

 

In the code you've shown above, there are no dynamic processes. Your code doesn't seem to be valid C++ code, there's no keyword "process", you have to declare a void function to create a static process, e.g.

 

void e() {

  cout << "this is a dynamic process" << endl;

}

 

SC_MODULE(M) {

 

  void f() {

    cout << "This is a static process" << endl;

    wait(10, SC_NS);

    sc_spawn (&e);

  }

 

  SC_CTOR(M) {

     SC_THREAD(f)

 }

 

};

 

regards

Alan

Hello Alan,

 

Simulating the above code generates me the following errors:

 

 

1.cpp: In member function ‘void M::f()’:
1.cpp:13:20: error: ‘sc_spawn’ was not declared in this scope
make: *** [1.o] Error 1
 
using "systemc-2.3.0" library.
 
Please help.
 
Regards,
KS

Share this post


Link to post
Share on other sites

In order to use sc_spawn and dynamic processes in general with the Accellera SystemC implementation, please define SC_INCLUDE_DYNAMIC_PROCESSES before including SystemC:

 

#define SC_INCLUDE_DYNAMIC_PROCESSES
#include <systemc> // or <systemc.h>

hth,
  Philipp

Share this post


Link to post
Share on other sites

The SystemC simulation engine performs two major tasks - 'elaboration'

and 'simulation'. In the elaboration step, the internal data structures to

used for the simulation are initialized. This corresponds to static process.

sc_spawn, sc_join etc., correspond to dynamic process.

Share this post


Link to post
Share on other sites

As Dave said "Static processes are created before the start of simulation, by calling e.g. SC_THREAD macro or sc_spawn in the constructor or end_elaboration callback."

 

Any example to create static process using sc_spawn (no SC_THREAD) ?

Share this post


Link to post
Share on other sites

Finally I am able to create process using sc_spawn() instead of SC_THREAD.

My question is in the following code, is the process process1 is static or dynamic process ?

 

class spawn_test : public sc_module {
    public:
    void process1();
    SC_HAS_PROCESS(spawn_test);
    spawn_test(sc_module_name name){
        //SC_THREAD(process1);
        sc_process_handle h1=sc_spawn(sc_bind(&spawn_test::process1,this));
     }
};

void spawn_test::process1(){
    cout<<"Hello1\n";
    wait(1,SC_NS);
    cout<<"Hello11\n";
}

int sc_main(int argc, char*argv[]){
    spawn_test* st = new spawn_test("st");
    sc_start(10,SC_NS);
    return 0;
}

Share this post


Link to post
Share on other sites

My question is in the following code, is the process process1 is static or dynamic process ?

 

Why don't you ask the process itself?

 std::cout << std::boolalpha << h1.dynamic() << std::endl;

Short answer: Processes created from the process macros SC_THREAD,... are called "unspawned" processes, whereas processes created by sc_spawn are called (surprise!) spawned processes. Unspawned processes are by definition static processes, as the macros can't be used during simulation.  On the other hand, spawned processes can be either static or dynamic processes:

 

A dynamic process is created during simulation, whereas a static process is created during elaboration.

 

hth,

Philipp

Share this post


Link to post
Share on other sites

Hi

In the following example I am creating a process in end_of_elaboration method.

Alan mentioned above that process created in end_of_elaboration method are static but when I call dynamic(), it return 1. So it is dynamic.

#include "systemc.h"

class test : public sc_module {
    public:
    sc_process_handle h;
    SC_HAS_PROCESS(test);
    test(sc_module_name name){
    }
    void end_of_elaboration(){
        SC_THREAD(fun);
    }
    void fun(){
        h = sc_get_current_process_handle();
        cout<<h.dynamic()<<endl;
    }
};

int sc_main(int, char**){
    test t("t");
    sc_start();
    return 0;
}

 

Thanks

Rahul

Share this post


Link to post
Share on other sites

Hi Rahul,

 I think I said "during elaboration" rather than "in the end_of elaboration callback". Anyway, the standard says on page 6

 

"A static process is a process created during the construction of the module hierarchy or from the
before_end_of_elaboration callback.
A dynamic process is a process created from the end_of_elaboration callback or during simulation."

 

So I was wrong to say "elaboration" (which includes the end_of_elaboration callback according to section 4 of the standard), I should have referred to page 6,

 

kind regards

Alan

 

P.S. Have you really been thinking about this for 2 years? :-)

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

×