Compare commits

...

10 Commits

10 changed files with 216 additions and 2 deletions

2
.gitignore vendored
View File

@ -44,3 +44,5 @@
/*.gtkw
/.envrc.*
/.direnv/
/.venv/
/.cache

25
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,25 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [{
"name": "cci_param_restricted",
"type": "cppdbg",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/build/tests/cci_param_restricted/cci_param_restricted",
"linux": {
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb"
},
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "CMake: build"
}]
}

16
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,16 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "cmake",
"label": "CMake: build",
"command": "build",
"targets": [
"all"
],
"group": "build",
"problemMatcher": ["$gcc"],
"detail": "CMake template build task",
}
]
}

14
Jenkinsfile vendored
View File

@ -89,6 +89,20 @@ pipeline {
stage('Build & test') { steps { build_n_test_project() }}
}
}
//
stage('Format check') {
agent {docker { image 'ubuntu-riscv' } }
stages {
stage('Checkout') { steps { checkout_project() }}
stage('Setup') { steps { setup_conan() }}
stage('Build & check format') { steps {
sh'''
cmake -S . -B build
cmake --build build --target format-check
'''
}}
}
}
}
}
}

View File

@ -1,3 +1,5 @@
[![Build Status](https://jenkins.minres.com/view/SystemC/job/SCC%20Test/job/develop/badge/icon)](https://jenkins.minres.com/view/SystemC/job/SCC%20Test/job/develop/)
# SystemC-Components-Test
Examples and tests for the SystemC-Components

2
scc

@ -1 +1 @@
Subproject commit 6063f8da997247d68aec9422e39c93458f18bba0
Subproject commit fe86bd5b68198a75082fe0b351cd675a62808c58

View File

@ -18,7 +18,7 @@ using namespace sc_core;
int sc_main(int argc, char* argv[]) {
auto my_name = util::split(argv[0], '/').back();
scc::init_logging(LogConfig().logLevel(getenv("SCC_TEST_VERBOSE") ? log::DEBUG : log::FATAL).logAsync(false));
scc::init_logging(LogConfig().logLevel(getenv("SCC_TEST_VERBOSE") ? log::DEBUG : log::FATAL).logAsync(false).msgTypeFieldWidth(35));
// create tracer if environment variable SCC_TEST_TRACE is defined
std::unique_ptr<scc::tracer> tracer;
if(getenv("SCC_TEST_TRACE"))

View File

@ -1,5 +1,6 @@
add_subdirectory(io-redirector)
add_subdirectory(ordered_semaphore)
add_subdirectory(cci_param_restricted)
add_subdirectory(ahb_pin_level)
add_subdirectory(axi4_pin_level)
add_subdirectory(ace_pin_level)

View File

@ -0,0 +1,9 @@
project (cci_param_restricted)
add_executable(${PROJECT_NAME}
test.cpp
${test_util_SOURCE_DIR}/sc_main.cpp
)
target_link_libraries (${PROJECT_NAME} PUBLIC test_util)
catch_discover_tests(${PROJECT_NAME})

View File

@ -0,0 +1,145 @@
#ifndef SC_INCLUDE_DYNAMIC_PROCESSES
#define SC_INCLUDE_DYNAMIC_PROCESSES
#include <sysc/kernel/sc_simcontext.h>
#endif
#include <catch2/catch_all.hpp>
#include <factory.h>
#include <scc/cci_param_restricted.h>
#include <scc/utilities.h>
#include <systemc>
using namespace sc_core;
struct top : public sc_core::sc_module {
top()
: top("top") {}
top(sc_module_name const& nm)
: sc_core::sc_module(nm) {}
scc::cci_param_restricted<int> param1{"param1", 5, scc::min_max_restriction(0, 10), "This is parameter 1"};
scc::cci_param_restricted<int> param2{"param2", 5, scc::min_max_excl_restriction(0, 10), "This is parameter 3"};
scc::cci_param_restricted<int> param3{"param3", 10, scc::min_restriction(0), "This is parameter 2"};
scc::cci_param_restricted<int> param4{"param4", 10, scc::min_excl_restriction(0), "This is parameter 4"};
scc::cci_param_restricted<int> param5{"param5", 1, scc::max_restriction(10), "This is parameter 5"};
scc::cci_param_restricted<int> param6{"param6", 1, scc::max_excl_restriction(10), "This is parameter 6"};
scc::cci_param_restricted<int> param7{"param7", 4, scc::discrete_restriction({1, 2, 4, 8, 16}), "This is parameter 7"};
std::array<int, 5> values_arr{1, 2, 4, 8, 16};
scc::cci_param_restricted<int> param8{"param8", 4, scc::discrete_restriction(values_arr), "This is parameter 8"};
std::vector<int> values_vec{1, 2, 4, 8, 16};
scc::cci_param_restricted<int> param9{"param9", 4, scc::discrete_restriction(values_vec), "This is parameter 9"};
};
factory::add<top> tb;
TEST_CASE("simple cci_param_restricted min_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<top>();
auto run1 = sc_spawn([&dut]() {
sc_core::wait(1_ns);
for(auto i : {0, 5, 10, -1, 11}) {
dut.param1.set_value(i);
sc_core::wait(1_ns);
}
});
sc_start(10_ns);
REQUIRE(run1.terminated());
REQUIRE(sc_report_handler::get_count(SC_ERROR) == 2);
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, 5, 10, -1, 11}) {
dut.param2.set_value(i);
sc_core::wait(1_ns);
}
});
sc_start(10_ns);
REQUIRE(run2.terminated());
REQUIRE(sc_report_handler::get_count(SC_ERROR) == 4);
REQUIRE(sc_report_handler::get_count(SC_WARNING) == 0);
sc_report_handler::initialize();
}
TEST_CASE("simple cci_param_restricted min 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<top>();
auto run1 = sc_spawn([&dut]() {
sc_core::wait(1_ns);
for(auto i : {0, 5, -1}) {
dut.param3.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, 5, -1}) {
dut.param4.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 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<top>();
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<top>();
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();
}