opentitan icon indicating copy to clipboard operation
opentitan copied to clipboard

[FPGA] Separating resets for logic and non-volatile memory

Open tjaychen opened this issue 7 years ago • 14 comments

right now the FPGA gets two resets, SRST and IO_RST_n. These are in my opinion more "logical" resets, and they should behave as intended on silicon.

For FPGAs though, we need a reset that should ideally wipe non-volatile memory (such as emulated flash and OTP). I'm thinking we can tie another one of the buttons to this purpose.

Does anyone have any objections?

tjaychen avatar Aug 01 '19 22:08 tjaychen

Just to be clear, a button to only reset the non-volatile memory for only the FPGA build?

towoe avatar Aug 06 '19 10:08 towoe

thats my current thinking...does this seem like an overkill?

We basically need a good clean way to initializing the fpga flash to all 1's..without always doing it on every reboot. Do you have any other thoughts?

tjaychen avatar Aug 06 '19 15:08 tjaychen

actually @rpenugo is this one something you can take?

The basic idea is that either we add a mechanism that can clear flash memories, or we build the fpga such that flash memory is initialized to all 1's. So we don't run into odd issues at boot.

cc @towoe @imphil @moidx

tjaychen avatar Aug 08 '19 17:08 tjaychen

Hi TIm,

there may not be a easy in RTL to do memory initialization to all 1's when the code is inferring BRAM .

We can work-around thru vivado xdc constraints to init the needed memories.. let me know the memories we want to target here

Thanks, Ram

On Thu, Aug 8, 2019 at 10:36 AM tjaychen [email protected] wrote:

actually @rpenugo https://github.com/rpenugo is this one something you can take?

The basic idea is that either we add a mechanism that can clear flash memories, or we build the fpga such that flash memory is initialized to all 1's. So we don't run into odd issues at boot.

cc @towoe https://github.com/towoe @imphil https://github.com/imphil @moidx https://github.com/moidx

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/26?email_source=notifications&email_token=ALULWCNYDJED2JKRR7DKO23QDRKSVA5CNFSM4IIXX2D2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD34LSGY#issuecomment-519616795, or mute the thread https://github.com/notifications/unsubscribe-auth/ALULWCKQCNL7R6RZCVI7JQDQDRKSVANCNFSM4IIXX2DQ .

rpenugo avatar Aug 08 '19 20:08 rpenugo

hey Ram, it's all the flash related memories. There are...A LOT of them (probably 128)

On Thu, Aug 8, 2019 at 1:49 PM rpenugo [email protected] wrote:

Hi TIm,

there may not be a easy in RTL to do memory initialization to all 1's when the code is inferring BRAM .

We can work-around thru vivado xdc constraints to init the needed memories.. let me know the memories we want to target here

Thanks, Ram

On Thu, Aug 8, 2019 at 10:36 AM tjaychen [email protected] wrote:

actually @rpenugo https://github.com/rpenugo is this one something you can take?

The basic idea is that either we add a mechanism that can clear flash memories, or we build the fpga such that flash memory is initialized to all 1's. So we don't run into odd issues at boot.

cc @towoe https://github.com/towoe @imphil https://github.com/imphil @moidx https://github.com/moidx

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/lowRISC/opentitan/issues/26?email_source=notifications&email_token=ALULWCNYDJED2JKRR7DKO23QDRKSVA5CNFSM4IIXX2D2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD34LSGY#issuecomment-519616795 , or mute the thread < https://github.com/notifications/unsubscribe-auth/ALULWCKQCNL7R6RZCVI7JQDQDRKSVANCNFSM4IIXX2DQ

.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/26?email_source=notifications&email_token=AAH2RSRFOXUS5DGSFZLOQADQDSBGJA5CNFSM4IIXX2D2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD343RFI#issuecomment-519682197, or mute the thread https://github.com/notifications/unsubscribe-auth/AAH2RSQXG252N4AJOBTIM23QDSBGJANCNFSM4IIXX2DQ .

tjaychen avatar Aug 08 '19 21:08 tjaychen

Any thoughts here Ram?

tjaychen avatar Sep 04 '19 03:09 tjaychen

Ram, just circled back to this one and wonder if you have any thoughts?

tjaychen avatar Sep 19 '19 21:09 tjaychen

@rpenugo @gorusso it would also be good to hear how you guys have dealt with non-volatile memories on FPGA in the past. I've seen one approach, but I am sure there are more. We will need some kind of strategy for eventual OTP as well.

tjaychen avatar Sep 25 '19 17:09 tjaychen

By non-volatile do you mean embedded FLASH emulation? Previously on a certain project I worked on we used a verilog model that would basically emulate an embedded flash according to the interface that is specified by the silicon vendor. i.e. erase time / program time, what should be the pulses legnth, addresses etc.

