Jump to content
TRANG

How to Method work with event?

Recommended Posts

Hi all,

I try code bellow

SC_METHOD(APMMethod);
sensitive << mAPMEvent;
...
void APMMethod(){
  printf("Reset port\n");
  ...
}
...
void Initialize()
{
   for(unsigned int i=0; i< 50; i++){
       mAPM_reg[i].value = 0;
       printf("Initialize %s\n",mAPM_reg[i].name);
    }
}
...
void EnableReset(){
    //reset port
    mAPMEvent.notify(SC_ZERO_TIME);
    //initialize reg
    Initialize();
}
 

When EnableReset occur. 

My output is:

Intialize APM_REG1
Intialize APM_REG2
...

Reset port

I try with 

mAPMEvent.notify();

But the same output.

1. why Initialize() call before APMMethod().

2. when to use notiffy() or notify(SC_ZERO_TIME)?

Thanks all.

Share this post


Link to post
Share on other sites

Notify (either case) is non-blocking, so your call to notify followed by initialize will happen. Then after you return, the notified element(s) may execute.

Notify() implies execution will be in the same delta-cycle; whereas, notify(SC_ZERO_TIME) postpones to the next one and allows other processes in the current delta-cycle to complete.

Take a look at <https://github.com/dcblack/SystemC-Engine/blob/master/Engine_v2.4.pdf>.

Share this post


Link to post
Share on other sites
12 hours ago, David Black said:

Notify (either case) is non-blocking, so your call to notify followed by initialize will happen. Then after you return, the notified element(s) may execute.

Notify() implies execution will be in the same delta-cycle; whereas, notify(SC_ZERO_TIME) postpones to the next one and allows other processes in the current delta-cycle to complete.

Take a look at <https://github.com/dcblack/SystemC-Engine/blob/master/Engine_v2.4.pdf>.

Thank you so much, @David Black

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.


×
×
  • Create New...