opentitan icon indicating copy to clipboard operation
opentitan copied to clipboard

[prim_ram*] Support for Parity/ECC in memory loaders

Open msfschaffner opened this issue 6 years ago • 9 comments

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.

msfschaffner avatar Jun 10 '20 00:06 msfschaffner

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.

sjgitty avatar Jun 10 '20 00:06 sjgitty

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.

tjaychen avatar Jun 10 '20 00:06 tjaychen

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 where prim_util_memload.sv is 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 mem element, containing the unencoded memory contents.
  • Include prim_util_memload.sv in the adv wrapper.
  • Add simulation-only code to add ecc/parity, and copy over the mem contents 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.

imphil avatar Jun 10 '20 10:06 imphil

@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?

imphil avatar May 06 '21 13:05 imphil

@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!

udinator avatar May 06 '21 18:05 udinator

The current status is as follows:

  • the mem_bkdr_if currently 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

udinator avatar May 06 '21 18:05 udinator

#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 avatar May 13 '21 05:05 udinator

@udinator can we consider this issue addressed then (and close it)?

msfschaffner avatar Sep 15 '21 16:09 msfschaffner

yup, this issue has been addressed.

udinator avatar Sep 20 '21 17:09 udinator