Skip to content

Commit

Permalink
Riscv sail update (#8)
Browse files Browse the repository at this point in the history
* riscof and sail support update.

* bash script executed with bash instead of sh.

* Added compile definition forwarding for riscof testsuite.

* .text.vecs sections placed close to .text start.

* Removed global compilation forward to test (change reverted).

---------

Co-authored-by: Benoit Denkinger <[email protected]>
  • Loading branch information
benoitdenkinger and Benoit Denkinger authored Jun 19, 2024
1 parent de1d8ec commit a213f18
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 19 deletions.
12 changes: 6 additions & 6 deletions cmake/firmware/add_tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function(add_tests EXECUTABLE DIRECTORY)
if(ARG_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "${CMAKE_CURRENT_FUNCTION} passed unrecognized argument " "${ARG_UNPARSED_ARGUMENTS}")
endif()

include("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../utils/subdirectory_search.cmake")
include("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../utils/colours.cmake")
include("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/fw_utils.cmake")
Expand All @@ -18,7 +18,7 @@ function(add_tests EXECUTABLE DIRECTORY)
else()
set(PREFIX --)
endif()

unset(msg)
list(APPEND _msg "-------------------------------------------------------------------------\n")
string(REPLACE "__" "::" ALIAS_NAME ${SOC_NAME})
Expand All @@ -40,16 +40,16 @@ function(add_tests EXECUTABLE DIRECTORY)
get_target_property(HEX_DATA_FILE ${fw_prj} HEX_DATA_${ARG_WIDTH}bit_FILE)
add_test(
NAME ${fw_prj}
COMMAND ./${EXECUTABLE}
${PREFIX}firmware=${HEX_FILE}
COMMAND ./${EXECUTABLE}
${PREFIX}firmware=${HEX_FILE}
${PREFIX}firmware_text=${HEX_TEXT_FILE}
${PREFIX}firmware_data=${HEX_DATA_FILE}
${ARG_ARGS}
)

add_custom_target(run_${fw_prj}
COMMAND ./${EXECUTABLE}
${PREFIX}firmware=${HEX_FILE}
COMMAND ./${EXECUTABLE}
${PREFIX}firmware=${HEX_FILE}
${PREFIX}firmware_text=${HEX_TEXT_FILE}
${PREFIX}firmware_data=${HEX_DATA_FILE}
${ARG_ARGS}
Expand Down
2 changes: 2 additions & 0 deletions cmake/firmware/linker_script/src/gen_linker_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class RDL2LdsExporter(RDLListener):
"""
def __init__(self):
self.memories = []
# SystemRDL registers with the UDP linker_symbol set to true
# These register adresses are exposed in the linker script
self.regs = []

def enter_Mem(self, node):
Expand Down
2 changes: 2 additions & 0 deletions cmake/firmware/linker_script/src/lds_props.rdl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ property sections {
component = mem;
};

// This property generate a symbol with the register
// absolute address in the linker script
property linker_symbol { // MOve to LDS_gen
type = boolean;
component = reg;
Expand Down
2 changes: 2 additions & 0 deletions cmake/firmware/linker_script/src/template/linker.lds.j2
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ SECTIONS
{
*(.text.unlikely .text.unlikely.*)
*(.text.startup .text.startup.*)
/* Keep interrupt handlers close to vector table */
*(.text.vecs*)
*(.text .text.*)
*(.gnu.linkonce.t.*)
} > {{ prog_mem.parent.inst_name }}
Expand Down
2 changes: 1 addition & 1 deletion cmake/firmware/toolchains/riscv_toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ set(CMAKE_EXE_LINKER_FLAGS "")
# a : Atomic instructions
# c : Compressed instructions
# zicsr : CSR Instructions (explicitely required with latest specs)
string(APPEND CMAKE_C_FLAGS " -march=rv32imac_zicsr")
string(APPEND CMAKE_C_FLAGS " -march=rv32imc_zicsr")
# int and pointers are 32bit, long 64bit, char 8bit, short 16bit
string(APPEND CMAKE_C_FLAGS " -mabi=ilp32")

Expand Down
25 changes: 13 additions & 12 deletions cmake/riscv/sail/sail_install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include_guard(GLOBAL)

set(SAIL_INSTALL_LIST_DIR ${CMAKE_CURRENT_LIST_DIR} CACHE INTERNAL "")

# SAIL C-emulator installation macro
macro(sail_install)
cmake_parse_arguments(ARG "" "" "" ${ARGN})
if(ARG_UNPARSED_ARGUMENTS)
Expand All @@ -12,30 +13,30 @@ macro(sail_install)
include("${SAIL_INSTALL_LIST_DIR}/../../utils/colours.cmake")
find_python3()

# Try to find SAIL executable
find_program(RISCV32_SAIL_EXE riscv_sim_RV32
HINTS ${FETCHCONTENT_BASE_DIR}/sail/*/*
${SAIL_HOME}/* $ENV{SAIL_HOME}/*
)

# Install SAIL if executable not found
if(NOT RISCV32_SAIL_EXE)

execute_process(COMMAND ${Python3_EXECUTABE} -m pip install -e ${SAIL_INSTALL_LIST_DIR}/requirements.txt)
execute_process(COMMAND /bin/sh ${SAIL_INSTALL_LIST_DIR}/install_sail.sh
execute_process(COMMAND /bin/bash ${SAIL_INSTALL_LIST_DIR}/install_sail.sh
--prefix ${FETCHCONTENT_BASE_DIR}/sail
--build-dir ${FETCHCONTENT_BASE_DIR}/sail-build
)
)

find_program(RISCV32_SAIL_EXE riscv_sim_RV32 REQUIRED
HINTS ${FETCHCONTENT_BASE_DIR}/sail/*/*
find_program(RISCV32_SAIL_EXE riscv_sim_RV32 REQUIRED
HINTS ${FETCHCONTENT_BASE_DIR}/sail/*/*
)

msg("-----------------------------------------------------------------" Yellow)
msg("- Successfull installation of Riscv-Sail" Yellow)
msg("- You can now delete directory ${FETCHCONTENT_BASE_DIR}/sail-build" Yellow)
msg("- Keep the binary installed in ${RISCV32_SAIL_EXE}" Yellow)
msg("- Variable is created holding path to sail binary RISCV32_SAIL_EXE" Yellow)
msg("-----------------------------------------------------------------" Yellow)

msg("-----------------------------------------------------------------" Yellow)
msg("- Successfull installation of Riscv-Sail" Yellow)
msg("- You can now delete directory ${FETCHCONTENT_BASE_DIR}/sail-build" Yellow)
msg("- Keep the binary installed in ${RISCV32_SAIL_EXE}" Yellow)
msg("- Variable is created holding path to sail binary RISCV32_SAIL_EXE" Yellow)
msg("-----------------------------------------------------------------" Yellow)
endif()

endmacro()

0 comments on commit a213f18

Please sign in to comment.