commit 15144ca608e60adff0db6fa9498b4ee02b151d00 Author: Eyck Jentzsch Date: Sun Jun 30 17:47:05 2024 +0200 initial version diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..48c14b9 --- /dev/null +++ b/.clang-format @@ -0,0 +1,96 @@ +Language: Cpp +# BasedOnStyle: LLVM +# should be in line with IndentWidth +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlinesLeft: false +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: false +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Attach +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: true +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 120 +CommentPragmas: '^( IWYU pragma:| @suppress)' +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 0 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + - Regex: '^(<|"(gtest|isl|json)/)' + Priority: 3 + - Regex: '.*' + Priority: 1 +IncludeIsMainRegex: '$' +IndentCaseLabels: false +IndentWidth: 4 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Left +ReflowComments: true +SortIncludes: true +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: Never +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +TabWidth: 4 +UseTab: Never +... + diff --git a/.cproject b/.cproject new file mode 100644 index 0000000..da3a85e --- /dev/null +++ b/.cproject @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CMAKE_BUILD_TOOL + + fw-hello-world + true + true + true + + + gmake + -C ../../fw/fir + clean all + true + false + true + + + gmake + -C ../../fw/fir VARIANT=ISAX + clean all + true + false + true + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..bcdccba --- /dev/null +++ b/.envrc @@ -0,0 +1,11 @@ +distro=`/bin/lsb_release -i -s` +if [ $distro == "CentOS" ]; then + . /opt/rh/devtoolset-8/enable + . /opt/rh/llvm-toolset-7/enable + . /opt/rh/rh-python38/enable +elif [ $distro == "Rocky" ]; then + . /opt/rh/gcc-toolset-11/enable +fi +module load ./Modulefile +layout python3 +[ -f .envrc.$USER ] && . .envrc.$USER diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cec994f --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +/build/ +/plugins/ +/.settings/ +*.o +*.a +*.lib +/*.log +/*.txlog +/*.vcd +/*.ftr +/*.fst +/.vs +/out +/coverage.info +/output.txt +/output.trc +CMakeSettings.json +/.venv +/src-gen/ +/*.json +/cfg.yaml +/.direnv +/.cache \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..fb817ea --- /dev/null +++ b/.gitmodules @@ -0,0 +1,18 @@ +[submodule "scc"] + path = scc + url = https://github.com/VP-Vibes/SystemC-Components.git +[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 diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile new file mode 100644 index 0000000..4b3e5a1 --- /dev/null +++ b/.gitpod.Dockerfile @@ -0,0 +1,31 @@ +FROM gitpod/workspace-full:latest + + +# Make a working folder and set the necessary environment variables. +ENV RISCV /opt/riscv +RUN sudo mkdir -p $RISCV +RUN sudo touch $RISCV/install.stamp + +# Add the GNU utils bin folder to the path. +ENV PATH $RISCV/bin:$PATH +MAINTAINER eyck@minres.com + +USER root +RUN apt-get install gnupg software-properties-common wget -y +RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add - +RUN apt-add-repository 'deb https://apt.kitware.com/ubuntu/ focal main' + +# Obtain the RISCV-tools repo which consists of a number of submodules +# so make sure we get those too. +WORKDIR /opt/riscv +RUN apt-get update && \ + apt-get install -y autoconf automake autotools-dev curl python3 python3-pip python3-venv libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev cmake gdb && \ + apt-get clean && rm -rf /var/lib/apt/lists/* +RUN git clone --recursive https://github.com/riscv/riscv-gnu-toolchain && \ + cd riscv-gnu-toolchain && \ + ./configure --prefix=/opt/riscv --without-system-zlib --enable-multilib --with-arch=rv32gc --with-abi=ilp32d && \ + make -j newlib && \ + cd .. && \ + rm -rf riscv-gnu-toolchain +RUN apt-get update && apt install default-jdk -y +USER gitpod diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 0000000..c41875c --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,22 @@ +--- +# Commands to start on workspace startup +image: stanka/gitpod-riscv-tools:latest +# file: .gitpod.Dockerfile +tasks: + - env: + CONAN_USER_HOME: "/workspace/conan" + init: | + python3 -m venv /workspace/venv + python3 -m pip install --upgrade pip + source /workspace/venv/bin/activate + pip install 'conan<2.0' + command: | + source /workspace/venv/bin/activate + cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON + cmake --build build +vscode: + extensions: + - ms-python.python + - webfreak.debug + - twxs.cmake + - ms-vscode.cmake-tools diff --git a/.launch/FW-Debug.launch b/.launch/FW-Debug.launch new file mode 100644 index 0000000..2889448 --- /dev/null +++ b/.launch/FW-Debug.launch @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/.launch/TGC-VP asmjit hello.launch b/.launch/TGC-VP asmjit hello.launch new file mode 100644 index 0000000..36b6a1e --- /dev/null +++ b/.launch/TGC-VP asmjit hello.launch @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.launch/TGC-VP interp dhrystone ce fast.launch b/.launch/TGC-VP interp dhrystone ce fast.launch new file mode 100644 index 0000000..af4bb02 --- /dev/null +++ b/.launch/TGC-VP interp dhrystone ce fast.launch @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.launch/TGC-VP interp dhrystone ce slow.launch b/.launch/TGC-VP interp dhrystone ce slow.launch new file mode 100644 index 0000000..1904fbd --- /dev/null +++ b/.launch/TGC-VP interp dhrystone ce slow.launch @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.launch/TGC-VP interp dhrystone.launch b/.launch/TGC-VP interp dhrystone.launch new file mode 100644 index 0000000..b2db581 --- /dev/null +++ b/.launch/TGC-VP interp dhrystone.launch @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.launch/TGC-VP interp hello cycle-estimate fast.launch b/.launch/TGC-VP interp hello cycle-estimate fast.launch new file mode 100644 index 0000000..7699356 --- /dev/null +++ b/.launch/TGC-VP interp hello cycle-estimate fast.launch @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.launch/TGC-VP interp hello cycle-estimate slow.launch b/.launch/TGC-VP interp hello cycle-estimate slow.launch new file mode 100644 index 0000000..cf33089 --- /dev/null +++ b/.launch/TGC-VP interp hello cycle-estimate slow.launch @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.launch/TGC-VP interp hello pctrace.launch b/.launch/TGC-VP interp hello pctrace.launch new file mode 100644 index 0000000..7f6f140 --- /dev/null +++ b/.launch/TGC-VP interp hello pctrace.launch @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.launch/TGC-VP interp hello.launch b/.launch/TGC-VP interp hello.launch new file mode 100644 index 0000000..7f8cfbe --- /dev/null +++ b/.launch/TGC-VP interp hello.launch @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.launch/TGC-VP llvm dhrystone.launch b/.launch/TGC-VP llvm dhrystone.launch new file mode 100644 index 0000000..240fd47 --- /dev/null +++ b/.launch/TGC-VP llvm dhrystone.launch @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.launch/TGC-VP llvm hello.launch b/.launch/TGC-VP llvm hello.launch new file mode 100644 index 0000000..8430b30 --- /dev/null +++ b/.launch/TGC-VP llvm hello.launch @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.launch/TGC-VP tcc dhrystone.launch b/.launch/TGC-VP tcc dhrystone.launch new file mode 100644 index 0000000..e1ef794 --- /dev/null +++ b/.launch/TGC-VP tcc dhrystone.launch @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.launch/TGC-VP tcc hello.launch b/.launch/TGC-VP tcc hello.launch new file mode 100644 index 0000000..b93fed4 --- /dev/null +++ b/.launch/TGC-VP tcc hello.launch @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.launch/TGC-VP-FW-Debug.launch b/.launch/TGC-VP-FW-Debug.launch new file mode 100644 index 0000000..16cc022 --- /dev/null +++ b/.launch/TGC-VP-FW-Debug.launch @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.launch/TGC-VP-GDBServer.launch b/.launch/TGC-VP-GDBServer.launch new file mode 100644 index 0000000..e92ffa7 --- /dev/null +++ b/.launch/TGC-VP-GDBServer.launch @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..2f8fe8f --- /dev/null +++ b/.project @@ -0,0 +1,59 @@ + + + TGC-VP + + + + + + org.python.pydev.PyDevBuilder + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + org.eclipse.xtext.ui.shared.xtextNature + org.python.pydev.pythonNature + + + + 0 + + 22 + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-false-false-*.o + + + + 0 + + 22 + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-false-false-*.a + + + + diff --git a/.pydevproject b/.pydevproject new file mode 100644 index 0000000..2b04565 --- /dev/null +++ b/.pydevproject @@ -0,0 +1,5 @@ + + + Default + python interpreter + diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..1211532 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,17 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [], + "compilerPath": "/usr/bin/gcc", + "cStandard": "gnu17", + "cppStandard": "gnu++14", + "intelliSenseMode": "linux-gcc-x64", + "configurationProvider": "ms-vscode.cmake-tools" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..68a1a1f --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,55 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "gdb", + "request": "attach", + "name": "Attach-to-gdbserver", + "executable": "./fw/hello-world/hello", + "target": ":10000", + "remote": true, + "cwd": "${workspaceRoot}", + "valuesFormatting": "prettyPrinters", + "gdbpath": "/opt/riscv/bin/riscv32-unknown-elf-gdb", + "debugger_args": [], + "presentation": { + "hidden": true, + "group": "FW Debug", + "order": 2 + } + }, + { + "type": "gdb", + "request": "launch", + "name": "Launch-VP-with-gdbserver", + "cwd": "${workspaceRoot}", + "valuesFormatting": "parseText", + "target": "./build/src/tgc-vp", + "arguments": "-f fw/hello-world/hello -g 10000", + "presentation": { + "hidden": true, + "group": "FW Debug", + "order": 1 + } + }, + { + "type": "gdb", + "request": "launch", + "name": "VP-Debug", + "cwd": "${workspaceRoot}", + "valuesFormatting": "parseText", + "target": "./build/src/tgc-vp", + "printCalls": false, + "arguments": "-f fw/hello-world/hello" + }, + ], + "compounds": [ + { + "name": "FW-Debug", + "configurations": ["Launch-VP-with-gdbserver", "Attach-to-gdbserver"] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4cfbe19 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "files.associations": { + "platform.h": "c" + }, + "debug.allowBreakpointsEverywhere": true +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..18fdf26 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,65 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "CMake-and-make", + "type": "shell", + "command": "source .venv/bin/activate && cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON && cmake --build build", + "problemMatcher": [], + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "dedicated", + "showReuseMessage": false, + "clear": true + }, + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "Build-FW", + "type": "shell", + "command": "cd fw/hello-world/ && make", + "problemMatcher": [], + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "dedicated", + "showReuseMessage": false, + "clear": true + } + }, + { + "label": "Execute-VP", + "type": "shell", + "command": "build/src/tgc-vp -f fw/hello-world/hello -p pctrace=contrib/TGC_C_cycles.json", + "problemMatcher": [], + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "dedicated", + "showReuseMessage": false, + "clear": true + } + }, + { + "label": "VP-GDB-Server", + "type": "shell", + "command": "build/src/tgc-vp -f fw/hello-world/hello -g 10000", + "problemMatcher": [], + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "dedicated", + "showReuseMessage": false, + "clear": true + }, + } + ] +} diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..37e7daa --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,89 @@ +cmake_minimum_required(VERSION 3.16) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/scc/cmake) + +project(riscv-vp LANGUAGES C CXX VERSION 1.0.0) + +option(LIBS_ONLY "Just build the shared libraries needed to build the VP" OFF) +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) + +set(SCC_LIB_ONLY ON) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +include(CheckCXXCompilerFlag) +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_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address") +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) +include(SystemCPackage) + +set(CLANG_FORMAT_EXCLUDE_PATTERNS "scc" "dbt-rise-riscv") +find_package(ClangFormat) + +if(ENABLE_COVERAGE) + include(CodeCoverage) + append_coverage_compiler_flags() + set(COVERAGE_EXCLUDES "$ENV{HOME}/.conan/*" "/opt/*") +endif() + +if(ENABLE_CLANGTIDY) + find_program(CLANG_TIDY_EXE NAMES "clang-tidy") + if (CLANG_TIDY_EXE) + message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}") + set(CLANG_TIDY_CHECKS + "-*,modernize-*,-modernize-use-trailing-return-type,clang-analyzer-*,concurrency-*,cppcoreguidelines-*,boost-*,bugprone-*,performance-*,portability-*,readability-*") + #set(CLANG_TIDY_CHECKS "*") + set(CMAKE_CXX_CLANG_TIDY + ${CLANG_TIDY_EXE}; + -header-filter=${tgfs_verif_SOURCE_DIR}; + -checks=${CLANG_TIDY_CHECKS};) + else() + message(AUTHOR_WARNING "clang-tidy not found!") + set(CMAKE_CXX_CLANG_TIDY "" CACHE STRING "" FORCE) # delete it + endif() +endif () + +add_subdirectory(scc) +add_subdirectory(dbt-rise-riscv) +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/dbt-rise-plugins) + add_subdirectory(dbt-rise-plugins) +endif() +if(NOT USE_CWR_SYSTEMC) + add_subdirectory(vpvper) +endif() +if(NOT LIBS_ONLY) + add_subdirectory(src) +endif() + +if(FW_BUILD) + include(FetchContent) + set(FETCHCONTENT_BASE_DIR ${CMAKE_CURRENT_BINARY_DIR}/..) + FetchContent_Declare( + riscvfw + GIT_REPOSITORY https://git.minres.com/Firmware/Firmwares.git + GIT_TAG develop + GIT_SHALLOW OFF + UPDATE_DISCONNECTED ON + ) + FetchContent_GetProperties(riscvfw) + if(NOT riscvfw_POPULATED) + FetchContent_Populate(riscvfw) + endif() + set(BOARD tgc_vp) + add_subdirectory(${riscvfw_SOURCE_DIR}) +endif() diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..4ce4152 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,109 @@ +def getBranch() { + if (env.BRANCH_NAME != null && !env.BRANCH_NAME.isEmpty() ) { + return env.BRANCH_NAME + } else { + return 'develop' + } +} + +void checkout_tgc_vp() { + sh("rm -rf *") + checkout([ + $class: 'GitSCM', + branches: [ + [name: 'refs/heads/' + getBranch()] + ], + extensions: [ + [$class: 'CleanBeforeCheckout'], + [$class: 'SubmoduleOption', + disableSubmodules: false, + recursiveSubmodules: true, + trackingSubmodules: false, + parentCredentials: true, + shallow: true + ] + ], + submoduleCfg: [], + userRemoteConfigs: [ + [url: 'https://github.com/Minres/TGC-VP.git'] + ] + ]) +} + +void build_tgc_vp() { + try { + sh("conan profile new default --detect --force") + sh("conan profile update settings.compiler.libcxx=libstdc++11 default") + sh("conan remote add minres https://git.minres.com/api/packages/Tooling/conan --force") + sh("conan --version && cmake --version") + } + catch (exc) { + echo 'Conan configured' + } + sh("rm -rf build") + sh("git submodule update --recursive") + sh("cmake -S . -B build -DWITH_TCC=OFF && cmake --build build -j16") + fingerprint 'build/src/tgc-vp' +} + +pipeline { + agent none + + options { + // using the Timestamper plugin we can add timestamps to the console log + timestamps() + skipStagesAfterUnstable() + } + + stages { + stage('TGC-VP pipeline') { + parallel { + stage('ubuntu20'){ + agent {docker { image 'ubuntu-20.04' } } + stages { + stage('Checkout on Ubuntu20.04') { steps { checkout_tgc_vp() }} + stage('Build') { steps { build_tgc_vp() } } + } + } + stage('ubuntu22'){ + agent {docker { image 'ubuntu-22.04' } } + stages { + stage('Checkout on Ubuntu22.04') { steps { checkout_tgc_vp() }} + stage('Build') { steps { build_tgc_vp() } } + } + } + stage('CentOS7'){ + agent {docker { image 'centos7' } } + stages { + stage('Checkout on Ubuntu') { steps {checkout_tgc_vp()}} + stage('Build') { steps {build_tgc_vp()} + } + } + } + stage('RockyLinux8'){ + agent {docker { image 'rockylinux8' } } + stages { + stage('Checkout on Ubuntu') { steps {checkout_tgc_vp()}} + stage('Build') { steps {build_tgc_vp()} + } + } + } + } + } + } + post { + success { + rocketSend ":thumbsup: TGC-VP verification run passed, results at ${env.RUN_DISPLAY_URL} " + } + failure { + archiveArtifacts artifacts: 'failed_seeds_*.txt', followSymlinks: false, onlyIfSuccessful: false + rocketSend ":thumbsdown: TGC-VP verification failed, please check ${env.RUN_DISPLAY_URL} " + emailext recipientProviders: [culprits(), requestor()], + subject: "TGC-VP Pipeline Failed: ${currentBuild.fullDisplayName}", + body: """ +

