Skip to content

Commit 45d7373

Browse files
committed
SDK Re-aligned with RTL, tested on main magia_v3
1 parent 8b26080 commit 45d7373

11 files changed

Lines changed: 40 additions & 69 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ endif ()
6464
if (COMPILER STREQUAL "GCC_MULTILIB")
6565
set(ISA rv32imc_xcvalu_xcvbi_xcvbitmanip_xcvhwlp_xcvmac_xcvmem_xcvsimd_xcvelw_zfinx_zhinxmin)
6666
set(CV32E40P 1)
67+
else ()
68+
set(CV32E40P 0)
6769
endif ()
6870

6971
message(STATUS "[MAGIA-SDK] ABI : ${ABI}")

cmake/pulp_config.cmake

Lines changed: 11 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ set(PULP_CORE_COUNT 8 CACHE STRING "Number of PULP cores per cluster")
1414
# ISA/ABI — same toolchain as CV32 Controller
1515
set(PULP_ARCH rv CACHE STRING "PULP32 ARCH prefix")
1616
set(PULP_XLEN 32 CACHE STRING "PULP32 XLEN")
17+
if (${COMPILER_NAME} STREQUAL "riscv64-unknown-elf-gcc")
1718
set(PULP_XTEN imc_xcvalu_xcvbi_xcvbitmanip_xcvhwlp_xcvmac_xcvmem_xcvsimd_xcvelw_zfinx_zhinxmin CACHE STRING "PULP32 ISA extensions")
19+
else ()
20+
set(PULP_XTEN imcxgap9 CACHE STRING "PULP32 ISA extensions")
21+
endif ()
1822
set(PULP_ABI ilp CACHE STRING "PULP32 ABI prefix")
1923
set(PULP_MARCH "-march=${PULP_ARCH}${PULP_XLEN}${PULP_XTEN}")
2024
set(PULP_MABI "-mabi=${PULP_ABI}${PULP_XLEN}")
@@ -24,6 +28,7 @@ set(PULP_ARCH_FLAGS
2428
${PULP_MARCH}
2529
${PULP_MABI}
2630
)
31+
2732
set(PULP_COMPILE_FLAGS
2833
${PULP_ARCH_FLAGS}
2934
"-O2"
@@ -38,74 +43,28 @@ set(PULP_COMPILE_FLAGS
3843
"-fdata-sections"
3944
"-fPIC"
4045
"-mcmodel=medany"
41-
"-fno-builtin"
4246
"-fno-jump-tables"
43-
"-fno-common"
4447
"-msmall-data-limit=0"
4548
"-DPULP_CORE_COUNT=${PULP_CORE_COUNT}"
46-
"-DCV32E40P"
4749
"-nostartfiles"
4850
"-nostdlib"
4951
"-U__riscv__"
50-
"-static"
5152
)
53+
5254
set(PULP_CFLAGS_DEFINES
5355
"-DPULP_CORE_COUNT=${PULP_CORE_COUNT}"
5456
"-DPULP_TARGET"
55-
"-DCV32E40P"
57+
"-DCV32E40P=${CV32E40P}"
5658
# "-save-temps"
5759
)
58-
set(PULP_LINK_FLAGS
59-
${PULP_ARCH_FLAGS}
60+
61+
set(PULP_LINK_FLAGS
62+
${PULP_ARCH_FLAGS}
6063
"-nostartfiles"
6164
"-nostdlib"
62-
"-Wl,--gc-sections"
63-
"-Wl,--allow-multiple-definition"
64-
"-T${PULP_LINK_SCRIPT}"
65-
"-flto"
6665
"-Wl,-z,norelro"
66+
"-Wl,--allow-multiple-definition"
6767
)
68-
# # Compiler flags for PULP task binary (position-independent, bare-metal)
69-
# set(PULP_COMPILE_FLAGS
70-
# ${PULP_MARCH}
71-
# ${PULP_MABI}
72-
# "-fPIC"
73-
# "-mcmodel=medany"
74-
# "-static"
75-
# "-nostartfiles"
76-
# "-nostdlib"
77-
# "-O2"
78-
# "-g"
79-
# "-Wall"
80-
# "-Wextra"
81-
# "-Wno-unused-parameter"
82-
# "-Wno-unused-variable"
83-
# "-Wno-unused-function"
84-
# "-Wundef"
85-
# "-fno-common"
86-
# "-ffunction-sections"
87-
# "-fdata-sections"
88-
# "-fno-builtin"
89-
# "-fno-jump-tables"
90-
# "-msmall-data-limit=0"
91-
# )
92-
93-
# set(PULP_CFLAGS_DEFINES
94-
# "-DPULP_CORE_COUNT=${PULP_CORE_COUNT}"
95-
# "-DPULP_TARGET"
96-
# "-DCV32E40P=${CV32E40P}"
97-
# "-save-temps"
98-
# )
99-
100-
# set(PULP_LINK_FLAGS
101-
# "-nostartfiles"
102-
# "-nostdlib"
103-
# "-Wl,-z,norelro"
104-
# "-Wl,--allow-multiple-definition"
105-
# "-flto"
106-
# "-Wl,--gc-sections"
107-
# "-Wl,--undefined=hello_task"
108-
# )
10968

11069
# add_pulp_task defaults
11170
set(PULP_TASK_OUTPUT_ROOT "${CMAKE_BINARY_DIR}/bin/${TARGET_PLATFORM}")

cmake/pulp_helpers.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function(add_pulp_task)
8484
${TASK_INCLUDE_FLAGS}
8585
${PULP_LINK_FLAGS}
8686
${TASK_UNDEF_FLAGS}
87-
# -T${PULP_LINK_SCRIPT}
87+
-T${PULP_LINK_SCRIPT}
8888
-o ${TASK_ELF}
8989
${TASK_CRT0_OBJ}
9090
${MAGIA_IO_SRC}
@@ -198,8 +198,8 @@ function(add_cv32_executable_with_pulp)
198198
${PULP_HEADER_DIR}
199199
)
200200

201-
target_compile_options(${ARG_TARGET_NAME} PRIVATE ${CV32_COMPILE_FLAGS})
202-
target_link_options(${ARG_TARGET_NAME} PRIVATE ${CV32_LINK_FLAGS})
201+
target_compile_options(${ARG_TARGET_NAME} PRIVATE ${PULP_COMPILE_FLAGS})
202+
target_link_options(${ARG_TARGET_NAME} PRIVATE ${PULP_LINK_FLAGS})
203203
target_link_libraries(${ARG_TARGET_NAME} PUBLIC runtime hal)
204204

205205
add_dependencies(${ARG_TARGET_NAME} ${${ARG_TARGET_NAME}_PULP_TARGET})
@@ -273,8 +273,8 @@ function(add_cv32_executable_with_pulp_and_spatz)
273273
${PULP_HEADER_DIR}
274274
)
275275

