From 73e4d5d644870af3acdcb7cc72d14e6e66a3e569 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Mon, 22 Sep 2025 11:54:46 +0200 Subject: [PATCH] extends cxs_tlm test to support tracing --- .envrc | 6 +++- .gitignore | 1 + .vscode/launch.json | 56 ++++++++++++++++++++----------- .vscode/settings.json | 12 ++++--- Modulefile | 17 ---------- scc | 2 +- src/sc_main.cpp | 3 ++ tests/cxs_tlm/csx_packet_test.cpp | 2 +- tests/cxs_tlm/testbench.h | 17 +++++++++- 9 files changed, 71 insertions(+), 45 deletions(-) delete mode 100644 Modulefile diff --git a/.envrc b/.envrc index 488f293..4460a8b 100644 --- a/.envrc +++ b/.envrc @@ -1,4 +1,8 @@ -module load ./Modulefile +module load tools/utilities +module load tools/cmake/3.28 +module load tools/clang/14.0 +module load tools/vscode + distro=`/bin/lsb_release -i -s` if [ $distro == "CentOS" ]; then . /opt/rh/devtoolset-8/enable diff --git a/.gitignore b/.gitignore index ffab976..65c3b47 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,4 @@ /.venv/ /.cache /CMakeUserPresets.json +*.scview diff --git a/.vscode/launch.json b/.vscode/launch.json index ea0ead0..61973d6 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,22 +1,38 @@ { - // 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": "gdb", - "request": "launch", - "cwd": "${workspaceRoot}", - "program": "${workspaceRoot}/build/Debug/tests/cci_param_restricted/cci_param_restricted", - "preLaunchTask": "CMake: build" - },{ - "name": "dmi_access", - "type": "gdb", - "request": "launch", - "cwd": "${workspaceRoot}", - "program": "${workspaceRoot}/build/Debug/tests/memory_subsys/memory_subsys", - "preLaunchTask": "CMake: build" - } - ] + // 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": "gdb", + "request": "launch", + "cwd": "${workspaceRoot}", + "program": "${workspaceRoot}/build/Debug/tests/cci_param_restricted/cci_param_restricted", + "preLaunchTask": "CMake: build" + }, + { + "name": "dmi_access", + "type": "gdb", + "request": "launch", + "cwd": "${workspaceRoot}", + "program": "${workspaceRoot}/build/Debug/tests/memory_subsys/memory_subsys", + "preLaunchTask": "CMake: build" + }, + { + "name": "cxs_tlm", + "type": "gdb", + "request": "launch", + "cwd": "${workspaceRoot}", + "program": "${workspaceRoot}/build/Debug/tests/cxs_tlm/cxs_tlm", + "arguments": "-n single-packet", + "preLaunchTask": "CMake: build", + "environment": { + "SCC_TEST_TRACE": "1", + "SCC_TEST_VERBOSE": "1" + }, + "openGdbConsole": true + } + ] } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 9ce5386..4dce1a6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,8 +11,8 @@ "--background-index", "--compile-commands-dir=${workspaceFolder}/build" ], - "cmake.buildDirectory" : "${workspaceRoot}/build/${buildType}", - "cmake.configureArgs": ["-B", "${workspaceRoot}/build/${buildType}"], + "cmake.buildDirectory": "${workspaceRoot}/build/${buildType}", + //"cmake.configureArgs": ["-B", "${workspaceRoot}/build/${buildType}"], "cmake.configureOnOpen": false, "cmake.configureOnEdit": true, "cmake.autoSelectActiveFolder": true, @@ -21,8 +21,12 @@ "cmake.copyCompileCommands": "${workspaceFolder}/build/compile_commands.json", "cmake.options.statusBarVisibility": "hidden", "cmake.options.advanced": { - "configure": {"projectStatusVisibility": "visible"}, - "build": {"statusBarVisibility": "visible"} + "configure": { + "projectStatusVisibility": "visible" + }, + "build": { + "statusBarVisibility": "visible" + } }, "todo-tree.ripgrep.ripgrep": "/bin/rg", "files.watcherExclude": { diff --git a/Modulefile b/Modulefile deleted file mode 100644 index 4891e78..0000000 --- a/Modulefile +++ /dev/null @@ -1,17 +0,0 @@ -#%Module###################################################################### -## -## Project Module -## -proc ModulesHelp { } { - puts stderr "\tThe SCC Tests Project Module\n" - puts stderr "\tThis module loads PATHs and variables for SCC tests." -} - -set distro [exec /usr/bin/lsb_release -i -s] -if { $distro == "CentOS" && ![info exists ::env(PROJECT)] && ![info exists ::env(PCP_DIR)] } { - puts stderr "Don't forget to execute 'scl enable devtoolset-7 llvm-toolset-7 bash'" -} - -module load tools/utilities -module load tools/cmake/3.28 -module load tools/clang/14.0 diff --git a/scc b/scc index 50de0c5..4429911 160000 --- a/scc +++ b/scc @@ -1 +1 @@ -Subproject commit 50de0c564ab314e385793e2a96b61d028f5cbdea +Subproject commit 4429911c18aa91eeab9e902f488e86aca6060237 diff --git a/src/sc_main.cpp b/src/sc_main.cpp index b1fe425..a530f12 100644 --- a/src/sc_main.cpp +++ b/src/sc_main.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -27,10 +28,12 @@ int sc_main(int argc, char* argv[]) { auto level = getenv("SCC_TEST_VERBOSE"); auto log_lvl = level ? static_cast(std::min(strtoul(level, nullptr, 10) + 4, 7UL)) : log::FATAL; scc::init_logging(LogConfig().logLevel(log_lvl).logAsync(false).msgTypeFieldWidth(35)); + scc::configurer cfg(""); // create tracer if environment variable SCC_TEST_TRACE is defined std::unique_ptr tracer; if(auto* test_trace = getenv("SCC_TEST_TRACE")) { tracer = std::make_unique(my_name, scc::tracer::ENABLE, scc::tracer::ENABLE); + cfg.set_value("scc_tracer.default_trace_enable", true); } int result = -1; if(setjmp(abrt) == 0) { diff --git a/tests/cxs_tlm/csx_packet_test.cpp b/tests/cxs_tlm/csx_packet_test.cpp index 8bfdcf3..4e2c492 100644 --- a/tests/cxs_tlm/csx_packet_test.cpp +++ b/tests/cxs_tlm/csx_packet_test.cpp @@ -5,7 +5,6 @@ #undef CHECK #include #include -#include using namespace sc_core; namespace cxs { @@ -17,6 +16,7 @@ template unsigned run_scenario(STATE& state, un auto& dut = factory::get>(); if(burst_factor) dut.tx.burst_len.set_value(burst_factor); + dut.rx.max_credit.set_value(5); dut.rst.write(true); sc_start(state.reset_cycles * dut.clk.period()); dut.rst.write(false); diff --git a/tests/cxs_tlm/testbench.h b/tests/cxs_tlm/testbench.h index 5ef8617..2982a0c 100644 --- a/tests/cxs_tlm/testbench.h +++ b/tests/cxs_tlm/testbench.h @@ -2,12 +2,12 @@ #define _TESTBENCH_H_ #include +#include #include #include #include #include #include -#include #include #include #include @@ -27,7 +27,9 @@ template struct testbench : public sc_core::sc_module { sc_core::sc_signal rst{"rst"}; tlm::nw::initiator_mixin, cxs_packet_types> isck{"isck"}; cxs_transmitter tx{"tx"}; + tlm::nw::scv::tlm_recorder_module tx_rec{"tx_rec"}; cxs_channel cxs_chan{"cxs_chan"}; + tlm::nw::scv::tlm_recorder_module rx_rec{"rx_rec"}; cxs_receiver rx{"rx"}; tlm::nw::target_mixin, false, cxs_packet_types> tsck{"tsck"}; @@ -43,12 +45,25 @@ template struct testbench : public sc_core::sc_module { isck(tx.tsck); tx.clk_i(clk); tx.rst_i(rst); + cxs_chan.tx_clk_i(clk); + cxs_chan.rx_clk_i(clk); +#if 0 tx.isck(cxs_chan.tsck); cxs_chan.isck(rx.tsck); +#else + tx.isck(tx_rec.ts); + tx_rec.is(cxs_chan.tsck); + cxs_chan.isck(rx_rec.ts); + rx_rec.is(rx.tsck); +#endif rx.clk_i(clk); rx.rst_i(rst); rx.isck(tsck); + tx.clock_period.set_value(1_ns); + cxs_chan.tx_clock_period.set_value(1_ns); cxs_chan.channel_delay.set_value(100_ns); + cxs_chan.rx_clock_period.set_value(1_ns); + rx.clock_period.set_value(1_ns); rx.max_credit.set_value(15); }