简体   繁体   English

Risc-V:能够利用 GCC 的简单 RV32I 实施的最低 CSR 要求

[英]Risc-V: Minimum CSR requirements for simple RV32I implementation capable of leveraging GCC

What would be the bare minimum CSR requirements for a RV32I capable of running machine code generated with GCC? RV32I 能够运行使用 GCC 生成的机器代码的最低 CSR 要求是什么?

I'm thinking of a simple fpga-based (embedded) implementation.我正在考虑一个简单的基于 fpga 的(嵌入式)实现。 No virtual memory or linux support is required.不需要虚拟 memory 或 linux 支持。

Also, what GCC flags should I use in order to prevent it from using unimplemented CSR related instructions?另外,我应该使用什么 GCC 标志来防止它使用未实现的 CSR 相关指令?

I'm still quite confused after scanning through the RISCV Privileged ISA Specification.浏览完 RISCV 特权 ISA 规范后,我仍然很困惑。

Thanks!谢谢!

Have a look at the RARS simulator as an example of a simple RISC V implementation.查看RARS模拟器作为简单 RISC V 实现的示例。 It implements sufficient CSRs (eg the exception cause, processor status, exception pc, vector table address, etc..) that you can program an interrupt handler.它实现了足够的 CSR(例如异常原因、处理器状态、异常 pc、向量表地址等),您可以对中断处理程序进行编程。

You'll need:你需要:

  • utvec — sets the exception handler address utvec — 设置异常处理程序地址
  • ustatus — to enable/disable interrupts, ustatus — 启用/禁用中断,
  • uscratch — needed by software exception handler, uscratch — 软件异常处理程序需要,
  • ucause — tells the reason for exception ucause — 告诉异常的原因
  • uepc — tells the address of uncompleted instruction at exception uepc — 告诉异常时未完成指令的地址

And some others.还有一些其他的。 In RARS, you can see the registers implemented in the register display, Control and Status tab.在 RARS 中,您可以在寄存器显示、控制和状态选项卡中看到实现的寄存器。

I believe RARS supports the timer, so has some CSRs for that.我相信 RARS 支持计时器,因此有一些 CSR。 It also provides a floating point unit, so some CSRs for exceptions for that as well as rounding configuration.它还提供了一个浮点单元,因此一些 CSR 用于例外以及舍入配置。 For handling memory access exceptions, it has utval .为了处理 memory 访问异常,它有utval And then it offers some counters.然后它提供了一些计数器。 See also table 2.2 in Document Version 20190608-Priv-MSU-Ratified另请参阅文档版本 20190608-Priv-MSU-Ratified中的表 2.2

I would think that your usage of CSRs would be restricted to standalone application configuration, eg initial bootup, and interrupt handling, both of which would be written in assembly.我认为您对 CSR 的使用将仅限于独立的应用程序配置,例如初始启动和中断处理,这两者都将用汇编语言编写。

Hard to imagine that compiled C code (object files, .o's) would touch the CSRs in any way.很难想象编译后的 C 代码(目标文件,.o's)会以任何方式触及 CSR。 If you have an example of that, please share it.如果你有这样的例子,请分享。

In some environments, the C implementation allows for standalone (eg unhosted) programs.在某些环境中,C 实现允许独立(例如非托管)程序。 It is possible that such a program created by some compiler includes startup configuration and an exception handler though more likely that these would be user supplied.由某些编译器创建的此类程序可能包括启动配置和异常处理程序,尽管这些更有可能是用户提供的。 See, for example, http://cs107e.github.io/guides/gcc/例如,参见http://cs107e.github.io/guides/gcc/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM