112855Sgabeblack@google.com#include <systemc>
212855Sgabeblack@google.com
312855Sgabeblack@google.comusing namespace sc_core;
412855Sgabeblack@google.comusing std::cout;
512855Sgabeblack@google.comusing std::endl;
612855Sgabeblack@google.com
712855Sgabeblack@google.comstruct M4: sc_module
812855Sgabeblack@google.com{
912855Sgabeblack@google.com  M4(sc_module_name _name)
1012855Sgabeblack@google.com  {
1112855Sgabeblack@google.com    SC_THREAD(calling);
1212855Sgabeblack@google.com    SC_THREAD(target);
1312855Sgabeblack@google.com      t = sc_get_current_process_handle();
1412855Sgabeblack@google.com  }
1512855Sgabeblack@google.com
1612855Sgabeblack@google.com  sc_process_handle t;
1712855Sgabeblack@google.com  sc_event ev;
1812855Sgabeblack@google.com  int count;
1912855Sgabeblack@google.com
2012855Sgabeblack@google.com  void calling()
2112855Sgabeblack@google.com  {
2212855Sgabeblack@google.com
2312855Sgabeblack@google.com    t.sync_reset_on();
2412855Sgabeblack@google.com    wait(10, SC_NS);
2512855Sgabeblack@google.com
2612855Sgabeblack@google.com    t.suspend();
2712855Sgabeblack@google.com    wait(10, SC_NS);
2812855Sgabeblack@google.com
2912855Sgabeblack@google.com    t.disable();
3012855Sgabeblack@google.com    wait(10, SC_NS);
3112855Sgabeblack@google.com
3212855Sgabeblack@google.com    t.enable();
3312855Sgabeblack@google.com    ev.notify();
3412855Sgabeblack@google.com    wait(10, SC_NS);  // !!!!!! target is RESET WHILE STILL SUSPENDED !!!!!!
3512855Sgabeblack@google.com
3612855Sgabeblack@google.com    sc_stop();
3712855Sgabeblack@google.com  }
3812855Sgabeblack@google.com
3912855Sgabeblack@google.com  void target()
4012855Sgabeblack@google.com  {
4112855Sgabeblack@google.com    cout << "Target called/reset at " << sc_time_stamp() << endl;
4212855Sgabeblack@google.com    count = 0;
4312855Sgabeblack@google.com    for (;;)
4412855Sgabeblack@google.com    {
4512855Sgabeblack@google.com      wait(ev);
4612855Sgabeblack@google.com      cout << "Target awoke at " << sc_time_stamp() << " count = " << count << endl;
4712855Sgabeblack@google.com      ++count;
4812855Sgabeblack@google.com    }
4912855Sgabeblack@google.com  }
5012855Sgabeblack@google.com
5112855Sgabeblack@google.com  SC_HAS_PROCESS(M4);
5212855Sgabeblack@google.com};
5312855Sgabeblack@google.com
5412855Sgabeblack@google.comint sc_main(int argc, char* argv[])
5512855Sgabeblack@google.com{
5612855Sgabeblack@google.com  M4 m("m");
5712855Sgabeblack@google.com
5812855Sgabeblack@google.com  sc_core::sc_allow_process_control_corners = true;
5912855Sgabeblack@google.com  sc_start();
6012855Sgabeblack@google.com
6112855Sgabeblack@google.com  return 0;
6212855Sgabeblack@google.com}
6312855Sgabeblack@google.com
64