No description
Find a file
2022-08-27 08:33:22 +02:00
aeadaes256ocbtaglen128v1-rv32 ABI 2022-08-27 08:32:38 +02:00
aes256ctrstandalone-rv32 ABI 2022-08-27 08:32:38 +02:00
aes256decrypt-rv32 ABI 2022-08-27 08:32:38 +02:00
aes256encrypt-rv32 ABI 2022-08-27 08:32:38 +02:00
aes256gcmv1standalone-rv32 ABI 2022-08-27 08:32:38 +02:00
chacha20standalone-rv32 ABI 2022-08-27 08:32:38 +02:00
sha256standalone-rv32 ABI 2022-08-27 08:32:38 +02:00
sha512standalone-rv32 ABI 2022-08-27 08:32:38 +02:00
BitManipBFPonly.scala merge CTZ and CLZ, seems to save some LUTs 2021-02-27 08:23:05 -05:00
BitManipZba.scala merge CTZ and CLZ, seems to save some LUTs 2021-02-27 08:23:05 -05:00
BitManipZbb.scala Update K scalar to 0.9.2 2021-06-11 13:20:38 +02:00
BitManipZbbZbp.scala merge CTZ and CLZ, seems to save some LUTs 2021-02-27 08:23:05 -05:00
BitManipZbc.scala denser (but slower?) clmulrh 2021-02-17 04:07:57 -05:00
BitManipZbe1cycle.scala merge CTZ and CLZ, seems to save some LUTs 2021-02-27 08:23:05 -05:00
BitManipZbe2cycles.scala Zbe (b[de]compress) 2021-02-23 12:21:42 -05:00
BitManipZbf.scala merge CTZ and CLZ, seems to save some LUTs 2021-02-27 08:23:05 -05:00
BitManipZbp.scala merge CTZ and CLZ, seems to save some LUTs 2021-02-27 08:23:05 -05:00
BitManipZbr.scala Some cleanup related to toolchain, add Zbr 2021-03-08 11:52:14 -05:00
BitManipZbs.scala merge CTZ and CLZ, seems to save some LUTs 2021-02-27 08:23:05 -05:00
BitManipZbt.scala merge CTZ and CLZ, seems to save some LUTs 2021-02-27 08:23:05 -05:00
CryptoZbkb.scala Update K scalar to 0.9.2 2021-06-11 13:20:38 +02:00
CryptoZbkc.scala Update K scalar to 0.9.2 2021-06-11 13:20:38 +02:00
CryptoZbkx.scala Update K scalar to 0.9.2 2021-06-11 13:20:38 +02:00
CryptoZknd.scala Update K scalar to 0.9.2 2021-06-11 13:20:38 +02:00
CryptoZkne.scala Update K scalar to 0.9.2 2021-06-11 13:20:38 +02:00
CryptoZknh.scala 'cleanup' 2021-02-14 04:28:18 -05:00
CryptoZks.scala Update K scalar to 0.9.2 2021-06-11 13:20:38 +02:00
data_aes.txt Update K scalar to 0.9.2 2021-06-11 13:20:38 +02:00
data_bitmanip.txt Update K scalar to 0.9.2 2021-06-11 13:20:38 +02:00
data_bitmanip_compress.txt Zbe (b[de]compress) 2021-02-23 12:21:42 -05:00
data_bitmanip_ZbbOnly.txt Update K scalar to 0.9.2 2021-06-11 13:20:38 +02:00
data_Chacha64.txt Using P opcodes (and double-width/read-rs3-from-rd behavior) to try some custom Chacha-oriented instructions 2021-02-27 04:44:51 -05:00
data_clmul.txt Update K scalar to 0.9.2 2021-06-11 13:20:38 +02:00
data_crc.txt Some cleanup related to toolchain, add Zbr 2021-03-08 11:52:14 -05:00
data_sha.txt move SHA to v0.8 of Kscalar 2020-12-06 16:03:42 +01:00
data_sm3.txt move to K 0.9.0 2021-03-06 04:39:34 -05:00
data_sm4.txt Update K scalar to 0.9.2 2021-06-11 13:20:38 +02:00
data_xar.txt Using P opcodes (and double-width/read-rs3-from-rd behavior) to try some custom Chacha-oriented instructions 2021-02-27 04:44:51 -05:00
data_Zp64.txt Zp64 not Zpn 2021-02-13 06:33:44 -05:00
data_Zpn.txt typo 2022-08-27 08:31:56 +02:00
data_Zpn_2cycles.txt MADDR32/MSUBR32 (2 cycles) 2021-02-14 07:02:28 -05:00
data_Zxrender_2cycles.txt custom SIMD 8-bits FMA for xrender 2022-08-27 08:33:22 +02: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
litex_extensions.patch add patch to litex 'litex/soc/cores/cpu/vexriscv_smp/core.py' that enables --extensions 2021-03-09 10:51:22 -05: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 K scalar to 0.9.2 2021-06-11 13:20:38 +02:00
new_instructions_support.h Update K scalar to 0.9.2 2021-06-11 07:55:24 -04:00
new_instructions_support_b.h Some cleanup related to toolchain, add Zbr 2021-03-08 11:52:14 -05:00
new_instructions_support_k.h Update K scalar to 0.9.2 2021-06-11 07:55:24 -04:00
new_instructions_support_p.h add and check some saturating instructions (w/o the CSR update) 2021-03-20 06:31:21 -04: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
r5.mk ABI 2022-08-27 08:32:38 +02:00
README.md Update K scalar to 0.9.2 2021-06-11 08:00:12 -04:00
signal.c enable SIGILl trapping (signal.c needs to be compiled/linked bythe buildroot compiler for this to work, test files are compiled with the B compiler) 2021-02-18 07:54:20 -05:00
test_b.c Some cleanup related to toolchain, add Zbr 2021-03-08 11:52:14 -05:00
test_common.h more systematic synthetic tests 2021-02-22 08:31:17 -05:00
test_p.c add and check some saturating instructions (w/o the CSR update) 2021-03-20 06:31:21 -04: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 last usage entry for SM4 2021-02-18 06:07:45 -05:00

B/K/... 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 K, this is targeting version 0.9.2. 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
  • Three-operands instructions (CMIX, CMOV, FS[RL]*); they are available but need a VexRiscv patch to support the third input (all VexRiscv patch are available on https://github.com/rdolbeau/VexRiscv/tree/three_operands)

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 BitManipZbe2cyclesPlugin, 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.9.2. There is also support for SM3 and SM4 acceleration (collectively Zks).

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

The plugin(s) can then be instantiated in the core definition. A way to test all of this is the LiteX SoC generator. There is a project to ease the generation of the SoC and associated software, Linux-on-Litex-Vexriscv. This is what is used for the development of the new instructions.

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/), from crypto_stream. 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, from crypto_stream and crypto_aead respectively. 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, from crypto_hashblocks. They should give the same results (checksums) as the version in Supercop, and require Zknh (SHA hash instructions) in addition to some of B.

aes256encrypt-rv32 and aes256decrypt-rv32 are on the same line, from crypto_core.

aeadaes256ocbtaglen128v1-rv32 is on the same line, from crypto_aead.

Acknowledgements

This work has partly been done as part of the European Processor Initiative project.

The European Processor Initiative (EPI) (FPA: 800928) has received funding from the Europe an Union's Horizon 2020 research and innovation programme under grant agreement EPI-SGA1: 826647