If I recall correctly, we have used a faster clock for the flash emulation model. and a single clock domain for it, even if the real embedded flash was asynchronous, since we were not trying to catch timing issues in FPGA.

As for non-volatility, the emulated FLASH was initialized after first power up (using mem init function the FPGA vendor has), and would not reset. the only way to erase it would be to actual issue a erase pulse through the flash memory controller, or power cycle the FPGA.

the emulated flash state machine would reset with the rest of the design, but the content of the memory will stay there as long as the FPGA is powered up.

If we really want to emulate an embedded flash, I think this should be the way to go. However, if you do want to have the flash wiped clean by a botton, than I think this requires some some sort of sequencer that will control an "uber-reset" where first the flash is being wiped, then the design is released from reset. Is that make sense?

Same goes for OTP, as long as the FPGA is powered the OTP is preserved. but we can have this uber-reset functionality for it as well.

gorusso avatar Sep 25 '19 19:09 gorusso

This basically matches my understanding of how to do it.

It can be handy to have a testbench-only port to the "flash"/"OTP" to enable certain kinds of error-case testing (i.e. to flip some bits in the flash/fuses and make sure the device recovers as expected). I am not sure what that would look like in our emulation configuration though, since I think the normal emulation interface for us is the UART/pins of an OpenTitan, these would be some out-of-band pins/controls.

For OTP it is also sometimes useful to mark a bit as "unprogrammable" or "hard-to-program" since we need to validate the programming procedure suggested by the macro vendor for setting fuse bits. Most of that will be handled in software in our case, but we have to make sure that the underlying hardware correctly supports whatever programming methods are needed to implement the correct procedure, and in order to model it correctly you need these flags in the NVM model sometimes.

cdgori avatar Sep 26 '19 17:09 cdgori

By non-volatile do you mean embedded FLASH emulation? Previously on a certain project I worked on we used a verilog model that would basically emulate an embedded flash according to the interface that is specified by the silicon vendor. i.e. erase time / program time, what should be the pulses legnth, addresses etc.

yes so we do have an emulated flash already. We emulate read / program / erase time but we don't really do anything about specific pulse widths yet, since we don't have a good idea what the final flash technology will look like.

If I recall correctly, we have used a faster clock for the flash emulation model. and a single clock domain for it, even if the real embedded flash was asynchronous, since we were not trying to catch timing issues in FPGA.

As for non-volatility, the emulated FLASH was initialized after first power up (using mem init function the FPGA vendor has), and would not reset. the only way to erase it would be to actual issue a erase pulse through the flash memory controller, or power cycle the FPGA.

yes i think this is basically what i'm asking for. Right now during our fpga build process, we initialize the ROM but don't have a good way of initializing the flash. We would like for the for the flash to be FFFFFF... by default.

We do have a flash FSM that would go through and initialize / wipe, but that needs to be different from the functional reset, as we have cases where we want to reset the chip but keep the flash contents. That's why I was asking whether it would be a good idea to have a separate reset for non-volatile memory. But really, anything that achieves the same goal would be fine.

the emulated flash state machine would reset with the rest of the design, but the content of the memory will stay there as long as the FPGA is powered up.

If we really want to emulate an embedded flash, I think this should be the way to go. However, if you do want to have the flash wiped clean by a botton, than I think this requires some some sort of sequencer that will control an "uber-reset" where first the flash is being wiped, then the design is released from reset. Is that make sense?

Same goes for OTP, as long as the FPGA is powered the OTP is preserved. but we can have this uber-reset functionality for it as well.

tjaychen avatar Sep 26 '19 21:09 tjaychen

@gorusso what's the conclusion of the discussion and next step to implement what @tjaychen was asking for, i.e. a "reset" for FPGA to initialize flash to 1's?

aytong avatar Oct 31 '19 23:10 aytong

I think eventually we decided not to go with a "reset" that will reset the embedded flash. This can be achieved by issuing a mass erase command. (The emulated flash should have a mass erase command.) @tjaychen could you confirm?

gorusso avatar Nov 01 '19 04:11 gorusso

i should still add that a feature like this would be really helpful. The boot ROM long term will only erase areas that it's programming, so tests on different platforms will likely assume different initiate states. We recently encountered a test failure because of this on verilator.

So I wouldn't say there is no need for this, but it's certainly not a high priority.

On Thu, Oct 31, 2019 at 9:14 PM gorusso [email protected] wrote:

I think eventually we decided not to go with a "reset" that will reset the embedded flash. This can be achieved by issuing a mass erase command. (The emulated flash should have a mass erase command.)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/26?email_source=notifications&email_token=AAH2RSVAHBZFNMMZOLVHEODQROUJZA5CNFSM4ISTJRWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECZ6HCY#issuecomment-548660107, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH2RSQTYTBAHYHDRWGR3E3QROUJZANCNFSM4ISTJRWA .

tjaychen avatar Nov 01 '19 04:11 tjaychen