Jump to content
Sign in to follow this  
bocuabeucon

Output of systemC

Recommended Posts

Hi all,

Suppose I have a Module which has 2 processes (SC_CTHREAD) T1, T2, and a shared signal as the follows:

 

sc_signal<int> a;

void T1() {

   wait();

   while(true) {

      a = 1;

      wait();

   }

}

 

void T2() {

   int b;

   wait();

   while(true) {

      b = a;

      wait();

   }

}

 

The SystemC design is simulated by 2 clock cycles. Suppose that the execution sequence will be (T1,T2,T1,T2). I donot understand why the ouput is (a = 1, b = 0).

Other execution sequences, like (T1,T2,T2,T1) produce the same output.

I think that the output should be (a=1, b=1).

 

Thanks,

 

 

Share this post


Link to post
Share on other sites

Hi,

I am very new in SystemC. This example is extracted from a slide, and it does not provide enough information.

However, I guess that the constructor of the module as the following:

 

SC_CTOR(example) {

   SC_CTHREAD(T1, clk.pos());

   SC_CTHREAD(T2, clk.pos());

}

 

Maybe, we can print the value of a and b at the end of the corresponding process.

As I understand, the scheduler of systemC maintains a runnable queue of processes. In this example, T2 always runs before T1, right? Or, the scheduler will randomly pick up one process to be executed.

 

Thanks,

Share this post


Link to post
Share on other sites

Scheduling order of processes in the same run phase is random.

It's important to realise that because a is a primitive channel (sc_signal), it doesn't update its value immediately. a will only update after all processes have and reached a wait statement,

 

regards

Alan

Share this post


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

Sign in to follow this  

×
×
  • Create New...