From 775cacf2b5d39f3b03d466ed883235aa3131008a Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sat, 6 Apr 2024 10:45:08 +0200 Subject: [PATCH] extends cci_param_restricted tests --- scc | 2 +- tests/cci_param_restricted/test.cpp | 67 ++++++++++++++++++++++++++--- 2 files changed, 63 insertions(+), 6 deletions(-) diff --git a/scc b/scc index c42c12c..ff7c45b 160000 --- a/scc +++ b/scc @@ -1 +1 @@ -Subproject commit c42c12c2662c955748d1574093f3bdf9c0efcc64 +Subproject commit ff7c45b19477f1591489465d3ae65458bf643de6 diff --git a/tests/cci_param_restricted/test.cpp b/tests/cci_param_restricted/test.cpp index 3fb0f4c..925edbc 100644 --- a/tests/cci_param_restricted/test.cpp +++ b/tests/cci_param_restricted/test.cpp @@ -16,11 +16,17 @@ struct top : public sc_core::sc_module { top(sc_module_name const& nm) : sc_core::sc_module(nm) {} - scc::cci_param_restricted param1{"param1", 1, scc::min_max_restriction(0, 10), "This is parameter 1"}; - scc::cci_param_restricted param2{"param2", 1, scc::min_max_excl_restriction(0, 10), "This is parameter 3"}; - scc::cci_param_restricted param3{"param3", 1, scc::min_restriction(0), "This is parameter 2"}; - scc::cci_param_restricted param4{"param4", 1, scc::min_excl_restriction(0), "This is parameter 4"}; - scc::cci_param_restricted param5{"param5", 4, scc::discrete_restriction({1, 2, 4, 8, 16}), "This is parameter 5"}; + scc::cci_param_restricted param1{"param1", 5, scc::min_max_restriction(0, 10), "This is parameter 1"}; + scc::cci_param_restricted param2{"param2", 5, scc::min_max_excl_restriction(0, 10), "This is parameter 3"}; + scc::cci_param_restricted param3{"param3", 10, scc::min_restriction(0), "This is parameter 2"}; + scc::cci_param_restricted param4{"param4", 10, scc::min_excl_restriction(0), "This is parameter 4"}; + scc::cci_param_restricted param5{"param5", 1, scc::max_restriction(10), "This is parameter 5"}; + scc::cci_param_restricted param6{"param6", 1, scc::max_excl_restriction(10), "This is parameter 6"}; + scc::cci_param_restricted param7{"param7", 4, scc::discrete_restriction({1, 2, 4, 8, 16}), "This is parameter 7"}; + std::array values_arr{1, 2, 4, 8, 16}; + scc::cci_param_restricted param8{"param8", 4, scc::discrete_restriction(values_arr), "This is parameter 8"}; + std::vector values_vec{1, 2, 4, 8, 16}; + scc::cci_param_restricted param9{"param9", 4, scc::discrete_restriction(values_vec), "This is parameter 9"}; }; factory::add tb; @@ -86,3 +92,54 @@ TEST_CASE("simple cci_param_restricted min test", "[SCC][cci_param_restricted]") REQUIRE(sc_report_handler::get_count(SC_WARNING) == 0); sc_report_handler::initialize(); } + +TEST_CASE("simple cci_param_restricted max test", "[SCC][cci_param_restricted]") { + sc_report_handler::set_actions(SC_ERROR, SC_LOG | SC_CACHE_REPORT | SC_DISPLAY | SC_DO_NOTHING); + auto& dut = factory::get(); + auto run1 = sc_spawn([&dut]() { + sc_core::wait(1_ns); + for(auto i : {0, 10, 11}) { + dut.param5.set_value(i); + sc_core::wait(1_ns); + } + }); + + sc_start(10_ns); + REQUIRE(run1.terminated()); + REQUIRE(sc_report_handler::get_count(SC_ERROR) == 1); + REQUIRE(sc_report_handler::get_count(SC_WARNING) == 0); + sc_report_handler::initialize(); + auto run2 = sc_spawn([&dut]() { + sc_core::wait(1_ns); + for(auto i : {0, 10, 11}) { + dut.param6.set_value(i); + sc_core::wait(1_ns); + } + }); + + sc_start(10_ns); + REQUIRE(run2.terminated()); + REQUIRE(sc_report_handler::get_count(SC_ERROR) == 2); + REQUIRE(sc_report_handler::get_count(SC_WARNING) == 0); + sc_report_handler::initialize(); +} + +TEST_CASE("simple cci_param_restricted discrete test", "[SCC][cci_param_restricted]") { + sc_report_handler::set_actions(SC_ERROR, SC_LOG | SC_CACHE_REPORT | SC_DISPLAY | SC_DO_NOTHING); + auto& dut = factory::get(); + auto run1 = sc_spawn([&dut]() { + sc_core::wait(1_ns); + for(auto i : {4, 10}) { + dut.param7.set_value(i); + dut.param8.set_value(i); + dut.param9.set_value(i); + sc_core::wait(1_ns); + } + }); + + sc_start(10_ns); + REQUIRE(run1.terminated()); + REQUIRE(sc_report_handler::get_count(SC_ERROR) == 3); + REQUIRE(sc_report_handler::get_count(SC_WARNING) == 0); + sc_report_handler::initialize(); +}