Compare commits
	
		
			62 Commits
		
	
	
		
			1629b165b5
			...
			develop
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 2e7ef7285e | |||
| dbb68b5fb1 | |||
| df513d4465 | |||
| 00ecea2bd6 | |||
| c068d6dbd3 | |||
| 578857997e | |||
| 56081dcb6f | |||
| b68c2226d9 | |||
| 925e312608 | |||
| 74275ddab4 | |||
| 0dafde8a4c | |||
| a5cf27744a | |||
| f46a211a8d | |||
| 57fff5c09b | |||
| e39264632f | |||
| 630f9993d6 | |||
| 9249f34038 | |||
| b14442d722 | |||
| 58e2dcfaf8 | |||
| a7559066f4 | |||
| 10eb3c88fc | |||
| 90720804ba | |||
| 4975a8273c | |||
| ed4ab31837 | |||
| 21391f1f01 | |||
| 21f97e9bc3 | |||
| d715d50dfb | |||
| a2cd38fbd5 | |||
| c7cd0843b8 | |||
| 83b2105c38 | |||
| 510695bf6e | |||
| 7258684a33 | |||
| 15cc2ece6f | |||
| 3e0eaba231 | |||
| 4bd2111c93 | |||
| f99db9409f | |||
| 87539a8433 | |||
| de4cf8f35a | |||
| 7d4bcea3ba | |||
| 74c2ec2014 | |||
| bccfc67926 | |||
| 8b3dc54e5c | |||
| 9909769c0a | |||
| 071d9cc8eb | |||
| a5825bfd67 | |||
| 36404dd7e0 | |||
| 658ffbb405 | |||
| c6bfaf0546 | |||
| e88c1148fb | |||
| 686d01ab3e | |||
| 339d6b0f2c | |||
| 884d445cb9 | |||
| eee14af478 | |||
| 727fdcb7bb | |||
| 36cb401420 | |||
| 3def42153f | |||
| 75ba2e7588 | |||
| f3dc9aea54 | |||
| 2f675e9bdd | |||
| 3114cb265a | |||
| fca9f04264 | |||
| fe1136c7ce | 
							
								
								
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -151,6 +151,4 @@ compile_commands.json
 | 
				
			|||||||
CTestTestfile.cmake
 | 
					CTestTestfile.cmake
 | 
				
			||||||
*.dump
 | 
					*.dump
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.vscode/c_cpp_properties.json
 | 
					build
 | 
				
			||||||
semihosting_test/build/semihosting_test
 | 
					 | 
				
			||||||
semihosting_test/build/Makefile
 | 
					 | 
				
			||||||
							
								
								
									
										189
									
								
								CMakeLists.txt
									
									
									
									
									
								
							
							
						
						
									
										189
									
								
								CMakeLists.txt
									
									
									
									
									
								
							@@ -1,172 +1,23 @@
 | 
				
			|||||||
cmake_minimum_required(VERSION 3.12)
 | 
					if (NOT DEFINED BOARD)
 | 
				
			||||||
 | 
						set(BOARD iss)
 | 
				
			||||||
# Set default RISC-V toolchain if not specified
 | 
					 | 
				
			||||||
if(NOT DEFINED RISCV_TOOLCHAIN_PATH)
 | 
					 | 
				
			||||||
    set(RISCV_TOOLCHAIN_PATH "/opt/shared/cross-toolchains/gcc13/CentOS/riscv64-unknown-elf/bin" CACHE STRING "Path to RISC-V toolchain")
 | 
					 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					if (NOT DEFINED ISA)
 | 
				
			||||||
# Allow override of compiler executables
 | 
						set(ISA imc)
 | 
				
			||||||
if(NOT DEFINED RISCV_GCC)
 | 
					 | 
				
			||||||
    set(RISCV_GCC "/opt/shared/cross-toolchains/gcc13/CentOS/riscv64-unknown-elf/bin/riscv64-unknown-elf-gcc" CACHE STRING "RISC-V GCC compiler")
 | 
					 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					if(DEFINED LINK_TARGET)
 | 
				
			||||||
if(NOT DEFINED RISCV_GXX)
 | 
					    set(LNK LINK_TARGET=${LINK_TARGET})
 | 
				
			||||||
    set(RISCV_GXX "${RISCV_TOOLCHAIN_PATH}/riscv64-unknown-elf-g++" CACHE STRING "RISC-V G++ compiler")
 | 
					 | 
				
			||||||
endif()
 | 
					endif()
 | 
				
			||||||
 | 
					message(STATUS "Building firmware using ${BOARD} board configuration and isa ${ISA}")
 | 
				
			||||||
