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

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

×