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 index 7d8ff25..a7806bc 100644 --- a/.cproject +++ b/.cproject @@ -12,11 +12,11 @@ - + - + @@ -46,6 +46,15 @@ + + + + + + + + + @@ -58,11 +67,11 @@ - + - + @@ -92,6 +101,13 @@ + + + + + + + @@ -99,21 +115,14 @@ + + - - - - - - - - - @@ -142,4 +151,19 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..bdad7ec --- /dev/null +++ b/.envrc @@ -0,0 +1,9 @@ +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 +fi +module load ./Modulefile +layout python3 +[ -f .envrc.$USER ] && . .envrc.$USER diff --git a/.gitignore b/.gitignore index 1c4ca24..40e5fa7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,10 +4,18 @@ *.o *.a *.lib +/*.log /*.txlog /*.vcd +/*.ftr +/*.fst /.vs /out /coverage.info /output.txt /output.trc +CMakeSettings.json +/.venv +/src-gen/ +/*.json +/cfg.yaml diff --git a/.gitpod.yml b/.gitpod.yml index f62d43a..c41875c 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -18,3 +18,5 @@ vscode: extensions: - ms-python.python - webfreak.debug + - twxs.cmake + - ms-vscode.cmake-tools diff --git a/contrib/eclipse_launch/FW-Debug.launch b/.launch/FW-Debug.launch similarity index 100% rename from contrib/eclipse_launch/FW-Debug.launch rename to .launch/FW-Debug.launch 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..d7bcc0c --- /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/contrib/eclipse_launch/TGC-VP.launch b/.launch/TGC-VP tcc dhrystone.launch similarity index 88% rename from contrib/eclipse_launch/TGC-VP.launch rename to .launch/TGC-VP tcc dhrystone.launch index 56a52c7..e1ef794 100644 --- a/contrib/eclipse_launch/TGC-VP.launch +++ b/.launch/TGC-VP tcc dhrystone.launch @@ -12,17 +12,18 @@ - + - - - - + + + + - + + 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/contrib/eclipse_launch/TGC-VP-FW-Debug.launch b/.launch/TGC-VP-FW-Debug.launch similarity index 100% rename from contrib/eclipse_launch/TGC-VP-FW-Debug.launch rename to .launch/TGC-VP-FW-Debug.launch diff --git a/contrib/eclipse_launch/TGC-VP-GDBServer.launch b/.launch/TGC-VP-GDBServer.launch similarity index 100% rename from contrib/eclipse_launch/TGC-VP-GDBServer.launch rename to .launch/TGC-VP-GDBServer.launch diff --git a/CMakeLists.txt b/CMakeLists.txt index c8ddc8c..80bfd10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,17 +1,19 @@ cmake_minimum_required(VERSION 3.16) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/scc/cmake) - -include(ConanInline) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/scc/cmake) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/tgc-iss/dbt-rise-tgc/cmake/) project(ecosystem-vp LANGUAGES C CXX VERSION 1.0.0) option(ENABLE_SCV "Enable the use of SCV" ON) option(LIBS_ONLY "Just build the shared libraries needed to build the VP" OFF) -option(NO_FW_BUILD "Disable the automatic rebuild of firmware running on the VP" OFF) +option(FW_BUILD "Enable the automatic download and build of some firmware to run on the VP" OFF) option(EN_EXT_DEBUG "Enable extended debug output at runtime" 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(WITH_TCC "Build TCC backend" ON) +option(WITH_LLVM "Build LLVM backend" OFF) +option(WITH_ASMJIT "Build ASMJIT backend" ON) set(SCC_LIB_ONLY ON) set(CMAKE_CXX_STANDARD 14) @@ -31,7 +33,17 @@ 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() + +include(ConanInline) +if(BUILD_SHARED_LIBS) + set(SHARED_FLAG "True") +else() + set(SHARED_FLAG "False") +endif() + set(CONAN_BOOST_OPTIONS +boost:fPIC=True +boost:shared=${SHARED_FLAG} boost:header_only=False boost:without_contract=True boost:without_fiber=True @@ -53,40 +65,82 @@ boost:without_timer=True boost:without_type_erasure=True boost:without_wave=True ) -if (UNIX) - list(APPEND CONAN_BOOST_OPTIONS boost:fPIC=True boost:shared=True) -endif (UNIX) -set(CONAN_PACKAGE_LIST fmt/8.0.1 zlib/1.2.11 boost/1.75.0 gsl-lite/0.37.0 elfio/3.8) - -if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") - list(APPEND CONAN_BOOST_OPTIONS boost:fPIC=True lua:compile_as_cpp=False) - list(APPEND CONAN_PACKAGE_LIST tcc/0.9.27 seasocks/1.4.4 lua/5.4.3) -endif() +set(CONAN_PACKAGE_LIST + fmt/8.0.1 + spdlog/1.9.2 + boost/1.75.0 + gsl-lite/0.37.0 + elfio/3.8 + lz4/1.9.3 + yaml-cpp/0.7.0 + jsoncpp/1.9.5 + zlib/1.2.13 +) set(CONAN_PACKAGE_OPTIONS fmt:header_only=True ${CONAN_BOOST_OPTIONS}) -if(NOT USE_CWR_SYSTEMC AND NOT USE_NCSC_SYSTEMC AND NOT DEFINED ENV{SYSTEMC_HOME}) - set(CONAN_PACKAGE_LIST ${CONAN_PACKAGE_LIST} systemc/2.3.3 systemc-cci/1.0.0) - set(CONAN_PACKAGE_OPTIONS ${CONAN_PACKAGE_OPTIONS} systemc:shared=True systemc-cci:shared=True systemc:disable_virtual_bind=False) +if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND WITH_TCC) + list(APPEND CONAN_PACKAGE_LIST seasocks/1.4.4) + if(WITH_TCC) + list(APPEND CONAN_PACKAGE_LIST tcc/0.9.27) + endif() + list(APPEND CONAN_PACKAGE_OPTIONS lua:compile_as_cpp=False ) +endif() +if(WITH_LLVM) + list(APPEND CONAN_PACKAGE_LIST llvm-core/13.0.0) + list(APPEND CONAN_PACKAGE_OPTIONS libiconv:shared=False) +endif() +if(WITH_ASMJIT) + list(APPEND CONAN_PACKAGE_LIST asmjit/cci.20230325) + list(APPEND CONAN_PACKAGE_OPTIONS asmjit:shared=False) +endif() +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tgc-iss/dbt-rise-plugins) + list(APPEND CONAN_PACKAGE_OPTIONS lua:compile_as_cpp=False) + list(APPEND CONAN_PACKAGE_LIST lua/5.4.3) endif() -conan_check() -conan_add_remote(NAME minres URL https://artifactory.minres.com/artifactory/api/conan/oss) +if(NOT USE_CWR_SYSTEMC AND NOT USE_NCSC_SYSTEMC AND NOT DEFINED ENV{SYSTEMC_HOME}) + set(CONAN_PACKAGE_LIST ${CONAN_PACKAGE_LIST} + systemc/2.3.3 + systemc-cci/1.0.0 + ) + set(CONAN_PACKAGE_OPTIONS ${CONAN_PACKAGE_OPTIONS} + systemc:shared=${SHARED_FLAG} + systemc-cci:shared=${SHARED_FLAG} + systemc:disable_virtual_bind=False) +endif() + +conan_check() +conan_add_remote(NAME minres URL https://git.minres.com/api/packages/Tooling/conan) +# Boost on CentOS 7 quirks: the b2 of conan-center is build against a newer libstdc++ and therefore does not run +# with the oooooold libs on CentOS 7. Therefore we build our own version of b2 if it is not there +execute_process(COMMAND bash -c "conan search -r all b2 | tail -1" OUTPUT_VARIABLE B2_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) +set(B2_META $ENV{HOME}/.conan/data/${B2_VERSION}/_/_/metadata.json) +if(DEFINED ENV{CONAN_USER_HOME}) + set(B2_META $ENV{CONAN_USER_HOME}/.conan/data/${B2_VERSION}/_/_/metadata.json) +endif() +if(NOT EXISTS ${B2_META}) + conan_configure(REQUIRES ${B2_VERSION}) + conan_cmake_autodetect(settings) + conan_cmake_install(PATH_OR_REFERENCE . BUILD b2 SETTINGS ${settings}) +endif() +# Boost on CentOS 7 quirks end conan_cmake_configure(REQUIRES ${CONAN_PACKAGE_LIST} GENERATORS cmake_find_package OPTIONS ${CONAN_PACKAGE_OPTIONS} ) conan_cmake_autodetect(settings) conan_install() -# needed when using CentOS devenv-7 or -8 and boost does not build because of missing GLIBCXX version -#conan_install(BUILD b2 missing) -find_package(tcc) + +set(CONAN_CMAKE_SILENT_OUTPUT ON) +find_package(tcc QUIET) find_package(elfio) find_package(fmt) +find_package(spdlog) find_package(gsl-lite) +find_package(yaml-cpp) set(Boost_NO_BOOST_CMAKE ON) # Don't do a find_package in config mode before searching for a regular boost install. - - find_package(Boost REQUIRED COMPONENTS program_options QUIET) +include(SystemCPackage) set(CLANG_FORMAT_EXCLUDE_PATTERNS "scc") find_package(ClangFormat) @@ -117,17 +171,36 @@ endif () add_subdirectory(scc) add_subdirectory(tgc-iss/dbt-rise-core) add_subdirectory(tgc-iss/dbt-rise-tgc) +if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tgc-iss//dbt-rise-plugins) + add_subdirectory(tgc-iss/dbt-rise-plugins) +endif() if(NOT USE_CWR_SYSTEMC) add_subdirectory(vpvper) endif() if(NOT LIBS_ONLY) add_subdirectory(src) endif() -if(NOT NO_FW_BUILD) - add_custom_target(fw-hello-world ALL COMMAND make -C fw/hello-world - USES_TERMINAL WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + +if(FW_BUILD) + include(FetchContent) + set(FETCHCONTENT_BASE_DIR ${CMAKE_CURRENT_BINARY_DIR}/..) + FetchContent_Declare( + riscvfw + GIT_REPOSITORY https://git.minres.com/VP/Firmwares.git + GIT_TAG main + 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() +install(FILES ${CMAKE_CURRENT_LIST_DIR}/fw/hello-world/prebuilt/hello.elf DESTINATION share/tgc-vp) + # CTest is a testing tool that can be used to test your project. enable_testing() add_test(NAME tgc-vp-hello-world diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..00afe21 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,100 @@ +def getBranch() { + if (env.BRANCH_NAME != null && !env.BRANCH_NAME.isEmpty() ) { + return env.BRANCH_NAME + } else { + return 'develop' + } +} + +void checkout_tgc_vp() { + 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('Fedora28'){ + agent {docker { image 'fedora28' } } + stages { + stage('Checkout on Fedora') { 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()} + } + } + } + } + } + } +} \ No newline at end of file diff --git a/Modulefile b/Modulefile index 67fc848..b4395ea 100644 --- a/Modulefile +++ b/Modulefile @@ -12,5 +12,6 @@ if { $distro == "CentOS" && ![info exists ::env(PROJECT)] && ![info exists ::env puts stderr "Don't forget to execute 'scl enable devtoolset-7 llvm-toolset-7 bash'" } -module load tools/gcc-riscv32/9.2.0 +module load tools/gcc-riscv32-unknown-elf/11 module load tools/cmake +module load tools/utilities \ No newline at end of file diff --git a/contrib/TGC_C_cycles.json b/contrib/TGC_C_cycles.json deleted file mode 100644 index 61bc4ee..0000000 --- a/contrib/TGC_C_cycles.json +++ /dev/null @@ -1,724 +0,0 @@ -{ - "TGC_C" : [ - { - "name" : "LUI", - "size" : 32, - "encoding": "0b00000000000000000000000000110111", - "mask": "0b00000000000000000000000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "AUIPC", - "size" : 32, - "encoding": "0b00000000000000000000000000010111", - "mask": "0b00000000000000000000000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "JAL", - "size" : 32, - "encoding": "0b00000000000000000000000001101111", - "mask": "0b00000000000000000000000001111111", - "branch": true, - "delay" : 2 - }, - { - "name" : "JALR", - "size" : 32, - "encoding": "0b00000000000000000000000001100111", - "mask": "0b00000000000000000111000001111111", - "branch": true, - "delay" : 2 - }, - { - "name" : "BEQ", - "size" : 32, - "encoding": "0b00000000000000000000000001100011", - "mask": "0b00000000000000000111000001111111", - "branch": true, - "delay" : [2,1] - }, - { - "name" : "BNE", - "size" : 32, - "encoding": "0b00000000000000000001000001100011", - "mask": "0b00000000000000000111000001111111", - "branch": true, - "delay" : [2,1] - }, - { - "name" : "BLT", - "size" : 32, - "encoding": "0b00000000000000000100000001100011", - "mask": "0b00000000000000000111000001111111", - "branch": true, - "delay" : [2,1] - }, - { - "name" : "BGE", - "size" : 32, - "encoding": "0b00000000000000000101000001100011", - "mask": "0b00000000000000000111000001111111", - "branch": true, - "delay" : [2,1] - }, - { - "name" : "BLTU", - "size" : 32, - "encoding": "0b00000000000000000110000001100011", - "mask": "0b00000000000000000111000001111111", - "branch": true, - "delay" : [2,1] - }, - { - "name" : "BGEU", - "size" : 32, - "encoding": "0b00000000000000000111000001100011", - "mask": "0b00000000000000000111000001111111", - "branch": true, - "delay" : [2,1] - }, - { - "name" : "LB", - "size" : 32, - "encoding": "0b00000000000000000000000000000011", - "mask": "0b00000000000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "LH", - "size" : 32, - "encoding": "0b00000000000000000001000000000011", - "mask": "0b00000000000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "LW", - "size" : 32, - "encoding": "0b00000000000000000010000000000011", - "mask": "0b00000000000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "LBU", - "size" : 32, - "encoding": "0b00000000000000000100000000000011", - "mask": "0b00000000000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "LHU", - "size" : 32, - "encoding": "0b00000000000000000101000000000011", - "mask": "0b00000000000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "SB", - "size" : 32, - "encoding": "0b00000000000000000000000000100011", - "mask": "0b00000000000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "SH", - "size" : 32, - "encoding": "0b00000000000000000001000000100011", - "mask": "0b00000000000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "SW", - "size" : 32, - "encoding": "0b00000000000000000010000000100011", - "mask": "0b00000000000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "ADDI", - "size" : 32, - "encoding": "0b00000000000000000000000000010011", - "mask": "0b00000000000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "SLTI", - "size" : 32, - "encoding": "0b00000000000000000010000000010011", - "mask": "0b00000000000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "SLTIU", - "size" : 32, - "encoding": "0b00000000000000000011000000010011", - "mask": "0b00000000000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "XORI", - "size" : 32, - "encoding": "0b00000000000000000100000000010011", - "mask": "0b00000000000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "ORI", - "size" : 32, - "encoding": "0b00000000000000000110000000010011", - "mask": "0b00000000000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "ANDI", - "size" : 32, - "encoding": "0b00000000000000000111000000010011", - "mask": "0b00000000000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "SLLI", - "size" : 32, - "encoding": "0b00000000000000000001000000010011", - "mask": "0b11111110000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "SRLI", - "size" : 32, - "encoding": "0b00000000000000000101000000010011", - "mask": "0b11111110000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "SRAI", - "size" : 32, - "encoding": "0b01000000000000000101000000010011", - "mask": "0b11111110000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "ADD", - "size" : 32, - "encoding": "0b00000000000000000000000000110011", - "mask": "0b11111110000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "SUB", - "size" : 32, - "encoding": "0b01000000000000000000000000110011", - "mask": "0b11111110000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "SLL", - "size" : 32, - "encoding": "0b00000000000000000001000000110011", - "mask": "0b11111110000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "SLT", - "size" : 32, - "encoding": "0b00000000000000000010000000110011", - "mask": "0b11111110000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "SLTU", - "size" : 32, - "encoding": "0b00000000000000000011000000110011", - "mask": "0b11111110000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "XOR", - "size" : 32, - "encoding": "0b00000000000000000100000000110011", - "mask": "0b11111110000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "SRL", - "size" : 32, - "encoding": "0b00000000000000000101000000110011", - "mask": "0b11111110000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "SRA", - "size" : 32, - "encoding": "0b01000000000000000101000000110011", - "mask": "0b11111110000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "OR", - "size" : 32, - "encoding": "0b00000000000000000110000000110011", - "mask": "0b11111110000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "AND", - "size" : 32, - "encoding": "0b00000000000000000111000000110011", - "mask": "0b11111110000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "FENCE", - "size" : 32, - "encoding": "0b00000000000000000000000000001111", - "mask": "0b00000000000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "ECALL", - "size" : 32, - "encoding": "0b00000000000000000000000001110011", - "mask": "0b11111111111111111111111111111111", - "branch": true, - "delay" : 2 - }, - { - "name" : "EBREAK", - "size" : 32, - "encoding": "0b00000000000100000000000001110011", - "mask": "0b11111111111111111111111111111111", - "branch": true, - "delay" : 2 - }, - { - "name" : "URET", - "size" : 32, - "encoding": "0b00000000001000000000000001110011", - "mask": "0b11111111111111111111111111111111", - "branch": true, - "delay" : 2 - }, - { - "name" : "SRET", - "size" : 32, - "encoding": "0b00010000001000000000000001110011", - "mask": "0b11111111111111111111111111111111", - "branch": true, - "delay" : 2 - }, - { - "name" : "MRET", - "size" : 32, - "encoding": "0b00110000001000000000000001110011", - "mask": "0b11111111111111111111111111111111", - "branch": true, - "delay" : 2 - }, - { - "name" : "WFI", - "size" : 32, - "encoding": "0b00010000010100000000000001110011", - "mask": "0b11111111111111111111111111111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "DRET", - "size" : 32, - "encoding": "0b01111011001000000000000001110011", - "mask": "0b11111111111111111111111111111111", - "branch": true, - "delay" : 2 - }, - { - "name" : "CSRRW", - "size" : 32, - "encoding": "0b00000000000000000001000001110011", - "mask": "0b00000000000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "CSRRS", - "size" : 32, - "encoding": "0b00000000000000000010000001110011", - "mask": "0b00000000000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "CSRRC", - "size" : 32, - "encoding": "0b00000000000000000011000001110011", - "mask": "0b00000000000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "CSRRWI", - "size" : 32, - "encoding": "0b00000000000000000101000001110011", - "mask": "0b00000000000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "CSRRSI", - "size" : 32, - "encoding": "0b00000000000000000110000001110011", - "mask": "0b00000000000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "CSRRCI", - "size" : 32, - "encoding": "0b00000000000000000111000001110011", - "mask": "0b00000000000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "FENCE_I", - "size" : 32, - "encoding": "0b00000000000000000001000000001111", - "mask": "0b00000000000000000111000001111111", - "branch": false, - "delay" : 2 - }, - { - "name" : "MUL", - "size" : 32, - "encoding": "0b00000010000000000000000000110011", - "mask": "0b11111110000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "MULH", - "size" : 32, - "encoding": "0b00000010000000000001000000110011", - "mask": "0b11111110000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "MULHSU", - "size" : 32, - "encoding": "0b00000010000000000010000000110011", - "mask": "0b11111110000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "MULHU", - "size" : 32, - "encoding": "0b00000010000000000011000000110011", - "mask": "0b11111110000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "DIV", - "size" : 32, - "encoding": "0b00000010000000000100000000110011", - "mask": "0b11111110000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "DIVU", - "size" : 32, - "encoding": "0b00000010000000000101000000110011", - "mask": "0b11111110000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "REM", - "size" : 32, - "encoding": "0b00000010000000000110000000110011", - "mask": "0b11111110000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "REMU", - "size" : 32, - "encoding": "0b00000010000000000111000000110011", - "mask": "0b11111110000000000111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "CADDI4SPN", - "size" : 16, - "encoding": "0b0000000000000000", - "mask": "0b1110000000000011", - "branch": false, - "delay" : 1 - }, - { - "name" : "CLW", - "size" : 16, - "encoding": "0b0100000000000000", - "mask": "0b1110000000000011", - "branch": false, - "delay" : 1 - }, - { - "name" : "CSW", - "size" : 16, - "encoding": "0b1100000000000000", - "mask": "0b1110000000000011", - "branch": false, - "delay" : 1 - }, - { - "name" : "CADDI", - "size" : 16, - "encoding": "0b0000000000000001", - "mask": "0b1110000000000011", - "branch": false, - "delay" : 1 - }, - { - "name" : "CNOP", - "size" : 16, - "encoding": "0b0000000000000001", - "mask": "0b1110111110000011", - "branch": false, - "delay" : 1 - }, - { - "name" : "CJAL", - "size" : 16, - "encoding": "0b0010000000000001", - "mask": "0b1110000000000011", - "branch": true, - "delay" : 2 - }, - { - "name" : "CLI", - "size" : 16, - "encoding": "0b0100000000000001", - "mask": "0b1110000000000011", - "branch": false, - "delay" : 1 - }, - { - "name" : "CLUI", - "size" : 16, - "encoding": "0b0110000000000001", - "mask": "0b1110000000000011", - "branch": false, - "delay" : 1 - }, - { - "name" : "CADDI16SP", - "size" : 16, - "encoding": "0b0110000100000001", - "mask": "0b1110111110000011", - "branch": false, - "delay" : 1 - }, - { - "name" : "__reserved_clui", - "size" : 16, - "encoding": "0b0110000000000001", - "mask": "0b1111000001111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "CSRLI", - "size" : 16, - "encoding": "0b1000000000000001", - "mask": "0b1111110000000011", - "branch": false, - "delay" : 1 - }, - { - "name" : "CSRAI", - "size" : 16, - "encoding": "0b1000010000000001", - "mask": "0b1111110000000011", - "branch": false, - "delay" : 1 - }, - { - "name" : "CANDI", - "size" : 16, - "encoding": "0b1000100000000001", - "mask": "0b1110110000000011", - "branch": false, - "delay" : 1 - }, - { - "name" : "CSUB", - "size" : 16, - "encoding": "0b1000110000000001", - "mask": "0b1111110001100011", - "branch": false, - "delay" : 1 - }, - { - "name" : "CXOR", - "size" : 16, - "encoding": "0b1000110000100001", - "mask": "0b1111110001100011", - "branch": false, - "delay" : 1 - }, - { - "name" : "COR", - "size" : 16, - "encoding": "0b1000110001000001", - "mask": "0b1111110001100011", - "branch": false, - "delay" : 1 - }, - { - "name" : "CAND", - "size" : 16, - "encoding": "0b1000110001100001", - "mask": "0b1111110001100011", - "branch": false, - "delay" : 1 - }, - { - "name" : "CJ", - "size" : 16, - "encoding": "0b1010000000000001", - "mask": "0b1110000000000011", - "branch": true, - "delay" : 2 - }, - { - "name" : "CBEQZ", - "size" : 16, - "encoding": "0b1100000000000001", - "mask": "0b1110000000000011", - "branch": true, - "delay" : [2,1] - }, - { - "name" : "CBNEZ", - "size" : 16, - "encoding": "0b1110000000000001", - "mask": "0b1110000000000011", - "branch": true, - "delay" : [2,1] - }, - { - "name" : "CSLLI", - "size" : 16, - "encoding": "0b0000000000000010", - "mask": "0b1111000000000011", - "branch": false, - "delay" : 1 - }, - { - "name" : "CLWSP", - "size" : 16, - "encoding": "0b0100000000000010", - "mask": "0b1110000000000011", - "branch": false, - "delay" : 1 - }, - { - "name" : "CMV", - "size" : 16, - "encoding": "0b1000000000000010", - "mask": "0b1111000000000011", - "branch": false, - "delay" : 1 - }, - { - "name" : "CJR", - "size" : 16, - "encoding": "0b1000000000000010", - "mask": "0b1111000001111111", - "branch": true, - "delay" : 2 - }, - { - "name" : "__reserved_cmv", - "size" : 16, - "encoding": "0b1000000000000010", - "mask": "0b1111111111111111", - "branch": false, - "delay" : 1 - }, - { - "name" : "CADD", - "size" : 16, - "encoding": "0b1001000000000010", - "mask": "0b1111000000000011", - "branch": false, - "delay" : 1 - }, - { - "name" : "CJALR", - "size" : 16, - "encoding": "0b1001000000000010", - "mask": "0b1111000001111111", - "branch": true, - "delay" : 2 - }, - { - "name" : "CEBREAK", - "size" : 16, - "encoding": "0b1001000000000010", - "mask": "0b1111111111111111", - "branch": true, - "delay" : 2 - }, - { - "name" : "CSWSP", - "size" : 16, - "encoding": "0b1100000000000010", - "mask": "0b1110000000000011", - "branch": false, - "delay" : 1 - }, - { - "name" : "DII", - "size" : 16, - "encoding": "0b0000000000000000", - "mask": "0b1111111111111111", - "branch": false, - "delay" : 1 - } - ] -} \ No newline at end of file diff --git a/fw/hello-world/Makefile b/fw/hello-world/Makefile index c8ea51e..6e7d998 100644 --- a/fw/hello-world/Makefile +++ b/fw/hello-world/Makefile @@ -13,6 +13,5 @@ LDFLAGS := -march=$(RISCV_ARCH) -mabi=$(RISCV_ABI) compiler := $(shell which riscv32-unknown-elf-gcc) TOOL_DIR=$(dir $(compiler)) -TRIPLET=riscv32-unknown-elf BSP_BASE = ../bsp include $(BSP_BASE)/env/common-gcc.mk diff --git a/scc b/scc index 93a5676..7cf3d94 160000 --- a/scc +++ b/scc @@ -1 +1 @@ -Subproject commit 93a5676fec9c1cb851b6a9cd4c462142de6dc144 +Subproject commit 7cf3d94c133b000e9dd5d29b5b7da670a15f0859 diff --git a/src/CLIParser.cpp b/src/CLIParser.cpp index 788db58..e80ed7d 100644 --- a/src/CLIParser.cpp +++ b/src/CLIParser.cpp @@ -10,12 +10,16 @@ #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) { @@ -24,13 +28,16 @@ CLIParser::CLIParser(int argc, char *argv[]) po::store(po::parse_command_line(argc, argv, desc), vm_); // can throw // --help option if (vm_.count("help")) { - std::cout << "DBT-RISE-RiscV simulator for RISC-V" << std::endl << desc << std::endl; + 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); @@ -74,14 +81,20 @@ void CLIParser::build() { "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 text, 4=TX compressed text, 6=TX in SQLite") + "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"), diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f848d17..778f9bc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,13 +4,15 @@ # SPDX-License-Identifier: Apache-2.0 # cmake_minimum_required(VERSION 3.12) - project(tgc-vp LANGUAGES C CXX VERSION 0.0.1) +include(flink) + find_package(Boost COMPONENTS program_options thread REQUIRED) ############################################################################### -# SiFive +# TGC ############################################################################### +set(CMAKE_INSTALL_RPATH $ORIGIN/../${CMAKE_INSTALL_LIBDIR}) add_executable(${PROJECT_NAME} sc_main.cpp CLIParser.cpp @@ -18,9 +20,19 @@ add_executable(${PROJECT_NAME} tgc_vp/system.cpp ) target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}) -target_link_libraries(${PROJECT_NAME} PUBLIC dbt-rise-tgc_sc vpvper_generic vpvper_sifive ${BOOST_program_options_LIBRARY}) +target_force_link_libraries(${PROJECT_NAME} PUBLIC dbt-rise-tgc_sc) +target_link_libraries(${PROJECT_NAME} PUBLIC vpvper_generic vpvper_sifive ${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() \ No newline at end of file +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 index 967af21..a6e97cb 100644 --- a/src/sc_main.cpp +++ b/src/sc_main.cpp @@ -9,15 +9,24 @@ #include #include +#include #include #include #include #include +#ifdef WITH_LLVM +#include +#endif #include #include +#include #include #include +#ifdef ERROR +#undef ERROR +#endif + const std::string core_path{"tb.top.core_complex"}; using namespace sysc; @@ -41,6 +50,12 @@ int sc_main(int argc, char *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 /////////////////////////////////////////////////////////////////////////// @@ -52,11 +67,17 @@ int sc_main(int argc, char *argv[]) { /////////////////////////////////////////////////////////////////////////// // set up tracing & transaction recording /////////////////////////////////////////////////////////////////////////// - auto trace_level = parser.get("trace-level"); - scc::configurable_tracer trace(parser.get("trace-file"), - static_cast(trace_level >> 1), // bit3-bit1 define the kind of transaction trace - (trace_level&0x1) != 0, // bit0 enables vcd - parser.is_set("trace-default-on")); + + 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 /////////////////////////////////////////////////////////////////////////// @@ -64,20 +85,25 @@ int sc_main(int argc, char *argv[]) { /////////////////////////////////////////////////////////////////////////// // add non-implemented 'enableTracing' properties /////////////////////////////////////////////////////////////////////////// - trace.add_control(); + 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); + 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); diff --git a/src/tgc_vp/gen/platform_mmap.h b/src/tgc_vp/gen/platform_mmap.h index a821ba4..9f8b352 100644 --- a/src/tgc_vp/gen/platform_mmap.h +++ b/src/tgc_vp/gen/platform_mmap.h @@ -7,7 +7,7 @@ #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 = {{ +const std::array, 13> platfrom_mmap = {{ {clint.socket, 0x2000000, 0xc000}, {plic.socket, 0xc000000, 0x200008}, {aon.socket, 0x10000000, 0x150}, diff --git a/src/tgc_vp/system.cpp b/src/tgc_vp/system.cpp index 4525174..94a59a4 100644 --- a/src/tgc_vp/system.cpp +++ b/src/tgc_vp/system.cpp @@ -13,7 +13,7 @@ using namespace sysc::tgfs; system::system(sc_core::sc_module_name nm) : sc_core::sc_module(nm) -, NAMED(router, platfrom_mmap.size() + 2, 1) +, NAMED(router, platfrom_mmap.size() + 2, 2) , NAMEDC(qspi0_ptr, spi, spi_impl::beh) , NAMEDC(qspi1_ptr, spi, spi_impl::beh) , NAMEDC(qspi2_ptr, spi, spi_impl::beh) @@ -24,7 +24,8 @@ system::system(sc_core::sc_module_name nm) auto& qspi0 = *qspi0_ptr; auto& qspi1 = *qspi1_ptr; auto& qspi2 = *qspi2_ptr; - core_complex.initiator(router.target[0]); + core_complex.ibus(router.target[0]); + core_complex.dbus(router.target[1]); size_t i = 0; for (const auto &e : platfrom_mmap) { router.initiator.at(i)(e.target); @@ -51,6 +52,8 @@ system::system(sc_core::sc_module_name nm) clint.tlclk_i(tlclk_s); clint.lfclk_i(lfclk_s); core_complex.clk_i(tlclk_s); + mem_qspi.clk_i(tlclk_s); + mem_ram.clk_i(tlclk_s); uart0.rst_i(rst_s); uart1.rst_i(rst_s); @@ -77,7 +80,7 @@ system::system(sc_core::sc_module_name nm) core_complex.sw_irq_i(msie_int_s); core_complex.timer_irq_i(mtime_int_s); - core_complex.global_irq_i(core_int_s); + core_complex.ext_irq_i(core_int_s); core_complex.local_irq_i(local_int_s); pins_i(gpio0.pins_i); @@ -96,8 +99,8 @@ system::system(sc_core::sc_module_name nm) qspi1.irq_o(global_int_s[6]); qspi2.irq_o(global_int_s[7]); - s_dummy_sck_i[0](uart1.tx_o); - uart1.rx_i(s_dummy_sck_o[0]); + gpio0.iof0_i[16](uart1.tx_o); + uart1.rx_i(gpio0.iof0_o[17]); uart1.irq_o(global_int_s[4]); gpio0.iof1_i[0](pwm0.cmpgpio_o[0]); @@ -129,8 +132,6 @@ system::system(sc_core::sc_module_name nm) pwm2.cmpip_o[1](global_int_s[49]); pwm2.cmpip_o[2](global_int_s[50]); pwm2.cmpip_o[3](global_int_s[51]); - - for (auto &sock : s_dummy_sck_i) sock.error_if_no_callback = false; } } /* namespace sysc */ diff --git a/src/tgc_vp/system.h b/src/tgc_vp/system.h index ae19a4c..ff41cbd 100644 --- a/src/tgc_vp/system.h +++ b/src/tgc_vp/system.h @@ -52,9 +52,9 @@ private: vpvper::sifive::prci prci{"prci"}; vpvper::sifive::clint clint{"clint"}; - using mem_qspi_t = scc::memory<512_MB, 32>; + using mem_qspi_t = scc::memory<512_MB, scc::LT>; mem_qspi_t mem_qspi{"mem_qspi"}; - using mem_ram_t = scc::memory<128_kB, 32>; + using mem_ram_t = scc::memory<128_kB, scc::LT>; mem_ram_t mem_ram{"mem_ram"}; sc_core::sc_signal tlclk_s{"tlclk_s"}; @@ -65,9 +65,6 @@ private: sc_core::sc_vector> global_int_s{"global_int_s", 256}, local_int_s{"local_int_s", 16}; sc_core::sc_signal core_int_s{"core_int_s"}; - sc_core::sc_vector s_dummy_sck_i{"s_dummy_sck_i", 16}; - sc_core::sc_vector s_dummy_sck_o{"s_dummy_sck_o", 16}; - protected: void gen_reset(); vpvper::sifive::spi& qspi0; diff --git a/src/tgc_vp/tb.cpp b/src/tgc_vp/tb.cpp index da2d0a6..dbacd2d 100644 --- a/src/tgc_vp/tb.cpp +++ b/src/tgc_vp/tb.cpp @@ -15,8 +15,10 @@ tb::tb(const sc_core::sc_module_name &nm): sc_core::sc_module(nm) { gpio_s[i].in(top.pins_o[i]); top.pins_i[i](gpio_s[i].out); } +#ifndef WIN32 // terminal terminal.tx_o(gpio_s[16].in); gpio_s[17].out(terminal.rx_i); +#endif } } diff --git a/src/tgc_vp/tb.h b/src/tgc_vp/tb.h index 764e8c9..062905f 100644 --- a/src/tgc_vp/tb.h +++ b/src/tgc_vp/tb.h @@ -21,7 +21,9 @@ public: tgc_vp::rst_gen rst_gen{"rst_gen"}; sc_core::sc_vector> gpio_s{"gpio_s", 32}; sc_core::sc_signal rst_n{"rst_n"}; +#ifndef WIN32 // Seasocks not available under windows vpvper::generic::terminal terminal{"terminal"}; +#endif }; } /* namespace tgc_vp */ diff --git a/tgc-iss/.gitignore b/tgc-iss/.gitignore new file mode 100644 index 0000000..098c3ef --- /dev/null +++ b/tgc-iss/.gitignore @@ -0,0 +1 @@ +/dbt-rise-plugins diff --git a/tgc-iss/dbt-rise-core b/tgc-iss/dbt-rise-core index 44acf8a..3743f38 160000 --- a/tgc-iss/dbt-rise-core +++ b/tgc-iss/dbt-rise-core @@ -1 +1 @@ -Subproject commit 44acf8a55936d5eedb5daf8cae0799ec1616413f +Subproject commit 3743f38999fc6ddd87e8553dc1cf3a5fa3a7e0cd diff --git a/tgc-iss/dbt-rise-tgc b/tgc-iss/dbt-rise-tgc index c054d75..926a03c 160000 --- a/tgc-iss/dbt-rise-tgc +++ b/tgc-iss/dbt-rise-tgc @@ -1 +1 @@ -Subproject commit c054d75717dcefbc2048ab277fdfe1cb428640ef +Subproject commit 926a03c346ba5128be510f5d3067e76c6daaffd9 diff --git a/tgc-iss/generate.sh b/tgc-iss/generate.sh deleted file mode 100644 index d735c0c..0000000 --- a/tgc-iss/generate.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -## - - -JAVA_OPTS="--add-modules ALL-SYSTEM --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.annotation=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.lang.module=ALL-UNNAMED --add-opens=java.base/java.lang.ref=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.math=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.net.spi=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.nio.channels=ALL-UNNAMED --add-opens=java.base/java.nio.channels.spi=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.nio.charset.spi=ALL-UNNAMED --add-opens=java.base/java.nio.file=ALL-UNNAMED --add-opens=java.base/java.nio.file.attribute=ALL-UNNAMED --add-opens=java.base/java.nio.file.spi=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED --add-opens=java.base/java.security.acl=ALL-UNNAMED --add-opens=java.base/java.security.cert=ALL-UNNAMED --add-opens=java.base/java.security.interfaces=ALL-UNNAMED --add-opens=java.base/java.security.spec=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.base/java.text.spi=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED --add-opens=java.base/java.time.chrono=ALL-UNNAMED --add-opens=java.base/java.time.format=ALL-UNNAMED --add-opens=java.base/java.time.temporal=ALL-UNNAMED --add-opens=java.base/java.time.zone=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.locks=ALL-UNNAMED --add-opens=java.base/java.util.function=ALL-UNNAMED --add-opens=java.base/java.util.jar=ALL-UNNAMED --add-opens=java.base/java.util.regex=ALL-UNNAMED --add-opens=java.base/java.util.spi=ALL-UNNAMED --add-opens=java.base/java.util.stream=ALL-UNNAMED --add-opens=java.base/java.util.zip=ALL-UNNAMED --add-opens=java.datatransfer/java.awt.datatransfer=ALL-UNNAMED --add-opens=java.desktop/java.applet=ALL-UNNAMED --add-opens=java.desktop/java.awt=ALL-UNNAMED --add-opens=java.desktop/java.awt.color=ALL-UNNAMED --add-opens=java.desktop/java.awt.desktop=ALL-UNNAMED --add-opens=java.desktop/java.awt.dnd=ALL-UNNAMED --add-opens=java.desktop/java.awt.dnd.peer=ALL-UNNAMED --add-opens=java.desktop/java.awt.event=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED --add-opens=java.desktop/java.awt.geom=ALL-UNNAMED --add-opens=java.desktop/java.awt.im=ALL-UNNAMED --add-opens=java.desktop/java.awt.im.spi=ALL-UNNAMED --add-opens=java.desktop/java.awt.image=ALL-UNNAMED --add-opens=java.desktop/java.awt.image.renderable=ALL-UNNAMED --add-opens=java.desktop/java.awt.peer=ALL-UNNAMED --add-opens=java.desktop/java.awt.print=ALL-UNNAMED --add-opens=java.desktop/java.beans=ALL-UNNAMED --add-opens=java.desktop/java.beans.beancontext=ALL-UNNAMED --add-opens=java.instrument/java.lang.instrument=ALL-UNNAMED --add-opens=java.logging/java.util.logging=ALL-UNNAMED --add-opens=java.management/java.lang.management=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.rmi/java.rmi=ALL-UNNAMED --add-opens=java.rmi/java.rmi.activation=ALL-UNNAMED --add-opens=java.rmi/java.rmi.dgc=ALL-UNNAMED --add-opens=java.rmi/java.rmi.registry=ALL-UNNAMED --add-opens=java.rmi/java.rmi.server=ALL-UNNAMED --add-opens=java.sql/java.sql=ALL-UNNAMED" - -GENERATOR="java $JAVA_OPTS -jar /scratch/eyck/workarea/RISC-V/TGFS-VERIF/tgfs_iss/coredsl/com.minres.coredsl.generator.repository/target/com.minres.coredsl.generator-2.0.0-SNAPSHOT.jar " - -CORE_NAME=$1 -BACKEND=$2 -CORE_NAME_LC=`echo $CORE_NAME | tr '[:upper:]' '[:lower:]' ` -INPUT_FILE=dbt-rise-tgc/gen_input/TGFS.core_desc - -REPO_DIR=dbt-rise-tgc/gen_input/CoreDSL-Instruction-Set-Description -TMPL_DIR=dbt-rise-tgc/gen_input/templates - -MAPPING="" -MAPPING="$MAPPING -m ${TMPL_DIR}/CORENAME.h.gtl:dbt-rise-tgc/incl/iss/arch/${CORE_NAME_LC}.h" -MAPPING="$MAPPING -m ${TMPL_DIR}/CORENAME.cpp.gtl:dbt-rise-tgc/src/iss/${CORE_NAME_LC}.cpp" -MAPPING="$MAPPING -m ${TMPL_DIR}/${BACKEND}/CORENAME.cpp.gtl:dbt-rise-tgc/src/vm/${BACKEND}/vm_${CORE_NAME_LC}.cpp" - -[ -f /scratch/eyck/workarea/RISC-V/TGFS-VERIF/tgfs_iss/coredsl/com.minres.coredsl.generator.repository/target/com.minres.coredsl.generator-2.0.0-SNAPSHOT.jar ] || (cd /scratch/eyck/workarea/RISC-V/TGFS-VERIF/tgfs_iss/coredsl; mvn package) - -$GENERATOR -c $CORE_NAME -r $REPO_DIR $MAPPING $INPUT_FILE - diff --git a/vpvper b/vpvper index 11e6dc5..2df18a1 160000 --- a/vpvper +++ b/vpvper @@ -1 +1 @@ -Subproject commit 11e6dc5926a4ee250dc1eb206c97445472049d80 +Subproject commit 2df18a17549559131f52f9bcc90d3cef44aa4f5d