diff --git a/.cproject b/.cproject index a0bd7a7..d7016c0 100644 --- a/.cproject +++ b/.cproject @@ -12,7 +12,7 @@ - + diff --git a/.gitignore b/.gitignore index 63dc490..d2d7f29 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ CMakeSettings.json /.cache /CMakeUserPresets.json /.envrc.* +.clangd diff --git a/.launch/TGC-VP interp dhrystone.launch b/.launch/RISCV-VP asmjit dhrystone.launch similarity index 63% rename from .launch/TGC-VP interp dhrystone.launch rename to .launch/RISCV-VP asmjit dhrystone.launch index 103965e..0e52b02 100644 --- a/.launch/TGC-VP interp dhrystone.launch +++ b/.launch/RISCV-VP asmjit dhrystone.launch @@ -12,16 +12,16 @@ - + - + - + @@ -30,6 +30,21 @@ + + + + + + + + + + + + + + + diff --git a/.launch/RISCV-VP interp dhrystone.launch b/.launch/RISCV-VP interp dhrystone.launch new file mode 100644 index 0000000..4036fa0 --- /dev/null +++ b/.launch/RISCV-VP interp dhrystone.launch @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.launch/TGC-VP interp dhrystone ce fast.launch b/.launch/TGC-VP interp dhrystone ce fast.launch index 5668914..0331967 100644 --- a/.launch/TGC-VP interp dhrystone ce fast.launch +++ b/.launch/TGC-VP interp dhrystone ce fast.launch @@ -22,7 +22,7 @@ - + diff --git a/.vscode/launch.json b/.vscode/launch.json index 68a1a1f..0cf3870 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -40,10 +40,8 @@ "request": "launch", "name": "VP-Debug", "cwd": "${workspaceRoot}", - "valuesFormatting": "parseText", - "target": "./build/src/tgc-vp", - "printCalls": false, - "arguments": "-f fw/hello-world/hello" + "program": "${workspaceFolder}/out/build/Debug/src/riscv-vp", + "arguments": "--isa ? -f fw/hello-world/hello" }, ], "compounds": [ diff --git a/CMakeLists.txt b/CMakeLists.txt index d75e413..7418014 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ option(ENABLE_COVERAGE "Enable code coverage" OFF) option(ENABLE_SANITIZER "Enable address sanitizer" OFF) option(ENABLE_CLANGTIDY "Enable static analysis with clang-tidy." OFF) option(ENABLE_FW_BUILD "Enable build of firmware of MIRES Firmware repo." OFF) +option(ENABLE_GPROF "Enable gprof profiling" OFF) set(SCC_LIB_ONLY ON) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -19,17 +20,21 @@ include(GNUInstallDirs) # add address sanitizer if(ENABLE_SANITIZER) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-omit-frame-pointer -fsanitize=address,thread") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=address,thread") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address") endif() +if(ENABLE_GPROF) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") +endif() if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") add_compile_options(/vmg /wd26812) # suppress Warnung C26812: "enum class" gegenüber "enum" (Enum.3) bevorzugen endif() find_package(elfio) -find_package(Boost REQUIRED COMPONENTS program_options QUIET) +find_package(Boost REQUIRED COMPONENTS program_options date_time QUIET) include(SystemCPackage) if(ENABLE_COVERAGE) @@ -57,6 +62,7 @@ endif () set(USE_SC_SIGNAL4IRQ ON) set(CLANG_FORMAT_EXCLUDE_PATTERNS /build/ /scc/ /dbt-rise-core/ /dbt-rise-riscv/) +set(USE_SC_SIGNAL4IRQ ON) add_subdirectory(scc) add_subdirectory(dbt-rise-core) add_subdirectory(dbt-rise-riscv) @@ -87,6 +93,7 @@ if(FW_BUILD) if(NOT riscvfw_POPULATED) FetchContent_Populate(riscvfw) endif() - set(BOARD ehrenberg) + set(BOARD moonlight) + set(LINK_TARGET ram) add_subdirectory(${riscvfw_SOURCE_DIR}) endif() diff --git a/CMakePresets.json b/CMakePresets.json index 3f20d85..7128e62 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -10,30 +10,40 @@ }, "configurePresets": [ { - "name": "Debug", + "name": "Base", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/${presetName}", "cacheVariables": { "CMAKE_POLICY_DEFAULT_CMP0091": "NEW", - "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_CXX_STANDARD": "17", - "CMAKE_PROJECT_TOP_LEVEL_INCLUDES":"dbt-rise-riscv/cmake-conan/conan_provider.cmake" + "CMAKE_CXX_STANDARD": "20", + "CMAKE_INSTALL_PREFIX": "${sourceDir}/install/${presetName}", + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON", + "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "scc/cmake/conan_provider.cmake", + "WITH_TCC": "OFF" + } + }, + { + "name": "Debug", + "inherits": "Base", + "displayName": "Debug build", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" } }, { "name": "RelWithDebInfo", + "inherits": "Base", + "displayName": "RelWithDebInfo build", "cacheVariables": { - "CMAKE_POLICY_DEFAULT_CMP0091": "NEW", - "CMAKE_BUILD_TYPE": "RelWithDebInfo", - "CMAKE_CXX_STANDARD": "17", - "CMAKE_PROJECT_TOP_LEVEL_INCLUDES":"dbt-rise-riscv/cmake-conan/conan_provider.cmake" + "CMAKE_BUILD_TYPE": "RelWithDebInfo" } }, { "name": "Release", + "inherits": "Base", + "displayName": "Release build", "cacheVariables": { - "CMAKE_POLICY_DEFAULT_CMP0091": "NEW", - "CMAKE_BUILD_TYPE": "Release", - "CMAKE_CXX_STANDARD": "17", - "CMAKE_PROJECT_TOP_LEVEL_INCLUDES":"dbt-rise-riscv/cmake-conan/conan_provider.cmake" + "CMAKE_BUILD_TYPE": "Release" } } ] diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..5a25656 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,60 @@ +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" + } + + def requirements(self): + self.requires("systemc/3.0.1") + 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("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/conanfile.txt b/conanfile.txt deleted file mode 100644 index 4c0e3fa..0000000 --- a/conanfile.txt +++ /dev/null @@ -1,48 +0,0 @@ -[requires] -yaml-cpp/0.8.0 -jsoncpp/1.9.5 -boost/1.85.0 -asmjit/cci.20240531 -elfio/3.12 -fmt/8.0.1 -spdlog/1.9.2 -gsl-lite/0.41.0 -lz4/1.9.3 -zlib/1.2.13 -seasocks/1.4.6 -systemc/2.3.4 - -[options] -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 -fmt/*:header_only=True -libiconv/*:shared=False -asmjit/*:shared=False -systemc/*:shared=True -systemc/*:disable_virtual_bind=False - -[generators] -CMakeDeps -CMakeToolchain - -[layout] -cmake_layout \ No newline at end of file diff --git a/dbt-rise-core b/dbt-rise-core index 7680458..2627112 160000 --- a/dbt-rise-core +++ b/dbt-rise-core @@ -1 +1 @@ -Subproject commit 7680458096f966db7ec3755d5b1f6c6b621a57ec +Subproject commit 2627112886005ba7e7415972bd9e76424c219e91 diff --git a/dbt-rise-riscv b/dbt-rise-riscv index a7f8af2..a13689b 160000 --- a/dbt-rise-riscv +++ b/dbt-rise-riscv @@ -1 +1 @@ -Subproject commit a7f8af279bed3e8c46e3914d32b59c3a628fba1b +Subproject commit a13689b3826b4f7b27fa400208599184e3956580 diff --git a/scc b/scc index 8c98137..3179717 160000 --- a/scc +++ b/scc @@ -1 +1 @@ -Subproject commit 8c981376f233847a5940c98398ea0ff4dfb6b7db +Subproject commit 3179717f71478bf25f11a3961808fa7920ae7932 diff --git a/src/sc_main.cpp b/src/sc_main.cpp index 9d90c3b..21c2276 100644 --- a/src/sc_main.cpp +++ b/src/sc_main.cpp @@ -76,15 +76,16 @@ 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::SC_VCD)); - tracer = - scc::make_unique(file_name, tx_trace_type, enable_sig_trace, trace_default_on); + if(parser.is_set("trace-default-off")) + cfg.set_value("scc_tracer.default_trace_enable", false); + 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 /////////////////////////////////////////////////////////////////////////// - auto i_system = scc::make_unique("tb"); + auto i_system = scc::make_unique("tb"); /////////////////////////////////////////////////////////////////////////// // add non-implemented 'enableTracing' properties /////////////////////////////////////////////////////////////////////////// diff --git a/src/vp/rst_gen.h b/src/vp/rst_gen.h deleted file mode 100644 index 020c69a..0000000 --- a/src/vp/rst_gen.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2019 -2021 MINRES Technolgies GmbH - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#include -namespace tgc_vp { - -class rst_gen : public sc_core::sc_module { - SC_HAS_PROCESS(rst_gen); - -public: - rst_gen(sc_core::sc_module_name const& nm) { SC_THREAD(run); } - sc_core::sc_out rst_n{"rst_n"}; - -private: - void run() { - rst_n.write(false); - wait(100_ns); - rst_n.write(true); - } -}; - -} /* namespace tgc_vp */ diff --git a/src/vp/system.cpp b/src/vp/system.cpp index 257227f..ab0069b 100644 --- a/src/vp/system.cpp +++ b/src/vp/system.cpp @@ -4,13 +4,14 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "../vp/system.h" +#include "system.h" -#include "minres/timer.h" -#include "minres/uart.h" -#include "scc/utilities.h" +#include +#include +#include + +namespace vp { -namespace tgc_vp { using namespace sc_core; using namespace vpvper::minres; @@ -24,7 +25,7 @@ system::system(sc_core::sc_module_name nm) ahb_router.initiator.at(0)(qspi.xip_sck); ahb_router.set_target_range(0, 0xE0000000, 16_MB); ahb_router.initiator.at(1)(mem_ram.target); - ahb_router.set_target_range(1, 0x80000000, 32_kB); + ahb_router.set_target_range(1, 0xC0000000, 128_kB); ahb_router.initiator.at(2)(apbBridge.target[0]); ahb_router.set_target_range(2, 0xF0000000, 256_MB); @@ -77,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; @@ -92,4 +90,4 @@ void system::gen_reset() { rst_s = 1; } -} // namespace tgc_vp +} // namespace vp diff --git a/src/vp/system.h b/src/vp/system.h index 8dc1e0d..3ae7b54 100644 --- a/src/vp/system.h +++ b/src/vp/system.h @@ -4,17 +4,15 @@ * SPDX-License-Identifier: Apache-2.0 */ -#ifndef _PLATFORM_H_ -#define _PLATFORM_H_ +#ifndef SRC_VP_SYSTEM_H_ +#define SRC_VP_SYSTEM_H_ -#include "minres/irq.h" -#include "minres/timer.h" -#include #include -#include #include #include +#include #include +#include #include #include #include @@ -27,7 +25,7 @@ #include #include -namespace tgc_vp { +namespace vp { class system : public sc_core::sc_module { public: @@ -40,10 +38,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"}; @@ -52,7 +47,7 @@ public: system(sc_core::sc_module_name nm); private: - sysc::riscv_vp::core_complex<> core_complex{"core_complex"}; + sysc::riscv::core_complex<> core_complex{"core_complex"}; scc::router<> ahb_router, apbBridge; vpvper::minres::gpio_tl gpio0{"gpio0"}; vpvper::minres::uart_tl uart0{"uart0"}; @@ -75,6 +70,6 @@ private: #include "../vp/gen/PipelinedMemoryBusToApbBridge.h" }; -} // namespace tgc_vp +} // namespace vp -#endif /* _PLATFORM_H_ */ +#endif /* SRC_VP_SYSTEM_H_ */ diff --git a/src/vp/tb.cpp b/src/vp/tb.cpp index b81adc6..b8515eb 100644 --- a/src/vp/tb.cpp +++ b/src/vp/tb.cpp @@ -4,16 +4,16 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "../vp/tb.h" - +#include "tb.h" #include -namespace tgc_vp { + +namespace vp { SC_HAS_PROCESS(tb); tb::tb(const sc_core::sc_module_name& nm) : sc_core::sc_module(nm) { top.erst_n(rst_n); - rst_gen.rst_n(rst_n); + rst_gen.rst_o(rst_n); top.pins_o(pins_o); top.pins_i(pins_i); top.pins_oe_o(pins_oe_o); @@ -21,11 +21,10 @@ 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.mspi0(spi()); + spi(0)(qspi_mem.spi_t); top.clk_i(clk_i); clk_i = 10_ns; + rst_gen.active_level = false; } -} // namespace tgc_vp +} // namespace vp diff --git a/src/vp/tb.h b/src/vp/tb.h index b78d07f..aeba73f 100644 --- a/src/vp/tb.h +++ b/src/vp/tb.h @@ -7,18 +7,19 @@ #ifndef SRC_VP_TB_H_ #define SRC_VP_TB_H_ +#include "system.h" +#include +#include #include #include -#include "../vp/rst_gen.h" -#include "../vp/system.h" -namespace tgc_vp { +namespace vp { class tb : public sc_core::sc_module { public: tb(sc_core::sc_module_name const& nm); - tgc_vp::system top{"top"}; - tgc_vp::rst_gen rst_gen{"rst_gen"}; + vp::system top{"top"}; + vpvper::generic::rst_gen rst_gen{"rst_gen"}; 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,13 +28,11 @@ 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}; + spi::spi_channel spi{"spi", 1}; + vpvper::generic::spi_mem qspi_mem{"qspi_mem"}; sc_core::sc_signal clk_i{"clk_i"}; }; -} /* namespace tgc_vp */ +} // namespace vp #endif /* SRC_VP_TB_H_ */ diff --git a/vpvper b/vpvper index cf7e348..77b5ffa 160000 --- a/vpvper +++ b/vpvper @@ -1 +1 @@ -Subproject commit cf7e348f626bd4afd897d321d3e8ff818e9e8ffe +Subproject commit 77b5ffa40d50f63f4adac0b32076d9da590a4c51