rahuljn Posted November 5, 2014 Report Posted November 5, 2014 Hi All I see immediate notification is not possible with sc_event_queue objects. Is there some specific reason for this. Thanks kartikkg 1 Quote
David Black Posted November 5, 2014 Report Posted November 5, 2014 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"); } } }; Quote
rahuljn Posted November 7, 2014 Author Report Posted November 7, 2014 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 Quote
David Black Posted November 9, 2014 Report Posted November 9, 2014 But why are you needing an immediate notification? Do you realize that this may cause some processes to never see the event? Philipp A Hartmann 1 Quote
mohitnegi Posted November 11, 2014 Report Posted November 11, 2014 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 ...... Quote
apfitch Posted November 11, 2014 Report Posted November 11, 2014 I don't understand the code. The commented code should not compile as you haven't declared event_1 Alan Quote
dakupoto Posted November 12, 2014 Report Posted November 12, 2014 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. Quote
Recommended Posts
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.