summaryrefslogtreecommitdiff
path: root/src/systemc/tests/systemc/compliance_1666/test234
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2018-05-24 01:37:55 -0700
committerGabe Black <gabeblack@google.com>2018-08-08 10:09:54 +0000
commit16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f (patch)
tree7b6faaacb4574a555e561534aa4a8508c0624c32 /src/systemc/tests/systemc/compliance_1666/test234
parent7235d3b5211d0ba8f528d930a4c1e7ad62eec51a (diff)
downloadgem5-16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f.tar.xz
systemc: Import tests from the Accellera systemc distribution.
Change-Id: Iad76b398949a55d768a34d027a2d8e3739953da6 Reviewed-on: https://gem5-review.googlesource.com/10845 Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/systemc/tests/systemc/compliance_1666/test234')
-rw-r--r--src/systemc/tests/systemc/compliance_1666/test234/golden/test234.log6
-rw-r--r--src/systemc/tests/systemc/compliance_1666/test234/test234.cpp110
2 files changed, 116 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/compliance_1666/test234/golden/test234.log b/src/systemc/tests/systemc/compliance_1666/test234/golden/test234.log
new file mode 100644
index 000000000..6dbc6d5c7
--- /dev/null
+++ b/src/systemc/tests/systemc/compliance_1666/test234/golden/test234.log
@@ -0,0 +1,6 @@
+SystemC Simulation
+Should be silent...
+
+Info: /OSCI/SystemC: Simulation stopped by user.
+
+Success
diff --git a/src/systemc/tests/systemc/compliance_1666/test234/test234.cpp b/src/systemc/tests/systemc/compliance_1666/test234/test234.cpp
new file mode 100644
index 000000000..1b5467544
--- /dev/null
+++ b/src/systemc/tests/systemc/compliance_1666/test234/test234.cpp
@@ -0,0 +1,110 @@
+#include <systemc>
+using namespace sc_core;
+using namespace sc_dt;
+using std::cout;
+using std::endl;
+
+// 34) event finder on multiport
+
+struct i_f: virtual sc_interface
+{
+ virtual const sc_event& event() const = 0;
+};
+
+struct Chan: i_f, sc_object
+{
+ virtual const sc_event& event() const { return ev; }
+ sc_event ev;
+};
+
+struct Port: sc_port<i_f,0>
+{
+ sc_event_finder& find_event() const
+ {
+ return *new sc_event_finder_t<i_f>( *this, &i_f::event );
+ }
+};
+
+SC_MODULE(M)
+{
+ Port mp;
+ bool flag, flag2;
+
+ SC_CTOR(M)
+ : flag(false), flag2(false)
+ {
+ SC_THREAD(T);
+ sensitive << mp.find_event();
+ }
+ void T()
+ {
+ wait();
+ sc_assert(sc_time_stamp() == sc_time(1, SC_NS));
+ wait();
+ sc_assert(sc_time_stamp() == sc_time(11, SC_NS));
+ wait();
+ sc_assert(sc_time_stamp() == sc_time(111, SC_NS));
+ flag = true;
+ wait();
+ flag = false;
+ }
+ void end_of_elaboration()
+ {
+ SC_THREAD(T2);
+ for (int i = 0; i < mp.size(); i++)
+ sensitive << mp[i]->event();
+ }
+ void T2()
+ {
+ wait();
+ sc_assert(sc_time_stamp() == sc_time(1, SC_NS));
+ wait();
+ sc_assert(sc_time_stamp() == sc_time(11, SC_NS));
+ wait();
+ sc_assert(sc_time_stamp() == sc_time(111, SC_NS));
+ flag2 = true;
+ wait();
+ flag2 = false;
+ }
+ void end_of_simulation()
+ {
+ sc_assert( flag );
+ sc_assert( flag2 );
+ }
+};
+
+SC_MODULE(Top)
+{
+ M *m;
+ Chan chan1, chan2, chan3;
+ SC_CTOR(Top)
+ {
+ m = new M("m");
+ m->mp(chan1);
+ m->mp(chan2);
+ m->mp(chan3);
+ SC_THREAD(T);
+ }
+ void T()
+ {
+ wait(1, SC_NS);
+ chan1.ev.notify();
+ wait(10, SC_NS);
+ chan2.ev.notify();
+ wait(100, SC_NS);
+ chan3.ev.notify();
+ wait(1, SC_NS);
+ sc_stop();
+ }
+};
+
+int sc_main(int argc, char* argv[])
+{
+ cout << "Should be silent..." << endl;
+
+ Top top("top");
+ sc_start();
+
+ cout << endl << "Success" << endl;
+ return 0;
+}