From de4d7401873cfe56ed1387baa4d0cc6706ba21c4 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sun, 16 Mar 2025 18:50:10 +0100 Subject: [PATCH] updates scc and adds simspeed test --- CMakePresets.json | 9 ++++++--- scc | 2 +- tests/CMakeLists.txt | 1 + tests/sim_speed/CMakeLists.txt | 3 +++ tests/sim_speed/sc_main.cpp | 24 ++++++++++++++++++++++++ 5 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 tests/sim_speed/CMakeLists.txt create mode 100644 tests/sim_speed/sc_main.cpp diff --git a/CMakePresets.json b/CMakePresets.json index 86840c3..774d9bb 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -15,7 +15,8 @@ "CMAKE_POLICY_DEFAULT_CMP0091": "NEW", "CMAKE_BUILD_TYPE": "Debug", "CMAKE_CXX_STANDARD": "17", - "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "cmake-conan/conan_provider.cmake" + "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "cmake-conan/conan_provider.cmake", + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" } }, { @@ -24,7 +25,8 @@ "CMAKE_POLICY_DEFAULT_CMP0091": "NEW", "CMAKE_BUILD_TYPE": "RelWithDebInfo", "CMAKE_CXX_STANDARD": "17", - "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "cmake-conan/conan_provider.cmake" + "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "cmake-conan/conan_provider.cmake", + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" } }, { @@ -33,7 +35,8 @@ "CMAKE_POLICY_DEFAULT_CMP0091": "NEW", "CMAKE_BUILD_TYPE": "Release", "CMAKE_CXX_STANDARD": "17", - "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "cmake-conan/conan_provider.cmake" + "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "cmake-conan/conan_provider.cmake", + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" } } ] diff --git a/scc b/scc index 414a772..a288c89 160000 --- a/scc +++ b/scc @@ -1 +1 @@ -Subproject commit 414a7724e2723acb6cd309ff2fb62a38eb1ab6e5 +Subproject commit a288c896f80f68edcde3b2f17fe49e0a31a3afbe diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7004527..cf8aa2f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -9,6 +9,7 @@ add_subdirectory(configuration) add_subdirectory(configurer) add_subdirectory(sc_fixed_tracing) add_subdirectory(cxs_tlm) +add_subdirectory(sim_speed) if(FULL_TEST_SUITE) add_subdirectory(sim_performance) endif() diff --git a/tests/sim_speed/CMakeLists.txt b/tests/sim_speed/CMakeLists.txt new file mode 100644 index 0000000..8516c5c --- /dev/null +++ b/tests/sim_speed/CMakeLists.txt @@ -0,0 +1,3 @@ +project (sim_speed) +add_executable(${PROJECT_NAME} sc_main.cpp) +target_link_libraries (${PROJECT_NAME} LINK_PUBLIC scc-sysc) diff --git a/tests/sim_speed/sc_main.cpp b/tests/sim_speed/sc_main.cpp new file mode 100644 index 0000000..a9936b7 --- /dev/null +++ b/tests/sim_speed/sc_main.cpp @@ -0,0 +1,24 @@ +#include +#include +#include + +using namespace sc_core; + +int sc_main(int argc, char* argv[]) { + const uint64_t NS_VAL = 100000000; + + sc_clock clk("clk", 1, SC_NS); + sc_time run_time(NS_VAL, SC_NS); + + auto start = std::chrono::high_resolution_clock::now(); + sc_start(run_time); + auto end = std::chrono::high_resolution_clock::now(); + auto duration = std::chrono::duration_cast(end - start); + + double simulated_cycles = (double)NS_VAL; + double real_us = duration.count(); + double speed_Mhz = simulated_cycles / real_us; + std::cout << "Simulation speed: " << speed_Mhz << " MHz\n"; + + return 0; +}