esl-epfl / x-heep

eXtendable Heterogeneous Energy-Efficient Platform based on RISC-V
Other
140 stars 75 forks source link

Confict in HEX format file for simulation #337

Closed danivz closed 1 year ago

danivz commented 1 year ago

By default the HEX format generated with CMake is verilog, used in tb_util.sv to load the program directly into memory: https://github.com/esl-epfl/x-heep/blob/8f2351053dd240d4e6a01ac90cfcd49fb78a747c/tb/tb_util.svh.tpl#L24C1-L28C8

However, If it's needed to program the system with JTAG to simulate and validate the debug module, this HEX format is not supported by the ETH SystemVerilog packages jtag_pkg.sv and srec_pkg.sv. This code only supports the SREC HEX format.

I have solved this patching CMakeLists.txt with:

diff --git a/sw/CMakeLists.txt b/sw/CMakeLists.txt
index c1d9e1d..00092de 100644
--- a/sw/CMakeLists.txt
+++ b/sw/CMakeLists.txt
@@ -299,7 +299,7 @@ if((${LINKER} STREQUAL "flash_load") OR (${LINKER} STREQUAL "flash_exec"))
             COMMENT "Invoking: Hexdump")
 else()
     add_custom_command(TARGET ${MAINFILE}.elf POST_BUILD
-            COMMAND ${CMAKE_OBJCOPY} -O verilog  ${MAINFILE}.elf  ${MAINFILE}.hex 
+            COMMAND ${CMAKE_OBJCOPY} --srec-forceS3 --srec-len 1 -O srec  ${MAINFILE}.elf  ${MAINFILE}.hex
             COMMENT "Invoking: Hexdump")
 endif()

It might be interesting to add a flag to the CMake flow to choose the preferred HEX file format. HEEPocrates and its derived repos need this format for the simulations.

davideschiavone commented 1 year ago

we can dump both the formats, it is not needed to select which of the 2. In HEEPpocrates testbench we used the JTAG functions to load the .HEX , you can check how we did there

benoitdenkinger commented 1 year ago

Just to clarify, in HEEPocrates, we used the SREC format, but we still used the HEX extension in the name to avoid confusing people, as it was a late modification. We couldn't make openocd work for HEEPocrates, so we switched to the PULP jtag_pkg.sv library to control the jtag (which required the SREC format).

JoseCalero commented 1 year ago

I think this is solved already, right?