Jump to content

Recommended Posts

Posted

I don't recall a strong reason for this, but I am not sure I see a use either. If you need immediate notification then use sc_event or you can always use a time delay of SC_ZERO_TIME.

 

The purpose of sc_event_queue was to be able to guarantee that every notification would be seen by any interested process. If you allowed for immediate notification, that would no longer be true because two notifications in a row would result in a lost notification. In other words:

SC_MODULE(Top) {
  sc_event_queue eq;

  SC_CTOR(Top) {
    SC_THREAD(sending_thread);
    SC_THREAD(watching_thread);
  }

  void sending_thread(void) {
    for(size_t i=0; i!=4; ++i) {
      eq.notify(); //< illegal syntax used for illustration
      eq.notify(); //< illegal syntax used for illustration -- **this would never be observed**
      wait(SC_ZERO_TIME);
    }
    sc_stop();
  }

  void watching_thread(void) {
    for(; {
      wait(eq);
      SC_REPORT_INFO("","Observed eq");
    }
  }
};
Posted

Thanks David.

 

Any way there is a hack, You can use the following to implement immediate notification with sc_event_queue

const_cast<sc_event*>(&eq.default_event())->notify();

 

Thanks

Posted

Hello guyz

i have some issue related to this

#include "systemc.h"

class test : public sc_module {
    public :
    sc_event_queue events;
    SC_HAS_PROCESS(test);
    test(sc_module_name name){
        SC_THREAD(thread1);
        SC_THREAD(thread2);
    }
    void thread1(){
        //wait(event_1);
        events.notify(SC_ZERO_TIME);
        events.notify(SC_ZERO_TIME);
    }

    void thread2(){
        while(1){
            wait(events.default_event());
            cout<<"event arrived"<<endl;
        }
    }
};

Now this is printing " event arrived " twice ...

Now but in actual there is also a wait (commented part) in code ...

now when i am actualling implementing it , it is running only once ...i dont understand the reason for this ......

Posted

Hello guyz

i have some issue related to this

#include "systemc.h"

class test : public sc_module {
    public :
    sc_event_queue events;
    SC_HAS_PROCESS(test);
    test(sc_module_name name){
        SC_THREAD(thread1);
        SC_THREAD(thread2);
    }
    void thread1(){
        //wait(event_1);
        events.notify(SC_ZERO_TIME);
        events.notify(SC_ZERO_TIME);
    }

    void thread2(){
        while(1){
            wait(events.default_event());
            cout<<"event arrived"<<endl;
        }
    }
};

Now this is printing " event arrived " twice ...

Now but in actual there is also a wait (commented part) in code ...

now when i am actualling implementing it , it is running only once ...i dont understand the reason for this ......

Sir,

It is not clear what is the final goal of this module.

Simply looking at the stated results, the module is

doing what it is supposed to do. In 'thread1', with 

the 'wait' commented out, at zero time two events

are inserted into the event queue, and 'thread2'

responds to them.

When the 'wait' in 'thread1' is activated, then that

thread goes on waiting for 'event_1', while 'thread2'

responds to some random default event, and then

goes on waiting for 'default_event' s in the event

queue.

How is 'event_1' getting generated -- in some other

module perhaps ? Please first identify what the 

modules are supposed to do, otherwise there will

more confusion. Hope that helps.

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