No description
Find a file
2021-02-18 04:13:42 -05:00
aeadaes256ocbtaglen128v1-rv32 add a quick'n'dirty implementation of RV32BK-accelerated AES-OCB, using the _m128i compatibility layer (spun off in its own header) 2021-02-17 09:02:43 -05:00
aes256ctrstandalone-rv32 propagate aes32esi-using setkey to ctr/gcm 2021-02-17 02:43:35 -05:00
aes256decrypt-rv32 add a quick'n'dirty implementation of RV32BK-accelerated AES-OCB, using the _m128i compatibility layer (spun off in its own header) 2021-02-17 09:02:43 -05:00
aes256encrypt-rv32 use aes32esi* for key schedule 2021-02-16 04:43:27 -05:00
aes256gcmv1standalone-rv32 add a quick'n'dirty implementation of RV32BK-accelerated AES-OCB, using the _m128i compatibility layer (spun off in its own header) 2021-02-17 09:02:43 -05:00
chacha20standalone-rv32 defines RISC-V as little-endian 2021-02-14 06:53:04 -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
BitManipBFPonly.scala add BFPOnly file 2021-02-14 09:24:56 -05:00
BitManipZba.scala add specialized versions of instructions in their own file for Zbb, proper definition of various Zb* plugins 2021-02-14 08:06:44 -05:00
BitManipZbb.scala add specialized versions of instructions in their own file for Zbb, proper definition of various Zb* plugins 2021-02-14 08:06:44 -05:00
BitManipZbbZbp.scala add specialized versions of instructions in their own file for Zbb, proper definition of various Zb* plugins 2021-02-14 08:06:44 -05:00
BitManipZbc.scala denser (but slower?) clmulrh 2021-02-17 04:07:57 -05:00
BitManipZbf.scala add specialized versions of instructions in their own file for Zbb, proper definition of various Zb* plugins 2021-02-14 08:06:44 -05:00
BitManipZbs.scala add specialized versions of instructions in their own file for Zbb, proper definition of various Zb* plugins 2021-02-14 08:06:44 -05:00
BitManipZbt.scala add specialized versions of instructions in their own file for Zbb, proper definition of various Zb* plugins 2021-02-14 08:06:44 -05:00
CryptoZknd.scala factorize aes32* 2021-02-17 05:50:11 -05:00
CryptoZkne.scala factorize aes32* 2021-02-17 05:50:11 -05:00
CryptoZknh.scala 'cleanup' 2021-02-14 04:28:18 -05:00
data_aes.txt factorize aes32* 2021-02-17 05:50:11 -05:00
data_bitmanip.txt more Z* definitions 2021-02-15 12:17:34 -05:00
data_bitmanip_ZbbOnly.txt fix imm 2021-02-18 02:57:33 -05:00
data_clmul.txt denser (but slower?) clmulrh 2021-02-17 04:07:57 -05:00
data_sha.txt move SHA to v0.8 of Kscalar 2020-12-06 16:03:42 +01:00
data_sm3.txt Update usage, add SM3 as it's an easy one 2021-02-18 04:13:42 -05:00
data_Zp64.txt Zp64 not Zpn 2021-02-13 06:33:44 -05:00
data_Zpn.txt [zs]unpkd8xy 2021-02-15 05:58:31 -05:00
data_Zpn_2cycles.txt MADDR32/MSUBR32 (2 cycles) 2021-02-14 07:02:28 -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
m128_compat.h add a quick'n'dirty implementation of RV32BK-accelerated AES-OCB, using the _m128i compatibility layer (spun off in its own header) 2021-02-17 09:02:43 -05:00
Makefile Update usage, add SM3 as it's an easy one 2021-02-18 04:13:42 -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 typo 2021-02-17 02:55:55 -05:00
new_instructions_support_p.h [zs]unpkd8xy 2021-02-15 05:58:31 -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 README, Makefile comments 2021-02-16 13:11:15 -05:00
test_b.c slo/sro are in none of the subextensions 2021-02-14 08:10:50 -05:00
test_p.c [zs]unpkd8xy 2021-02-15 05:58:31 -05:00
unparse.cpp add specialized versions of instructions in their own file for Zbb, proper definition of various Zb* plugins 2021-02-14 08:06:44 -05:00
unparse.hpp prototype version with 2 cycles instructions 2021-02-14 03:18:11 -05:00
usage.txt Update usage, add SM3 as it's an easy one 2021-02-18 04:13:42 -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. Packed SIMD (P) stuff is missing a lot of feature and targets 0.92.

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 support for partial instructions (rev8, zext.h, orc.b) so that the default plugins generated for Zba, Zbb and Zbc should be feature-complete. To get everything without conflicts, use: new BitManipZbaPlugin, new BitManipZbbZbpPlugin, new BitManipZbcPlugin, new BitManipBFPOnlyPlugin, new BitManipZbsPlugin, new BitManipZbtPlugin,

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 include prototype support for RV32Zkn[ed] (AES encryption/decryption instructions) and RV32Zknh (SHA hash instructions) from the K ("crypto") extension draft 0.8.1. This requires another patch to VexRiscv, as Zkn[ed] use field rs1 instead of rd for the output register.

There's also some experimental support for some P ("packed SIMD") instructions. It requires even more patches to VexRiscv, first to use a third input sourced from the destination register (so not R4 format like B's ternaries), and second to enable Zp64 instructions that write to two registers (x(2n) and x(2n+1)).

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.