112855Sgabeblack@google.com 212855Sgabeblack@google.com// sc_start with event starvation policy 312855Sgabeblack@google.com 412855Sgabeblack@google.com#define SC_INCLUDE_DYNAMIC_PROCESSES 512855Sgabeblack@google.com 612855Sgabeblack@google.com#include <systemc> 712855Sgabeblack@google.comusing namespace sc_core; 812855Sgabeblack@google.comusing std::cout; 912855Sgabeblack@google.comusing std::endl; 1012855Sgabeblack@google.com 1112855Sgabeblack@google.comSC_MODULE(Top) 1212855Sgabeblack@google.com{ 1312855Sgabeblack@google.com SC_CTOR(Top) 1412855Sgabeblack@google.com { 1512855Sgabeblack@google.com SC_THREAD(T); 1612855Sgabeblack@google.com } 1712855Sgabeblack@google.com 1812855Sgabeblack@google.com sc_event ev2; 1912855Sgabeblack@google.com 2012855Sgabeblack@google.com void T() 2112855Sgabeblack@google.com { 2212855Sgabeblack@google.com sc_assert( sc_get_status() == SC_RUNNING ); 2312855Sgabeblack@google.com ev2.notify(150, SC_NS); 2412855Sgabeblack@google.com 2512855Sgabeblack@google.com //wait(ev2); // Inserting this line makes the test pass 2612855Sgabeblack@google.com } 2712855Sgabeblack@google.com}; 2812855Sgabeblack@google.com 2912855Sgabeblack@google.comint sc_main(int argc, char* argv[]) 3012855Sgabeblack@google.com{ 3112855Sgabeblack@google.com Top top("top"); 3212855Sgabeblack@google.com 3312855Sgabeblack@google.com sc_event ev; 3412855Sgabeblack@google.com ev.notify(250, SC_NS); 3512855Sgabeblack@google.com 3612855Sgabeblack@google.com sc_assert( sc_get_status() == SC_ELABORATION ); 3712855Sgabeblack@google.com sc_assert( sc_time_stamp() == SC_ZERO_TIME ); 3812855Sgabeblack@google.com sc_start(100, SC_NS); 3912855Sgabeblack@google.com sc_assert( sc_get_status() == SC_PAUSED ); 4012855Sgabeblack@google.com sc_assert( sc_time_stamp() == sc_time(100, SC_NS) ); 4112855Sgabeblack@google.com 4212855Sgabeblack@google.com sc_start(10, SC_NS, SC_RUN_TO_TIME); 4312855Sgabeblack@google.com sc_assert( sc_time_stamp() == sc_time(110, SC_NS) ); 4412855Sgabeblack@google.com 4512855Sgabeblack@google.com sc_start(10, SC_NS, SC_EXIT_ON_STARVATION); 4612855Sgabeblack@google.com sc_assert( sc_time_stamp() == sc_time(110, SC_NS) ); 4712855Sgabeblack@google.com 4812855Sgabeblack@google.com sc_start(80, SC_NS, SC_EXIT_ON_STARVATION); 4912855Sgabeblack@google.com 5012855Sgabeblack@google.com cout << "sc_time_stamp() = " << sc_time_stamp() << endl; 5112855Sgabeblack@google.com cout << "sc_pending_activity_at_future_time() = " << sc_pending_activity_at_future_time() << endl; 5212855Sgabeblack@google.com cout << "sc_time_to_pending_activity() = " << sc_time_to_pending_activity() << endl; 5312855Sgabeblack@google.com 5412855Sgabeblack@google.com sc_assert( sc_time_stamp() == sc_time(150, SC_NS) ); // FAILS. Does not see ev2 5512855Sgabeblack@google.com 5612855Sgabeblack@google.com sc_start(50, SC_NS, SC_EXIT_ON_STARVATION); 5712855Sgabeblack@google.com sc_assert( sc_time_stamp() == sc_time(150, SC_NS) ); 5812855Sgabeblack@google.com 5912855Sgabeblack@google.com sc_start(50, SC_NS, SC_RUN_TO_TIME); 6012855Sgabeblack@google.com sc_assert( sc_time_stamp() == sc_time(200, SC_NS) ); 6112855Sgabeblack@google.com 6212855Sgabeblack@google.com sc_start(); 6312855Sgabeblack@google.com sc_assert( sc_get_status() == SC_PAUSED ); 6412855Sgabeblack@google.com sc_assert( sc_time_stamp() == sc_time(250, SC_NS) ); 6512855Sgabeblack@google.com 6612855Sgabeblack@google.com ev.notify(SC_ZERO_TIME); 6712855Sgabeblack@google.com sc_start(); 6812855Sgabeblack@google.com sc_assert( sc_time_stamp() == sc_time(250, SC_NS) ); 6912855Sgabeblack@google.com 7012855Sgabeblack@google.com ev.notify(10, SC_NS); 7112855Sgabeblack@google.com sc_start(); 7212855Sgabeblack@google.com sc_assert( sc_time_stamp() == sc_time(260, SC_NS) ); 7312855Sgabeblack@google.com 7412855Sgabeblack@google.com ev.notify(10, SC_NS); 7512855Sgabeblack@google.com sc_start(sc_time(100, SC_NS), SC_EXIT_ON_STARVATION); 7612855Sgabeblack@google.com sc_assert( sc_time_stamp() == sc_time(270, SC_NS) ); 7712855Sgabeblack@google.com 7812855Sgabeblack@google.com ev.notify(10, SC_NS); 7912855Sgabeblack@google.com sc_start(sc_time(100, SC_NS)); // SC_RUN_TO_TIME 8012855Sgabeblack@google.com sc_assert( sc_time_stamp() == sc_time(370, SC_NS) ); 8112855Sgabeblack@google.com sc_assert( sc_get_status() == SC_PAUSED ); 8212855Sgabeblack@google.com 8312855Sgabeblack@google.com cout << endl << "Success" << endl; 8412855Sgabeblack@google.com return 0; 8512855Sgabeblack@google.com} 86