From cde2d0463c566a3da813c120789fc9027d90b081 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Tue, 21 Oct 2025 16:52:01 +0200 Subject: [PATCH] adds initial files for mt test --- .vscode/launch.json | 30 ++++++++++++++++++ .vscode/settings.json | 1 + conanfile.py | 5 +-- scc | 2 +- tests/CMakeLists.txt | 1 + tests/quantum_keeper_mt/CMakeLists.txt | 5 +++ tests/quantum_keeper_mt/sc_main.cpp | 38 ++++++++++++++++++++++ tests/quantum_keeper_mt/top_module.h | 44 ++++++++++++++++++++++++++ 8 files changed, 121 insertions(+), 5 deletions(-) create mode 100644 tests/quantum_keeper_mt/CMakeLists.txt create mode 100644 tests/quantum_keeper_mt/sc_main.cpp create mode 100644 tests/quantum_keeper_mt/top_module.h diff --git a/.vscode/launch.json b/.vscode/launch.json index 61973d6..bbf0a1b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,6 +4,36 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "type": "gdb", + "request": "launch", + "name": "quantum_keeper_mt", + "program": "${workspaceFolder}/build/Debug/tests/quantum_keeper_mt/quantum_keeper_mt" + }, + { + "name": "cppdbg quantum_keeper_mt", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceRoot}/build/Debug/tests/quantum_keeper_mt/quantum_keeper_mt", + "args": [], + "stopAtEntry": false, + "cwd": "${fileDirname}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + { + "description": "Set Disassembly Flavor to Intel", + "text": "-gdb-set disassembly-flavor intel", + "ignoreFailures": true + } + ] + }, { "name": "cci_param_restricted", "type": "gdb", diff --git a/.vscode/settings.json b/.vscode/settings.json index 4dce1a6..d46a1f1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,6 +6,7 @@ } ], "editor.formatOnSave": true, + "editor.hover.delay": 1500, "clangd.arguments": [ "--pretty", "--background-index", diff --git a/conanfile.py b/conanfile.py index 9be5614..edfda26 100644 --- a/conanfile.py +++ b/conanfile.py @@ -35,7 +35,7 @@ class Pkg(ConanFile): } def requirements(self): - self.requires("systemc/2.3.4") + self.requires("systemc/3.0.1") self.requires("fmt/8.0.1") self.requires("spdlog/1.9.2") self.requires("boost/1.85.0") @@ -44,9 +44,6 @@ class Pkg(ConanFile): self.requires("yaml-cpp/0.7.0") self.requires("jsoncpp/1.9.5") self.requires("zlib/1.2.12") - self.requires("rapidjson/cci.20230929") - if os.path.isdir("tgc-iss/dbt-rise-plugins"): - self.requires("lua/5.4.3") def build_requirements(self): pass diff --git a/scc b/scc index 6c25b65..0330180 160000 --- a/scc +++ b/scc @@ -1 +1 @@ -Subproject commit 6c25b65dc95d8310f613d689ce1e4a59647521d6 +Subproject commit 0330180d7b576fb0e9795076cef8bea3c5ec8ad7 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0982470..90877e2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -11,6 +11,7 @@ add_subdirectory(sc_fixed_tracing) add_subdirectory(cxs_tlm) add_subdirectory(tlm_memory) add_subdirectory(memory_subsys) +add_subdirectory(quantum_keeper_mt) add_subdirectory(sim_speed) if(FULL_TEST_SUITE) add_subdirectory(sim_performance) diff --git a/tests/quantum_keeper_mt/CMakeLists.txt b/tests/quantum_keeper_mt/CMakeLists.txt new file mode 100644 index 0000000..413e451 --- /dev/null +++ b/tests/quantum_keeper_mt/CMakeLists.txt @@ -0,0 +1,5 @@ +add_executable (quantum_keeper_mt + sc_main.cpp +) +target_link_libraries (quantum_keeper_mt LINK_PUBLIC scc-sysc) +add_test(NAME quantum_keeper_mt COMMAND quantum_keeper_mt) \ No newline at end of file diff --git a/tests/quantum_keeper_mt/sc_main.cpp b/tests/quantum_keeper_mt/sc_main.cpp new file mode 100644 index 0000000..6e4157d --- /dev/null +++ b/tests/quantum_keeper_mt/sc_main.cpp @@ -0,0 +1,38 @@ +#include "top_module.h" +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace scc; +using namespace sc_core; + +jmp_buf abrt; +void ABRThandler(int sig) { longjmp(abrt, 1); } + +int sc_main(int argc, char* argv[]) { + signal(SIGABRT, ABRThandler); + auto my_name = util::split(argv[0], '/').back(); + auto level = "7"; // 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) { + // instantiate design(s) + top_module top_mod("top_module_inst"); + // Start the simulation + sc_core::sc_start(1140, sc_core::SC_NS); + } + return result; +} diff --git a/tests/quantum_keeper_mt/top_module.h b/tests/quantum_keeper_mt/top_module.h new file mode 100644 index 0000000..86dd326 --- /dev/null +++ b/tests/quantum_keeper_mt/top_module.h @@ -0,0 +1,44 @@ +#ifndef _TOP_MODULE_H_ +#define _TOP_MODULE_H_ + +#include +#include +#include +#include +#include +#include +#include + +struct top_module : ::sc_core ::sc_module { + top_module(sc_core::sc_module_name nm) + : sc_core::sc_module(nm) { + SC_THREAD(run); + } + + ~top_module() {} + +private: + void run() { + wait(sc_core::SC_ZERO_TIME); // separate from elaboration phase + do { + quantum_keeper.reset(); + core_executor.start([this]() { thread_exec(); }); + wait(core_executor.thread_finish_event()); + } while(!finish.load(std::memory_order_relaxed)); + sc_core::sc_stop(); + } + + void thread_exec() { + for(auto i = 0u; i < 16; ++i) { + SCCINFO(SCMOD) << "[" << __PRETTY_FUNCTION__ << "]" << " local time " << quantum_keeper.get_local_absolute_time(); + quantum_keeper.check_and_sync(1_us); + } + finish.store(true, std::memory_order_release); + } + tlm::scc::quantumkeeper_mt quantum_keeper; + std::atomic_bool finish{false}; + scc::async_thread core_executor; +}; +// top_module + +#endif // _TOP_MODULE_H_