Jump to content

static and dynamic processes


amitk3553

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

Link to comment
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??

Link to comment
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

Link to comment
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

Link to comment
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

Link to comment
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

Link to comment
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 ...

Link to comment
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
Link to comment
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.

Link to comment
Share on other sites

  • 1 year later...

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

Link to comment
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

Link to comment
Share on other sites

  • 1 year later...

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

Link to comment
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? :-)

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