[prim_ram*] Support for Parity/ECC in memory loaders
If we want to enable Parity or ECC on our main SRAM, we need support for that in our backdoor memory loading mechanisms.
This can be achieved in several ways, e.g. by either manipulating the binary before loading, or by directly incorporating that functionality into the backdoor interfaces themselves:
https://github.com/lowRISC/opentitan/blob/master/hw/dv/sv/mem_bkdr_if/mem_bkdr_if.sv https://github.com/lowRISC/opentitan/blob/master/hw/ip/prim/rtl/prim_util_memload.sv
I tend towards the second approach, but would like ask whether there are other opinions / ideas.
One reason for the former is if we want to inject parity errors during the backdoor load, otherwise I recommend the latter. We could for that matter add a backdoor interface method that injects an error if we wanted to.
i think the last time i spoke to @imphil about this (when he was doing the 64b expansion), he seemed to prefer the approach of manipulating before loading.
@tomroberts-lowrisc also did some work here, so i'm adding him as well.
A couple of guiding questions I can think of:
- Where do we have the information of what kind of transformation is needed? We currently don't have it in
prim_ram_1p/prim_ram_2p, which is the whereprim_util_memload.svis used (the ECC/Parity information is only in the advanced wrapper, the underlying RAM is unaware of it). - How much "fancy transformation" do we want to do. If it's only ECC/parity or simple error injection, it should be easy to do so in SV. If we want to go for fancier ways to prepare the binary to inject errors, we might be better off with a pre-processing step before loading.
For now, I think I'd go with a rather simple approach: Add the memory loading functionality we have in the non-adv RAM primitives to the adv primitives as well, and let it handle the addition of ECC/parity. This avoids us having to duplicate the ECC/parity settings somewhere else and makes it easy to change the settings as needed.
- Add a simulation-only shadow
memelement, containing the unencoded memory contents. - Include
prim_util_memload.svin the adv wrapper. - Add simulation-only code to add ecc/parity, and copy over the
memcontents to the actual memory. I'm not sure how fragile/tricky the "keeping the two memories in sync" part will be, this could make this approach a dead end. - Point the mem_bkdr_if and memory paths in our verilator simulation to the adv module. (There will be another loader available one level down in the non-adv RAMs if more control over the encoding is needed.)
Maybe another aspect to keep in mind when considering the cost of pre-processing VMEM files: do we want to have ECC/parity for ROM images as well? For those we most likely need to pre-process the VMEM file.
@udinator I know you have been working on this issue recently, can you update this issue with the current approach and/or close if all is done?
@udinator I know you have been working on this issue recently, can you update this issue with the current approach and/or close if all is done?
will do!
The current status is as follows:
- the
mem_bkdr_ifcurrently fully supports memory parity as well as injecting parity errors - this can safely be used to backdoor initialize a memory with minimal work needed from the executing environment - #6441 is currently in flight and being reviewed/enhanced - this adds full ECC support to the
mem_bkdr_if, including single and double bit error injections
#6441 should now be completely merged - so currently the mem_bkdr_if supports both parity and ECC memories, so can be used as a backdoor loading mechanism if desired.
@udinator can we consider this issue addressed then (and close it)?
yup, this issue has been addressed.