Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for fast register saving #81

Open
mithro opened this issue Jul 26, 2019 · 3 comments
Open

Add support for fast register saving #81

mithro opened this issue Jul 26, 2019 · 3 comments

Comments

@mithro
Copy link
Contributor

mithro commented Jul 26, 2019

VexRISC-V uses blockrams on the iCE40. This should make it easy to support saving the whole register file by changing one of the upper address bits. This would be super useful for making interrupt handling a lot faster.

I'm unsure how this should be exposed? Maybe as a custom instruction or something?

@Dolu1990
Copy link
Member

I hade some discution about that with @gmarkall
So, it look like the fast interrupt workgroup isn't looking that way, but you are right, it would be a realy easy way to have fast interrupt (for free in FPGA)

I already explored a bit this idea in the actual RegFilePlugin (https://github.com/SpinalHDL/VexRiscv/blob/master/src/main/scala/vexriscv/plugin/RegFilePlugin.scala#L21)
But never realy tested it / used it.

This would save 16 load + 16 store + 2 pc write on C compatible interrupts, which is much.

Actualy the way it is implemented is by adding new CSR which allow switching between the two register file banks with two modes : Permanant switch / Single instruction switch.
It could have been custom instruction instead of additional CSR, it do not realy matter.

@Dolu1990
Copy link
Member

Also, nothing prevents to swap the default RegFilePlugin for another implementation for new experiments.

@hpax
Copy link

hpax commented Aug 14, 2023

This is indeed a very common situation on FPGAs; most FPGA block RAMs are much larger than 1024 bits (the standard RISC-V register file size.)

I experimented with this on picorv32, and ended up settling on a way to use this for a tiny embedded real time OS in this manner:

  1. A new CSR represents the current user (as opposed to interrupt) context.
  2. In interrupt context, register bank 0 is always used.
  3. In user context, the CSR determines the bank used.
  4. A separate instruction (or mapping to CSR space) for copying data to/from user context registers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants