1// sc_writer_policy template argument of class sc_signal
2
3#define SC_INCLUDE_DYNAMIC_PROCESSES
4#include <systemc>
5
6using namespace sc_core;
7using namespace sc_dt;
8using std::cout;
9using std::endl;
10using std::string;
11
12
13struct M: sc_module
14{
15  sc_inout<bool> port;
16
17  sc_time delay;
18
19  M(sc_module_name _name, sc_time _delay)
20  : port("port")
21  , delay(_delay)
22  {
23    SC_THREAD(T);
24  }
25
26  void T()
27  {
28	wait(delay);
29	port.write(true);
30	cout << "port written in " << name() << " at " << sc_time_stamp()
31	     << endl;
32        wait(sc_time(1, SC_NS));
33  }
34
35  SC_HAS_PROCESS(M);
36};
37
38struct Top: sc_module
39{
40  M *m1;
41  M *m2;
42
43  sc_signal<bool,SC_MANY_WRITERS> multi_sig_1;
44
45  Top(sc_module_name _name)
46  : multi_sig_1("multi_sig_1")
47  {
48    m1 = new M("m1", sc_time(1, SC_PS));
49    m2 = new M("m2", sc_time(2, SC_PS));
50
51    m1->port.bind(multi_sig_1);
52    m2->port.bind(multi_sig_1);
53
54    multi_sig_1.write(true);
55  }
56
57  SC_HAS_PROCESS(Top);
58};
59
60
61int sc_main(int argc, char* argv[])
62{
63  Top top("top");
64  sc_start(5,SC_PS);
65
66  cout << endl << "Success" << endl;
67  return 0;
68}
69
70