pulp-platform / pulp-riscv-gnu-toolchain

Other
68 stars 50 forks source link

How to add custom instruction to this pulp-riscv-gnu-toolchain #26

Closed 20171166 closed 3 years ago

20171166 commented 3 years ago

Hi.

I slightly modify the cv32e40p so I need to add custom instruction to this gcc. It is enough if I can use inline assembly which is named to be built-in in paper.

like volatile asm { instrucitons; }

I try to follow this tutorial https://nitish2112.github.io/post/adding-instruction-riscv/ but I think I don't have to use riscv-tools and It would be better if I can choose MATCH_CUSTOM and MASK_CUSTOM. It would be better if you can let me know how to fill the filed in the appropriate way.

Can you help me? or please tell me where to start.

Thanks.

osta1 commented 3 years ago

Hello,

I am also facing the same issue; I want to add some new instructions to pulp-riscv-gnu-toolchain, but I am not able to find some satisfying answers about how to add new instructions. Thank you for informing me, in case you have solved the problem.

Thanks.

20171166 commented 3 years ago

The above way of the question is adding custom instruction to gcc binutils. As I say, You should add and declare instruction to proper file. You can do this with trial and error looking at the rule of MASK.

I recommend using .word directive. You can use like this volatile asm{ .word 0x12345678 };

in this way, you can use custom instruction for only that part.