112855Sgabeblack@google.com// sc_writer_policy template argument of class sc_signal
212855Sgabeblack@google.com
312855Sgabeblack@google.com#define SC_INCLUDE_DYNAMIC_PROCESSES
412855Sgabeblack@google.com#include <systemc>
512855Sgabeblack@google.com
612855Sgabeblack@google.comusing namespace sc_core;
712855Sgabeblack@google.comusing namespace sc_dt;
812855Sgabeblack@google.comusing std::cout;
912855Sgabeblack@google.comusing std::endl;
1012855Sgabeblack@google.comusing std::string;
1112855Sgabeblack@google.com
1212855Sgabeblack@google.com
1312855Sgabeblack@google.comstruct M: sc_module
1412855Sgabeblack@google.com{
1512855Sgabeblack@google.com  sc_inout<bool> port;
1612855Sgabeblack@google.com
1712855Sgabeblack@google.com  sc_time delay;
1812855Sgabeblack@google.com
1912855Sgabeblack@google.com  M(sc_module_name _name, sc_time _delay)
2012855Sgabeblack@google.com  : port("port")
2112855Sgabeblack@google.com  , delay(_delay)
2212855Sgabeblack@google.com  {
2312855Sgabeblack@google.com    SC_THREAD(T);
2412855Sgabeblack@google.com  }
2512855Sgabeblack@google.com
2612855Sgabeblack@google.com  void T()
2712855Sgabeblack@google.com  {
2812855Sgabeblack@google.com	wait(delay);
2912855Sgabeblack@google.com	port.write(true);
3012855Sgabeblack@google.com	cout << "port written in " << name() << " at " << sc_time_stamp()
3112855Sgabeblack@google.com	     << endl;
3212855Sgabeblack@google.com        wait(sc_time(1, SC_NS));
3312855Sgabeblack@google.com  }
3412855Sgabeblack@google.com
3512855Sgabeblack@google.com  SC_HAS_PROCESS(M);
3612855Sgabeblack@google.com};
3712855Sgabeblack@google.com
3812855Sgabeblack@google.comstruct Top: sc_module
3912855Sgabeblack@google.com{
4012855Sgabeblack@google.com  M *m1;
4112855Sgabeblack@google.com  M *m2;
4212855Sgabeblack@google.com
4312855Sgabeblack@google.com  sc_signal<bool,SC_MANY_WRITERS> multi_sig_1;
4412855Sgabeblack@google.com
4512855Sgabeblack@google.com  Top(sc_module_name _name)
4612855Sgabeblack@google.com  : multi_sig_1("multi_sig_1")
4712855Sgabeblack@google.com  {
4812855Sgabeblack@google.com    m1 = new M("m1", sc_time(1, SC_PS));
4912855Sgabeblack@google.com    m2 = new M("m2", sc_time(2, SC_PS));
5012855Sgabeblack@google.com
5112855Sgabeblack@google.com    m1->port.bind(multi_sig_1);
5212855Sgabeblack@google.com    m2->port.bind(multi_sig_1);
5312855Sgabeblack@google.com
5412855Sgabeblack@google.com    multi_sig_1.write(true);
5512855Sgabeblack@google.com  }
5612855Sgabeblack@google.com
5712855Sgabeblack@google.com  SC_HAS_PROCESS(Top);
5812855Sgabeblack@google.com};
5912855Sgabeblack@google.com
6012855Sgabeblack@google.com
6112855Sgabeblack@google.comint sc_main(int argc, char* argv[])
6212855Sgabeblack@google.com{
6312855Sgabeblack@google.com  Top top("top");
6412855Sgabeblack@google.com  sc_start(5,SC_PS);
6512855Sgabeblack@google.com
6612855Sgabeblack@google.com  cout << endl << "Success" << endl;
6712855Sgabeblack@google.com  return 0;
6812855Sgabeblack@google.com}
6912855Sgabeblack@google.com
70