From 3dfe84edf52ebd754d294a5d14d69b2a8b36af57 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Mon, 4 Aug 2025 06:44:12 +0200 Subject: [PATCH] updates submodules and build system --- .envrc | 4 +- .vscode/extensions.json | 10 +++++ .vscode/launch.json | 28 ++++++------ .vscode/settings.json | 19 +++++++- CMakeLists.txt | 96 +---------------------------------------- conanfile.py | 63 +++++++++++++++++++++++++++ requirements.txt | 4 +- scc | 2 +- src/sc_main.cpp | 9 ++-- src/tgc_vp/system.cpp | 5 +-- src/tgc_vp/system.h | 9 ++-- src/tgc_vp/tb.cpp | 9 ++-- src/tgc_vp/tb.h | 10 ++--- tgc-iss/dbt-rise-core | 2 +- tgc-iss/dbt-rise-tgc | 2 +- vpvper | 2 +- 16 files changed, 131 insertions(+), 143 deletions(-) create mode 100644 .vscode/extensions.json create mode 100644 conanfile.py diff --git a/.envrc b/.envrc index bcdccba..032d31f 100644 --- a/.envrc +++ b/.envrc @@ -6,6 +6,8 @@ if [ $distro == "CentOS" ]; then elif [ $distro == "Rocky" ]; then . /opt/rh/gcc-toolset-11/enable fi -module load ./Modulefile +if has module; then + module load ./Modulefile +fi layout python3 [ -f .envrc.$USER ] && . .envrc.$USER diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..c15ab36 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + "recommendations": [ + "ms-vscode.cpptools-extension-pack", + "llvm-vs-code-extensions.vscode-clangd", + "eclipse-cdt.cdt-gdb-vscode", + "eclipse-cdt.memory-inspector", + "eclipse-cdt.peripheral-inspector", + + ] +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 68a1a1f..2ffdc73 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,16 +5,18 @@ "version": "0.2.0", "configurations": [ { - "type": "gdb", + "type": "gdbtarget", "request": "attach", "name": "Attach-to-gdbserver", - "executable": "./fw/hello-world/hello", - "target": ":10000", - "remote": true, + "program": "fw/hello-world/prebuilt/hello.elf", + "imageAndSymbols": { + "symbolFileName": "fw/hello-world/prebuilt/hello.elf" + }, + "target": { + "port": "10000" + }, "cwd": "${workspaceRoot}", - "valuesFormatting": "prettyPrinters", - "gdbpath": "/opt/riscv/bin/riscv32-unknown-elf-gdb", - "debugger_args": [], + "gdb": "riscv64-unknown-elf-gdb", "presentation": { "hidden": true, "group": "FW Debug", @@ -26,9 +28,8 @@ "request": "launch", "name": "Launch-VP-with-gdbserver", "cwd": "${workspaceRoot}", - "valuesFormatting": "parseText", - "target": "./build/src/tgc-vp", - "arguments": "-f fw/hello-world/hello -g 10000", + "program": "${workspaceFolder}/build/Debug/src/tgc-vp", + "arguments": "-f fw/hello-world/prebuilt/hello.elf -g 10000", "presentation": { "hidden": true, "group": "FW Debug", @@ -40,10 +41,9 @@ "request": "launch", "name": "VP-Debug", "cwd": "${workspaceRoot}", - "valuesFormatting": "parseText", - "target": "./build/src/tgc-vp", - "printCalls": false, - "arguments": "-f fw/hello-world/hello" + "program": "${workspaceFolder}/build/Debug/src/tgc-vp", + "arguments": "-f fw/hello-world/prebuilt/hello.elf", + "openGdbConsole": true }, ], "compounds": [ diff --git a/.vscode/settings.json b/.vscode/settings.json index 4cfbe19..ee48999 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,5 +2,20 @@ "files.associations": { "platform.h": "c" }, - "debug.allowBreakpointsEverywhere": true -} \ No newline at end of file + "debug.allowBreakpointsEverywhere": true, + "chat.sendElementsToChat.attachCSS": false, + "chat.sendElementsToChat.attachImages": false, + "chat.sendElementsToChat.enabled": false, + "editor.rulers": [ + { + "column": 140, + "comment": "clang-format" + } + ], + "clangd.arguments": [ + "--pretty", + "--background-index", + "--compile-commands-dir=${workspaceFolder}/build" + ], + "cmake.copyCompileCommands": "${workspaceFolder}/build/compile_commands.json" +} diff --git a/CMakeLists.txt b/CMakeLists.txt index 2fe7190..be688a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,6 @@ option(WITH_LLVM "Build LLVM backend" OFF) option(WITH_ASMJIT "Build ASMJIT backend" ON) set(SCC_LIB_ONLY ON) -set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_POSITION_INDEPENDENT_CODE ON) @@ -34,103 +33,10 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") add_compile_options(/vmg /wd26812) # suppress Warnung C26812: "enum class" gegenüber "enum" (Enum.3) bevorzugen endif() -include(ConanInline) -if(BUILD_SHARED_LIBS) - set(SHARED_FLAG "True") -else() - set(SHARED_FLAG "False") -endif() - -set(CONAN_BOOST_OPTIONS -boost:fPIC=True -boost:shared=${SHARED_FLAG} -boost:header_only=False -boost:without_contract=True -boost:without_fiber=True -boost:without_graph=True -boost:without_graph_parallel=True -boost:without_iostreams=True -boost:without_json=True -boost:without_locale=True -boost:without_log=True -boost:without_math=True -boost:without_mpi=True -boost:without_nowide=True -boost:without_python=True -boost:without_random=True -boost:without_regex=True -boost:without_stacktrace=True -boost:without_test=True -boost:without_timer=True -boost:without_type_erasure=True -boost:without_wave=True -) - -set(CONAN_PACKAGE_LIST - fmt/8.0.1 - spdlog/1.9.2 - boost/1.75.0 - gsl-lite/0.37.0 - elfio/3.11 - lz4/1.9.3 - yaml-cpp/0.7.0 - jsoncpp/1.9.5 - zlib/1.2.13 -) -set(CONAN_PACKAGE_OPTIONS fmt:header_only=True ${CONAN_BOOST_OPTIONS}) -if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND WITH_TCC) - list(APPEND CONAN_PACKAGE_LIST seasocks/1.4.4) - list(APPEND CONAN_PACKAGE_OPTIONS lua:compile_as_cpp=False ) -endif() -if(WITH_LLVM) - list(APPEND CONAN_PACKAGE_LIST llvm-core/13.0.0) - list(APPEND CONAN_PACKAGE_OPTIONS libiconv:shared=False) -endif() -if(WITH_ASMJIT) - list(APPEND CONAN_PACKAGE_LIST asmjit/cci.20240531) - list(APPEND CONAN_PACKAGE_OPTIONS asmjit:shared=False) -endif() -if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tgc-iss/dbt-rise-plugins) - list(APPEND CONAN_PACKAGE_OPTIONS lua:compile_as_cpp=False) - list(APPEND CONAN_PACKAGE_LIST lua/5.4.3) -endif() - -if(NOT USE_CWR_SYSTEMC AND NOT USE_NCSC_SYSTEMC AND NOT DEFINED ENV{SYSTEMC_HOME}) - set(CONAN_PACKAGE_LIST ${CONAN_PACKAGE_LIST} - systemc/2.3.4) - set(CONAN_PACKAGE_OPTIONS ${CONAN_PACKAGE_OPTIONS} - systemc:shared=${SHARED_FLAG} - systemc:disable_virtual_bind=False) -endif() - -conan_check() -#conan_add_remote(NAME minres URL https://git.minres.com/api/packages/Tooling/conan) -# Boost on CentOS 7 quirks: the b2 of conan-center is build against a newer libstdc++ and therefore does not run -# with the oooooold libs on CentOS 7. Therefore we build our own version of b2 if it is not there -execute_process(COMMAND bash -c "conan search -r all b2 | tail -1" OUTPUT_VARIABLE B2_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) -set(B2_META $ENV{HOME}/.conan/data/${B2_VERSION}/_/_/metadata.json) -if(DEFINED ENV{CONAN_USER_HOME}) - set(B2_META $ENV{CONAN_USER_HOME}/.conan/data/${B2_VERSION}/_/_/metadata.json) -endif() -if(NOT EXISTS ${B2_META}) - conan_configure(REQUIRES ${B2_VERSION}) - conan_cmake_autodetect(settings) - conan_cmake_install(PATH_OR_REFERENCE . BUILD b2 SETTINGS ${settings}) -endif() -# Boost on CentOS 7 quirks end -conan_cmake_configure(REQUIRES ${CONAN_PACKAGE_LIST} - GENERATORS cmake_find_package - OPTIONS ${CONAN_PACKAGE_OPTIONS} - ) -conan_cmake_autodetect(settings) -conan_install() - -set(CONAN_CMAKE_SILENT_OUTPUT ON) find_package(tcc QUIET) find_package(elfio) find_package(fmt) find_package(spdlog) -find_package(gsl-lite) find_package(yaml-cpp) set(Boost_NO_BOOST_CMAKE ON) # Don't do a find_package in config mode before searching for a regular boost install. find_package(Boost REQUIRED COMPONENTS program_options QUIET) @@ -142,7 +48,7 @@ find_package(ClangFormat) if(ENABLE_COVERAGE) include(CodeCoverage) append_coverage_compiler_flags() - set(COVERAGE_EXCLUDES "${tgfs_verif_SOURCE_DIR}/scc/*" "${tgfs_verif_SOURCE_DIR}/build/*" "$ENV{HOME}/.conan/*" "/opt/*") + set(COVERAGE_EXCLUDES "${tgfs_verif_SOURCE_DIR}/scc/*" "${tgfs_verif_SOURCE_DIR}/build/*" "$ENV{HOME}/.conan2/*" "/opt/*") endif() if(ENABLE_CLANGTIDY) diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..ad45d1f --- /dev/null +++ b/conanfile.py @@ -0,0 +1,63 @@ +import os + +from conan import ConanFile +from conan.tools.cmake import cmake_layout + + +class Pkg(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = ( + "CMakeDeps", + "CMakeToolchain", + ) + default_options = { + "llvm-core/*:targets": "X86", + "boost/*:fPIC": "True", + "boost/*:header_only": "False", + "boost/*:without_contract": "True", + "boost/*:without_fiber": "True", + "boost/*:without_graph": "True", + "boost/*:without_graph_parallel": "True", + "boost/*:without_iostreams": "True", + "boost/*:without_json": "True", + "boost/*:without_locale": "True", + "boost/*:without_log": "True", + "boost/*:without_math": "True", + "boost/*:without_mpi": "True", + "boost/*:without_nowide": "True", + "boost/*:without_python": "True", + "boost/*:without_random": "True", + "boost/*:without_regex": "True", + "boost/*:without_stacktrace": "True", + "boost/*:without_test": "True", + "boost/*:without_timer": "True", + "boost/*:without_type_erasure": "True", + "boost/*:without_wave": "True", + "systemc/*:shared": "True", + "lua/*:compile_as_cpp": "False", + "asmjit/*:shared": "False" + } + + def requirements(self): + self.requires("systemc/2.3.4") + self.requires("fmt/8.0.1") + self.requires("spdlog/1.9.2") + self.requires("boost/1.85.0") + self.requires("abseil/20250127.0") + self.requires("elfio/3.12") + self.requires("lz4/1.9.3") + self.requires("yaml-cpp/0.8.0") + self.requires("jsoncpp/1.9.5") + self.requires("zlib/1.2.12") + self.requires("seasocks/1.4.4") + self.requires("asmjit/cci.20240531") + if "WITH_LLVM" in os.environ: + self.requires("llvm-core/19.1.7") + if os.path.isdir("dbt-rise-plugins"): + self.requires("lua/5.4.3") + + def build_requirements(self): + pass + + def layout(self): + cmake_layout(self) diff --git a/requirements.txt b/requirements.txt index 5cbe7e7..6e6708c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,3 @@ -conan==1.59 +conan +cmake +clang-format \ No newline at end of file diff --git a/scc b/scc index 916923b..374d481 160000 --- a/scc +++ b/scc @@ -1 +1 @@ -Subproject commit 916923b51e13f6face70075a5023bd25043129e6 +Subproject commit 374d481d717afe67d72d56c85e55b2b508c90526 diff --git a/src/sc_main.cpp b/src/sc_main.cpp index cd17b19..d348066 100644 --- a/src/sc_main.cpp +++ b/src/sc_main.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #ifdef ERROR #undef ERROR @@ -31,7 +30,6 @@ const std::string core_path{"tb.top.core_complex"}; using namespace sysc; using namespace sc_core; -namespace po = boost::program_options; namespace { const size_t ERRORR_IN_COMMAND_LINE = 1; @@ -76,10 +74,9 @@ int sc_main(int argc, char* argv[]) { auto tx_trace_type = static_cast(trace_level >> 1); // bit3-bit1 define the kind of transaction trace auto trace_default_on = parser.is_set("trace-default-on"); - cfg.set_value("$$$scc_tracer$$$.tx_trace_type", static_cast(scc::tracer::file_type::FTR)); - cfg.set_value("$$$scc_tracer$$$.sig_trace_type", static_cast(scc::tracer::file_type::FST)); - tracer = - scc::make_unique(file_name, tx_trace_type, enable_sig_trace, trace_default_on); + cfg.set_value("scc_tracer.tx_trace_type", static_cast(scc::tracer::file_type::FTR)); + cfg.set_value("scc_tracer.sig_trace_type", static_cast(scc::tracer::file_type::FST)); + tracer = scc::make_unique(file_name, tx_trace_type, enable_sig_trace); } /////////////////////////////////////////////////////////////////////////// // instantiate top level diff --git a/src/tgc_vp/system.cpp b/src/tgc_vp/system.cpp index 126261b..3adc0ca 100644 --- a/src/tgc_vp/system.cpp +++ b/src/tgc_vp/system.cpp @@ -78,10 +78,7 @@ system::system(sc_core::sc_module_name nm) timer0.clear_i(t0_clear_i); timer0.tick_i(t0_tick_i); - qspi.ssclk_o(ssclk_o); - qspi.dq_o(dq_o); - qspi.dq_i(dq_i); - qspi.oe_o(dq_oe_o); + qspi.spi_i(mspi0); SC_METHOD(gen_reset); sensitive << erst_n; diff --git a/src/tgc_vp/system.h b/src/tgc_vp/system.h index e4ff3d2..f80b7da 100644 --- a/src/tgc_vp/system.h +++ b/src/tgc_vp/system.h @@ -40,10 +40,7 @@ public: sc_core::sc_in uart0_rx_i{"uart0_rx_i"}; sc_core::sc_vector> t0_clear_i{"t0_clear_i", vpvper::minres::timer::CLEAR_CNT}; sc_core::sc_vector> t0_tick_i{"t0_tick_i", vpvper::minres::timer::TICK_CNT - 1}; - sc_core::sc_out ssclk_o{"ssclk_o"}; - sc_core::sc_vector> dq_o{"dq_o", 4}; - sc_core::sc_vector> dq_oe_o{"dq_oe_o", 4}; - sc_core::sc_vector> dq_i{"dq_i", 4}; + spi::spi_pkt_initiator_socket<> mspi0{"mspi0"}; sc_core::sc_in clk_i{"clk_i"}; @@ -61,8 +58,8 @@ private: vpvper::minres::irq_tl irq_ctrl{"irq_ctrl"}; vpvper::minres::qspi_tl qspi{"qspi"}; - scc::memory<1_kB, scc::LT> boot_rom{"boot_rom"}; - scc::memory<32_kB, scc::LT> main_ram{"main_ram"}; + scc::memory_tl<1_kB, scc::LT> boot_rom{"boot_rom"}; + scc::memory_tl<32_kB, scc::LT> main_ram{"main_ram"}; sc_core::sc_signal rst_s{"rst_s"}, mtime_int_s{"mtime_int_s"}, msip_int_s{"msip_int_s"}; diff --git a/src/tgc_vp/tb.cpp b/src/tgc_vp/tb.cpp index 2fa2747..7e64ebc 100644 --- a/src/tgc_vp/tb.cpp +++ b/src/tgc_vp/tb.cpp @@ -11,6 +11,7 @@ namespace tgc_vp { SC_HAS_PROCESS(tb); tb::tb(const sc_core::sc_module_name& nm) : sc_core::sc_module(nm) { + top.clk_i(clk_i); top.erst_n(rst_n); rst_gen.rst_n(rst_n); top.pins_o(pins_o); @@ -20,11 +21,9 @@ tb::tb(const sc_core::sc_module_name& nm) top.uart0_tx_o(uart0_tx_o); top.t0_clear_i(t0_clear_i); top.t0_tick_i(t0_tick_i); - top.ssclk_o(ssclk_o); - top.dq_o(dq_o); - top.dq_i(dq_i); - top.dq_oe_o(dq_oe_o); - top.clk_i(clk_i); + top.mspi0(spi()); + spi(0)(qspi_mem.spi_t); + clk_i = 10_ns; } } // namespace tgc_vp diff --git a/src/tgc_vp/tb.h b/src/tgc_vp/tb.h index 66664ea..c1ead08 100644 --- a/src/tgc_vp/tb.h +++ b/src/tgc_vp/tb.h @@ -12,6 +12,8 @@ #include "tgc_vp/rst_gen.h" #include "tgc_vp/system.h" +#include + namespace tgc_vp { class tb : public sc_core::sc_module { @@ -19,6 +21,7 @@ public: tb(sc_core::sc_module_name const& nm); tgc_vp::system top{"top"}; tgc_vp::rst_gen rst_gen{"rst_gen"}; + sc_core::sc_signal clk_i{"clk_i"}; sc_core::sc_signal rst_n{"rst_n"}; sc_core::sc_vector> pins_o{"pins_o", 32}; sc_core::sc_vector> pins_oe_o{"pins_oe_o", 32}; @@ -27,11 +30,8 @@ public: sc_core::sc_signal uart0_rx_i{"uart0_rx_i"}; sc_core::sc_vector> t0_clear_i{"t0_clear_i", vpvper::minres::timer::CLEAR_CNT}; sc_core::sc_vector> t0_tick_i{"t0_tick_i", vpvper::minres::timer::TICK_CNT - 1}; - sc_core::sc_signal ssclk_o{"ssclk_o"}; - sc_core::sc_vector> dq_o{"dq_o", 4}; - sc_core::sc_vector> dq_oe_o{"dq_oe_o", 4}; - sc_core::sc_vector> dq_i{"dq_i", 4}; - sc_core::sc_signal clk_i{"clk_i"}; + spi::spi_channel spi{"spi", 1}; + vpvper::generic::spi_mem qspi_mem{"qspi_mem"}; }; } /* namespace tgc_vp */ diff --git a/tgc-iss/dbt-rise-core b/tgc-iss/dbt-rise-core index 99cf682..b0fd676 160000 --- a/tgc-iss/dbt-rise-core +++ b/tgc-iss/dbt-rise-core @@ -1 +1 @@ -Subproject commit 99cf6823a9f565ecb6cc7f8fe2cef1e52830890b +Subproject commit b0fd6762be2a39e4b05667f71778be4fb1bd6019 diff --git a/tgc-iss/dbt-rise-tgc b/tgc-iss/dbt-rise-tgc index 21e1f79..6f08f40 160000 --- a/tgc-iss/dbt-rise-tgc +++ b/tgc-iss/dbt-rise-tgc @@ -1 +1 @@ -Subproject commit 21e1f791adbfc502f232c288cd1bcec5df0af7a0 +Subproject commit 6f08f4010cb6400cacfa78e9e0b431c2777628c0 diff --git a/vpvper b/vpvper index 99f8c5d..77b5ffa 160000 --- a/vpvper +++ b/vpvper @@ -1 +1 @@ -Subproject commit 99f8c5dd4a9e523998f3247cfb6c756ee660e3d1 +Subproject commit 77b5ffa40d50f63f4adac0b32076d9da590a4c51