No description
Find a file
2021-02-14 03:18:11 -05:00
aes256ctrstandalone-rv32 clean-up 2021-02-13 04:55:07 -05:00
aes256gcmv1standalone-rv32 clean-up 2021-02-13 04:55:07 -05:00
chacha20standalone-rv32 clean-up 2021-02-13 04:55:07 -05:00
sha256standalone-rv32 clean-up 2021-02-13 04:55:07 -05:00
sha512standalone-rv32 clean-up 2021-02-13 04:55:07 -05:00
BitManipAllPlugin.scala make earlyInjection optional in plugins 2021-02-11 09:13:14 -05:00
BitManipZbpPlugin.scala make earlyInjection optional in plugins 2021-02-11 09:13:14 -05:00
BitManipZclmul.scala make earlyInjection optional in plugins 2021-02-11 09:13:14 -05:00
CryptoZknePlugin.scala make earlyInjection optional in plugins 2021-02-11 09:13:14 -05:00
CryptoZknh.scala make earlyInjection optional in plugins 2021-02-11 09:13:14 -05:00
data_aes.txt Move to Kscalar 0.8.1 ; this means Zkne requires a VexRiscv patch to support the 'rt' field 2021-02-05 11:36:01 -05:00
data_bitmanip.txt comment out unimplemented stuff 2021-02-11 12:11:48 -05:00
data_clmul.txt More subextensions 2020-12-07 15:15:59 +01:00
data_sha.txt move SHA to v0.8 of Kscalar 2020-12-06 16:03:42 +01:00
data_Zp64.txt Zp64 not Zpn 2021-02-13 06:33:44 -05:00
data_Zpn.txt simple *maqa, unbreak smaqa 2021-02-13 08:51:47 -05:00
data_Zpn_2cycles.txt prototype version with 2 cycles instructions 2021-02-14 03:18:11 -05:00
extract_bitmanip.sh First version of the plugin generator for B 2020-11-05 09:26:16 +01:00
gen_plugin.cpp prototype version with 2 cycles instructions 2021-02-14 03:18:11 -05:00
gen_plugin.hpp prototype version with 2 cycles instructions 2021-02-14 03:18:11 -05:00
group.hpp First version of the plugin generator for B 2020-11-05 09:26:16 +01:00
inst.hpp find the 'I' of immediate even if it's not the last character 2021-02-08 05:49:14 -05:00
inst_lex.l prototype version with 2 cycles instructions 2021-02-14 03:18:11 -05:00
inst_par.h prototype version with 2 cycles instructions 2021-02-14 03:18:11 -05:00
inst_par.y prototype version with 2 cycles instructions 2021-02-14 03:18:11 -05:00
LICENSE First version of the plugin generator for B 2020-11-05 09:26:16 +01:00
Makefile prototype version with 2 cycles instructions 2021-02-14 03:18:11 -05:00
new_instructions_support.h drop the mvs in FUN2W ; add [us]maqa (require a non-earlyInjection plugin to meet timing...) ; use umaqa in sse8 2021-02-13 08:30:29 -05:00
new_instructions_support_b.h clean-up 2021-02-13 04:55:07 -05:00
new_instructions_support_k.h clean-up 2021-02-13 04:55:07 -05:00
new_instructions_support_p.h drop the mvs in FUN2W ; add [us]maqa (require a non-earlyInjection plugin to meet timing...) ; use umaqa in sse8 2021-02-13 08:30:29 -05:00
pbsad.c clean-up 2021-02-13 04:55:07 -05:00
pbsse.c drop the mvs in FUN2W ; add [us]maqa (require a non-earlyInjection plugin to meet timing...) ; use umaqa in sse8 2021-02-13 08:30:29 -05:00
README.md update for options 2021-02-12 07:15:58 -05:00
test_b.c clean-up 2021-02-13 04:55:07 -05:00
test_p.c drop the mvs in FUN2W ; add [us]maqa (require a non-earlyInjection plugin to meet timing...) ; use umaqa in sse8 2021-02-13 08:30:29 -05:00
unparse.cpp prototype version with 2 cycles instructions 2021-02-14 03:18:11 -05:00
unparse.hpp prototype version with 2 cycles instructions 2021-02-14 03:18:11 -05:00
usage.txt add extras 2020-11-28 06:34:35 -05:00
vexriscv_d6e8a5ef22042ddb962cfbf627efe909bb23da95_3ops.patch add patch to VexRiscV to support 3 input operands 2021-02-02 12:30:27 -05:00

