Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
658ffbb405 | |||
c6bfaf0546 | |||
e88c1148fb | |||
686d01ab3e | |||
884d445cb9 | |||
eee14af478 | |||
727fdcb7bb | |||
3def42153f | |||
75ba2e7588 | |||
1629b165b5 | |||
a2e932c56f | |||
cde5ae627c | |||
85304d1a43 | |||
fddf608418 | |||
90c45d7c3c |
179
CMakeLists.txt
179
CMakeLists.txt
@ -1,11 +1,172 @@
|
||||
if (NOT DEFINED BOARD)
|
||||
set(BOARD iss)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
# 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()
|
||||
if (NOT DEFINED ISA)
|
||||
set(ISA imc)
|
||||
|
||||
# Allow override of compiler executables
|
||||
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()
|
||||
message(STATUS "Building firmware using ${BOARD} board configuration and isa ${ISA}")
|
||||
add_custom_target(fw-common ALL
|
||||
COMMAND make -C hello-world BOARD=${BOARD} ISA=${ISA} && make -C benchmarks/dhrystone BOARD=${BOARD} ISA=${ISA} && make -C benchmarks/coremark BOARD=${BOARD} ISA=${ISA}
|
||||
USES_TERMINAL
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
if(NOT DEFINED RISCV_GXX)
|
||||
set(RISCV_GXX "${RISCV_TOOLCHAIN_PATH}/riscv64-unknown-elf-g++" CACHE STRING "RISC-V G++ compiler")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED RISCV_OBJCOPY)
|
||||
set(RISCV_OBJCOPY "${RISCV_TOOLCHAIN_PATH}/riscv64-unknown-elf-objcopy" CACHE STRING "RISC-V objcopy")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED RISCV_OBJDUMP)
|
||||
set(RISCV_OBJDUMP "${RISCV_TOOLCHAIN_PATH}/riscv64-unknown-elf-objdump" CACHE STRING "RISC-V objdump")
|
||||
endif()
|
||||
|
||||
# Set the compilers
|
||||
set(CMAKE_C_COMPILER ${RISCV_GCC})
|
||||
set(CMAKE_CXX_COMPILER ${RISCV_GXX})
|
||||
|
||||
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++ ..")
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 87dc0ec2304adcb94a25b397a357aadae1304867
|
||||
Subproject commit 7d55172d51290ab1e9d36d40c600da0d7a386b69
|
40
benchmarks/coremark/CMakeLists.txt
Normal file
40
benchmarks/coremark/CMakeLists.txt
Normal file
@ -0,0 +1,40 @@
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
project(coremark C)
|
||||
set(TARGET coremark)
|
||||
#set(CMAKE_BUILD_TYPE Release)
|
||||
|
||||
|
||||
|
||||
# Source files
|
||||
set(SOURCES
|
||||
core_portme.c
|
||||
cvt.c
|
||||
ee_printf.c
|
||||
cm/core_list_join.c
|
||||
cm/core_main.c
|
||||
cm/core_matrix.c
|
||||
cm/core_state.c
|
||||
cm/core_util.c
|
||||
)
|
||||
|
||||
|
||||
# Create executable
|
||||
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-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)
|
||||
|
||||
set(BOARD "iss" CACHE STRING "Target board")
|
||||
add_subdirectory(../../bare-metal-bsp bsp)
|
||||
target_link_libraries(${TARGET} PRIVATE bsp)
|
||||
target_link_options(${TARGET} PRIVATE -Wl,-Map=${TARGET}.map)
|
||||
|
||||
include(CMakePrintHelpers)
|
||||
cmake_print_properties(TARGETS ${TARGET} PROPERTIES COMPILE_DEFINITIONS COMPILE_OPTIONS LINK_OPTIONS INTERFACE_LINK_OPTIONS)
|
||||
|
||||
#message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
|
||||
#message(STATUS "CMAKE_C_FLAGS = ${CMAKE_C_FLAGS}")
|
||||
|
||||
add_custom_command(TARGET ${TARGET} POST_BUILD
|
||||
COMMAND ${CMAKE_OBJDUMP} -S ${TARGET}.elf > ${TARGET}.dis
|
||||
COMMENT "Creating disassembly for ${TARGET}")
|
27
benchmarks/coremark/CMakePresets.json
Normal file
27
benchmarks/coremark/CMakePresets.json
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"version": 3,
|
||||
"vendor": {
|
||||
"conan": {}
|
||||
},
|
||||
"cmakeMinimumRequired": {
|
||||
"major": 3,
|
||||
"minor": 24,
|
||||
"patch": 0
|
||||
},
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "dbg",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Debug",
|
||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "rel",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Release",
|
||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -15,55 +15,54 @@ limitations under the License.
|
||||
|
||||
Original Author: Shay Gal-on
|
||||
*/
|
||||
#include "coremark.h"
|
||||
#include "core_portme.h"
|
||||
//Read cycle CSR
|
||||
unsigned long long _read_cycle()
|
||||
{
|
||||
unsigned long long result;
|
||||
unsigned long lower;
|
||||
unsigned long upper1;
|
||||
unsigned long upper2;
|
||||
#include "coremark.h"
|
||||
// Read cycle CSR
|
||||
unsigned long long _read_cycle() {
|
||||
unsigned long long result;
|
||||
unsigned long lower;
|
||||
unsigned long upper1;
|
||||
unsigned long upper2;
|
||||
|
||||
asm volatile (
|
||||
"repeat_cycle_%=: csrr %0, cycleh;\n"
|
||||
" csrr %1, cycle;\n"
|
||||
" csrr %2, cycleh;\n"
|
||||
" bne %0, %2, repeat_cycle_%=;\n"
|
||||
: "=r" (upper1),"=r" (lower),"=r" (upper2) // Outputs : temp variable for load result
|
||||
:
|
||||
:
|
||||
);
|
||||
*(unsigned long *)(&result) = lower;
|
||||
*((unsigned long *)(&result)+1) = upper1;
|
||||
asm volatile("repeat_cycle_%=: csrr %0, cycleh;\n"
|
||||
" csrr %1, cycle;\n"
|
||||
" csrr %2, cycleh;\n"
|
||||
" bne %0, %2, repeat_cycle_%=;\n"
|
||||
: "=r"(upper1), "=r"(lower),
|
||||
"=r"(upper2) // Outputs : temp variable for load result
|
||||
:
|
||||
:);
|
||||
*(unsigned long *)(&result) = lower;
|
||||
*((unsigned long *)(&result) + 1) = upper1;
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
volatile int tohost;
|
||||
volatile int fromhost;
|
||||
extern volatile int tohost;
|
||||
extern volatile int fromhost;
|
||||
|
||||
void exit(int n){
|
||||
tohost = 0x1;
|
||||
for (;;);
|
||||
void exit(int n) {
|
||||
tohost = 0x1;
|
||||
for (;;)
|
||||
;
|
||||
}
|
||||
|
||||
void __libc_init_array (void) {
|
||||
/*
|
||||
size_t count;
|
||||
size_t i;
|
||||
count = __preinit_array_end - __preinit_array_start;
|
||||
for (i = 0; i < count; i++)
|
||||
__preinit_array_start[i] ();
|
||||
void __libc_init_array(void) {
|
||||
/*
|
||||
size_t count;
|
||||
size_t i;
|
||||
count = __preinit_array_end - __preinit_array_start;
|
||||
for (i = 0; i < count; i++)
|
||||
__preinit_array_start[i] ();
|
||||
|
||||
#ifdef HAVE_INIT_FINI
|
||||
_init ();
|
||||
#endif
|
||||
#ifdef HAVE_INIT_FINI
|
||||
_init ();
|
||||
#endif
|
||||
|
||||
count = __init_array_end - __init_array_start;
|
||||
for (i = 0; i < count; i++)
|
||||
__init_array_start[i] ();
|
||||
*/
|
||||
count = __init_array_end - __init_array_start;
|
||||
for (i = 0; i < count; i++)
|
||||
__init_array_start[i] ();
|
||||
*/
|
||||
}
|
||||
#if VALIDATION_RUN
|
||||
volatile ee_s32 seed1_volatile = 0x3415;
|
||||
@ -89,10 +88,7 @@ volatile ee_s32 seed5_volatile = 0;
|
||||
time.h and windows.h definitions included.
|
||||
*/
|
||||
CORETIMETYPE
|
||||
barebones_clock()
|
||||
{
|
||||
return (CORETIMETYPE)_read_cycle();
|
||||
}
|
||||
barebones_clock() { return (CORETIMETYPE)_read_cycle(); }
|
||||
/* Define : TIMER_RES_DIVIDER
|
||||
Divider to trade off timer resolution and total time that can be
|
||||
measured.
|
||||
@ -101,11 +97,11 @@ barebones_clock()
|
||||
does not occur. If there are issues with the return value overflowing,
|
||||
increase this value.
|
||||
*/
|
||||
#define GETMYTIME(_t) (*_t = barebones_clock())
|
||||
#define MYTIMEDIFF(fin, ini) ((fin) - (ini))
|
||||
#define TIMER_RES_DIVIDER 1
|
||||
#define GETMYTIME(_t) (*_t = barebones_clock())
|
||||
#define MYTIMEDIFF(fin, ini) ((fin) - (ini))
|
||||
#define TIMER_RES_DIVIDER 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. */
|
||||
static CORETIMETYPE start_time_val, stop_time_val;
|
||||
@ -118,11 +114,7 @@ static CORETIMETYPE start_time_val, stop_time_val;
|
||||
example code) or zeroing some system parameters - e.g. setting the cpu clocks
|
||||
cycles to 0.
|
||||
*/
|
||||
void
|
||||
start_time(void)
|
||||
{
|
||||
GETMYTIME(&start_time_val);
|
||||
}
|
||||
void start_time(void) { GETMYTIME(&start_time_val); }
|
||||
/* Function : stop_time
|
||||
This function will be called right after ending the timed portion of the
|
||||
benchmark.
|
||||
@ -131,11 +123,7 @@ start_time(void)
|
||||
example code) or other system parameters - e.g. reading the current value of
|
||||
cpu cycles counter.
|
||||
*/
|
||||
void
|
||||
stop_time(void)
|
||||
{
|
||||
GETMYTIME(&stop_time_val);
|
||||
}
|
||||
void stop_time(void) { GETMYTIME(&stop_time_val); }
|
||||
/* Function : get_time
|
||||
Return an abstract "ticks" number that signifies time on the system.
|
||||
|
||||
@ -146,11 +134,9 @@ stop_time(void)
|
||||
controlled by <TIMER_RES_DIVIDER>
|
||||
*/
|
||||
CORE_TICKS
|
||||
get_time(void)
|
||||
{
|
||||
CORE_TICKS elapsed
|
||||
= (CORE_TICKS)(MYTIMEDIFF(stop_time_val, start_time_val));
|
||||
return elapsed;
|
||||
get_time(void) {
|
||||
CORE_TICKS elapsed = (CORE_TICKS)(MYTIMEDIFF(stop_time_val, start_time_val));
|
||||
return elapsed;
|
||||
}
|
||||
/* Function : time_in_secs
|
||||
Convert the value returned by get_time to seconds.
|
||||
@ -159,11 +145,9 @@ get_time(void)
|
||||
floating point. Default implementation implemented by the EE_TICKS_PER_SEC
|
||||
macro above.
|
||||
*/
|
||||
secs_ret
|
||||
time_in_secs(CORE_TICKS ticks)
|
||||
{
|
||||
secs_ret retval = ((secs_ret)ticks) / (secs_ret)EE_TICKS_PER_SEC;
|
||||
return retval;
|
||||
secs_ret time_in_secs(CORE_TICKS ticks) {
|
||||
secs_ret retval = ((secs_ret)ticks) / (secs_ret)EE_TICKS_PER_SEC;
|
||||
return retval;
|
||||
}
|
||||
|
||||
ee_u32 default_num_contexts = 1;
|
||||
@ -172,27 +156,18 @@ ee_u32 default_num_contexts = 1;
|
||||
Target specific initialization code
|
||||
Test for some common mistakes.
|
||||
*/
|
||||
void
|
||||
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 "
|
||||
"pointer!\n");
|
||||
}
|
||||
if (sizeof(ee_u32) != 4)
|
||||
{
|
||||
ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n");
|
||||
}
|
||||
p->portable_id = 1;
|
||||
ee_printf("portable_init finished.\n");
|
||||
void 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 "
|
||||
"pointer!\n");
|
||||
}
|
||||
if (sizeof(ee_u32) != 4) {
|
||||
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
|
||||
Target specific final code
|
||||
*/
|
||||
void
|
||||
portable_fini(core_portable *p)
|
||||
{
|
||||
p->portable_id = 0;
|
||||
}
|
||||
void portable_fini(core_portable *p) { p->portable_id = 0; }
|
||||
|
File diff suppressed because it is too large
Load Diff
1
benchmarks/dhrystone/.gitignore
vendored
1
benchmarks/dhrystone/.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
dhrystone
|
||||
/dhrystone.dis
|
||||
build/
|
22
benchmarks/dhrystone/CMakeLists.txt
Normal file
22
benchmarks/dhrystone/CMakeLists.txt
Normal file
@ -0,0 +1,22 @@
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
project(dhrystone C)
|
||||
set(TARGET dhrystone)
|
||||
|
||||
set(ITERATIONS 50000) # 20000 for TGC
|
||||
|
||||
add_executable(${TARGET} dhry_1.c dhry_2.c dhry_stubs.c)
|
||||
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_definitions(${TARGET} PRIVATE ITERATIONS=${ITERATIONS} HZ=32768 TIME NO_INIT)
|
||||
|
||||
set(BOARD "iss" CACHE STRING "Target board")
|
||||
add_subdirectory(../../bare-metal-bsp bsp)
|
||||
target_link_libraries(${TARGET} PRIVATE bsp)
|
||||
target_link_options(${TARGET} PRIVATE LINKER:--wrap=scanf)
|
||||
target_link_options(${TARGET} PRIVATE -Wl,-Map=${TARGET}.map)
|
||||
include(CMakePrintHelpers)
|
||||
cmake_print_properties(TARGETS ${TARGET} PROPERTIES COMPILE_DEFINITIONS COMPILE_OPTIONS LINK_OPTIONS INTERFACE_LINK_OPTIONS)
|
||||
|
||||
add_custom_command(TARGET ${TARGET} POST_BUILD
|
||||
COMMAND ${CMAKE_OBJDUMP} -S ${TARGET}.elf > ${TARGET}.dis
|
||||
COMMENT "Creating disassembly for ${TARGET}")
|
27
benchmarks/dhrystone/CMakePresets.json
Normal file
27
benchmarks/dhrystone/CMakePresets.json
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"version": 3,
|
||||
"vendor": {
|
||||
"conan": {}
|
||||
},
|
||||
"cmakeMinimumRequired": {
|
||||
"major": 3,
|
||||
"minor": 24,
|
||||
"patch": 0
|
||||
},
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "dbg",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Debug",
|
||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "rel",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Release",
|
||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -17,6 +17,7 @@ endif
|
||||
# '-lgcc -lm' are needed to add softfloat routines
|
||||
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
|
||||
LDFLAGS := -Wl,--wrap=scanf
|
||||
|
||||
TOOL_DIR=$(dir $(compiler))
|
||||
|
||||
|
1
hello-world/.gitignore
vendored
1
hello-world/.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
/hello
|
||||
/hello.dis
|
||||
build/
|
12
hello-world/CMakeLists.txt
Normal file
12
hello-world/CMakeLists.txt
Normal file
@ -0,0 +1,12 @@
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
project(hello-world C)
|
||||
set(TARGET hello)
|
||||
add_executable(${TARGET} hello.c)
|
||||
|
||||
set(BOARD "iss" CACHE STRING "Target board")
|
||||
add_subdirectory(../bare-metal-bsp bsp)
|
||||
target_link_libraries(${TARGET} PRIVATE bsp)
|
||||
|
||||
add_custom_command(TARGET ${TARGET} POST_BUILD
|
||||
COMMAND ${CMAKE_OBJDUMP} -S ${TARGET}.elf > ${TARGET}.dis
|
||||
COMMENT "Creating disassembly for ${TARGET}")
|
27
hello-world/CMakePresets.json
Normal file
27
hello-world/CMakePresets.json
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"version": 3,
|
||||
"vendor": {
|
||||
"conan": {}
|
||||
},
|
||||
"cmakeMinimumRequired": {
|
||||
"major": 3,
|
||||
"minor": 24,
|
||||
"patch": 0
|
||||
},
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "dbg",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Debug",
|
||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "rel",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Release",
|
||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -1,24 +1,33 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "encoding.h"
|
||||
#include "platform.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;
|
||||
}
|
||||
extern volatile uint32_t tohost;
|
||||
extern volatile uint32_t fromhost;
|
||||
int main() {
|
||||
volatile int result = factorial(10);
|
||||
volatile char string[] = "hello world with write in hello";
|
||||
|
||||
int main()
|
||||
{
|
||||
volatile int result = factorial (10);
|
||||
printf("Factorial is %d\n", result);
|
||||
printf("End of execution");
|
||||
return 0;
|
||||
volatile uint64_t payload[4] = {64, 0, (uintptr_t)string,
|
||||
(strlen(string) + 1)};
|
||||
tohost = (uint32_t)payload;
|
||||
|
||||
write(STDOUT_FILENO, string, sizeof(string));
|
||||
|
||||
printf("Factorial is %d", result);
|
||||
// printf("End of execution");
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user