Build Status: ${currentBuild.currentResult}

+

Check logs at Build Console Logs or at Overview

+ """ + } + } +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/Modulefile b/Modulefile new file mode 100644 index 0000000..c04143a --- /dev/null +++ b/Modulefile @@ -0,0 +1,15 @@ +#%Module###################################################################### +## +## Project Module +## +proc ModulesHelp { } { + puts stderr "\tThe TGC verification project Module\n" + puts stderr "\tThis module loads PATHs and variables for running TGC verification." +} + +set distro [exec /usr/bin/lsb_release -i -s] +if { $distro == "CentOS" && ![info exists ::env(PROJECT)] && ![info exists ::env(PCP_DIR)] } { + puts stderr "Don't forget to execute 'scl enable devtoolset-7 llvm-toolset-7 bash'" +} + +module load tools/gcc-riscv64-unknown-elf/13 tools/cmake/3.28 tools/utilities \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..325fddc --- /dev/null +++ b/README.md @@ -0,0 +1,126 @@ +# TGC-VP +The Scale4Edge ecosystem VP using VP-VIBES peripherals. + +This VP is based in MINRES TGC series cores and uses CoreDSL to generate the concrete ISS +of a particular ISA + extensions. The generator approach makes it very flexible and adaptable. +Since the CoreDSL description is used to generate RTL as well as verification artifacts it +provides a comprehensive and consistent solution to develop processor cores. + +## Ultra Quick start + +Using gitpod you can run the VP in the cloud. Just visit [Gitpod.io](https://www.gitpod.io/#https://github.com/Minres/TGC-VP/tree/develop) +and follow the instructions. After the build finished you can run + +``` + +build/src/tgc-vp -f fw/hello-world/prebuilt/hello.elf + +``` + +or use ctest: + +``` + +cd build +ctest + +``` + + +You will see on console the prints of the hello world firmware at fw/hello-world/hello.c + +[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/Minres/TGC-VP) + +## Quick start + +* you need to have a C++14 capable compiler, make, python, and cmake installed + +* install conan.io (see also http://docs.conan.io/en/latest/installation.html): + + ``` + + pip3 install --user conan + + ``` + + It is advised to use conan version 1.36 or newer. In case of an older version please run + + ```sh + + pip3 install --user --upgrade conan + + ``` + + Installing conan for the first time you need to create a profile: + + ``` + + conan profile create default --detect + + ``` + +* checkout source from git + + ```sh + + git clone --recursive -b develop https://github.com/Minres/TGC-VP.git + + ``` + +* start an out-of-source build: + + ``` + + cd TGC-VP + mkdir build + cd build + cmake .. + make -j tgc-vp + + ``` + +* run the VP with pre-built firmware + + ``` + + ctest + + ``` + + or + + ``` + + src/tgc-vp -f ../fw/hello-world/prebuild/hello.elf + + ``` + +To rebuild the firmware you need to install a RISC-V toolchain like https://github.com/riscv/riscv-tools. + +# Windows/Visual Studio build + +TGC-VP supports VS2019/MSVC 16 and has been tested only with this version + +## Prerequisites + +You need to have to following installed: + +* Visual Studio 2019 (community edition is sufficient) with C/C++ support +* Python 3.6 or newer +* SystemC 2.3.3 and SystemC-CCI 1.0.0. Both should be installed into the same location and the + environment variable SYSTEMC_HOME should point to it +* Conan (https://conan.io/) version 1.36 or newer. If python is installed this can be installed using pip + (see above in [Quick start](#quick-start)) + +## build step + +Create a project at the location of the git workarea. This can be done + +``` + +devenv + +``` + +The build steps are as described in the VS documentation for CMake based projects. + diff --git a/conanfile.txt b/conanfile.txt new file mode 100644 index 0000000..8979eab --- /dev/null +++ b/conanfile.txt @@ -0,0 +1,48 @@ +[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-riscv b/dbt-rise-riscv new file mode 160000 index 0000000..85e2ced --- /dev/null +++ b/dbt-rise-riscv @@ -0,0 +1 @@ +Subproject commit 85e2cedb1a9cc86aae4d63e77627df18fc1e3923 diff --git a/pysysc/.gitignore b/pysysc/.gitignore new file mode 100644 index 0000000..bee8a64 --- /dev/null +++ b/pysysc/.gitignore @@ -0,0 +1 @@ +__pycache__ diff --git a/pysysc/gitpod_install.sh b/pysysc/gitpod_install.sh new file mode 100755 index 0000000..32f5b78 --- /dev/null +++ b/pysysc/gitpod_install.sh @@ -0,0 +1,11 @@ +#!/bin/sh +## + +# Install prerequisites +pip install wheel +# clone and install PySysC +git clone https://github.com/Minres/PySysC.git /workspace/PySysC +STDCXX=14 SYSTEMC_HOME=`ls -d $CONAN_USER_HOME/.conan/data/systemc/2.3.3/_/_/package/* | head -1` \ + pip install /workspace/PySysC/ +# install SCC integration +pip install scc/contrib/pysysc diff --git a/pysysc/modules.py b/pysysc/modules.py new file mode 100644 index 0000000..970b7c4 --- /dev/null +++ b/pysysc/modules.py @@ -0,0 +1,66 @@ +from cppyy import gbl as cpp +from pysysc.structural import Connection, Module, Signal, Clock, Simulation +############################################################################### +# define toplevel class +############################################################################### +class TopModule(cpp.scc.PyScModule): + + def __init__(self, name): + super().__init__(self, name) + ############################################################################### + # instantiate + ############################################################################### + self.rst_gen = Module(cpp.tgfs_vp.rst_gen).create("rst_gen") + self.aon = Module(cpp.vpvper.sifive.aon).create("aon") + self.clint = Module(cpp.vpvper.sifive.clint).create("clint") + self.uart = Module(cpp.vpvper.sifive.uart_terminal).create("uart0") + + self.mem_qspi = Module(cpp.scc.memory[2**24,32]).create("mem_qspi") + self.mem_ram = Module(cpp.scc.memory[1024,32]).create("mem_ram") + self.core_complex = Module(cpp.sysc.tgfs.core_complex).create("core_complex") + self.router = Module(cpp.scc.router[32]).create("router", 5) + ############################################################################### + # connect them + ############################################################################### + Clock("clock", 64.5, 'SC_NS')\ + .sink(self.aon.clk_i)\ + .sink(self.clint.tlclk_i)\ + .sink(self.core_complex.clk_i) + + self.lfclk = Signal("lfclk").src(self.aon.lfclkc_o).sink(self.clint.lfclk_i) + + self.rst = Signal("rst").src(self.aon.rst_o)\ + .sink(self.clint.rst_i)\ + .sink(self.uart.rst_i)\ + .sink(self.core_complex.rst_i) + + Signal("erst_s").src(self.rst_gen.rst_n).sink(self.aon.erst_n_i) + + # Interrupts + Signal("timer_irq_s").src(self.clint.mtime_int_o).sink(self.core_complex.timer_irq_i) + Signal("sw_irq_s").src(self.clint.msip_int_o).sink(self.core_complex.sw_irq_i) + Signal("core_irq_s").src(self.uart.irq_o).sink(self.core_complex.global_irq_i) + [Signal(f"local_irq_{idx}").sink(self.core_complex.local_irq_i.at(idx)) for idx in range(self.core_complex.local_irq_i.size())] + + # Routing + Connection().src(self.core_complex.initiator).sink(self.router.target.at(0)) + Connection().src(self.router.initiator.at(0)).sink(self.clint.socket) + self.router.set_target_range(0, 0x2000000, 0xc000) + Connection().src(self.router.initiator.at(1)).sink(self.aon.socket) + self.router.set_target_range(1, 0x10000000, 0x150) + Connection().src(self.router.initiator.at(2)).sink(self.mem_qspi.target) + self.router.set_target_range(2, 0x20000000, 2**24) + Connection().src(self.router.initiator.at(3)).sink(self.mem_ram.target) + self.router.set_target_range(3, 0x80000000, 1024) + Connection().src(self.router.initiator.at(4)).sink(self.uart.socket) + self.router.set_target_range(4, 0x10013000, 0x1c) + + def EndOfElaboration(self): + print("Elaboration finished") + + def StartOfSimulation(self): + print("Simulation started") + + def EndOfSimulation(self): + print("Simulation finished") + diff --git a/pysysc/tgc-vp-toplevel.py b/pysysc/tgc-vp-toplevel.py new file mode 100755 index 0000000..b1a3b9f --- /dev/null +++ b/pysysc/tgc-vp-toplevel.py @@ -0,0 +1,66 @@ +# +# Copyright (c) 2019 -2021 MINRES Technolgies GmbH +# +# SPDX-License-Identifier: Apache-2.0 +# + +import os.path +import logging +import cppyy +from cppyy import gbl as cpp +import pysysc +import pysysc.scc as scc +from pysysc.structural import Module, Simulation + +############################################################################### +# Include and load section +############################################################################### +logging.basicConfig(level=logging.DEBUG) +############################################################################### +current_dir = os.path.dirname(os.path.realpath(__file__)) +project_dir = os.path.dirname(current_dir) +logging.info(f"Project dir: {project_dir}") +if os.path.isdir(os.path.join(project_dir, 'build/Debug')): + pysysc.read_config_from_conan(os.path.join(project_dir, 'build/Debug')) +elif os.path.isdir(os.path.join(project_dir, 'build/Release')): + pysysc.read_config_from_conan(os.path.join(project_dir, 'build/Release')) +elif os.path.isdir(os.path.join(project_dir, 'build')): + pysysc.read_config_from_conan(os.path.join(project_dir, 'build')) +else: + sys.exit("Could not find build dir") + +pysysc.load_systemc() +############################################################################### +scc.load_lib(project_dir) +############################################################################### +logging.debug("Loading TGC-VP Peripherals libs") +pysysc.add_include_path(os.path.join(project_dir, 'vpvper')) +pysysc.add_library('sifive.h', 'libvpvper_sifive.so', project_dir) +############################################################################### +logging.debug("Loading TGC-ISS") +pysysc.add_include_path(os.path.join(project_dir, 'tgc-iss/dbt-rise-tgc/incl/sysc')) +pysysc.add_library('core_complex.h', 'libdbt-rise-tgc_sc.so', project_dir) +############################################################################### +# Include section +############################################################################### +cppyy.include(os.path.join(project_dir, 'src/tgfs_vp/rst_gen.h')) +############################################################################### +# configure +############################################################################### +scc.setup(logging.root.level) +scc.configure(enable_trace=True) +############################################################################### +# instantiate +############################################################################### +from modules import TopModule +dut = Module(TopModule).create("dut") +# Load FW +dut.core_complex.instance.elf_file.set_value(os.path.join(project_dir, 'fw/hello-world/prebuilt/hello.elf')) +#dut.core_complex.instance.enable_disass.set_value(True) +############################################################################### +# run if it is standalone +############################################################################### +if __name__ == "__main__": + Simulation.run() + logging.debug("Done") + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a646a0e --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +conan>=2.0 diff --git a/scc b/scc new file mode 160000 index 0000000..f16144c --- /dev/null +++ b/scc @@ -0,0 +1 @@ +Subproject commit f16144cd023aac774b882d20b4818857c920622c diff --git a/src/CLIParser.cpp b/src/CLIParser.cpp new file mode 100644 index 0000000..e80ed7d --- /dev/null +++ b/src/CLIParser.cpp @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2019 -2021 MINRES Technolgies GmbH + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "CLIParser.h" +#include +#include +#include +#include +#include +#include +#ifdef ERROR +#undef ERROR +#endif +namespace po = boost::program_options; +using namespace sc_core; + +namespace { +std::unordered_set backend_opts = {"interp", "tcc", "llvm", "asmjit"}; +} +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")) { + 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)) + throw po::error("Illegal value for switch backend"); + } 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)::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)::print_time() = false; + LOG_OUTPUT(connection)::ostream() = &std::cout; + /////////////////////////////////////////////////////////////////////////// + // configure logging + /////////////////////////////////////////////////////////////////////////// + scc::init_logging(scc::LogConfig() + .logFileName(vm_["log-file"].as()) + .logLevel(vm_["verbose"].as()) + .logFilterRegex(vm_["log-filter"].as()) + .logAsync(!vm_["log-sync"].as())); + scc::stream_redirection cout_redir(std::cout, scc::log::DEBUG); + 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); +} + +void CLIParser::build() { + // clang-format off + desc.add_options() + ("help,h", + "Print help message") + ("verbose,v", po::value()->default_value(scc::log::INFO), + "debug output level (NONE, FATAL, ERROR, WARNING, INFO, DEBUG, TRACE, TRACEALL)") + ("log-file,l", po::value()->default_value(""), + "log file name") + ("log-filter", po::value()->default_value(""), + "log filter regular expression name") + ("log-sync", po::bool_switch(), + "Disable asynchronous logging") + ("disass,d", po::value()->implicit_value(""), + "Enables disassembly") + ("elf,f", po::value(), + "ELF file to load") + ("gdb-port,g", po::value()->default_value(0), + "enable gdb server and specify port to use") + ("backend", po::value()->default_value("interp"), + "the ISS backend to use, options are: interp, tcc") + ("isa", po::value()->default_value("tgc5c"), + "core or isa name to use for simulation, use '?' to get list") + ("dump-ir", + "dump the intermediate representation") + ("dump-structure", po::value(), + "dump model structure to ELK file") + ("quantum", po::value(), + "SystemC quantum time in ns") + ("reset,r", po::value(), + "reset address") + ("trace-level,t", po::value()->default_value(0), + "enable tracing, or combination of 1=signals and 2=TX") + ("trace-default-on", + "enables tracing for all unspecified modules") + ("trace-file", po::value()->default_value("system"), + "set th ename of the trace file") + ("max_time,m", po::value(), + "maximum time to run") + ("config-file,c", po::value()->default_value(""), + "read configuration from file") + ("plugin,p", po::value>(), + "plugin(s) to activate") + ("dump-config,dc", po::value()->default_value(""), + "dump configuration to file file"); + // clang-format on +} + +CLIParser::~CLIParser() = default; diff --git a/src/CLIParser.h b/src/CLIParser.h new file mode 100644 index 0000000..858d75f --- /dev/null +++ b/src/CLIParser.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2019 -2021 MINRES Technolgies GmbH + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef PLATFORM_SRC_CLIPARSER_H_ +#define PLATFORM_SRC_CLIPARSER_H_ + +#include +#include +#include + +class CLIParser { +public: + CLIParser(int argc, char *argv[]); + + virtual ~CLIParser(); + + bool is_valid() { return valid; } + + const boost::program_options::variables_map &vm() { return vm_; } + + bool is_set(const char *option) { return vm_.count(option) != 0; } + + template const T &get(const char *option) { return vm_[option].as(); } + +private: + void build(); + bool valid; + boost::program_options::variables_map vm_; + boost::program_options::options_description desc; + std::array, 2> redir; +}; + +#endif /* PLATFORM_SRC_CLIPARSER_H_ */ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..b0b3137 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,38 @@ +# +# Copyright (c) 2019 -2021 MINRES Technolgies GmbH +# +# SPDX-License-Identifier: Apache-2.0 +# +cmake_minimum_required(VERSION 3.12) +project(riscv-vp LANGUAGES C CXX VERSION 0.0.1) + +include(flink) + +find_package(Boost COMPONENTS program_options thread REQUIRED) +############################################################################### +# +############################################################################### +set(CMAKE_INSTALL_RPATH $ORIGIN/../${CMAKE_INSTALL_LIBDIR}) +add_executable(${PROJECT_NAME} + sc_main.cpp + CLIParser.cpp + vp/tb.cpp + vp/system.cpp +) +target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}) +target_force_link_libraries(${PROJECT_NAME} PUBLIC dbt-rise-riscv_sc) +target_link_libraries(${PROJECT_NAME} PUBLIC vpvper_generic vpvper_minres ${BOOST_program_options_LIBRARY}) +if(TARGET Boost::program_options) + target_link_libraries(${PROJECT_NAME} PUBLIC Boost::program_options Boost::thread) +else() + target_link_libraries(${PROJECT_NAME} PUBLIC ${BOOST_program_options_LIBRARY}) +endif() + +install(TARGETS ${PROJECT_NAME} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # static lib + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # binaries + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # shared lib + FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} # for mac + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} # headers for mac (note the different component -> different package) + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} # headers +) diff --git a/src/sc_main.cpp b/src/sc_main.cpp new file mode 100644 index 0000000..3b02135 --- /dev/null +++ b/src/sc_main.cpp @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2019 -2021 MINRES Technolgies GmbH + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "CLIParser.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#ifdef WITH_LLVM +#include +#endif + +#include +#include "vp/tb.h" +#include +#include +#include +#ifdef ERROR +#undef ERROR +#endif + +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; +const size_t SUCCESS = 0; +} // namespace + +int sc_main(int argc, char *argv[]) { + /////////////////////////////////////////////////////////////////////////// + // SystemC >=2.2 got picky about multiple drivers so disable check + /////////////////////////////////////////////////////////////////////////// + sc_report_handler::set_actions(SC_ID_MORE_THAN_ONE_SIGNAL_DRIVER_, SC_DO_NOTHING); + /////////////////////////////////////////////////////////////////////////// + // CLI argument parsing & logging setup + /////////////////////////////////////////////////////////////////////////// + CLIParser parser(argc, argv); + 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); + /////////////////////////////////////////////////////////////////////////// + // set up infrastructure + /////////////////////////////////////////////////////////////////////////// +#ifdef WITH_LLVM + iss::init_jit_debug(argc, argv); +#endif + /////////////////////////////////////////////////////////////////////////// + // create the performance estimation module + /////////////////////////////////////////////////////////////////////////// + scc::perf_estimator estimator; + /////////////////////////////////////////////////////////////////////////// + // set up configuration + /////////////////////////////////////////////////////////////////////////// + scc::configurer cfg(parser.get("config-file")); + /////////////////////////////////////////////////////////////////////////// + // set up tracing & transaction recording + /////////////////////////////////////////////////////////////////////////// + + std::unique_ptr tracer; + 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 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); + } + /////////////////////////////////////////////////////////////////////////// + // instantiate top level + /////////////////////////////////////////////////////////////////////////// + auto i_system = scc::make_unique("tb"); + /////////////////////////////////////////////////////////////////////////// + // add non-implemented 'enableTracing' properties + /////////////////////////////////////////////////////////////////////////// + if(tracer) tracer->add_control(); + /////////////////////////////////////////////////////////////////////////// + // dump configuration if requested + /////////////////////////////////////////////////////////////////////////// + if (parser.get("dump-config").size() > 0) { + std::ofstream of{parser.get("dump-config")}; + 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)); + /////////////////////////////////////////////////////////////////////////// + // overwrite config with command line settings + /////////////////////////////////////////////////////////////////////////// + cfg.set_value(core_path + ".gdb_server_port", parser.get("gdb-port")); + 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"),","); + 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")) + tlm::tlm_global_quantum::instance().set(sc_core::sc_time(parser.get("quantum"), sc_core::SC_NS)); + 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); + cfg.set_value(core_path + ".reset_address", start_address); + } + 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) { + LOG_OUTPUT(disass)::stream() = fopen(file_name.c_str(), "w"); + LOGGER(disass)::print_time() = false; + LOGGER(disass)::print_severity() = false; + } + } + /////////////////////////////////////////////////////////////////////////// + // run simulation + /////////////////////////////////////////////////////////////////////////// + try { + 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) { + 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 new file mode 100644 index 0000000..df1acc7 --- /dev/null +++ b/src/vp/gen/PipelinedMemoryBusToApbBridge.h @@ -0,0 +1,21 @@ +/* +* 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 +const std::array, 6> 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 }, + //{ bootloader.socket, 0x80000, 0x400 }, + }} ; \ No newline at end of file diff --git a/src/vp/gen/platform_mmap.h b/src/vp/gen/platform_mmap.h new file mode 100644 index 0000000..9f8b352 --- /dev/null +++ b/src/vp/gen/platform_mmap.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2019 -2021 MINRES Technolgies GmbH + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef _PLATFORM_MMAP_H_ +#define _PLATFORM_MMAP_H_ +// need double braces, see +// https://stackoverflow.com/questions/6893700/how-to-construct-stdarray-object-with-initializer-list#6894191 +const std::array, 13> platfrom_mmap = {{ + {clint.socket, 0x2000000, 0xc000}, + {plic.socket, 0xc000000, 0x200008}, + {aon.socket, 0x10000000, 0x150}, + {prci.socket, 0x10008000, 0x14}, + {gpio0.socket, 0x10012000, 0x44}, + {uart0.socket, 0x10013000, 0x1c}, + {qspi0.socket, 0x10014000, 0x78}, + {pwm0.socket, 0x10015000, 0x30}, + {uart1.socket, 0x10023000, 0x1c}, + {qspi1.socket, 0x10024000, 0x78}, + {pwm1.socket, 0x10025000, 0x30}, + {qspi2.socket, 0x10034000, 0x78}, + {pwm2.socket, 0x10035000, 0x30}, +}}; + +#endif /* _PLATFORM_MMAP_H_ */ diff --git a/src/vp/platform.rdl b/src/vp/platform.rdl new file mode 100644 index 0000000..aedabcb --- /dev/null +++ b/src/vp/platform.rdl @@ -0,0 +1,25 @@ +`include "gpio.rdl" +`include "uart.rdl" +`include "spi.rdl" +`include "pwm.rdl" +`include "plic.rdl" +`include "aon.rdl" +`include "prci.rdl" +`include "clint.rdl" + +addrmap e300_plat_t { + lsb0; + clint_regs clint @0x02000000; + plic_regs plic @0x0C000000; + aon_regs aon @0x10000000; + prci_regs prci @0x10008000; + gpio_regs gpio0 @0x10012000; + uart_regs uart0 @0x10013000; + spi_regs qspi0 @0x10014000; + pwm_regs pwm0 @0x10015000; + uart_regs uart1 @0x10023000; + spi_regs qspi1 @0x10024000; + pwm_regs pwm1 @0x10025000; + spi_regs qspi2 @0x10034000; + pwm_regs pwm2 @0x10035000; +} e300_plat; diff --git a/src/vp/rst_gen.h b/src/vp/rst_gen.h new file mode 100644 index 0000000..63b9bed --- /dev/null +++ b/src/vp/rst_gen.h @@ -0,0 +1,27 @@ +/* + * 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 new file mode 100644 index 0000000..e565092 --- /dev/null +++ b/src/vp/system.cpp @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2019 -2021 MINRES Technolgies GmbH + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "../vp/system.h" + +#include "minres/timer.h" +#include "minres/uart.h" +#include "scc/utilities.h" + +namespace tgc_vp { +using namespace sc_core; +using namespace vpvper::minres; +using namespace sysc::tgfs; + +system::system(sc_core::sc_module_name nm) +: sc_core::sc_module(nm) +, NAMED(ahb_router, 3, 2) +, 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.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) { + apbBridge.initiator.at(i)(e.target); + apbBridge.set_target_range(i, e.start, e.size); + i++; + } + + gpio0.clk_i(clk_i); + uart0.clk_i(clk_i); + timer0.clk_i(clk_i); + aclint.clk_i(clk_i); + irq_ctrl.clk_i(clk_i); + qspi.clk_i(clk_i); + core_complex.clk_i(clk_i); + //mem_ram.clk_i(clk_i); + + gpio0.rst_i(rst_s); + uart0.rst_i(rst_s); + timer0.rst_i(rst_s); + aclint.rst_i(rst_s); + irq_ctrl.rst_i(rst_s); + qspi.rst_i(rst_s); + core_complex.rst_i(rst_s); + + aclint.mtime_int_o(mtime_int_s); + aclint.msip_int_o(msip_int_s); + irq_ctrl.irq_o(core_int_s); + irq_ctrl.pending_irq_i(irq_int_s); + + uart0.irq_o(irq_int_s[0]); + timer0.interrupt_o[0](irq_int_s[1]); + timer0.interrupt_o[1](irq_int_s[2]); + qspi.irq_o(irq_int_s[3]); + + core_complex.timer_irq_i(mtime_int_s); + core_complex.ext_irq_i(core_int_s); + core_complex.local_irq_i(local_int_s); + core_complex.sw_irq_i(msip_int_s); + + gpio0.pins_i(pins_i); + gpio0.pins_o(pins_o); + gpio0.oe_o(pins_oe_o); + + uart0.tx_o(uart0_tx_o); + uart0.rx_i(uart0_rx_i); + + 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); + + SC_METHOD(gen_reset); + sensitive << erst_n; +} +void system::gen_reset(){ + if(erst_n.read()) + rst_s = 0; + else rst_s = 1; +} + + +} /* namespace sysc */ diff --git a/src/vp/system.h b/src/vp/system.h new file mode 100644 index 0000000..516f55f --- /dev/null +++ b/src/vp/system.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2019 -2021 MINRES Technolgies GmbH + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _PLATFORM_H_ +#define _PLATFORM_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 + +namespace tgc_vp { + +class system : public sc_core::sc_module { +public: + SC_HAS_PROCESS(system);// NOLINT + + 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_in clk_i{"clk_i"}; + + sc_core::sc_in erst_n{"erst_n"}; + + system(sc_core::sc_module_name nm); + +private: + sysc::tgfs::core_complex core_complex{"core_complex"}; + scc::router<> ahb_router, apbBridge; + vpvper::minres::gpio_tl gpio0{"gpio0"}; + vpvper::minres::uart_tl uart0{"uart0"}; + vpvper::minres::timer_tl timer0{"timer0"}; + vpvper::minres::aclint_tl aclint{"aclint"}; + vpvper::minres::irq_tl irq_ctrl{"irq_ctrl"}; + vpvper::minres::qspi_tl qspi{"qspi"}; + + //scc::memory<1_kB, scc::LT> bootloader{"bootloader"}; + scc::memory<32_kB, scc::LT> mem_ram {"mem_ram"}; + + 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 */ + +#endif /* _PLATFORM_H_ */ diff --git a/src/vp/tb.cpp b/src/vp/tb.cpp new file mode 100644 index 0000000..8620bfc --- /dev/null +++ b/src/vp/tb.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2019 -2021 MINRES Technolgies GmbH + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "../vp/tb.h" + +#include +namespace tgc_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); + top.pins_o(pins_o); + top.pins_i(pins_i); + top.pins_oe_o(pins_oe_o); + top.uart0_rx_i(uart0_rx_i); + 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); + clk_i = 10_ns; +} +} diff --git a/src/vp/tb.h b/src/vp/tb.h new file mode 100644 index 0000000..02143e0 --- /dev/null +++ b/src/vp/tb.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2019 -2021 MINRES Technolgies GmbH + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef SRC_VP_TB_H_ +#define SRC_VP_TB_H_ + +#include +#include + +#include "../vp/rst_gen.h" +#include "../vp/system.h" +namespace tgc_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"}; + 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}; + 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_signal clk_i{"clk_i"}; +}; + +} /* namespace tgc_vp */ + +#endif /* SRC_VP_TB_H_ */ diff --git a/vpvper b/vpvper new file mode 160000 index 0000000..899316d --- /dev/null +++ b/vpvper @@ -0,0 +1 @@ +Subproject commit 899316db7ec527a46c968199a9c0e0f64e48fc2b