Risc-V:能够利用GCC的简单RV32I实现的最低CSR要求 [英] Risc-V: Minimum CSR requirements for simple RV32I implementation capable of leveraging GCC

查看:140
本文介绍了Risc-V:能够利用GCC的简单RV32I实现的最低CSR要求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

能够运行由GCC生成的机器代码的RV32I的最低CSR要求是什么?

What would be the bare minimum CSR requirements for a RV32I capable of running machine code generated with GCC?

我正在考虑一个基于fpga的简单(嵌入式)实现.不需要虚拟内存或linux支持.

I'm thinking of a simple fpga-based (embedded) implementation. No virtual memory or linux support is required.

此外,为了防止它使用未执行的CSR相关指令,我应该使用哪些GCC标志?

Also, what GCC flags should I use in order to prevent it from using unimplemented CSR related instructions?

浏览RISCV特权ISA规范后,我仍然很困惑.

I'm still quite confused after scanning through the RISCV Privileged ISA Specification.

谢谢!

推荐答案

看看 RARS 模拟器作为简单RISC V实现的示例.它实现了足够的CSR(例如,异常原因,处理器状态,异常pc,向量表地址等),可以对中断处理程序进行编程.

Have a look at the RARS simulator as an example of a simple RISC V implementation.  It implements sufficient CSRs (e.g. the exception cause, processor status, exception pc, vector table address, etc..) that you can program an interrupt handler.

您需要:

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

还有其他一些.在RARS中,您可以在寄存器显示的控制和状态选项卡中看到实现的寄存器.

And some others.  In RARS, you can see the registers implemented in the register display, Control and Status tab.

我相信RARS支持计时器,所以有一些计时器为此的企业社会责任.它还提供了浮点单元,因此某些CSR对于该异常以及四舍五入配置.为了处理内存访问异常,它具有 utval .然后提供一些柜台.另请参见文档版本中的表2.220190608-Priv-MSU认证

I believe RARS supports the timer, so has some CSRs for that.  It also provides a floating point unit, so some CSRs for exceptions for that as well as rounding configuration.  For handling memory access exceptions, it has utval.  And then it offers some counters.  See also table 2.2 in Document Version 20190608-Priv-MSU-Ratified

我认为您对CSR的使用仅限于独立的应用程序配置,例如初始启动和中断处理,都将用汇编语言编写.

I would think that your usage of CSRs would be restricted to standalone application configuration, e.g. initial bootup, and interrupt handling, both of which would be written in assembly.

很难想象编译的C代码(目标文件,.o)会以任何方式触及CSR.如果您有这样的例子,请分享.

Hard to imagine that compiled C code (object files, .o's) would touch the CSRs in any way.  If you have an example of that, please share it.

在某些环境中,C实现允许使用独立(例如,非托管)程序.由某些编译器创建的此类程序可能包含启动配置和异常处理程序,尽管这些更有可能由用户提供.例如,参见 http://cs107e.github.io/guides/gcc/

In some environments, the C implementation allows for standalone (e.g. unhosted) programs.  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/

这篇关于Risc-V:能够利用GCC的简单RV32I实现的最低CSR要求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