if(NOT DEFINED RISCV_OBJCOPY)
 | 
					add_custom_target(fw-common ALL 
 | 
				
			||||||
    set(RISCV_OBJCOPY "${RISCV_TOOLCHAIN_PATH}/riscv64-unknown-elf-objcopy" CACHE STRING "RISC-V objcopy")
 | 
						COMMAND make -C ${CMAKE_CURRENT_SOURCE_DIR}/hello-world BOARD=${BOARD} ISA=${ISA} ${LNK}
 | 
				
			||||||
endif()
 | 
						COMMAND make -C ${CMAKE_CURRENT_SOURCE_DIR}/benchmarks/dhrystone BOARD=${BOARD} ISA=${ISA} ${LNK}
 | 
				
			||||||
 | 
						COMMAND make -C ${CMAKE_CURRENT_SOURCE_DIR}/benchmarks/coremark BOARD=${BOARD} ISA=${ISA} ${LNK}
 | 
				
			||||||
if(NOT DEFINED RISCV_OBJDUMP)
 | 
					    USES_TERMINAL
 | 
				
			||||||
    set(RISCV_OBJDUMP "${RISCV_TOOLCHAIN_PATH}/riscv64-unknown-elf-objdump" CACHE STRING "RISC-V objdump")
 | 
					    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
 | 
				
			||||||
endif()
 | 
					add_custom_target(fw-common-clean 
 | 
				
			||||||
 | 
						COMMAND make -C ${CMAKE_CURRENT_SOURCE_DIR}/hello-world BOARD=${BOARD} ISA=${ISA} ${LNK} clean
 | 
				
			||||||
# Set the compilers
 | 
						COMMAND make -C ${CMAKE_CURRENT_SOURCE_DIR}/benchmarks/dhrystone BOARD=${BOARD} ISA=${ISA} ${LNK} clean
 | 
				
			||||||
set(CMAKE_C_COMPILER ${RISCV_GCC})
 | 
						COMMAND make -C ${CMAKE_CURRENT_SOURCE_DIR}/benchmarks/coremark BOARD=${BOARD} ISA=${ISA} ${LNK} clean
 | 
				
			||||||
set(CMAKE_CXX_COMPILER ${RISCV_GXX})
 | 
					    USES_TERMINAL
 | 
				
			||||||
 | 
					    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
 | 
				
			||||||
project(Firmware)
 | 
					    
 | 
				
			||||||
 | 
					 | 
				
			||||||
# Define supported configurations
 | 
					 | 
				
			||||||
set(SUPPORTED_BOARDS iss)
 | 
					 | 
				
			||||||
set(SUPPORTED_ISAS "rv32i;rv32im;rv32imc;rv64i;rv64im;rv64imc;imc")
 | 
					 | 
				
			||||||
set(SUPPORTED_ABIS "ilp32;ilp32f;lp64;lp64f")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Build target options
 | 
					 | 
				
			||||||
option(BUILD_HELLO_WORLD "Build hello-world example" ON)
 | 
					 | 
				
			||||||
option(BUILD_DHRYSTONE "Build dhrystone benchmark" OFF)
 | 
					 | 
				
			||||||
option(BUILD_COREMARK "Build coremark benchmark" OFF)
 | 
					 | 
				
			||||||
option(BUILD_ALL "Build all targets" OFF)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# If BUILD_ALL is ON, enable all targets
 | 
					 | 
				
			||||||
if(BUILD_ALL)
 | 
					 | 
				
			||||||
    set(BUILD_HELLO_WORLD ON)
 | 
					 | 
				
			||||||
    set(BUILD_DHRYSTONE ON)
 | 
					 | 
				
			||||||
    set(BUILD_COREMARK ON)
 | 
					 | 
				
			||||||
endif()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Set default values and validate configurations
 | 
					 | 
				
			||||||
if(NOT DEFINED BOARD)
 | 
					 | 
				
			||||||
    set(BOARD iss CACHE STRING "Target board")
 | 
					 | 
				
			||||||
endif()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if(NOT DEFINED ISA)
 | 
					 | 
				
			||||||
    set(ISA rv32imc CACHE STRING "Target ISA")
 | 
					 | 
				
			||||||
endif()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if(NOT DEFINED RISCV_ABI)
 | 
					 | 
				
			||||||
    if(ISA MATCHES "^rv64")
 | 
					 | 
				
			||||||
        set(RISCV_ABI "lp64" CACHE STRING "RISC-V ABI")
 | 
					 | 
				
			||||||
    else()
 | 
					 | 
				
			||||||
        set(RISCV_ABI "ilp32" CACHE STRING "RISC-V ABI")
 | 
					 | 
				
			||||||
    endif()
 | 
					 | 
				
			||||||
endif()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Validate configurations
 | 
					 | 
				
			||||||
if(NOT BOARD IN_LIST SUPPORTED_BOARDS)
 | 
					 | 
				
			||||||
    message(FATAL_ERROR "Invalid BOARD specified. Supported boards: ${SUPPORTED_BOARDS}")
 | 
					 | 
				
			||||||
endif()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if(NOT ISA IN_LIST SUPPORTED_ISAS)
 | 
					 | 
				
			||||||
    message(FATAL_ERROR "Invalid ISA specified(${ISA}). Supported ISAs: ${SUPPORTED_ISAS}")
 | 
					 | 
				
			||||||
endif()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if(NOT RISCV_ABI IN_LIST SUPPORTED_ABIS)
 | 
					 | 
				
			||||||
    message(FATAL_ERROR "Invalid ABI specified. Supported ABIs: ${SUPPORTED_ABIS}")
 | 
					 | 
				
			||||||
endif()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Set RISC-V architecture based on ISA
 | 
					 | 
				
			||||||
if(ISA MATCHES "^rv")
 | 
					 | 
				
			||||||
    set(RISCV_ARCH ${ISA})
 | 
					 | 
				
			||||||
else()
 | 
					 | 
				
			||||||
    # Default to rv32 for backward compatibility
 | 
					 | 
				
			||||||
    set(RISCV_ARCH "rv32${ISA}")
 | 
					 | 
				
			||||||
endif()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Set BSP base directory
 | 
					 | 
				
			||||||
set(BSP_BASE "${CMAKE_CURRENT_SOURCE_DIR}/bare-metal-bsp")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Global compile definitions
 | 
					 | 
				
			||||||
add_compile_definitions(BOARD_${BOARD})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# RISC-V specific compiler flags
 | 
					 | 
				
			||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -g -march=${RISCV_ARCH}_zicsr_zifencei -mabi=${RISCV_ABI} -mcmodel=medany")
 | 
					 | 
				
			||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -g -march=${RISCV_ARCH}_zicsr_zifencei -mabi=${RISCV_ABI} -mcmodel=medany")
 | 
					 | 
				
			||||||
#set(CMAKE_ASM_COMPILER riscv64-unknown-elf-as)
 | 
					 | 
				
			||||||
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -O2 -g -march=${RISCV_ARCH}_zicsr_zifencei -mabi=${RISCV_ABI} -mcmodel=medany")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Optional: Enable semihosting support
 | 
					 | 
				
			||||||
option(SEMIHOSTING "Enable semihosting support" OFF)
 | 
					 | 
				
			||||||
if(SEMIHOSTING)
 | 
					 | 
				
			||||||
    add_compile_definitions(SEMIHOSTING)
 | 
					 | 
				
			||||||
endif()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#create interface library for propagating compile options
 | 
					 | 
				
			||||||
#add_library(global_compile_options INTERFACE)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Compile options
 | 
					 | 
				
			||||||
#target_compile_options(global_compile_options INTERFACE
 | 
					 | 
				
			||||||
#    -march=${RISCV_ARCH}_zicsr_zifencei
 | 
					 | 
				
			||||||
 #   -mabi=${RISCV_ABI}
 | 
					 | 
				
			||||||
 #   -mcmodel=medany
 | 
					 | 
				
			||||||
 #   -O2
 | 
					 | 
				
			||||||
 #   -g
 | 
					 | 
				
			||||||
  #  -ffunction-sections
 | 
					 | 
				
			||||||
  #  -fdata-sections
 | 
					 | 
				
			||||||
#)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
message(STATUS "Building firmware with configuration:")
 | 
					 | 
				
			||||||
message(STATUS "  Board: ${BOARD}")
 | 
					 | 
				
			||||||
message(STATUS "  ISA: ${ISA} (Architecture: ${RISCV_ARCH})")
 | 
					 | 
				
			||||||
message(STATUS "  ABI: ${RISCV_ABI}")
 | 
					 | 
				
			||||||
message(STATUS "  Semihosting: ${SEMIHOSTING}")
 | 
					 | 
				
			||||||
message(STATUS "  Toolchain:")
 | 
					 | 
				
			||||||
message(STATUS "    Path: ${RISCV_TOOLCHAIN_PATH}")
 | 
					 | 
				
			||||||
message(STATUS "    C Compiler: ${CMAKE_C_COMPILER}")
 | 
					 | 
				
			||||||
message(STATUS "    C++ Compiler: ${CMAKE_CXX_COMPILER}")
 | 
					 | 
				
			||||||
message(STATUS "Targets to build:")
 | 
					 | 
				
			||||||
message(STATUS "  hello-world: ${BUILD_HELLO_WORLD}")
 | 
					 | 
				
			||||||
message(STATUS "  dhrystone: ${BUILD_DHRYSTONE}")
 | 
					 | 
				
			||||||
message(STATUS "  coremark: ${BUILD_COREMARK}")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
add_subdirectory(bare-metal-bsp)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Add subdirectories based on build options
 | 
					 | 
				
			||||||
if(BUILD_HELLO_WORLD)
 | 
					 | 
				
			||||||
    add_subdirectory(hello-world)
 | 
					 | 
				
			||||||
endif()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if(BUILD_DHRYSTONE)
 | 
					 | 
				
			||||||
    add_subdirectory(benchmarks/dhrystone)
 | 
					 | 
				
			||||||
endif()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if(BUILD_COREMARK)
 | 
					 | 
				
			||||||
    add_subdirectory(benchmarks/coremark)
 | 
					 | 
				
			||||||
endif()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Create an all-inclusive target only if BUILD_ALL is ON
 | 
					 | 
				
			||||||
if(BUILD_ALL)
 | 
					 | 
				
			||||||
    add_custom_target(fw-common ALL
 | 
					 | 
				
			||||||
        DEPENDS 
 | 
					 | 
				
			||||||
            hello-world
 | 
					 | 
				
			||||||
            dhrystone
 | 
					 | 
				
			||||||
            coremark
 | 
					 | 
				
			||||||
    )
 | 
					 | 
				
			||||||
endif()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Print build instructions
 | 
					 | 
				
			||||||
message(STATUS "")
 | 
					 | 
				
			||||||
message(STATUS "Build instructions:")
 | 
					 | 
				
			||||||
message(STATUS "  Build all targets:           cmake -DBUILD_ALL=ON ..")
 | 
					 | 
				
			||||||
message(STATUS "  Build specific target:       cmake -DBUILD_HELLO_WORLD=ON -DBUILD_DHRYSTONE=OFF -DBUILD_COREMARK=OFF ..")
 | 
					 | 
				
			||||||
message(STATUS "  Configure board:             cmake -DBOARD=iss ..")
 | 
					 | 
				
			||||||
message(STATUS "  Configure ISA:               cmake -DISA=rv32imc ..")
 | 
					 | 
				
			||||||
message(STATUS "  Configure ABI:               cmake -DRISCV_ABI=ilp32 ..")
 | 
					 | 
				
			||||||
message(STATUS "  Enable semihosting:          cmake -DSEMIHOSTING=ON ..")
 | 
					 | 
				
			||||||
message(STATUS "  Set toolchain path:          cmake -DRISCV_TOOLCHAIN_PATH=/path/to/toolchain ..")
 | 
					 | 
				
			||||||
message(STATUS "  Set specific compiler:       cmake -DRISCV_GCC=/path/to/riscv-gcc -DRISCV_GXX=/path/to/riscv-g++ ..")
 | 
					 | 
				
			||||||
							
								
								
									
										122
									
								
								Jenkinsfile
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										122
									
								
								Jenkinsfile
									
									
									
									
										vendored
									
									
								
							@@ -2,7 +2,7 @@ void checkout_project() {
 | 
				
			|||||||
    checkout([
 | 
					    checkout([
 | 
				
			||||||
        $class: 'GitSCM',
 | 
					        $class: 'GitSCM',
 | 
				
			||||||
        branches: [
 | 
					        branches: [
 | 
				
			||||||
            [name: '*/main']
 | 
					            [name: '*/develop']
 | 
				
			||||||
        ],
 | 
					        ],
 | 
				
			||||||
        extensions: [
 | 
					        extensions: [
 | 
				
			||||||
            [$class: 'CleanBeforeCheckout'],
 | 
					            [$class: 'CleanBeforeCheckout'],
 | 
				
			||||||
@@ -15,6 +15,24 @@ void checkout_project() {
 | 
				
			|||||||
    ])
 | 
					    ])
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void checkout_iss_project(String repoUrl, String branch = 'develop') {
 | 
				
			||||||
 | 
					    checkout([
 | 
				
			||||||
 | 
					        $class: 'GitSCM',
 | 
				
			||||||
 | 
					        branches: [
 | 
				
			||||||
 | 
					            [name: "*/${branch}"]
 | 
				
			||||||
 | 
					        ],
 | 
				
			||||||
 | 
					        extensions: [
 | 
				
			||||||
 | 
					            [$class: 'CleanBeforeCheckout'],
 | 
				
			||||||
 | 
					            [$class: 'SubmoduleOption', disableSubmodules: false, parentCredentials: true, recursiveSubmodules: true, reference: '', trackingSubmodules: false, shallow: true]
 | 
				
			||||||
 | 
					        ],
 | 
				
			||||||
 | 
					        submoduleCfg: [],
 | 
				
			||||||
 | 
					        userRemoteConfigs: [
 | 
				
			||||||
 | 
					            [credentialsId: 'gitea-jenkins', url: repoUrl]
 | 
				
			||||||
 | 
					        ]
 | 
				
			||||||
 | 
					    ])
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void checkout_develop() {
 | 
					void checkout_develop() {
 | 
				
			||||||
    dir("bare-metal-bsp") {
 | 
					    dir("bare-metal-bsp") {
 | 
				
			||||||
        withCredentials([usernamePassword(credentialsId: 'gitea-jenkins', usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD')]) {
 | 
					        withCredentials([usernamePassword(credentialsId: 'gitea-jenkins', usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD')]) {
 | 
				
			||||||
@@ -29,6 +47,14 @@ void make_hello(board) {
 | 
				
			|||||||
    sh("make -C hello-world/ clean")
 | 
					    sh("make -C hello-world/ clean")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void cmake_hello(board,build_type,core_type) {  
 | 
				
			||||||
 | 
					    def flavor ="${board}_${build_type}_${core_type}"
 | 
				
			||||||
 | 
					    if (core_type=="32")
 | 
				
			||||||
 | 
					        flavor ="${board}_${build_type}"
 | 
				
			||||||
 | 
					    sh("cmake -B ${flavor}  --preset=${flavor}") 
 | 
				
			||||||
 | 
					    sh("cmake --build ${flavor}")    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pipeline {
 | 
					pipeline {
 | 
				
			||||||
    agent { docker { 
 | 
					    agent { docker { 
 | 
				
			||||||
        image 'ubuntu-riscv'
 | 
					        image 'ubuntu-riscv'
 | 
				
			||||||
@@ -48,12 +74,13 @@ pipeline {
 | 
				
			|||||||
        stage('make rtl') {steps { make_hello("rtl")}}
 | 
					        stage('make rtl') {steps { make_hello("rtl")}}
 | 
				
			||||||
        stage('make ehrenberg') {steps { make_hello("ehrenberg")}}
 | 
					        stage('make ehrenberg') {steps { make_hello("ehrenberg")}}
 | 
				
			||||||
        stage('make tgc_vp') {steps { make_hello("tgc_vp")}}*/
 | 
					        stage('make tgc_vp') {steps { make_hello("tgc_vp")}}*/
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        stage('make hello-world') {
 | 
					        stage('make hello-world') {
 | 
				
			||||||
            matrix {
 | 
					            matrix {
 | 
				
			||||||
                axes {
 | 
					                axes {
 | 
				
			||||||
                    axis{
 | 
					                    axis{
 | 
				
			||||||
                        name 'BOARD'
 | 
					                        name 'BOARD'
 | 
				
			||||||
                        values 'iss', 'hifive1', 'TGCP', 'ehrenberg', 'rtl', 'tgc_vp'
 | 
					                        values 'iss',  'moonlight',  'tgc_vp'
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                stages {
 | 
					                stages {
 | 
				
			||||||
@@ -72,10 +99,91 @@ pipeline {
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            } 
 | 
					            } 
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					        
 | 
				
			||||||
    post {
 | 
					        stage('CMAKE flow for hello-world') {
 | 
				
			||||||
        failure {
 | 
					            matrix {
 | 
				
			||||||
            sh("make -C hello-world/ clean")       
 | 
					                axes {
 | 
				
			||||||
 | 
					                    axis{
 | 
				
			||||||
 | 
					                        name 'BOARD'
 | 
				
			||||||
 | 
					                        values 'ISS',  'Moonlight', 'TGC_VP'
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    axis{
 | 
				
			||||||
 | 
					                        name 'BUILD_TYPE'
 | 
				
			||||||
 | 
					                        values 'Debug',  'Release'
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    axis{
 | 
				
			||||||
 | 
					                        name 'CORE_TYPE'
 | 
				
			||||||
 | 
					                        values '32',  '64'
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                stages {
 | 
				
			||||||
 | 
					                    stage('Force sequential') {
 | 
				
			||||||
 | 
					                        options {
 | 
				
			||||||
 | 
					                            lock("One Board at a time")
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        when{
 | 
				
			||||||
 | 
					                            not {
 | 
				
			||||||
 | 
					                                anyOf {
 | 
				
			||||||
 | 
					                                    expression { BOARD == 'Moonlight' && CORE_TYPE =='64'}
 | 
				
			||||||
 | 
					                                    expression { BOARD == 'TGC_VP' && CORE_TYPE =='64'}
 | 
				
			||||||
 | 
					                                }                                
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        stages {
 | 
				
			||||||
 | 
					                            stage("CMAKE") {
 | 
				
			||||||
 | 
					                                steps {
 | 
				
			||||||
 | 
					                                    dir("hello-world"){
 | 
				
			||||||
 | 
					                                        cmake_hello("${BOARD}","${BUILD_TYPE}","${CORE_TYPE}")
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            } 
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					        stage("Checkout TGC-ISS, TGC-Compliance and TGC-GEN"){
 | 
				
			||||||
 | 
					            steps {                                       
 | 
				
			||||||
 | 
					                dir("TGC-ISS"){                    
 | 
				
			||||||
 | 
					                    sh 'rm -rf * .??* '
 | 
				
			||||||
 | 
					                    checkout_iss_project("https://git.minres.com/TGFS/TGC-ISS.git", "develop")
 | 
				
			||||||
 | 
					                    dir("TGC-COMPLIANCE"){                        
 | 
				
			||||||
 | 
					                        checkout_iss_project("https://git.minres.com/TGFS/TGC-COMPLIANCE.git", "master")
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    dir("TGC-GEN"){                        
 | 
				
			||||||
 | 
					                        checkout_iss_project("https://git.minres.com/TGFS/TGC-GEN.git", "develop")
 | 
				
			||||||
 | 
					                        }                            
 | 
				
			||||||
 | 
					                    } 
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        stage("Generate cores and build TGC-ISS"){
 | 
				
			||||||
 | 
					            steps {                
 | 
				
			||||||
 | 
					                sh 'rm -rf *@tmp'                     
 | 
				
			||||||
 | 
					                sh '''
 | 
				
			||||||
 | 
					                for core in RV32GC; do 
 | 
				
			||||||
 | 
					                    for backend in interp; do 
 | 
				
			||||||
 | 
					                            TGC-ISS/TGC-GEN/scripts/generate_iss.sh -o TGC-ISS/dbt-rise-tgc/ -c $core -b ${backend} TGC-ISS/TGC-GEN/CoreDSL/${core}.core_desc
 | 
				
			||||||
 | 
					                    done
 | 
				
			||||||
 | 
					                done
 | 
				
			||||||
 | 
					                for core in RV64GC; do
 | 
				
			||||||
 | 
					                    for backend in interp; do 
 | 
				
			||||||
 | 
					                        TGC-ISS/TGC-GEN/scripts/generate_iss.sh -o TGC-ISS/dbt-rise-tgc/ -c $core -b ${backend} TGC-ISS/TGC-GEN/CoreDSL/${core}.core_desc
 | 
				
			||||||
 | 
					                    done
 | 
				
			||||||
 | 
					                done
 | 
				
			||||||
 | 
					                '''
 | 
				
			||||||
 | 
					                sh 'conan profile detect --force'
 | 
				
			||||||
 | 
					                sh 'rm -rf TGC-ISS/build'
 | 
				
			||||||
 | 
					                sh 'cmake -S TGC-ISS/. -B TGC-ISS/build --preset Release -DWITH_ASMJIT=ON -DWITH_TCC=ON -DWITH_LLVM=OFF'                
 | 
				
			||||||
 | 
					                sh 'cmake --build TGC-ISS/build -j'
 | 
				
			||||||
 | 
					                sh 'TGC-ISS/build/dbt-rise-tgc/tgc-sim --isa ?'                       
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        stage("start to run hello FW on ISS") {
 | 
				
			||||||
 | 
					            steps {                
 | 
				
			||||||
 | 
					                sh 'TGC-ISS/build/dbt-rise-tgc/tgc-sim -f hello-world/ISS_Debug/hello.elf'
 | 
				
			||||||
 | 
					                sh 'TGC-ISS/build/dbt-rise-tgc/tgc-sim -f hello-world/ISS_Debug_64/hello.elf --isa=rv64gc'                
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }    
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
 Submodule bare-metal-bsp updated: fbe6560e79...bf0e4ec057
									
								
							@@ -1,8 +1,7 @@
 | 
				
			|||||||
cmake_minimum_required(VERSION 3.12)
 | 
					cmake_minimum_required(VERSION 3.21)
 | 
				
			||||||
project(coremark C)
 | 
					project(coremark C)
 | 
				
			||||||
 | 
					set(TARGET coremark)
 | 
				
			||||||
# Include BSP libwrap
 | 
					set(CMAKE_BUILD_TYPE Release)
 | 
				
			||||||
include(${BSP_BASE}/libwrap/CMakeLists.txt)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Source files
 | 
					# Source files
 | 
				
			||||||
set(SOURCES
 | 
					set(SOURCES
 | 
				
			||||||
@@ -18,49 +17,15 @@ set(SOURCES
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
# Create executable
 | 
					# Create executable
 | 
				
			||||||
add_executable(coremark ${SOURCES})
 | 
					add_executable(coremark ${SOURCES})
 | 
				
			||||||
 | 
					target_include_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_LIST_DIR}/cm)
 | 
				
			||||||
 | 
					target_compile_options(${TARGET} PRIVATE  -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -fno-builtin-strnlen -fno-common -funroll-loops -finline-functions -falign-functions=16 -falign-jumps=4 -falign-loops=4 -finline-limit=1000 -fno-if-conversion2 -fselective-scheduling -fno-crossjumping -freorder-blocks-and-partition -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -fno-common -funroll-loops -finline-functions -falign-functions=16 -falign-jumps=4 -falign-loops=4 -finline-limit=1000 -fno-if-conversion2 -fselective-scheduling -fno-crossjumping -freorder-blocks-and-partition )
 | 
				
			||||||
 | 
					target_compile_definitions(${TARGET} PRIVATE PERFORMANCE_RUN=1 CLOCKS_PER_SEC=10000000 FLAGS_STR="" PERFORMANCE_RUN=1 CLOCKS_PER_SEC=10000000 ITERATIONS=600)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Include directories
 | 
					set(BOARD "iss" CACHE STRING "Target board")
 | 
				
			||||||
target_include_directories(coremark PRIVATE
 | 
					add_subdirectory(../../bare-metal-bsp bsp)
 | 
				
			||||||
    ${BSP_BASE}/include
 | 
					target_link_libraries(${TARGET} PRIVATE bsp)
 | 
				
			||||||
    ${BSP_BASE}/drivers
 | 
					target_link_options(${TARGET} PRIVATE LINKER:-Map=${TARGET}.map)  
 | 
				
			||||||
    ${BSP_BASE}/env
 | 
					 | 
				
			||||||
    ${CMAKE_CURRENT_SOURCE_DIR}
 | 
					 | 
				
			||||||
    ${CMAKE_CURRENT_SOURCE_DIR}/cm
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Link with libwrap
 | 
					add_custom_command(TARGET ${TARGET} POST_BUILD
 | 
				
			||||||
target_link_libraries(coremark PRIVATE
 | 
					        COMMAND ${CMAKE_OBJDUMP} -S  ${TARGET}.elf > ${TARGET}.dis
 | 
				
			||||||
    LIBWRAP_TGC
 | 
					        COMMENT "Creating disassembly for ${TARGET}")
 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Add compile definitions
 | 
					 | 
				
			||||||
target_compile_definitions(coremark PRIVATE
 | 
					 | 
				
			||||||
    BOARD_${BOARD}
 | 
					 | 
				
			||||||
    PERFORMANCE_RUN=1
 | 
					 | 
				
			||||||
    ITERATIONS=1000
 | 
					 | 
				
			||||||
    COMPILER_FLAGS="${CMAKE_C_FLAGS}"
 | 
					 | 
				
			||||||
    COMPILER_VERSION="${CMAKE_C_COMPILER_VERSION}"
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Set compile options
 | 
					 | 
				
			||||||
target_compile_options(coremark PRIVATE
 | 
					 | 
				
			||||||
    -march=${RISCV_ARCH}_zicsr_zifencei
 | 
					 | 
				
			||||||
    -mabi=${RISCV_ABI}
 | 
					 | 
				
			||||||
    -mcmodel=medany
 | 
					 | 
				
			||||||
    -ffunction-sections
 | 
					 | 
				
			||||||
    -fdata-sections
 | 
					 | 
				
			||||||
    -O2  # Optimization level for benchmarking
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Set linker options
 | 
					 | 
				
			||||||
target_link_options(coremark PRIVATE
 | 
					 | 
				
			||||||
    -T${BSP_BASE}/env/${BOARD}/link.ld
 | 
					 | 
				
			||||||
    -nostartfiles
 | 
					 | 
				
			||||||
    -Wl,--gc-sections
 | 
					 | 
				
			||||||
    ${LIBWRAP_TGC_LDFLAGS}
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Install target
 | 
					 | 
				
			||||||
install(TARGETS coremark
 | 
					 | 
				
			||||||
    RUNTIME DESTINATION bin
 | 
					 | 
				
			||||||
)
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										118
									
								
								benchmarks/coremark/CMakePresets.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										118
									
								
								benchmarks/coremark/CMakePresets.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,118 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "version": 3,
 | 
				
			||||||
 | 
					    "vendor": {
 | 
				
			||||||
 | 
					        "conan": {}
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "cmakeMinimumRequired": {
 | 
				
			||||||
 | 
					        "major": 3,
 | 
				
			||||||
 | 
					        "minor": 24,
 | 
				
			||||||
 | 
					        "patch": 0
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "configurePresets": [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "32imc",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "64imc",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "iss",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "BOARD": "iss"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "moonlight",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "BOARD": "moonlight"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "tgc_vp",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "BOARD": "tgc_vp"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "rtl",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "BOARD": "rtl"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "debug",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "CMAKE_BUILD_TYPE": "Debug"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "release",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "CMAKE_BUILD_TYPE": "Release"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "ISS_Debug",
 | 
				
			||||||
 | 
					            "inherits": ["iss", "debug", "32imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "Moonlight_Debug",
 | 
				
			||||||
 | 
					            "inherits": ["moonlight", "debug", "32imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "TGC_VP_Debug",
 | 
				
			||||||
 | 
					            "inherits": ["tgc_vp", "debug", "32imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "ISS_Debug_64",
 | 
				
			||||||
 | 
					            "inherits": ["iss", "debug", "64imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "Moonlight_Debug_64",
 | 
				
			||||||
 | 
					            "inherits": ["moonlight", "debug", "64imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "TGC_VP_Debug_64",
 | 
				
			||||||
 | 
					            "inherits": ["tgc_vp", "debug", "64imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "ISS_Release",
 | 
				
			||||||
 | 
					            "inherits": ["iss", "release", "32imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "Moonlight_Release",
 | 
				
			||||||
 | 
					            "inherits": ["moonlight", "release", "32imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "TGC_VP_Release",
 | 
				
			||||||
 | 
					            "inherits": ["tgc_vp", "release", "32imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "ISS_Release_64",
 | 
				
			||||||
 | 
					            "inherits": ["iss", "release", "64imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "Moonlight_Release_64",
 | 
				
			||||||
 | 
					            "inherits": ["moonlight", "release", "64imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "TGC_VP_Release_64",
 | 
				
			||||||
 | 
					            "inherits": ["tgc_vp", "release", "64imc"]
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					                 
 | 
				
			||||||
 | 
					    ]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -15,55 +15,58 @@ limitations under the License.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
Original Author: Shay Gal-on
 | 
					Original Author: Shay Gal-on
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
#include "coremark.h"
 | 
					 | 
				
			||||||
#include "core_portme.h"
 | 
					#include "core_portme.h"
 | 
				
			||||||
//Read cycle CSR
 | 
					#include "coremark.h"
 | 
				
			||||||
unsigned long long _read_cycle()
 | 
					#include <unistd.h>
 | 
				
			||||||
{
 | 
					// Read cycle CSR
 | 
				
			||||||
    unsigned long long result;
 | 
					unsigned long long _read_cycle() {
 | 
				
			||||||
    unsigned long lower;
 | 
					  unsigned long long result;
 | 
				
			||||||
    unsigned long upper1;
 | 
					  unsigned long lower;
 | 
				
			||||||
    unsigned long upper2;
 | 
					  unsigned long upper1;
 | 
				
			||||||
 | 
					  unsigned long upper2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    asm volatile (
 | 
					  asm volatile("repeat_cycle_%=: csrr %0, cycleh;\n"
 | 
				
			||||||
        "repeat_cycle_%=: csrr %0, cycleh;\n"
 | 
					               "        csrr %1, cycle;\n"
 | 
				
			||||||
        "        csrr %1, cycle;\n"
 | 
					               "        csrr %2, cycleh;\n"
 | 
				
			||||||
        "        csrr %2, cycleh;\n"
 | 
					               "        bne %0, %2, repeat_cycle_%=;\n"
 | 
				
			||||||
        "        bne %0, %2, repeat_cycle_%=;\n"
 | 
					               : "=r"(upper1), "=r"(lower),
 | 
				
			||||||
        : "=r" (upper1),"=r" (lower),"=r" (upper2)    // Outputs   : temp variable for load result
 | 
					                 "=r"(upper2) // Outputs   : temp variable for load result
 | 
				
			||||||
        :
 | 
					               :
 | 
				
			||||||
        :
 | 
					               :);
 | 
				
			||||||
    );
 | 
					  *(unsigned long *)(&result) = lower;
 | 
				
			||||||
    *(unsigned long *)(&result) = lower;
 | 
					  *((unsigned long *)(&result) + 1) = upper1;
 | 
				
			||||||
    *((unsigned long *)(&result)+1) = upper1;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return result;
 | 
					  return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
volatile int tohost;
 | 
					// extern volatile int tohost;
 | 
				
			||||||
volatile int fromhost;
 | 
					// extern volatile int fromhost;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void exit(int n){
 | 
					void write_hex(int fd, uint32_t hex);
 | 
				
			||||||
      tohost = 0x1;
 | 
					
 | 
				
			||||||
      for (;;);
 | 
					void exit(int n) {
 | 
				
			||||||
 | 
					  write_hex(STDERR_FILENO, 1);
 | 
				
			||||||
 | 
					  // tohost = 0x1;
 | 
				
			||||||
 | 
					  for (;;)
 | 
				
			||||||
 | 
					    ;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void __libc_init_array (void) {
 | 
					void __libc_init_array(void) {
 | 
				
			||||||
/*
 | 
					  /*
 | 
				
			||||||
    size_t count;
 | 
					      size_t count;
 | 
				
			||||||
    size_t i;
 | 
					      size_t i;
 | 
				
			||||||
    count = __preinit_array_end - __preinit_array_start;
 | 
					      count = __preinit_array_end - __preinit_array_start;
 | 
				
			||||||
    for (i = 0; i < count; i++)
 | 
					      for (i = 0; i < count; i++)
 | 
				
			||||||
        __preinit_array_start[i] ();
 | 
					          __preinit_array_start[i] ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef HAVE_INIT_FINI
 | 
					  #ifdef HAVE_INIT_FINI
 | 
				
			||||||
    _init ();
 | 
					      _init ();
 | 
				
			||||||
#endif
 | 
					  #endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    count = __init_array_end - __init_array_start;
 | 
					      count = __init_array_end - __init_array_start;
 | 
				
			||||||
    for (i = 0; i < count; i++)
 | 
					      for (i = 0; i < count; i++)
 | 
				
			||||||
    __init_array_start[i] ();
 | 
					      __init_array_start[i] ();
 | 
				
			||||||
*/
 | 
					  */
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#if VALIDATION_RUN
 | 
					#if VALIDATION_RUN
 | 
				
			||||||
volatile ee_s32 seed1_volatile = 0x3415;
 | 
					volatile ee_s32 seed1_volatile = 0x3415;
 | 
				
			||||||
@@ -89,10 +92,7 @@ volatile ee_s32 seed5_volatile = 0;
 | 
				
			|||||||
   time.h and windows.h definitions included.
 | 
					   time.h and windows.h definitions included.
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
CORETIMETYPE
 | 
					CORETIMETYPE
 | 
				
			||||||
barebones_clock()
 | 
					barebones_clock() { return (CORETIMETYPE)_read_cycle(); }
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    return (CORETIMETYPE)_read_cycle();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
/* Define : TIMER_RES_DIVIDER
 | 
					/* Define : TIMER_RES_DIVIDER
 | 
				
			||||||
        Divider to trade off timer resolution and total time that can be
 | 
					        Divider to trade off timer resolution and total time that can be
 | 
				
			||||||
   measured.
 | 
					   measured.
 | 
				
			||||||
@@ -101,11 +101,11 @@ barebones_clock()
 | 
				
			|||||||
   does not occur. If there are issues with the return value overflowing,
 | 
					   does not occur. If there are issues with the return value overflowing,
 | 
				
			||||||
   increase this value.
 | 
					   increase this value.
 | 
				
			||||||
        */
 | 
					        */
 | 
				
			||||||
#define GETMYTIME(_t)              (*_t = barebones_clock())
 | 
					#define GETMYTIME(_t) (*_t = barebones_clock())
 | 
				
			||||||
#define MYTIMEDIFF(fin, ini)       ((fin) - (ini))
 | 
					#define MYTIMEDIFF(fin, ini) ((fin) - (ini))
 | 
				
			||||||
#define TIMER_RES_DIVIDER          1
 | 
					#define TIMER_RES_DIVIDER 1
 | 
				
			||||||
#define SAMPLE_TIME_IMPLEMENTATION 1
 | 
					#define SAMPLE_TIME_IMPLEMENTATION 1
 | 
				
			||||||
#define EE_TICKS_PER_SEC           (CLOCKS_PER_SEC / TIMER_RES_DIVIDER)
 | 
					#define EE_TICKS_PER_SEC (CLOCKS_PER_SEC / TIMER_RES_DIVIDER)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** Define Host specific (POSIX), or target specific global time variables. */
 | 
					/** Define Host specific (POSIX), or target specific global time variables. */
 | 
				
			||||||
static CORETIMETYPE start_time_val, stop_time_val;
 | 
					static CORETIMETYPE start_time_val, stop_time_val;
 | 
				
			||||||
@@ -118,11 +118,7 @@ static CORETIMETYPE start_time_val, stop_time_val;
 | 
				
			|||||||
   example code) or zeroing some system parameters - e.g. setting the cpu clocks
 | 
					   example code) or zeroing some system parameters - e.g. setting the cpu clocks
 | 
				
			||||||
   cycles to 0.
 | 
					   cycles to 0.
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
void
 | 
					void start_time(void) { GETMYTIME(&start_time_val); }
 | 
				
			||||||
start_time(void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    GETMYTIME(&start_time_val);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
/* Function : stop_time
 | 
					/* Function : stop_time
 | 
				
			||||||
        This function will be called right after ending the timed portion of the
 | 
					        This function will be called right after ending the timed portion of the
 | 
				
			||||||
   benchmark.
 | 
					   benchmark.
 | 
				
			||||||
@@ -131,11 +127,7 @@ start_time(void)
 | 
				
			|||||||
   example code) or other system parameters - e.g. reading the current value of
 | 
					   example code) or other system parameters - e.g. reading the current value of
 | 
				
			||||||
   cpu cycles counter.
 | 
					   cpu cycles counter.
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
void
 | 
					void stop_time(void) { GETMYTIME(&stop_time_val); }
 | 
				
			||||||
stop_time(void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    GETMYTIME(&stop_time_val);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
/* Function : get_time
 | 
					/* Function : get_time
 | 
				
			||||||
        Return an abstract "ticks" number that signifies time on the system.
 | 
					        Return an abstract "ticks" number that signifies time on the system.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -146,11 +138,9 @@ stop_time(void)
 | 
				
			|||||||
   controlled by <TIMER_RES_DIVIDER>
 | 
					   controlled by <TIMER_RES_DIVIDER>
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
CORE_TICKS
 | 
					CORE_TICKS
 | 
				
			||||||
get_time(void)
 | 
					get_time(void) {
 | 
				
			||||||
{
 | 
					  CORE_TICKS elapsed = (CORE_TICKS)(MYTIMEDIFF(stop_time_val, start_time_val));
 | 
				
			||||||
    CORE_TICKS elapsed
 | 
					  return elapsed;
 | 
				
			||||||
        = (CORE_TICKS)(MYTIMEDIFF(stop_time_val, start_time_val));
 | 
					 | 
				
			||||||
    return elapsed;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/* Function : time_in_secs
 | 
					/* Function : time_in_secs
 | 
				
			||||||
        Convert the value returned by get_time to seconds.
 | 
					        Convert the value returned by get_time to seconds.
 | 
				
			||||||
@@ -159,11 +149,9 @@ get_time(void)
 | 
				
			|||||||
   floating point. Default implementation implemented by the EE_TICKS_PER_SEC
 | 
					   floating point. Default implementation implemented by the EE_TICKS_PER_SEC
 | 
				
			||||||
   macro above.
 | 
					   macro above.
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
secs_ret
 | 
					secs_ret time_in_secs(CORE_TICKS ticks) {
 | 
				
			||||||
time_in_secs(CORE_TICKS ticks)
 | 
					  secs_ret retval = ((secs_ret)ticks) / (secs_ret)EE_TICKS_PER_SEC;
 | 
				
			||||||
{
 | 
					  return retval;
 | 
				
			||||||
    secs_ret retval = ((secs_ret)ticks) / (secs_ret)EE_TICKS_PER_SEC;
 | 
					 | 
				
			||||||
    return retval;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ee_u32 default_num_contexts = 1;
 | 
					ee_u32 default_num_contexts = 1;
 | 
				
			||||||
@@ -172,27 +160,18 @@ ee_u32 default_num_contexts = 1;
 | 
				
			|||||||
        Target specific initialization code
 | 
					        Target specific initialization code
 | 
				
			||||||
        Test for some common mistakes.
 | 
					        Test for some common mistakes.
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
void
 | 
					void portable_init(core_portable *p, int *argc, char *argv[]) {
 | 
				
			||||||
portable_init(core_portable *p, int *argc, char *argv[])
 | 
					  if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) {
 | 
				
			||||||
{
 | 
					    ee_printf("ERROR! Please define ee_ptr_int to a type that holds a "
 | 
				
			||||||
    if (sizeof(ee_ptr_int) != sizeof(ee_u8 *))
 | 
					              "pointer!\n");
 | 
				
			||||||
    {
 | 
					  }
 | 
				
			||||||
        ee_printf(
 | 
					  if (sizeof(ee_u32) != 4) {
 | 
				
			||||||
            "ERROR! Please define ee_ptr_int to a type that holds a "
 | 
					    ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n");
 | 
				
			||||||
            "pointer!\n");
 | 
					  }
 | 
				
			||||||
    }
 | 
					  p->portable_id = 1;
 | 
				
			||||||
    if (sizeof(ee_u32) != 4)
 | 
					  ee_printf("portable_init finished.\n");
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n");
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    p->portable_id = 1;
 | 
					 | 
				
			||||||
    ee_printf("portable_init finished.\n");
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/* Function : portable_fini
 | 
					/* Function : portable_fini
 | 
				
			||||||
        Target specific final code
 | 
					        Target specific final code
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
void
 | 
					void portable_fini(core_portable *p) { p->portable_id = 0; }
 | 
				
			||||||
portable_fini(core_portable *p)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    p->portable_id = 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -1,21 +1,28 @@
 | 
				
			|||||||
cmake_minimum_required(VERSION 3.21)
 | 
					cmake_minimum_required(VERSION 3.21)
 | 
				
			||||||
project(dhrystone C)
 | 
					project(dhrystone C)
 | 
				
			||||||
set(TARGET dhrystone)
 | 
					set(TARGET dhrystone)
 | 
				
			||||||
set(CMAKE_BUILD_TYPE Release)
 | 
					
 | 
				
			||||||
set(ITERATIONS 50000) # 20000 for TGC
 | 
					set(ITERATIONS 50000 CACHE STRING "")
 | 
				
			||||||
 | 
					set(FREQ 100e6 CACHE STRING "")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					set(CMAKE_C_FLAGS_RELEASE -O3)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_executable(${TARGET} dhry_1.c dhry_2.c dhry_stubs.c)
 | 
					add_executable(${TARGET} dhry_1.c dhry_2.c dhry_stubs.c)
 | 
				
			||||||
target_include_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_LIST_DIR})
 | 
					target_include_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_LIST_DIR})
 | 
				
			||||||
target_compile_options(${TARGET} PRIVATE -fno-inline -fno-builtin-printf -fno-common -Wno-implicit -funroll-loops -fpeel-loops -fgcse-sm -fgcse-las)
 | 
					target_compile_options(${TARGET} PRIVATE 
 | 
				
			||||||
target_compile_definitions(${TARGET} PRIVATE ITERATIONS=${ITERATIONS} HZ=32768 TIME NO_INIT)
 | 
					        -Wno-implicit -fno-builtin-printf 
 | 
				
			||||||
 | 
					        -finline -fno-common -funroll-loops -fpeel-loops 
 | 
				
			||||||
 | 
					        -finline-functions -finline-limit=1000
 | 
				
			||||||
 | 
					        -fgcse-sm -fgcse-las 
 | 
				
			||||||
 | 
					        -falign-functions=16 -falign-jumps=4 -falign-loops=4 
 | 
				
			||||||
 | 
					        -freorder-blocks-and-partition -fno-if-conversion2 -fno-crossjumping)
 | 
				
			||||||
 | 
					target_compile_definitions(${TARGET} PRIVATE ITERATIONS=${ITERATIONS} HZ=${FREQ} TIME NO_INIT)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set(BOARD "iss" CACHE STRING "Target board")
 | 
					set(BOARD "iss" CACHE STRING "Target board")
 | 
				
			||||||
add_subdirectory(../../bare-metal-bsp bsp)
 | 
					add_subdirectory(../../bare-metal-bsp bsp)
 | 
				
			||||||
target_link_libraries(${TARGET} PRIVATE bsp)
 | 
					target_link_libraries(${TARGET} PRIVATE bsp)
 | 
				
			||||||
target_link_options(${TARGET} PRIVATE LINKER:--wrap=scanf)
 | 
					target_link_options(${TARGET} PRIVATE LINKER:-Map=${TARGET}.map -Wl,--wrap=scanf)
 | 
				
			||||||
include(CMakePrintHelpers)
 | 
					 | 
				
			||||||
cmake_print_properties(TARGETS ${TARGET} PROPERTIES COMPILE_DEFINITIONS COMPILE_OPTIONS LINK_OPTIONS INTERFACE_LINK_OPTIONS)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_custom_command(TARGET ${TARGET} POST_BUILD
 | 
					add_custom_command(TARGET ${TARGET} POST_BUILD
 | 
				
			||||||
        COMMAND ${CMAKE_OBJDUMP} -S  ${TARGET}.elf > ${TARGET}.dis
 | 
					        COMMAND ${CMAKE_OBJDUMP} -S ${TARGET}.elf > ${TARGET}.dis
 | 
				
			||||||
        COMMENT "Creating disassembly for ${TARGET}")
 | 
					        COMMENT "Creating disassembly for ${TARGET}")
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										118
									
								
								benchmarks/dhrystone/CMakePresets.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										118
									
								
								benchmarks/dhrystone/CMakePresets.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,118 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "version": 3,
 | 
				
			||||||
 | 
					    "vendor": {
 | 
				
			||||||
 | 
					        "conan": {}
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "cmakeMinimumRequired": {
 | 
				
			||||||
 | 
					        "major": 3,
 | 
				
			||||||
 | 
					        "minor": 24,
 | 
				
			||||||
 | 
					        "patch": 0
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "configurePresets": [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "32imc",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "64imc",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "iss",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "BOARD": "iss"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "moonlight",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "BOARD": "moonlight"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "tgc_vp",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "BOARD": "tgc_vp"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "rtl",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "BOARD": "rtl"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "debug",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "CMAKE_BUILD_TYPE": "Debug"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "release",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "CMAKE_BUILD_TYPE": "Release"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "ISS_Debug",
 | 
				
			||||||
 | 
					            "inherits": ["iss", "debug", "32imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "Moonlight_Debug",
 | 
				
			||||||
 | 
					            "inherits": ["moonlight", "debug", "32imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "TGC_VP_Debug",
 | 
				
			||||||
 | 
					            "inherits": ["tgc_vp", "debug", "32imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "ISS_Debug_64",
 | 
				
			||||||
 | 
					            "inherits": ["iss", "debug", "64imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "Moonlight_Debug_64",
 | 
				
			||||||
 | 
					            "inherits": ["moonlight", "debug", "64imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "TGC_VP_Debug_64",
 | 
				
			||||||
 | 
					            "inherits": ["tgc_vp", "debug", "64imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "ISS_Release",
 | 
				
			||||||
 | 
					            "inherits": ["iss", "release", "32imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "Moonlight_Release",
 | 
				
			||||||
 | 
					            "inherits": ["moonlight", "release", "32imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "TGC_VP_Release",
 | 
				
			||||||
 | 
					            "inherits": ["tgc_vp", "release", "32imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "ISS_Release_64",
 | 
				
			||||||
 | 
					            "inherits": ["iss", "release", "64imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "Moonlight_Release_64",
 | 
				
			||||||
 | 
					            "inherits": ["moonlight", "release", "64imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "TGC_VP_Release_64",
 | 
				
			||||||
 | 
					            "inherits": ["tgc_vp", "release", "64imc"]
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					                 
 | 
				
			||||||
 | 
					    ]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -9,7 +9,7 @@ HEADERS := dhry.h
 | 
				
			|||||||
BOARD?=iss
 | 
					BOARD?=iss
 | 
				
			||||||
LINK_TARGET=link
 | 
					LINK_TARGET=link
 | 
				
			||||||
RISCV_ARCH:=rv32$(ISA)
 | 
					RISCV_ARCH:=rv32$(ISA)
 | 
				
			||||||
ifeq ($(ISA),e)
 | 
					ifneq (,$(findstring e,$(ISA)))
 | 
				
			||||||
    RISCV_ABI:=ilp32e
 | 
					    RISCV_ABI:=ilp32e
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
    RISCV_ABI:=ilp32
 | 
					    RISCV_ABI:=ilp32
 | 
				
			||||||
@@ -18,7 +18,6 @@ endif
 | 
				
			|||||||
CFLAGS  := -g -O3 -DITERATIONS=$(ITERATIONS) -DHZ=32768 -DTIME -DNO_INIT -fno-inline -fno-builtin-printf -fno-common -Wno-implicit \
 | 
					CFLAGS  := -g -O3 -DITERATIONS=$(ITERATIONS) -DHZ=32768 -DTIME -DNO_INIT -fno-inline -fno-builtin-printf -fno-common -Wno-implicit \
 | 
				
			||||||
 -funroll-loops -fpeel-loops -fgcse-sm -fgcse-las
 | 
					 -funroll-loops -fpeel-loops -fgcse-sm -fgcse-las
 | 
				
			||||||
LDFLAGS := -Wl,--wrap=scanf
 | 
					LDFLAGS := -Wl,--wrap=scanf
 | 
				
			||||||
 | 
					 | 
				
			||||||
TOOL_DIR=$(dir $(compiler))
 | 
					TOOL_DIR=$(dir $(compiler))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
BSP_BASE = ../../bare-metal-bsp
 | 
					BSP_BASE = ../../bare-metal-bsp
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -212,7 +212,7 @@ main ()
 | 
				
			|||||||
  printf ("Arr_2_Glob[8][7]:    %d\n", Arr_2_Glob[8][7]);
 | 
					  printf ("Arr_2_Glob[8][7]:    %d\n", Arr_2_Glob[8][7]);
 | 
				
			||||||
  printf ("        should be:   Number_Of_Runs + 10\n");
 | 
					  printf ("        should be:   Number_Of_Runs + 10\n");
 | 
				
			||||||
  printf ("Ptr_Glob->\n");
 | 
					  printf ("Ptr_Glob->\n");
 | 
				
			||||||
  printf ("  Ptr_Comp:          %d\n", (int) Ptr_Glob->Ptr_Comp);
 | 
					  printf ("  Ptr_Comp:          %d\n", (long) Ptr_Glob->Ptr_Comp);
 | 
				
			||||||
  printf ("        should be:   (implementation-dependent)\n");
 | 
					  printf ("        should be:   (implementation-dependent)\n");
 | 
				
			||||||
  printf ("  Discr:             %d\n", Ptr_Glob->Discr);
 | 
					  printf ("  Discr:             %d\n", Ptr_Glob->Discr);
 | 
				
			||||||
  printf ("        should be:   %d\n", 0);
 | 
					  printf ("        should be:   %d\n", 0);
 | 
				
			||||||
@@ -223,7 +223,7 @@ main ()
 | 
				
			|||||||
  printf ("  Str_Comp:          %s\n", Ptr_Glob->variant.var_1.Str_Comp);
 | 
					  printf ("  Str_Comp:          %s\n", Ptr_Glob->variant.var_1.Str_Comp);
 | 
				
			||||||
  printf ("        should be:   DHRYSTONE PROGRAM, SOME STRING\n");
 | 
					  printf ("        should be:   DHRYSTONE PROGRAM, SOME STRING\n");
 | 
				
			||||||
  printf ("Next_Ptr_Glob->\n");
 | 
					  printf ("Next_Ptr_Glob->\n");
 | 
				
			||||||
  printf ("  Ptr_Comp:          %d\n", (int) Next_Ptr_Glob->Ptr_Comp);
 | 
					  printf ("  Ptr_Comp:          %d\n", (long) Next_Ptr_Glob->Ptr_Comp);
 | 
				
			||||||
  printf ("        should be:   (implementation-dependent), same as above\n");
 | 
					  printf ("        should be:   (implementation-dependent), same as above\n");
 | 
				
			||||||
  printf ("  Discr:             %d\n", Next_Ptr_Glob->Discr);
 | 
					  printf ("  Discr:             %d\n", Next_Ptr_Glob->Discr);
 | 
				
			||||||
  printf ("        should be:   %d\n", 0);
 | 
					  printf ("        should be:   %d\n", 0);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,5 @@
 | 
				
			|||||||
#include "platform.h"
 | 
					#include "platform.h"
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
#ifndef ITERATIONS
 | 
					#ifndef ITERATIONS
 | 
				
			||||||
#define ITERATIONS 20000
 | 
					#define ITERATIONS 20000
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@@ -6,20 +7,16 @@
 | 
				
			|||||||
/* The functions in this file are only meant to support Dhrystone on an
 | 
					/* The functions in this file are only meant to support Dhrystone on an
 | 
				
			||||||
 * embedded RV32 system and are obviously incorrect in general. */
 | 
					 * embedded RV32 system and are obviously incorrect in general. */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
long time(void)
 | 
					long time(void) { return get_timer_value(); }
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  return get_timer_value();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
// set the number of dhrystone iterations
 | 
					// set the number of dhrystone iterations
 | 
				
			||||||
void __wrap_scanf(const char* fmt, int* n)
 | 
					void __wrap_scanf(const char *fmt, int *n) { *n = ITERATIONS; }
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  *n = ITERATIONS;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern volatile uint32_t tohost;
 | 
					// extern volatile uint64_t tohost;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void exit(int n){
 | 
					void exit(int n) {
 | 
				
			||||||
      tohost = 0x1;
 | 
					  // tohost = 0x1;
 | 
				
			||||||
      for (;;);
 | 
					  write_hex(STDERR_FILENO, 1);
 | 
				
			||||||
 | 
					  for (;;)
 | 
				
			||||||
 | 
					    ;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,8 +4,9 @@ set(TARGET hello)
 | 
				
			|||||||
add_executable(${TARGET} hello.c)
 | 
					add_executable(${TARGET} hello.c)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set(BOARD "iss" CACHE STRING "Target board")
 | 
					set(BOARD "iss" CACHE STRING "Target board")
 | 
				
			||||||
add_subdirectory(../bare-metal-bsp bsp)
 | 
					add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../bare-metal-bsp bsp)
 | 
				
			||||||
target_link_libraries(${TARGET} PRIVATE bsp)
 | 
					target_link_libraries(${TARGET} PRIVATE bsp)
 | 
				
			||||||
 | 
					target_link_options(${TARGET} PRIVATE LINKER:-Map=${TARGET}.map)  
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_custom_command(TARGET ${TARGET} POST_BUILD
 | 
					add_custom_command(TARGET ${TARGET} POST_BUILD
 | 
				
			||||||
        COMMAND ${CMAKE_OBJDUMP} -S  ${TARGET}.elf > ${TARGET}.dis
 | 
					        COMMAND ${CMAKE_OBJDUMP} -S  ${TARGET}.elf > ${TARGET}.dis
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										122
									
								
								hello-world/CMakePresets.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										122
									
								
								hello-world/CMakePresets.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,122 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "version": 3,
 | 
				
			||||||
 | 
					    "vendor": {
 | 
				
			||||||
 | 
					        "conan": {}
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "cmakeMinimumRequired": {
 | 
				
			||||||
 | 
					        "major": 3,
 | 
				
			||||||
 | 
					        "minor": 24,
 | 
				
			||||||
 | 
					        "patch": 0
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "configurePresets": [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "32imc",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/../bare-metal-bsp/cmake/rv32imc.cmake"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "64imc",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/../bare-metal-bsp/cmake/rv64gc.cmake"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "iss",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "BOARD": "iss"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "moonlight",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "BOARD": "moonlight"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "tgc_vp",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "BOARD": "tgc_vp"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "rtl",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "BOARD": "rtl"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "debug",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "CMAKE_BUILD_TYPE": "Debug"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "release",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "cacheVariables": {    
 | 
				
			||||||
 | 
					                "CMAKE_BUILD_TYPE": "Release"
 | 
				
			||||||
 | 
					            }  
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "ISS_Debug",
 | 
				
			||||||
 | 
					            "inherits": ["iss", "debug", "32imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "Moonlight_Debug",
 | 
				
			||||||
 | 
					            "inherits": ["moonlight", "debug", "32imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "TGC_VP_Debug",
 | 
				
			||||||
 | 
					            "inherits": ["tgc_vp", "debug", "32imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "ISS_Debug_64",
 | 
				
			||||||
 | 
					            "inherits": ["iss", "debug", "64imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "Moonlight_Debug_64",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "inherits": ["moonlight", "debug", "64imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "TGC_VP_Debug_64",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "inherits": ["tgc_vp", "debug", "64imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "ISS_Release",
 | 
				
			||||||
 | 
					            "inherits": ["iss", "release", "32imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "Moonlight_Release",
 | 
				
			||||||
 | 
					            "inherits": ["moonlight", "release", "32imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "TGC_VP_Release",
 | 
				
			||||||
 | 
					            "inherits": ["tgc_vp", "release", "32imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "ISS_Release_64",        
 | 
				
			||||||
 | 
					            "inherits": ["iss", "release", "64imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "Moonlight_Release_64",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "inherits": ["moonlight", "release", "64imc"]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "TGC_VP_Release_64",
 | 
				
			||||||
 | 
					            "hidden": true,
 | 
				
			||||||
 | 
					            "inherits": ["tgc_vp", "release", "64imc"]
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					                 
 | 
				
			||||||
 | 
					    ]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,4 +1,3 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
TARGET  = hello
 | 
					TARGET  = hello
 | 
				
			||||||
ISA?=imc
 | 
					ISA?=imc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,24 +1,21 @@
 | 
				
			|||||||
#include <stdint.h>
 | 
					#include <stdint.h>
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					#include <sys/types.h>
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "platform.h"
 | 
					#include "platform.h"
 | 
				
			||||||
#include "encoding.h"
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					 | 
				
			||||||
int factorial(int i){
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	volatile int result = 1;
 | 
					 | 
				
			||||||
	for (int ii = 1; ii <= i; ii++) {
 | 
					 | 
				
			||||||
		result = result * ii;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return result;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int factorial(int i) {
 | 
				
			||||||
 | 
					  volatile int result = 1;
 | 
				
			||||||
 | 
					  for (int ii = 1; ii <= i; ii++) {
 | 
				
			||||||
 | 
					    result = result * ii;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main()
 | 
					int main() {
 | 
				
			||||||
{
 | 
					  int result = factorial(10);
 | 
				
			||||||
	volatile int result = factorial (10);
 | 
					  printf("Factorial is %d", result);
 | 
				
			||||||
	printf("Factorial is %d\n", result);
 | 
					  return 0;
 | 
				
			||||||
	printf("End of execution");
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user