summaryrefslogtreecommitdiff
path: root/src/systemc/tests/systemc/communication/reverse_bind
diff options
context:
space:
mode:
Diffstat (limited to 'src/systemc/tests/systemc/communication/reverse_bind')
-rw-r--r--src/systemc/tests/systemc/communication/reverse_bind/test01/golden/test01.log25
-rw-r--r--src/systemc/tests/systemc/communication/reverse_bind/test01/test01.cpp73
-rw-r--r--src/systemc/tests/systemc/communication/reverse_bind/test02/golden/test02.log25
-rw-r--r--src/systemc/tests/systemc/communication/reverse_bind/test02/test02.cpp73
4 files changed, 196 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/communication/reverse_bind/test01/golden/test01.log b/src/systemc/tests/systemc/communication/reverse_bind/test01/golden/test01.log
new file mode 100644
index 000000000..19836dbfb
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/reverse_bind/test01/golden/test01.log
@@ -0,0 +1,25 @@
+SystemC Simulation
+READ_LEAF: change 0
+TOP: change 0
+TOP: change 1
+READ_LEAF: change 1
+TOP: change 2
+READ_LEAF: change 2
+TOP: change 3
+READ_LEAF: change 3
+TOP: change 4
+READ_LEAF: change 4
+TOP: change 5
+READ_LEAF: change 5
+TOP: change 6
+READ_LEAF: change 6
+TOP: change 7
+READ_LEAF: change 7
+TOP: change 8
+READ_LEAF: change 8
+TOP: change 9
+READ_LEAF: change 9
+TOP: change 10
+READ_LEAF: change 10
+TOP: change 11
+READ_LEAF: change 11
diff --git a/src/systemc/tests/systemc/communication/reverse_bind/test01/test01.cpp b/src/systemc/tests/systemc/communication/reverse_bind/test01/test01.cpp
new file mode 100644
index 000000000..a98f7c46a
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/reverse_bind/test01/test01.cpp
@@ -0,0 +1,73 @@
+#include "systemc.h"
+
+SC_MODULE(READ_LEAF)
+{
+ SC_CTOR(READ_LEAF)
+ {
+ SC_METHOD(delta);
+ sensitive << in;
+ }
+ void delta()
+ {
+ cout << "READ_LEAF: change " << (int)in.read() << endl;
+ }
+ sc_in<sc_uint<8> > in;
+};
+
+SC_MODULE(WRITE_LEAF)
+{
+ SC_CTOR(WRITE_LEAF)
+ {
+ SC_METHOD(sync)
+ sensitive << clk.pos();
+ }
+ void sync()
+ {
+ out = out.read() + 1;
+ }
+ sc_signal<sc_uint<8> > out;
+ sc_in_clk clk;
+};
+
+SC_MODULE(MIDDLE)
+{
+ SC_CTOR(MIDDLE) : reader("reader"), writer("writer")
+ {
+ writer.clk(clk); // Bind clk going down the module hierarchy.
+ reader.in(my_port); // Bind my_port going down the module hierarchy.
+ my_port(writer.out); // Bind my_port coming up the module hierarchy.
+ }
+ sc_in_clk clk;
+ sc_in<sc_uint<8> > my_port;
+ READ_LEAF reader;
+ WRITE_LEAF writer;
+};
+
+SC_MODULE(TOP)
+{
+ SC_CTOR(TOP) : down("down")
+ {
+ down.clk(clk); // Bind clk going down the module hierarchy.
+ in(down.my_port); // Bind in coming up the module hierarchy.
+ SC_METHOD(delta);
+ sensitive << in;
+ }
+ void delta()
+ {
+ cout << "TOP: change " << (int)in.read() << endl;
+ }
+ sc_in_clk clk;
+ sc_in<sc_uint<8> > in;
+ MIDDLE down;
+};
+
+int sc_main(int argc, char* arg[])
+{
+ sc_clock clock;
+ TOP top("top");
+ top.clk(clock);
+
+ sc_start(10, SC_NS);
+ return 0;
+}
+
diff --git a/src/systemc/tests/systemc/communication/reverse_bind/test02/golden/test02.log b/src/systemc/tests/systemc/communication/reverse_bind/test02/golden/test02.log
new file mode 100644
index 000000000..19836dbfb
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/reverse_bind/test02/golden/test02.log
@@ -0,0 +1,25 @@
+SystemC Simulation
+READ_LEAF: change 0
+TOP: change 0
+TOP: change 1
+READ_LEAF: change 1
+TOP: change 2
+READ_LEAF: change 2
+TOP: change 3
+READ_LEAF: change 3
+TOP: change 4
+READ_LEAF: change 4
+TOP: change 5
+READ_LEAF: change 5
+TOP: change 6
+READ_LEAF: change 6
+TOP: change 7
+READ_LEAF: change 7
+TOP: change 8
+READ_LEAF: change 8
+TOP: change 9
+READ_LEAF: change 9
+TOP: change 10
+READ_LEAF: change 10
+TOP: change 11
+READ_LEAF: change 11
diff --git a/src/systemc/tests/systemc/communication/reverse_bind/test02/test02.cpp b/src/systemc/tests/systemc/communication/reverse_bind/test02/test02.cpp
new file mode 100644
index 000000000..1f7fa5420
--- /dev/null
+++ b/src/systemc/tests/systemc/communication/reverse_bind/test02/test02.cpp
@@ -0,0 +1,73 @@
+#include "systemc.h"
+
+SC_MODULE(READ_LEAF)
+{
+ SC_CTOR(READ_LEAF)
+ {
+ SC_METHOD(delta);
+ sensitive << in;
+ }
+ void delta()
+ {
+ cout << "READ_LEAF: change " << (int)in.read() << endl;
+ }
+ sc_in<sc_int<8> > in;
+};
+
+SC_MODULE(WRITE_LEAF)
+{
+ SC_CTOR(WRITE_LEAF)
+ {
+ SC_METHOD(sync)
+ sensitive << clk.pos();
+ }
+ void sync()
+ {
+ out = out.read() + 1;
+ }
+ sc_signal<sc_int<8> > out;
+ sc_in_clk clk;
+};
+
+SC_MODULE(MIDDLE)
+{
+ SC_CTOR(MIDDLE) : reader("reader"), writer("writer")
+ {
+ writer.clk(clk); // Bind clk going down the module hierarchy.
+ reader.in(my_port); // Bind my_port going down the module hierarchy.
+ my_port(writer.out); // Bind my_port coming up the module hierarchy.
+ }
+ sc_in_clk clk;
+ sc_in<sc_int<8> > my_port;
+ READ_LEAF reader;
+ WRITE_LEAF writer;
+};
+
+SC_MODULE(TOP)
+{
+ SC_CTOR(TOP) : down("down")
+ {
+ down.clk(clk); // Bind clk going down the module hierarchy.
+ in(down.my_port); // Bind in coming up the module hierarchy.
+ SC_METHOD(delta);
+ sensitive << in;
+ }
+ void delta()
+ {
+ cout << "TOP: change " << (int)in.read() << endl;
+ }
+ sc_in_clk clk;
+ sc_in<sc_int<8> > in;
+ MIDDLE down;
+};
+
+int sc_main(int argc, char* arg[])
+{
+ sc_clock clock;
+ TOP top("top");
+ top.clk(clock);
+
+ sc_start(10, SC_NS);
+ return 0;
+}
+