diff --git a/.cproject b/.cproject index f2a8b0a..d7016c0 100644 --- a/.cproject +++ b/.cproject @@ -12,7 +12,7 @@ - + @@ -46,11 +46,13 @@ - - + + + + @@ -99,12 +101,67 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -114,6 +171,7 @@ + @@ -122,11 +180,30 @@ + + + + + + + + + + + + + + + + + + + + CMAKE_BUILD_TOOL - fw-hello-world true true @@ -148,26 +225,22 @@ false true + + make + $<cmake4eclipse_dyn> + format + true + true + true + + + make + $<cmake4eclipse_dyn> + format-check + true + true + true + - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9d73bd5..d2d7f29 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,5 @@ CMakeSettings.json /.direnv /.cache /CMakeUserPresets.json +/.envrc.* +.clangd diff --git a/.gitmodules b/.gitmodules index fb817ea..d0d8283 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,15 +4,12 @@ [submodule "vpvper"] path = vpvper url = https://github.com/VP-Vibes/VPV-Peripherals.git -[submodule "tgc-iss/dbt-rise-core"] - path = tgc-iss/dbt-rise-core - url = https://github.com/Minres/DBT-RISE-Core.git -[submodule "tgc-iss/dbt-rise-tgc"] - path = tgc-iss/dbt-rise-tgc - url = https://git.minres.com/DBT-RISE/DBT-RISE-TGC.git [submodule "fw/bsp"] path = fw/bsp url = https://git.minres.com/Firmware/MNRS-BM-BSP.git [submodule "dbt-rise-riscv"] path = dbt-rise-riscv url = https://github.com/Minres/DBT-RISE-RISCV.git +[submodule "dbt-rise-core"] + path = dbt-rise-core + url = https://github.com/Minres/DBT-RISE-Core.git diff --git a/.launch/TGC-VP interp dhrystone.launch b/.launch/RISCV-VP asmjit dhrystone.launch similarity index 61% rename from .launch/TGC-VP interp dhrystone.launch rename to .launch/RISCV-VP asmjit dhrystone.launch index c655467..0e52b02 100644 --- a/.launch/TGC-VP interp dhrystone.launch +++ b/.launch/RISCV-VP asmjit dhrystone.launch @@ -18,10 +18,10 @@ - - + + - + @@ -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 asmjit hello.launch b/.launch/TGC-VP asmjit hello.launch index 866dd02..ff4efbc 100644 --- a/.launch/TGC-VP asmjit hello.launch +++ b/.launch/TGC-VP asmjit hello.launch @@ -18,8 +18,8 @@ - - + + diff --git a/.launch/TGC-VP interp dhrystone ce fast.launch b/.launch/TGC-VP interp dhrystone ce fast.launch index cfe0483..0331967 100644 --- a/.launch/TGC-VP interp dhrystone ce fast.launch +++ b/.launch/TGC-VP interp dhrystone ce fast.launch @@ -19,7 +19,7 @@ - + diff --git a/.launch/TGC-VP interp dhrystone ce slow.launch b/.launch/TGC-VP interp dhrystone ce slow.launch index 7dd892c..bf259ab 100644 --- a/.launch/TGC-VP interp dhrystone ce slow.launch +++ b/.launch/TGC-VP interp dhrystone ce slow.launch @@ -19,10 +19,10 @@ - + - + diff --git a/.launch/TGC-VP interp hello cycle-estimate fast.launch b/.launch/TGC-VP interp hello cycle-estimate fast.launch index ffdd03c..8bbd7a3 100644 --- a/.launch/TGC-VP interp hello cycle-estimate fast.launch +++ b/.launch/TGC-VP interp hello cycle-estimate fast.launch @@ -18,8 +18,8 @@ - - + + diff --git a/.launch/TGC-VP interp hello cycle-estimate slow.launch b/.launch/TGC-VP interp hello cycle-estimate slow.launch index 415d359..f97370a 100644 --- a/.launch/TGC-VP interp hello cycle-estimate slow.launch +++ b/.launch/TGC-VP interp hello cycle-estimate slow.launch @@ -18,8 +18,8 @@ - - + + diff --git a/.launch/TGC-VP interp hello pctrace.launch b/.launch/TGC-VP interp hello pctrace.launch index 98004c9..de457ee 100644 --- a/.launch/TGC-VP interp hello pctrace.launch +++ b/.launch/TGC-VP interp hello pctrace.launch @@ -18,8 +18,8 @@ - - + + diff --git a/.launch/TGC-VP interp hello.launch b/.launch/TGC-VP interp hello.launch index dd07431..6170202 100644 --- a/.launch/TGC-VP interp hello.launch +++ b/.launch/TGC-VP interp hello.launch @@ -16,13 +16,13 @@ - + - - + + - + diff --git a/.launch/TGC-VP llvm hello.launch b/.launch/TGC-VP llvm hello.launch index e29c3e2..00190e9 100644 --- a/.launch/TGC-VP llvm hello.launch +++ b/.launch/TGC-VP llvm hello.launch @@ -18,8 +18,8 @@ - - + + diff --git a/.launch/TGC-VP tcc dhrystone.launch b/.launch/TGC-VP tcc dhrystone.launch index 4c41daa..ec9c3a0 100644 --- a/.launch/TGC-VP tcc dhrystone.launch +++ b/.launch/TGC-VP tcc dhrystone.launch @@ -19,7 +19,7 @@ - + diff --git a/.launch/TGC-VP tcc hello.launch b/.launch/TGC-VP tcc hello.launch index 14a8547..a8a47c7 100644 --- a/.launch/TGC-VP tcc hello.launch +++ b/.launch/TGC-VP tcc hello.launch @@ -18,8 +18,8 @@ - - + + diff --git a/.launch/TGC-VP-FW-Debug.launch b/.launch/TGC-VP-FW-Debug.launch index 9ec2929..de24dad 100644 --- a/.launch/TGC-VP-FW-Debug.launch +++ b/.launch/TGC-VP-FW-Debug.launch @@ -25,10 +25,10 @@ - + - + @@ -36,7 +36,7 @@ - + diff --git a/.launch/TGC-VP-GDBServer.launch b/.launch/TGC-VP-GDBServer.launch index 88fe43e..f0f403b 100644 --- a/.launch/TGC-VP-GDBServer.launch +++ b/.launch/TGC-VP-GDBServer.launch @@ -18,11 +18,12 @@ - - + + - + + 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/.vscode/settings.json b/.vscode/settings.json index 4cfbe19..c0a759c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,5 +2,16 @@ "files.associations": { "platform.h": "c" }, - "debug.allowBreakpointsEverywhere": true + "debug.allowBreakpointsEverywhere": true, + "editor.rulers": [ + { + "column": 120, + "comment": "clang-format" + } + ], + "cmake.configureArgs": [ + "--preset", + "Debug", + "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" + ] } \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 3fc3c6c..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,22 +20,23 @@ 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) -set(CLANG_FORMAT_EXCLUDE_PATTERNS "scc" "dbt-rise-riscv") -find_package(ClangFormat) - if(ENABLE_COVERAGE) include(CodeCoverage) append_coverage_compiler_flags() @@ -58,8 +60,13 @@ if(ENABLE_CLANGTIDY) endif() 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) + if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/dbt-rise-plugins) add_subdirectory(dbt-rise-plugins) endif() @@ -70,6 +77,8 @@ if(NOT LIBS_ONLY) add_subdirectory(src) endif() +find_package(ClangFormat) + if(FW_BUILD) include(FetchContent) set(FETCHCONTENT_BASE_DIR ${CMAKE_CURRENT_BINARY_DIR}/..) @@ -84,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/README.md b/README.md index 319604f..6cfe4e6 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ To install conan.io version 2.0 and above (see also http://docs.conan.io/en/late python3 -m venv .venv . .venv/bin/activate pip3 install conan -conan profile new default --detect +conan profile detect ``` Building the VP is as simple as: 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 8979eab..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=False -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 new file mode 160000 index 0000000..2627112 --- /dev/null +++ b/dbt-rise-core @@ -0,0 +1 @@ +Subproject commit 2627112886005ba7e7415972bd9e76424c219e91 diff --git a/dbt-rise-riscv b/dbt-rise-riscv index ccc1b48..a13689b 160000 --- a/dbt-rise-riscv +++ b/dbt-rise-riscv @@ -1 +1 @@ -Subproject commit ccc1b4827ef5a52967a3d24607377b5f4b4320d8 +Subproject commit a13689b3826b4f7b27fa400208599184e3956580 diff --git a/scc b/scc index cecb22f..3179717 160000 --- a/scc +++ b/scc @@ -1 +1 @@ -Subproject commit cecb22f13d6aa1372d2cad21f296d869632d2aa8 +Subproject commit 3179717f71478bf25f11a3961808fa7920ae7932 diff --git a/src/CLIParser.cpp b/src/CLIParser.cpp index 92c4ab9..8109434 100644 --- a/src/CLIParser.cpp +++ b/src/CLIParser.cpp @@ -5,7 +5,6 @@ */ #include "CLIParser.h" -#include #include #include #include @@ -20,31 +19,34 @@ using namespace sc_core; namespace { std::unordered_set backend_opts = {"interp", "tcc", "llvm", "asmjit"}; } -CLIParser::CLIParser(int argc, char *argv[]) +CLIParser::CLIParser(int argc, char* argv[]) : desc("Options") , valid(false) { build(); try { po::store(po::parse_command_line(argc, argv, desc), vm_); // can throw // --help option - if (vm_.count("help")) { + if(vm_.count("help")) { std::cout << "DBT-RISE-TGC based virtual platform of TGC cores" << std::endl << desc << std::endl; } po::notify(vm_); // throws on error, so do after help in case there are any problems valid = true; - if(backend_opts.find(vm_["backend"].as())== std::end(backend_opts)) + if(backend_opts.find(vm_["backend"].as()) == std::end(backend_opts)) throw po::error("Illegal value for switch backend"); - } catch (po::error &e) { + } catch(po::error& e) { std::cerr << "ERROR: " << e.what() << std::endl << std::endl; std::cerr << desc << std::endl; exit(-1); } auto log_level = vm_["verbose"].as(); auto log_level_num = static_cast(log_level); - LOGGER(DEFAULT)::reporting_level() = logging::as_log_level(log_level_num > 6 ? 6 : log_level_num);; + LOGGER(DEFAULT)::reporting_level() = logging::as_log_level(log_level_num > 6 ? 6 : log_level_num); + ; LOGGER(DEFAULT)::print_time() = false; LOG_OUTPUT(DEFAULT)::ostream() = &std::cout; - LOGGER(connection)::reporting_level() = logging::as_log_level(log_level_num > 4 ? log_level_num-1 : log_level_num);; + LOGGER(connection)::reporting_level() = + logging::as_log_level(log_level_num > 4 ? log_level_num - 1 : log_level_num); + ; LOGGER(connection)::print_time() = false; LOG_OUTPUT(connection)::ostream() = &std::cout; /////////////////////////////////////////////////////////////////////////// @@ -59,7 +61,8 @@ CLIParser::CLIParser(int argc, char *argv[]) scc::stream_redirection cerr_redir(std::cerr, scc::log::ERROR); sc_core::sc_report_handler::set_actions("/IEEE_Std_1666/deprecated", sc_core::SC_DO_NOTHING); sc_core::sc_report_handler::set_actions(sc_core::SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_, sc_core::SC_DO_NOTHING); - sc_core::sc_report_handler::set_actions(sc_core::SC_ERROR, sc_core::SC_LOG | sc_core::SC_CACHE_REPORT | sc_core::SC_DISPLAY | sc_core::SC_STOP); + sc_core::sc_report_handler::set_actions(sc_core::SC_ERROR, sc_core::SC_LOG | sc_core::SC_CACHE_REPORT | + sc_core::SC_DISPLAY | sc_core::SC_STOP); } void CLIParser::build() { diff --git a/src/CLIParser.h b/src/CLIParser.h index 858d75f..d94e2fb 100644 --- a/src/CLIParser.h +++ b/src/CLIParser.h @@ -8,22 +8,22 @@ #define PLATFORM_SRC_CLIPARSER_H_ #include -#include #include +#include class CLIParser { public: - CLIParser(int argc, char *argv[]); + CLIParser(int argc, char* argv[]); virtual ~CLIParser(); bool is_valid() { return valid; } - const boost::program_options::variables_map &vm() { return vm_; } + const boost::program_options::variables_map& vm() { return vm_; } - bool is_set(const char *option) { return vm_.count(option) != 0; } + bool is_set(const char* option) { return vm_.count(option) != 0; } - template const T &get(const char *option) { return vm_[option].as(); } + template const T& get(const char* option) { return vm_[option].as(); } private: void build(); diff --git a/src/sc_main.cpp b/src/sc_main.cpp index 3b02135..21c2276 100644 --- a/src/sc_main.cpp +++ b/src/sc_main.cpp @@ -10,18 +10,18 @@ #include #include #include +#include #include #include #include -#include #ifdef WITH_LLVM #include #endif -#include #include "vp/tb.h" -#include +#include #include +#include #include #ifdef ERROR #undef ERROR @@ -38,7 +38,7 @@ const size_t ERRORR_IN_COMMAND_LINE = 1; const size_t SUCCESS = 0; } // namespace -int sc_main(int argc, char *argv[]) { +int sc_main(int argc, char* argv[]) { /////////////////////////////////////////////////////////////////////////// // SystemC >=2.2 got picky about multiple drivers so disable check /////////////////////////////////////////////////////////////////////////// @@ -47,7 +47,8 @@ int sc_main(int argc, char *argv[]) { // CLI argument parsing & logging setup /////////////////////////////////////////////////////////////////////////// CLIParser parser(argc, argv); - if (!parser.is_valid()) return ERRORR_IN_COMMAND_LINE; + if(!parser.is_valid()) + return ERRORR_IN_COMMAND_LINE; scc::stream_redirection cout_redir(std::cout, scc::log::INFO); scc::stream_redirection cerr_redir(std::cerr, scc::log::ERROR); /////////////////////////////////////////////////////////////////////////// @@ -69,34 +70,40 @@ int sc_main(int argc, char *argv[]) { /////////////////////////////////////////////////////////////////////////// std::unique_ptr tracer; - if( auto trace_level = parser.get("trace-level")) { + if(auto trace_level = parser.get("trace-level")) { auto file_name = parser.get("trace-file"); - auto enable_sig_trace = (trace_level&0x1) != 0;// bit0 enables sig trace - auto tx_trace_type = static_cast(trace_level >> 1); // bit3-bit1 define the kind of transaction trace + auto enable_sig_trace = (trace_level & 0x1) != 0; // bit0 enables sig trace + 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 /////////////////////////////////////////////////////////////////////////// - if(tracer) tracer->add_control(); + if(tracer) + tracer->add_control(); /////////////////////////////////////////////////////////////////////////// // dump configuration if requested /////////////////////////////////////////////////////////////////////////// - if (parser.get("dump-config").size() > 0) { + if(parser.get("dump-config").size() > 0) { std::ofstream of{parser.get("dump-config")}; - if (of.is_open()) cfg.dump_configuration(of, true); + if(of.is_open()) + cfg.dump_configuration(of, true); } cfg.configure(); std::unique_ptr dumper; if(parser.is_set("dump-structure")) - dumper.reset(new scc::hierarchy_dumper(parser.get("dump-structure"), scc::hierarchy_dumper::D3JSON)); + dumper.reset( + new scc::hierarchy_dumper(parser.get("dump-structure"), scc::hierarchy_dumper::D3JSON)); /////////////////////////////////////////////////////////////////////////// // overwrite config with command line settings /////////////////////////////////////////////////////////////////////////// @@ -104,23 +111,25 @@ int sc_main(int argc, char *argv[]) { cfg.set_value(core_path + ".dump_ir", parser.is_set("dump-ir")); cfg.set_value(core_path + ".backend", parser.get("backend")); cfg.set_value(core_path + ".core_type", parser.get("isa")); - if(parser.is_set("plugin")){ - auto plugins = util::join(parser.get>("plugin"),","); + if(parser.is_set("plugin")) { + auto plugins = util::join(parser.get>("plugin"), ","); cfg.set_value(core_path + ".plugins", plugins); } - if (parser.is_set("elf")) cfg.set_value(core_path + ".elf_file", parser.get("elf")); - if (parser.is_set("quantum")) + if(parser.is_set("elf")) + cfg.set_value(core_path + ".elf_file", parser.get("elf")); + if(parser.is_set("quantum")) tlm::tlm_global_quantum::instance().set(sc_core::sc_time(parser.get("quantum"), sc_core::SC_NS)); - if (parser.is_set("reset")) { + if(parser.is_set("reset")) { auto str = parser.get("reset"); - uint64_t start_address = str.find("0x") == 0 ? std::stoull(str.substr(2), nullptr, 16) : std::stoull(str, nullptr, 10); + uint64_t start_address = + str.find("0x") == 0 ? std::stoull(str.substr(2), nullptr, 16) : std::stoull(str, nullptr, 10); cfg.set_value(core_path + ".reset_address", start_address); } - if (parser.is_set("disass")) { + if(parser.is_set("disass")) { cfg.set_value(core_path + ".enable_disass", true); LOGGER(disass)::reporting_level() = logging::INFO; auto file_name = parser.get("disass"); - if (file_name.length() > 0) { + if(file_name.length() > 0) { LOG_OUTPUT(disass)::stream() = fopen(file_name.c_str(), "w"); LOGGER(disass)::print_time() = false; LOGGER(disass)::print_severity() = false; @@ -130,12 +139,13 @@ int sc_main(int argc, char *argv[]) { // run simulation /////////////////////////////////////////////////////////////////////////// try { - if (parser.is_set("max_time")) { + if(parser.is_set("max_time")) { sc_core::sc_start(scc::parse_from_string(parser.get("max_time"))); } else sc_core::sc_start(); - if (!sc_core::sc_end_of_simulation_invoked()) sc_core::sc_stop(); - } catch (sc_core::sc_report &rep) { + if(!sc_core::sc_end_of_simulation_invoked()) + sc_core::sc_stop(); + } catch(sc_core::sc_report& rep) { sc_core::sc_report_handler::get_handler()(rep, sc_core::SC_DISPLAY | sc_core::SC_STOP); } return 0; diff --git a/src/vp/gen/PipelinedMemoryBusToApbBridge.h b/src/vp/gen/PipelinedMemoryBusToApbBridge.h index 0ff5bea..2bdb616 100644 --- a/src/vp/gen/PipelinedMemoryBusToApbBridge.h +++ b/src/vp/gen/PipelinedMemoryBusToApbBridge.h @@ -1,21 +1,22 @@ /* -* Copyright (c) 2023 - 2024 MINRES Technologies GmbH -* -* SPDX-License-Identifier: Apache-2.0 -* -* Generated at 2024-02-08 14:41:56 UTC -* by peakrdl_mnrs version 1.2.2 -*/ + * Copyright (c) 2023 - 2024 MINRES Technologies GmbH + * + * SPDX-License-Identifier: Apache-2.0 + * + * Generated at 2024-02-08 14:41:56 UTC + * by peakrdl_mnrs version 1.2.2 + */ #pragma once -// need double braces, see https://stackoverflow.com/questions/6893700/how-to-construct-stdarray-object-with-initializer-list#6894191 +// need double braces, see +// https://stackoverflow.com/questions/6893700/how-to-construct-stdarray-object-with-initializer-list#6894191 const std::array, 7> PipelinedMemoryBusToApbBridge_map = {{ - { gpio0.socket, 0x0, 0xc }, - { uart0.socket, 0x1000, 0x14 }, - { timer0.socket, 0x20000, 0x1c }, - { aclint.socket, 0x30000, 0xc000 }, - { irq_ctrl.socket, 0x40000, 0x8 }, - { qspi.socket, 0x50000, 0x5c }, - { boot_rom.target, 0x80000, 0x2000 }, - }} ; + {gpio0.socket, 0x0, 0xc}, + {uart0.socket, 0x1000, 0x14}, + {timer0.socket, 0x20000, 0x1c}, + {aclint.socket, 0x30000, 0xc000}, + {irq_ctrl.socket, 0x40000, 0x8}, + {qspi.socket, 0x50000, 0x5c}, + {boot_rom.target, 0x80000, 0x2000}, +}}; diff --git a/src/vp/rst_gen.h b/src/vp/rst_gen.h deleted file mode 100644 index 63b9bed..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 760d4e0..ab0069b 100644 --- a/src/vp/system.cpp +++ b/src/vp/system.cpp @@ -4,32 +4,33 @@ * 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; system::system(sc_core::sc_module_name nm) : sc_core::sc_module(nm) , NAMED(ahb_router, 3, 2) -, NAMED(apbBridge, PipelinedMemoryBusToApbBridge_map.size(), 1){ +, NAMED(apbBridge, PipelinedMemoryBusToApbBridge_map.size(), 1) { core_complex.ibus(ahb_router.target[0]); core_complex.dbus(ahb_router.target[1]); 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); size_t i = 0; - for (const auto &e : PipelinedMemoryBusToApbBridge_map) { + for(const auto& e : PipelinedMemoryBusToApbBridge_map) { apbBridge.initiator.at(i)(e.target); apbBridge.set_target_range(i, e.start, e.size); i++; @@ -42,7 +43,7 @@ system::system(sc_core::sc_module_name nm) irq_ctrl.clk_i(clk_i); qspi.clk_i(clk_i); core_complex.clk_i(clk_i); - //mem_ram.clk_i(clk_i); + // mem_ram.clk_i(clk_i); gpio0.rst_i(rst_s); uart0.rst_i(rst_s); @@ -77,19 +78,16 @@ 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; } -void system::gen_reset(){ +void system::gen_reset() { if(erst_n.read()) rst_s = 0; - else rst_s = 1; + else + rst_s = 1; } - -} /* namespace sysc */ +} // namespace vp diff --git a/src/vp/system.h b/src/vp/system.h index 8dac8be..3ae7b54 100644 --- a/src/vp/system.h +++ b/src/vp/system.h @@ -4,47 +4,42 @@ * 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 #include #include #include +#include +#include +#include +#include #include #include #include -#include -#include -#include -namespace tgc_vp { +namespace vp { class system : public sc_core::sc_module { public: - SC_HAS_PROCESS(system);// NOLINT + SC_HAS_PROCESS(system); // NOLINT - sc_core::sc_vector> pins_o{"pins_o",32}; + sc_core::sc_vector> pins_o{"pins_o", 32}; sc_core::sc_vector> pins_oe_o{"pins_oe_o", 32}; - sc_core::sc_vector> pins_i{"pins_i", 32}; - sc_core::sc_out uart0_tx_o {"uart0_tx_o"}; - 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}; - + sc_core::sc_vector> pins_i{"pins_i", 32}; + sc_core::sc_out uart0_tx_o{"uart0_tx_o"}; + 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}; + spi::spi_pkt_initiator_socket<> mspi0{"mspi0"}; + sc_core::sc_in clk_i{"clk_i"}; sc_core::sc_in erst_n{"erst_n"}; @@ -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"}; @@ -61,18 +56,20 @@ private: vpvper::minres::irq_tl irq_ctrl{"irq_ctrl"}; vpvper::minres::qspi_tl qspi{"qspi"}; - scc::memory<128_kB, scc::LT> mem_ram {"mem_ram"}; - scc::memory<8_kB, scc::LT> boot_rom {"boot_rom"}; - - sc_core::sc_signal rst_s{"rst_s"}, mtime_int_s{"mtime_int_s"}, msip_int_s{"msip_int_s"}; - - sc_core::sc_vector> irq_int_s{"irq_int_s", 32}, local_int_s{"local_int_s", 16}; + scc::memory<128_kB, scc::LT> mem_ram{"mem_ram"}; + scc::memory<8_kB, scc::LT> boot_rom{"boot_rom"}; + + sc_core::sc_signal rst_s{"rst_s"}, mtime_int_s{"mtime_int_s"}, + msip_int_s{"msip_int_s"}; + + sc_core::sc_vector> irq_int_s{"irq_int_s", 32}, + local_int_s{"local_int_s", 16}; sc_core::sc_signal core_int_s{"core_int_s"}; - + void gen_reset(); #include "../vp/gen/PipelinedMemoryBusToApbBridge.h" }; -} /* namespace sysc */ +} // namespace vp -#endif /* _PLATFORM_H_ */ +#endif /* SRC_VP_SYSTEM_H_ */ diff --git a/src/vp/tb.cpp b/src/vp/tb.cpp index 8620bfc..b8515eb 100644 --- a/src/vp/tb.cpp +++ b/src/vp/tb.cpp @@ -4,15 +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) { +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); @@ -20,11 +21,10 @@ tb::tb(const sc_core::sc_module_name &nm): sc_core::sc_module(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 vp diff --git a/src/vp/tb.h b/src/vp/tb.h index 02143e0..aeba73f 100644 --- a/src/vp/tb.h +++ b/src/vp/tb.h @@ -7,33 +7,32 @@ #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_o{"pins_o", 32}; sc_core::sc_vector> pins_oe_o{"pins_oe_o", 32}; - sc_core::sc_vector> pins_i{"pins_i", 32}; - sc_core::sc_signal uart0_tx_o {"uart0_tx_o"}; - 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_vector> pins_i{"pins_i", 32}; + sc_core::sc_signal uart0_tx_o{"uart0_tx_o"}; + 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}; + 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 899316d..77b5ffa 160000 --- a/vpvper +++ b/vpvper @@ -1 +1 @@ -Subproject commit 899316db7ec527a46c968199a9c0e0f64e48fc2b +Subproject commit 77b5ffa40d50f63f4adac0b32076d9da590a4c51