diff options
author | Gabe Black <gabeblack@google.com> | 2018-05-24 01:37:55 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2018-08-08 10:09:54 +0000 |
commit | 16fa8d7cc8c92f5ab879e4cf9c6c0bbb3567860f (patch) | |
tree | 7b6faaacb4574a555e561534aa4a8508c0624c32 /src/systemc/tests/systemc/compliance_1666/test219 | |
parent | 7235d3b5211d0ba8f528d930a4c1e7ad62eec51a (diff) | |
download | gem5-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/test219')
-rw-r--r-- | src/systemc/tests/systemc/compliance_1666/test219/golden/test219.log | 4 | ||||
-rw-r--r-- | src/systemc/tests/systemc/compliance_1666/test219/test219.cpp | 79 |
2 files changed, 83 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/compliance_1666/test219/golden/test219.log b/src/systemc/tests/systemc/compliance_1666/test219/golden/test219.log new file mode 100644 index 000000000..d1a84db9a --- /dev/null +++ b/src/systemc/tests/systemc/compliance_1666/test219/golden/test219.log @@ -0,0 +1,4 @@ +SystemC Simulation +Should be silent... + +Success diff --git a/src/systemc/tests/systemc/compliance_1666/test219/test219.cpp b/src/systemc/tests/systemc/compliance_1666/test219/test219.cpp new file mode 100644 index 000000000..0dc0f5361 --- /dev/null +++ b/src/systemc/tests/systemc/compliance_1666/test219/test219.cpp @@ -0,0 +1,79 @@ +#define SC_INCLUDE_DYNAMIC_PROCESSES
+
+#include <systemc>
+using namespace sc_core;
+using namespace sc_dt;
+using std::cout;
+using std::endl;
+
+// 19) Call to sc_spawn in what would have been the final update phase...
+
+sc_event ev;
+
+struct Prim: sc_prim_channel, sc_interface
+{
+ Prim() : count(0) {}
+
+ void write() {
+ request_update();
+ }
+ void update() {
+ sc_spawn(sc_bind(&Prim::spawned_proc, this));
+ }
+ void spawned_proc()
+ {
+ ++ count;
+ ev.notify(5, SC_NS);
+ }
+ const sc_event& default_event() const { return ev; }
+ int count;
+};
+
+SC_MODULE(M)
+{
+ Prim prim;
+ SC_CTOR(M)
+ : ME_count(0)
+ {
+ SC_THREAD(T);
+ SC_METHOD(ME);
+ sensitive << prim;
+ dont_initialize();
+ }
+ void T()
+ {
+ wait(10, SC_NS);
+ prim.write();
+ sc_assert(sc_time_stamp() == sc_time(10, SC_NS));
+ }
+ void ME()
+ {
+ ++ ME_count;
+ sc_assert(sc_time_stamp() == sc_time(15, SC_NS));
+ }
+ int ME_count;
+};
+
+struct Top: sc_module
+{
+ M *m;
+ Top(sc_module_name)
+ {
+ m = new M("m");
+ }
+};
+
+int sc_main(int argc, char* argv[])
+{
+ cout << "Should be silent..." << endl;
+
+ Top top("top");
+ sc_start();
+
+ sc_assert(top.m->prim.count == 1);
+ sc_assert(top.m->ME_count == 1);
+
+
+ cout << endl << "Success" << endl;
+ return 0;
+}
|