Jump to content
sheridp@umich.edu

SC_METHOD Dynamic Sensititivity Modification

Recommended Posts

Is is possible to modify an sc_method_process's dynamic sensitivity from outside the method itself?

While I can call next_trigger when the method is running, it would be preferable to add event sensitivity from another method/thread.

 

If not, one work workaround I came up with is the following:

sc_core::sc_event_or_list dynamic_sensitivity;
sc_core::sc_event sensitivity_change_event;

SC_METHOD(Change_Me_Method);
sensitive << sensitivity_change_event;

SC_THREAD(Changer_Thread);

void Change_Me_Method(){
  if(!sensitivity_change_event.triggered()){
	//Do stuff
  }
  next_trigger(dynamic_sensitivity | sensitivity_change_event);
}

sc_core::sc_event new_event;
void Changer_Thread(){
  dynamic_sensitivity |= new_event;
  sensitivity_change_event.notify();
}

Wondering if there is a cleaner solution.

Share this post


Link to post
Share on other sites

Basically there are other ways if you have a process handle. But for this you need to get a emthod handle. To do this you have 2 options:

  • You don't use SC_METHOD rather use sc_spawn directly (my _handle is a the part of you rmodule:
    sc_core::sc_spawn_options opt; 
    opt.dont_initialize();
    opt.spawn_method();
    my_handle = sc_core::sc_spawn(func, name,  &opt);
    this->sensitive << my_handle;
    this->sensitive_pos << my_handle;

    (if you don't use satic sensitivity you can skipe the last 2 liens). Using the handle you can change the sensitivity:
     

    reinterpret_cast<sc_method_process*>(my_handle.get_process_object())->next_trigger( sensitivity_change_event );

     

  • The other option is to retrieve the process handle upon the first invocation of your method using 'reinterpret_cast<sc_method_handle>(sc_get_current_process_handle()), store it in your module and then call next_trigger for it.

But I'm not sure it this is cleaner...

Share this post


Link to post
Share on other sites
20 hours ago, sheridp@umich.edu said:

This is exactly what I want to do, but next_trigger(sc_event_or_list&) is protected within sc_method_process.

... and sc_method_process is a non-standard class, which even is incomplete on the model side when including <systemc(.h)>. So I would not call this clean.

Regarding your original solution, it is important to note that you are not supposed to change an sc_event_list object while processes are sensitive to it. In your case, it works because you trigger the process immediately, which then 're-reads' the event list right away and therefore updates the sensitivity without breaking the kernel state

What do you want to achieve that makes you want to do this?

/Philipp

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