From 16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 24 May 2018 01:37:55 -0700 Subject: systemc: Import tests from the Accellera systemc distribution. Change-Id: Iad76b398949a55d768a34d027a2d8e3739953da6 Reviewed-on: https://gem5-review.googlesource.com/10845 Reviewed-by: Giacomo Travaglini Maintainer: Gabe Black --- .../communication/reverse_bind/test02/test02.cpp | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/systemc/tests/systemc/communication/reverse_bind/test02/test02.cpp (limited to 'src/systemc/tests/systemc/communication/reverse_bind/test02/test02.cpp') 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 > in; +}; + +SC_MODULE(WRITE_LEAF) +{ + SC_CTOR(WRITE_LEAF) + { + SC_METHOD(sync) + sensitive << clk.pos(); + } + void sync() + { + out = out.read() + 1; + } + sc_signal > 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 > 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 > 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; +} + -- cgit v1.2.3