XUANTIE-RV / openc906

OpenXuantie - OpenC906 Core
Apache License 2.0
315 stars 95 forks source link

The vector unit seems disabled #3

Open mp-17 opened 2 years ago

mp-17 commented 2 years ago

It seems that critical signals relative to the vector unit are hardcoded to zero. Some examples:

1) The VS bits in mstatus https://github.com/T-head-Semi/openc906/blob/main/C906_RTL_FACTORY/gen_rtl/cp0/rtl/aq_cp0_trap_csr.v#L505 2) Decoder signals https://github.com/T-head-Semi/openc906/blob/main/C906_RTL_FACTORY/gen_rtl/idu/rtl/aq_idu_id_decd.v#L1011 https://github.com/T-head-Semi/openc906/blob/main/C906_RTL_FACTORY/gen_rtl/idu/rtl/aq_idu_id_decd.v#L934 https://github.com/T-head-Semi/openc906/blob/main/C906_RTL_FACTORY/gen_rtl/idu/rtl/aq_idu_id_decd.v#L3740

I tried to run some vector code, but it always triggers exceptions on the vector instructions (if I fix some of the hardcoded values, the exception is generated by some other disabled signals). This makes me think that the code was generated with incorrect settings, or that this version of the processor simply does not support the V extension. Can this be the case? If yes, are there any plans to open-source it?

Thanks a lot, Matteo

CaffreyCC commented 2 years ago

Yes, openC906 didn't include the V extension because it wasn't officially final yet. In the future, we will open-source it the time is ripe.

mp-17 commented 2 years ago

Hello @CaffreyCC, thanks a lot for the information! Is this true also for the RISC-V physical boards with C906? I bought one, but I cannot enable the V extension.

PhilippvK commented 2 years ago

@mp-17 I have an Sipeed Lichee RV D1 board with a C906 and was able to use the vector unit. However it only support RVV v0.7, so you can not use more recent toolchains to work with the vector instructions.

mp-17 commented 2 years ago

Thanks a lot, @PhilippvK. I have the Nezha board, and the V extension seems disabled by default. I cannot modify the machine/supervisor CSRs to enable it either since the board runs Linux and my applications are kept in U mode.

PhilippvK commented 2 years ago

@mp-17 I also had similar issues running Linux. I had to build baremetal programs to make use of the vector extension. I am not sure if this would somehow be possible from an OS.

Reference: https://github.com/bigmagic123/d1-nezha-baremeta/tree/main/src/2.vector_example

mp-17 commented 2 years ago

This is really useful, I will try it. Thank you. I also tried to build a kernel module to modify the CSR settings in supervisor mode but did not find the correct headers to build kernel modules for the native Linux distro on the board. It would be quite useful to have something like this. If I make it, I will upload it.

mp-17 commented 2 years ago

So, just to understand: you booted the board in a baremetal environment taking the material from this repo, right?

PhilippvK commented 2 years ago

@mp-17 Not exactly. I put together code from multiple sources also including the relevant parts for uboot/xfel/mksunxi. However I am unfortunately unable to publish the project in its current stage. Sorry for that.

mp-17 commented 2 years ago

No problems, thank you very much for the help!