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 --- .../systemc/compliance_1666/test235b/test235b.cpp | 92 ++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 src/systemc/tests/systemc/compliance_1666/test235b/test235b.cpp (limited to 'src/systemc/tests/systemc/compliance_1666/test235b/test235b.cpp') diff --git a/src/systemc/tests/systemc/compliance_1666/test235b/test235b.cpp b/src/systemc/tests/systemc/compliance_1666/test235b/test235b.cpp new file mode 100644 index 000000000..d5855e1cc --- /dev/null +++ b/src/systemc/tests/systemc/compliance_1666/test235b/test235b.cpp @@ -0,0 +1,92 @@ +#include +using namespace sc_core; +using namespace sc_dt; +using std::cout; +using std::endl; + +// 35) Port policy (incorrect binding) + +SC_MODULE(M) +{ + sc_port,1,SC_ONE_OR_MORE_BOUND> p1; + sc_port,2,SC_ALL_BOUND> p2; + sc_port,2,SC_ZERO_OR_MORE_BOUND> p3; + sc_port,1,SC_ONE_OR_MORE_BOUND> p4; + sc_port,5,SC_ALL_BOUND> p5; + sc_port,5,SC_ALL_BOUND> p6; + sc_port,0,SC_ZERO_OR_MORE_BOUND> p7; + + SC_CTOR(M) + : p1("p1"), + p2("p2"), + p3("p3"), + p4("p4"), + p5("p5"), + p6("p6"), + p7("p7") + {} + void end_of_elaboration() + { + sc_assert(p1.size() == 0); + sc_assert(p2.size() == 1); + sc_assert(p3.size() == 3); + sc_assert(p4.size() == 2); + sc_assert(p5.size() == 6); + sc_assert(p6.size() == 0); + sc_assert(p7.size() == 2); + } +}; + +SC_MODULE(Top) +{ + sc_port,0,SC_ZERO_OR_MORE_BOUND> p0_unbound; + sc_port,0,SC_ZERO_OR_MORE_BOUND> p1_once; + sc_port,0,SC_ZERO_OR_MORE_BOUND> p2_twice; + + M *m; + sc_signal sig1, sig2, sig3, sig4; + + SC_CTOR(Top) + { + m = new M("m"); + m->p1(p0_unbound); + + m->p2(p1_once); + + m->p3(p1_once); + m->p3(p2_twice); + + m->p4(p2_twice); + + m->p5(sig1); + m->p5(p1_once); + m->p5(sig2); + m->p5(p2_twice); + m->p5(sig3); + + m->p7(sig1); + m->p7(sig1); + } +}; + +int sc_main(int argc, char* argv[]) +{ + cout << "Should be 7 errors but no aborts ..." << endl; + + sc_report_handler::set_actions(SC_ERROR, SC_DISPLAY); + + sc_signal sig1, sig2, sig3, sig4; + + Top top("top"); + top.p1_once(sig1); + + top.p2_twice(sig2); + top.p2_twice(sig3); + + sc_start(1, SC_NS); + + sc_assert(sc_report_handler::get_count(SC_ERROR) == 7); + + cout << endl << "Success" << endl; + return 0; +} -- cgit v1.2.3