Repository navigation
[hal] add Erbium HAL(HW generated constants), relocate etsoc-hal under hal/platform/, replace sw-sysemu hard-coded constants - #128
Conversation
|
cc @FCLC as I can't add you to review list. |
vidas
left a comment
There was a problem hiding this comment.
Great job for an MVP!
Some notes (opinions/thinking out loud):
- I'm not sure how interchangeable we want etsoc-hal and erbium-hal to be. The only project that could use both directly is gp-sdk, but I expect gp-sdk to have explicit ifdefs.
- I don't think we should strive for any compatibility with etsoc-hal (therefore keeping etsoc-hal project as is and only use it for inspiration)
- It's not obvious (without cmakelists) how should I configure my
-Iand what files to include for common use. Should we have flatincludestructure perhaps? topis weird naming in software context.esr_addrexpectsshireargument, when Erbium doesn't have meaningful one. We will need one for soc1sim simulator though (defined at compile time?). Question: what would be the right way to introduce it? Have compile time SHIRE_ID symbol/define? Use it implicitly inesr_addr? Let users take care of it explicitly and never to assume shire_id to be zero even on actual Erbium?
| uint32_t subregion, uint32_t offset) | ||
| { | ||
| return (uintptr_t)ERBIUM_TOP_CPU_REGISTERS_BASE | ||
| | ((uint64_t)(shire & 0x7F) << 24) |
There was a problem hiding this comment.
I removed this, but the meaning of this is that in the encoding, those bits mean shire. Although for erbium they are all 0 AFAIK.
|
@vidas Helper functions were removed. We will deal with interchangeability on et-common-libs. I think I'm keeping top.h because the mapping from RDL is cleaner, but if you have strong opinions, I can always change it to something like mem_regions esr_addr isn't part oft his commit anymore. |
|
There's also a question for this PR wether we should keep the HAL name, given that this is just HW constant defitions from erbium side. @glguida Please review the CMake, it makes sense to me and looks aligned with the project. |
vidas
left a comment
There was a problem hiding this comment.
LGTM - I already use it daily, seems to work.
Pipeline that reproduces erbium-hal/include/hwinc/ from Erbium SystemRDL sources: - rdl2hal.py converts one SystemRDL register block into a Semifore-style C header. It emits per-register _ADDRESS, _OFFSET, _SIZE, _RESET_VALUE, field accessor macros, and a block-level typedef struct. - top2h.py parses the top-level address-map RDL and emits <PLATFORM>_TOP_<INSTANCE>_BASE macros for every peripheral instance, including nested external regions such as BOOTROM and SRAM inside ROMRAM. - csr2rdl.py converts the Minion CSR CSV into synthetic SystemRDL as a byte-addressed register map, using byte_offset = csr_number * 8, so the same RDL-to-C generator can handle the CSR block. This is adapted from the hardware team csr2rdl.py. - gen_all_headers.py is the driver. It invokes csr2rdl.py for Minion CSRs, rdl2hal.py per peripheral, and top2h.py for the top map. All input paths are provided by the caller through CLI flags or environment variables. The scripts do not hardcode RTL-tree paths.
Add the Erbium HAL as a repo-root host package under erbium-hal/. - include/hwinc/ contains Semifore-style register headers for Erbium peripherals generated by erbium-hal/scripts: esr, plic, uart, system, i2c, qspi, minion_csr, plus top.h for the top-level address map. - CMakeLists.txt declares erbium_hal as a header-only INTERFACE library, installs the hwinc/ headers, and exports erbium_hal::erbium_hal for consumers that use find_package(erbium_hal REQUIRED). - erbium_halConfig.cmake.in provides the package config boilerplate used by downstream CMake projects. The top-level build registers erbium-hal with HostProject(erbium-hal "") so it is built and installed from the repository root rather than through hal/platform/erbium.
Replace hardcoded Erbium memory-map addresses, register addresses, field layouts, and read/write masks in sw-sysemu with macros from the Erbium HAL hwinc/ headers.
Updated areas:
- pma_er.cpp uses hwinc/top.h for paddr_is_* region predicates and the MRAM PMP MRAM_BASE constant.
- esrs.h and esrs_er.cpp use hwinc/esr.h for neigh_esrs_t::cold_reset minion_boot defaults plus ESR addresses and reset values.
- devices/shakti_uart.h uses hwinc/uart.h for UART register addresses and field masks.
- devices/sysregs_er.{cpp,h} use hwinc/system.h for system register addresses and fields.
- memory/erbium/main_memory.h pulls the Erbium region layout from hwinc/top.h.
- emu_defines.h and sys_emu.h replace remaining Erbium literals with HAL-derived constants where applicable.
sw-sysemu/CMakeLists.txt now finds erbium_hal and links sw-erbium with erbium_hal::erbium_hal. The top-level build adds erbium-hal to HostProject(sw-sysemu ...) so the Erbium HAL package is installed before sw-sysemu configures.
glguida
left a comment
There was a problem hiding this comment.
Note about sysemu (it is a major architectural change in a single line)
But this is really welcome.
Thanks,
G.
| find_package(lz4 REQUIRED) | ||
|
|
||
| # Erbium HAL: hwinc/ register headers and platform encoders. Header-only. | ||
| find_package(erbium_hal REQUIRED) |
There was a problem hiding this comment.
This is something we will have to remember and revert in the future: sysemu is much better served by not making it dependent on et-platform packages. Actually @yhxln I wonder if this would kill our current cosim infrastructure.
In any case, I am fine with this changes now, and we should possibly in case it's a problem for cosim just add the autogenerated headers directly into sysemu as an extra copy. And everytime we generate, duplicate them in the hal (for et software) and in sysemu (that has a much more interesting life).
Introduces a hal/platform/{erbium,etsoc}/ layout for per-chip HALs. Moves
the existing etsoc-hal into hal/platform/etsoc/, pure relocation.
Adds the Erbium HAL: header-only register-access primitives (mmio.h,
csr.h, esr.h with an Erbium ESR address encoder), generated peripheral
register definitions under hwinc/, and the SystemRDL → C scripts that
regenerate them from the hardware team's RDL sources.
This is the first PR on the HAL series and lays the fundamentals to build upon.