B plugin generator for VexRiscv

beware This is targeting the bitmanip extension (B) on an intermediate draft from January 20, 2021, so opcodes and subsets might be not match the current version of B. Ditto for Z, this is targeting version 0.8.1. Both may require feature patch to VexRiscv, see below.

This repository

This is a quick'n'dirty plugin generator to add a subset of the B extension to the VexRiscv core.

The generated plugin is for RV32 only. It doesn't yet support all B instructions; missing instructions are:

  • all instructions ending in 'W', as they are RV64-only
  • BMAT*, as they are RV64-only
  • BDEP/BEXT
  • CRC32*
  • Three-operands instructions (CMIX, CMOV, FS[RL]*); they are available but need a VexRiscv patch to support the third input

There is no support for 'partial' instruction - implementing only a subset of the functionality of one instruction. So grev is supported, but rev8 alone isn't. Subextension are defined without 'partial' instructions - so Zbb doesn't have rev8 or orc.B.

This has received limited testing in a Linux-on-Litex-VexRiscv SoC. YMMV. SMP mode was tested as well.

Also, the implementations of the instructions in SpinalHDL are written for tuncitonality, and not tuned or optimized in any way for performance/area/... (file usage.txt has some numbers).

A separate data file includes prototype support for RV32Zkne (AES encryption instructions) and RV32Zknh (SHA hash instructions) from the K extension draft 0.8.1. This requires another patch to VexRiscv, as Zkne uses field rs1 instead of rd for the output register.

How to use

There shouldn't be any dependency beyond gcc, g++, flex and bison. Instructions are defined in data_bitmanip.txt, look at the header of that file for the format - it should be fairly easy to add custom instructions if needed (as long as they are register-register, register-immediate, or unary and execute in one cycle).

The tool need an extension name, the data file and the list of instructions and/or sub-extension to support in the plugin:

./gen_plugin -n BitManipZbpZba -i data_bitmanip.txt -I Zba -I Zbb -I GORC -I GREV > BitManipZbbZba.scala

Will generate a plugin supporting Zbb (using the full version of grev and gorc) and Zba. You can use a star to say 'all supported instructions':

./gen_plugin -n BitManipAll -i data_bitmanip.txt -I '*' > BitManipAllPlugin.scala

Test codes

test_b.c is a small synthetic test for RV32IMAB Linux, to check B instructions with various test patterns. See in the file on how to use it.

chacha20standalone-rv32 is a stand-alone code extracted from the Supercop benchmark (similar to https://github.com/rdolbeau/EPI-test-codes-vector/). It should give the same results (checksums) as the version in Supercop, and can be compiled for RV32IMA or RV32IMAB. From B, they mostly rely on the rotation instructions (although the B toolchain also generates other instructions, in particular those from Zba).

aes256ctrstandalone-rv32 and aes256gcmv1standalone-rv32 are stand-alone codes extracted from the Supercop benchmark. They should give the same results (checksums) as the version in Supercop, and require Zkne (AES encryption instructions) in addition to some of B. aes256gcmv1standalone-rv32 also requires clmul[h].

sha256standalone-rv32 and sha512standalone-rv32 are stand-alone codes extracted from the Supercop benchmark. They should give the same results (checksums) as the version in Supercop, and require Zknh (SHA hash instructions) in addition to some of B.