276-
target_compile_options(${ARG_TARGET_NAME} PRIVATE ${CV32_COMPILE_FLAGS})
277-
target_link_options(${ARG_TARGET_NAME} PRIVATE ${CV32_LINK_FLAGS})
276+
target_compile_options(${ARG_TARGET_NAME} PRIVATE ${PULP_COMPILE_FLAGS})
277+
target_link_options(${ARG_TARGET_NAME} PRIVATE ${PULP_LINK_FLAGS})
278278
target_link_libraries(${ARG_TARGET_NAME} PUBLIC runtime hal)
279279

280280
add_dependencies(${ARG_TARGET_NAME}

cmake/toolchain_gcc_multilib.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ set(CMAKE_EXECUTABLE_SUFFIX ".elf")
1010
set(CMAKE_SYSTEM_NAME Generic)
1111

1212
set(CMAKE_C_COMPILER riscv64-unknown-elf-gcc)
13+
set(COMPILER_NAME riscv64-unknown-elf-gcc)
1314
set(CMAKE_CXX_COMPILER riscv64-unknown-elf-g++)
1415
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
1516
set(CMAKE_OBJCOPY riscv64-unknown-elf-objcopy)
1617
set(CMAKE_OBJDUMP riscv64-unknown-elf-objdump)
17-
set(CMAKE_AR riscv64-unknown-elf-ar)
18+
set(CMAKE_AR riscv64-unknown-elf-ar)
19+

cmake/toolchain_gcc_pulp.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ set(CMAKE_EXECUTABLE_SUFFIX ".elf")
1010
set(CMAKE_SYSTEM_NAME Generic)
1111

1212
set(CMAKE_C_COMPILER riscv32-unknown-elf-gcc)
13+
set(COMPILER_NAME riscv32-unknown-elf-gcc)
1314
set(CMAKE_CXX_COMPILER riscv32-unknown-elf-g++)
1415
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
1516
set(CMAKE_OBJCOPY riscv32-unknown-elf-objcopy)

scripts/extract_pulp_symbols.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ echo "#define PULP_BINARY_START ((uint32_t)&_pulp_binary_start)" >> "${TASK_HEAD
2626
# Add task function entry points (all global functions with 'task' in their name)
2727
echo "" >> "${TASK_HEADER}"
2828
echo "/* Task function entry points - OFFSETS from PULP_BINARY_START */" >> "${TASK_HEADER}"
29-
"${OBJDUMP}" -t "${TASK_ELF}" | awk '$2 == "g" && $NF ~ /task/ {print $1, $NF}' | while read addr name; do
29+
"${OBJDUMP}" -t "${TASK_ELF}" | grep -E "F .text.*task" | awk '{print $1, $NF}' | while read addr name; do
3030
if [[ "$name" != "__first_task" ]]; then
3131
TASK_NAME=$(echo "$name" | tr 'a-z' 'A-Z')
3232
echo "#define ${TASK_NAME} (PULP_BINARY_START + 0x${addr})" >> "${TASK_HEADER}"

targets/magia_v3/include/utils/eu_isa_utils.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,13 @@ static inline uint32_t eu_wait_events_polling(uint32_t event_mask, uint32_t time
151151
static inline unsigned int evt_read32(unsigned int addr)
152152
{
153153
unsigned int value;
154-
// Direct p.elw inline assembly for PULP cores (RI5CY, CV32E40P)
154+
// Direct p.elw inline assembly for PULP cores (CV32E40P)
155155
#if STALLING == 0
156+
#if CV32E40P == 1
156157
__asm__ __volatile__("cv.elw %0, 0(%1)" : "=r"(value) : "r"(addr) : "memory");
158+
#else
159+
__asm__ __volatile__("p.elw %0, 0(%1)" : "=r"(value) : "r"(addr) : "memory");
160+
#endif
157161
#endif
158162
return value;
159163
}

targets/magia_v3/include/utils/typedefs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define TYPEDEFS_H_
33

44
// GCC_MULTILIB doesn't know what a float16 is.
5-
#if CV32E40P
5+
#if CV32E40P == 1
66
typedef _Float16 float16;
77
#endif
88

tests/magia/mesh/hello_world/src/test.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ int main(void)
1616

1717
int test = NULL;
1818

19-
// volatile float a = -12.0456f;
20-
// volatile float b = 4.0f;
21-
// volatile float c = (a + b);
19+
volatile float16 a = -12.0456f;
20+
volatile float16 b = 4.0f;
21+
volatile float16 c = (a + b);
2222
int test_integer = -123;
2323

24-
// uint32_t *v = (uint32_t *) &c;
25-
// printf("Hello world! %#x\n", *v);
24+
uint32_t *v = (uint32_t *) &c;
25+
printf("Hello world! %#x\n", *v);
2626
// printf("Hello world! %f\n", c);
2727
printf("Hello world! %d\n", test_integer);
2828

tests/pulp_on_magia/hello_pulp/pulp_task/hello_task.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
#include "tile.h"
1+
#include "utils/magia_utils.h"
2+
#include "addr_map/tile_addr_map.h"
3+
#include "utils/printf.h"
4+
25

36
void hello_pulp_task(void)
47
{
58
uint32_t hartid = get_hartid();
69
uint32_t local_id = GET_PULP_LOCAL_ID(hartid);
710
uint32_t tile_id = GET_PULP_TILE_ID(hartid);
8-
wait_nop((tile_id + 1) * hartid * 2000);
11+
//wait_nop((tile_id + 1) * hartid * 2000);
912
printf("[PULP][tile-id=%u local-core-id=%u global-hartid=%u] Hello from PULP!\n",
1013
tile_id,
1114
local_id,

0 commit comments

Comments
 (0)