Jump to content

sc_event_queue


rahuljn

Recommended Posts

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");
    }
  }
};
Link to post
Share on other sites

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

Link to post
Share on other sites

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.

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...