Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
a2cd38fbd5 | |||
c7cd0843b8 | |||
83b2105c38 | |||
510695bf6e | |||
7258684a33 | |||
15cc2ece6f | |||
3e0eaba231 | |||
4bd2111c93 | |||
f99db9409f | |||
87539a8433 | |||
de4cf8f35a | |||
7d4bcea3ba | |||
339d6b0f2c | |||
36cb401420 | |||
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
|
|
@ -0,0 +1,14 @@
|
|||||||
|
if (NOT DEFINED BOARD)
|
||||||
|
set(BOARD iss)
|
||||||
|
endif()
|
||||||
|
if (NOT DEFINED ISA)
|
||||||
|
set(ISA imc)
|
||||||
|
endif()
|
||||||
|
if(DEFINED LINK_TARGET)
|
||||||
|
set(LNK LINK_TARGET=${LINK_TARGET})
|
||||||
|
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} ${LNK} && make -C benchmarks/dhrystone BOARD=${BOARD} ISA=${ISA} ${LNK} && make -C benchmarks/coremark BOARD=${BOARD} ISA=${ISA} ${LNK}
|
||||||
|
USES_TERMINAL
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
Submodule bare-metal-bsp updated: 540397494a...ca36d3ef84
@ -1,15 +1,7 @@
|
|||||||
cmake_minimum_required(VERSION 3.21)
|
cmake_minimum_required(VERSION 3.21)
|
||||||
project(coremark C)
|
project(coremark C)
|
||||||
set(TARGET coremark)
|
set(TARGET coremark)
|
||||||
#set(CMAKE_BUILD_TYPE Release)
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
|
|
||||||
option(HAVE_NO_INIT_FINI "Enable NO_INIT_FINI" OFF)
|
|
||||||
|
|
||||||
if(HAVE_NO_INIT_FINI)
|
|
||||||
#if HAVE_NO_INIT_FINI is ON
|
|
||||||
add_definitions(-DHAVE_NO_INIT_FINI)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
# Source files
|
# Source files
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
@ -23,7 +15,6 @@ set(SOURCES
|
|||||||
cm/core_util.c
|
cm/core_util.c
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# 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_include_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_LIST_DIR}/cm)
|
||||||
@ -33,13 +24,7 @@ target_compile_definitions(${TARGET} PRIVATE PERFORMANCE_RUN=1 CLOCKS_PER_SEC=10
|
|||||||
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 -Wl,-Map=${TARGET}.map)
|
target_link_options(${TARGET} PRIVATE LINKER:-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
|
add_custom_command(TARGET ${TARGET} POST_BUILD
|
||||||
COMMAND ${CMAKE_OBJDUMP} -S ${TARGET}.elf > ${TARGET}.dis
|
COMMAND ${CMAKE_OBJDUMP} -S ${TARGET}.elf > ${TARGET}.dis
|
||||||
|
@ -9,62 +9,110 @@
|
|||||||
"patch": 0
|
"patch": 0
|
||||||
},
|
},
|
||||||
"configurePresets": [
|
"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",
|
"name": "debug",
|
||||||
|
"hidden": true,
|
||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
"CMAKE_BUILD_TYPE": "Debug"
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "debug_moon",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "moonlight",
|
|
||||||
"HAVE_NO_INIT_FINI": "ON",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "debug_tgc",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "tgc_vp",
|
|
||||||
"HAVE_NO_INIT_FINI": "ON",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "debug_64",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "debug_64_moon",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "moonlight",
|
|
||||||
"HAVE_NO_INIT_FINI": "ON",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "debug_64_tgc",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "tgc_vp",
|
|
||||||
"HAVE_NO_INIT_FINI": "ON",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "release",
|
"name": "release",
|
||||||
"cacheVariables": {
|
"hidden": true,
|
||||||
"CMAKE_BUILD_TYPE": "Release",
|
"cacheVariables": {
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
"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"]
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -2,14 +2,7 @@ cmake_minimum_required(VERSION 3.21)
|
|||||||
project(dhrystone C)
|
project(dhrystone C)
|
||||||
set(TARGET dhrystone)
|
set(TARGET dhrystone)
|
||||||
|
|
||||||
option(HAVE_NO_INIT_FINI "Enable NO_INIT_FINI" OFF)
|
set(ITERATIONS 50000)
|
||||||
|
|
||||||
if(HAVE_NO_INIT_FINI)
|
|
||||||
#if HAVE_NO_INIT_FINI is ON
|
|
||||||
add_definitions(-DHAVE_NO_INIT_FINI)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(ITERATIONS 50000) # 20000 for TGC
|
|
||||||
|
|
||||||
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})
|
||||||
@ -19,12 +12,7 @@ target_compile_definitions(${TARGET} PRIVATE ITERATIONS=${ITERATIONS} HZ=32768 T
|
|||||||
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)
|
||||||
#target_link_options(${TARGET} PRIVATE LINKER:--wrap=scanf -Wl,--no-gc-sections)
|
|
||||||
|
|
||||||
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
|
add_custom_command(TARGET ${TARGET} POST_BUILD
|
||||||
COMMAND ${CMAKE_OBJDUMP} -S ${TARGET}.elf > ${TARGET}.dis
|
COMMAND ${CMAKE_OBJDUMP} -S ${TARGET}.elf > ${TARGET}.dis
|
||||||
|
@ -9,62 +9,110 @@
|
|||||||
"patch": 0
|
"patch": 0
|
||||||
},
|
},
|
||||||
"configurePresets": [
|
"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",
|
"name": "debug",
|
||||||
|
"hidden": true,
|
||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
"CMAKE_BUILD_TYPE": "Debug"
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "debug_moon",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "moonlight",
|
|
||||||
"HAVE_NO_INIT_FINI": "ON",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "debug_tgc",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "tgc_vp",
|
|
||||||
"HAVE_NO_INIT_FINI": "ON",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "debug_64",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "debug_64_moon",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "moonlight",
|
|
||||||
"HAVE_NO_INIT_FINI": "ON",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "debug_64_tgc",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "tgc_vp",
|
|
||||||
"HAVE_NO_INIT_FINI": "ON",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "release",
|
"name": "release",
|
||||||
"cacheVariables": {
|
"hidden": true,
|
||||||
"CMAKE_BUILD_TYPE": "Release",
|
"cacheVariables": {
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
"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,22 +1,12 @@
|
|||||||
cmake_minimum_required(VERSION 3.21)
|
cmake_minimum_required(VERSION 3.21)
|
||||||
project(hello-world C)
|
project(hello-world C)
|
||||||
set(TARGET hello)
|
set(TARGET hello)
|
||||||
option(HAVE_NO_INIT_FINI "Enable NO_INIT_FINI" OFF)
|
|
||||||
|
|
||||||
if(HAVE_NO_INIT_FINI)
|
|
||||||
#if HAVE_NO_INIT_FINI is ON
|
|
||||||
add_definitions(-DHAVE_NO_INIT_FINI)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_executable(${TARGET} hello.c)
|
add_executable(${TARGET} hello.c)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
set(BOARD "iss" CACHE STRING "Target board")
|
set(BOARD "iss" CACHE STRING "Target board")
|
||||||
message(" BOARD = ${BOARD}")
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../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 -Wl,-Map=${TARGET}.map)
|
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
|
||||||
|
@ -9,62 +9,110 @@
|
|||||||
"patch": 0
|
"patch": 0
|
||||||
},
|
},
|
||||||
"configurePresets": [
|
"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",
|
"name": "debug",
|
||||||
|
"hidden": true,
|
||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
"CMAKE_BUILD_TYPE": "Debug"
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "debug_moon",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "moonlight",
|
|
||||||
"HAVE_NO_INIT_FINI": "ON",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "debug_tgc",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "tgc_vp",
|
|
||||||
"HAVE_NO_INIT_FINI": "ON",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "debug_64",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "debug_64_moon",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "moonlight",
|
|
||||||
"HAVE_NO_INIT_FINI": "ON",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "debug_64_tgc",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug",
|
|
||||||
"BOARD": "tgc_vp",
|
|
||||||
"HAVE_NO_INIT_FINI": "ON",
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv64gc.cmake"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "release",
|
"name": "release",
|
||||||
"cacheVariables": {
|
"hidden": true,
|
||||||
"CMAKE_BUILD_TYPE": "Release",
|
"cacheVariables": {
|
||||||
"CMAKE_TOOLCHAIN_FILE": "../../bare-metal-bsp/cmake/rv32imc.cmake"
|
"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"]
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
TARGET = hello
|
TARGET = hello
|
||||||
ISA?=imc
|
ISA?=imc
|
||||||
|
|
||||||
|
@ -3,35 +3,19 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "encoding.h"
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
int factorial(int i) {
|
int factorial(int i) {
|
||||||
|
|
||||||
volatile int result = 1;
|
volatile int result = 1;
|
||||||
for (int ii = 1; ii <= i; ii++) {
|
for (int ii = 1; ii <= i; ii++) {
|
||||||
result = result * ii;
|
result = result * ii;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
extern volatile uintptr_t tohost;
|
|
||||||
|
|
||||||
void write_tohost(char *string) {
|
|
||||||
volatile uint64_t payload[4] = {64, 0, (uintptr_t)string,
|
|
||||||
(strlen(string) + 1)};
|
|
||||||
tohost = (uintptr_t)payload;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
char string[] = "hello world with write in hello";
|
|
||||||
|
|
||||||
write_tohost(string);
|
|
||||||
|
|
||||||
write(STDOUT_FILENO, string, sizeof(string));
|
|
||||||
|
|
||||||
int result = factorial(10);
|
int result = factorial(10);
|
||||||
printf("Factorial is %d", result);
|
printf("Factorial is %d", result);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user