mirror of
https://github.com/rdolbeau/VexRiscvBPluginGenerator.git
synced 2025-04-18 18:44:42 -04:00
Move to Kscalar 0.8.1 ; this means Zkne requires a VexRiscv patch to support the 'rt' field
This commit is contained in:
parent
f74ff13d7f
commit
51c635723b
6 changed files with 100 additions and 67 deletions
|
@ -380,14 +380,14 @@ class CryptoZknePlugin extends Plugin[VexRiscv] {
|
|||
RS3_USE -> True,
|
||||
IS_CryptoZkne -> True
|
||||
)
|
||||
def aes32esmi0_KEY = M"0011011----------000-----0110011"
|
||||
def aes32esmi1_KEY = M"0111011----------000-----0110011"
|
||||
def aes32esmi2_KEY = M"1011011----------000-----0110011"
|
||||
def aes32esmi3_KEY = M"1111011----------000-----0110011"
|
||||
def aes32esi0_KEY = M"0011001----------000-----0110011"
|
||||
def aes32esi1_KEY = M"0111001----------000-----0110011"
|
||||
def aes32esi2_KEY = M"1011001----------000-----0110011"
|
||||
def aes32esi3_KEY = M"1111001----------000-----0110011"
|
||||
def aes32esmi0_KEY = M"0011011----------000000000110011"
|
||||
def aes32esmi1_KEY = M"0111011----------000000000110011"
|
||||
def aes32esmi2_KEY = M"1011011----------000000000110011"
|
||||
def aes32esmi3_KEY = M"1111011----------000000000110011"
|
||||
def aes32esi0_KEY = M"0011001----------000000000110011"
|
||||
def aes32esi1_KEY = M"0111001----------000000000110011"
|
||||
def aes32esi2_KEY = M"1011001----------000000000110011"
|
||||
def aes32esi3_KEY = M"1111001----------000000000110011"
|
||||
val decoderService = pipeline.service(classOf[DecoderService])
|
||||
decoderService.addDefault(IS_CryptoZkne, False)
|
||||
decoderService.add(List(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# B plugin generator for VexRiscv
|
||||
|
||||
**beware** This is targeting 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.0.
|
||||
**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
|
||||
|
||||
|
@ -20,7 +20,7 @@ This has received limited testing in a [Linux-on-Litex-VexRiscv](https://github.
|
|||
|
||||
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
|
||||
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
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
".word ("#O" | (\\rd << 7) | (\\rs1 << 15) | (\\rs2 << 20))\n" \
|
||||
".endm\n");
|
||||
asm("#define reg_zero 0\n");
|
||||
#define ASM2FMACRO(N, O) asm(".macro "#N" rt, rs2\n" \
|
||||
".word ("#O" | (\\rt << 15) | (\\rs2 << 20))\n" \
|
||||
".endm\n");
|
||||
asm("#define reg_ra 1\n");
|
||||
asm("#define reg_sp 2\n");
|
||||
asm("#define reg_gp 3\n");
|
||||
|
@ -45,23 +48,31 @@ asm("#define reg_t6 31\n");
|
|||
: "r" (rs1), "r" (rs2)); \
|
||||
return r; \
|
||||
}
|
||||
|
||||
ASM2MACRO(AES32ESMI0,0x36000033)
|
||||
ASM2MACRO(AES32ESMI1,0x76000033)
|
||||
ASM2MACRO(AES32ESMI2,0xb6000033)
|
||||
ASM2MACRO(AES32ESMI3,0xf6000033)
|
||||
ASM2MACRO(AES32ESI0,0x32000033)
|
||||
ASM2MACRO(AES32ESI1,0x72000033)
|
||||
ASM2MACRO(AES32ESI2,0xb2000033)
|
||||
ASM2MACRO(AES32ESI3,0xf2000033)
|
||||
FUN2(aes32esmi0,AES32ESMI0)
|
||||
FUN2(aes32esmi1,AES32ESMI1)
|
||||
FUN2(aes32esmi2,AES32ESMI2)
|
||||
FUN2(aes32esmi3,AES32ESMI3)
|
||||
FUN2(aes32esi0,AES32ESI0)
|
||||
FUN2(aes32esi1,AES32ESI1)
|
||||
FUN2(aes32esi2,AES32ESI2)
|
||||
FUN2(aes32esi3,AES32ESI3)
|
||||
#define FUN2F(NAME, ASNAME) \
|
||||
static inline uint32_t NAME(uint32_t rs1, uint32_t rs2) { \
|
||||
uint32_t r = rs1; \
|
||||
asm (#ASNAME " reg_%0, reg_%1\n" \
|
||||
: "+&r" (r) \
|
||||
: "r" (rs2)); \
|
||||
return r; \
|
||||
}
|
||||
|
||||
ASM2FMACRO(AES32ESMI0,0x36000033)
|
||||
ASM2FMACRO(AES32ESMI1,0x76000033)
|
||||
ASM2FMACRO(AES32ESMI2,0xb6000033)
|
||||
ASM2FMACRO(AES32ESMI3,0xf6000033)
|
||||
ASM2FMACRO(AES32ESI0,0x32000033)
|
||||
ASM2FMACRO(AES32ESI1,0x72000033)
|
||||
ASM2FMACRO(AES32ESI2,0xb2000033)
|
||||
ASM2FMACRO(AES32ESI3,0xf2000033)
|
||||
FUN2F(aes32esmi0,AES32ESMI0)
|
||||
FUN2F(aes32esmi1,AES32ESMI1)
|
||||
FUN2F(aes32esmi2,AES32ESMI2)
|
||||
FUN2F(aes32esmi3,AES32ESMI3)
|
||||
FUN2F(aes32esi0,AES32ESI0)
|
||||
FUN2F(aes32esi1,AES32ESI1)
|
||||
FUN2F(aes32esi2,AES32ESI2)
|
||||
FUN2F(aes32esi3,AES32ESI3)
|
||||
|
||||
/*
|
||||
~/LITEX/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-gcc -march=rv32ima -mabi=ilp32 -Os -S comp.c -o comp.S && ~/LITEX/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-gcc -march=rv32ima -mabi=ilp32 -Os -c comp.S -o comp.o && ~/LITEX/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-gcc -march=rv32ima -mabi=ilp32 -Os comp.o -o comp
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
#define ASM2MACRO(N, O) asm(".macro "#N" rd, rs1, rs2\n" \
|
||||
".word ("#O" | (\\rd << 7) | (\\rs1 << 15) | (\\rs2 << 20))\n" \
|
||||
".endm\n");
|
||||
#define ASM2FMACRO(N, O) asm(".macro "#N" rt, rs2\n" \
|
||||
".word ("#O" | (\\rt << 15) | (\\rs2 << 20))\n" \
|
||||
".endm\n");
|
||||
asm("#define reg_zero 0\n");
|
||||
asm("#define reg_ra 1\n");
|
||||
asm("#define reg_sp 2\n");
|
||||
|
@ -71,23 +74,31 @@ asm("#define reg_t6 31\n");
|
|||
: "r" (rs1), "r" (rs2)); \
|
||||
return r; \
|
||||
}
|
||||
#define FUN2F(NAME, ASNAME) \
|
||||
static inline uint32_t NAME(uint32_t rs1, uint32_t rs2) { \
|
||||
uint32_t r = rs1; \
|
||||
asm (#ASNAME " reg_%0, reg_%1\n" \
|
||||
: "+&r" (r) \
|
||||
: "r" (rs2)); \
|
||||
return r; \
|
||||
}
|
||||
|
||||
ASM2MACRO(AES32ESMI0,0x36000033)
|
||||
ASM2MACRO(AES32ESMI1,0x76000033)
|
||||
ASM2MACRO(AES32ESMI2,0xb6000033)
|
||||
ASM2MACRO(AES32ESMI3,0xf6000033)
|
||||
ASM2MACRO(AES32ESI0,0x32000033)
|
||||
ASM2MACRO(AES32ESI1,0x72000033)
|
||||
ASM2MACRO(AES32ESI2,0xb2000033)
|
||||
ASM2MACRO(AES32ESI3,0xf2000033)
|
||||
FUN2(aes32esmi0,AES32ESMI0)
|
||||
FUN2(aes32esmi1,AES32ESMI1)
|
||||
FUN2(aes32esmi2,AES32ESMI2)
|
||||
FUN2(aes32esmi3,AES32ESMI3)
|
||||
FUN2(aes32esi0,AES32ESI0)
|
||||
FUN2(aes32esi1,AES32ESI1)
|
||||
FUN2(aes32esi2,AES32ESI2)
|
||||
FUN2(aes32esi3,AES32ESI3)
|
||||
ASM2FMACRO(AES32ESMI0,0x36000033)
|
||||
ASM2FMACRO(AES32ESMI1,0x76000033)
|
||||
ASM2FMACRO(AES32ESMI2,0xb6000033)
|
||||
ASM2FMACRO(AES32ESMI3,0xf6000033)
|
||||
ASM2FMACRO(AES32ESI0,0x32000033)
|
||||
ASM2FMACRO(AES32ESI1,0x72000033)
|
||||
ASM2FMACRO(AES32ESI2,0xb2000033)
|
||||
ASM2FMACRO(AES32ESI3,0xf2000033)
|
||||
FUN2F(aes32esmi0,AES32ESMI0)
|
||||
FUN2F(aes32esmi1,AES32ESMI1)
|
||||
FUN2F(aes32esmi2,AES32ESMI2)
|
||||
FUN2F(aes32esmi3,AES32ESMI3)
|
||||
FUN2F(aes32esi0,AES32ESI0)
|
||||
FUN2F(aes32esi1,AES32ESI1)
|
||||
FUN2F(aes32esi2,AES32ESI2)
|
||||
FUN2F(aes32esi3,AES32ESI3)
|
||||
|
||||
#define AES_ROUND1T(TAB,I,X0,X1,X2,X3,Y0,Y1,Y2,Y3) \
|
||||
{ \
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
#define ASM2MACRO(N, O) asm(".macro "#N" rd, rs1, rs2\n" \
|
||||
".word ("#O" | (\\rd << 7) | (\\rs1 << 15) | (\\rs2 << 20))\n" \
|
||||
".endm\n");
|
||||
#define ASM2FMACRO(N, O) asm(".macro "#N" rt, rs2\n" \
|
||||
".word ("#O" | (\\rt << 15) | (\\rs2 << 20))\n" \
|
||||
".endm\n");
|
||||
asm("#define reg_zero 0\n");
|
||||
asm("#define reg_ra 1\n");
|
||||
asm("#define reg_sp 2\n");
|
||||
|
@ -63,23 +66,31 @@ asm("#define reg_t6 31\n");
|
|||
: "r" (rs1), "r" (rs2)); \
|
||||
return r; \
|
||||
}
|
||||
#define FUN2F(NAME, ASNAME) \
|
||||
static inline uint32_t NAME(uint32_t rs1, uint32_t rs2) { \
|
||||
uint32_t r = rs1; \
|
||||
asm (#ASNAME " reg_%0, reg_%1\n" \
|
||||
: "+&r" (r) \
|
||||
: "r" (rs2)); \
|
||||
return r; \
|
||||
}
|
||||
|
||||
ASM2MACRO(AES32ESMI0,0x36000033)
|
||||
ASM2MACRO(AES32ESMI1,0x76000033)
|
||||
ASM2MACRO(AES32ESMI2,0xb6000033)
|
||||
ASM2MACRO(AES32ESMI3,0xf6000033)
|
||||
ASM2MACRO(AES32ESI0,0x32000033)
|
||||
ASM2MACRO(AES32ESI1,0x72000033)
|
||||
ASM2MACRO(AES32ESI2,0xb2000033)
|
||||
ASM2MACRO(AES32ESI3,0xf2000033)
|
||||
FUN2(aes32esmi0,AES32ESMI0)
|
||||
FUN2(aes32esmi1,AES32ESMI1)
|
||||
FUN2(aes32esmi2,AES32ESMI2)
|
||||
FUN2(aes32esmi3,AES32ESMI3)
|
||||
FUN2(aes32esi0,AES32ESI0)
|
||||
FUN2(aes32esi1,AES32ESI1)
|
||||
FUN2(aes32esi2,AES32ESI2)
|
||||
FUN2(aes32esi3,AES32ESI3)
|
||||
ASM2FMACRO(AES32ESMI0,0x36000033)
|
||||
ASM2FMACRO(AES32ESMI1,0x76000033)
|
||||
ASM2FMACRO(AES32ESMI2,0xb6000033)
|
||||
ASM2FMACRO(AES32ESMI3,0xf6000033)
|
||||
ASM2FMACRO(AES32ESI0,0x32000033)
|
||||
ASM2FMACRO(AES32ESI1,0x72000033)
|
||||
ASM2FMACRO(AES32ESI2,0xb2000033)
|
||||
ASM2FMACRO(AES32ESI3,0xf2000033)
|
||||
FUN2F(aes32esmi0,AES32ESMI0)
|
||||
FUN2F(aes32esmi1,AES32ESMI1)
|
||||
FUN2F(aes32esmi2,AES32ESMI2)
|
||||
FUN2F(aes32esmi3,AES32ESMI3)
|
||||
FUN2F(aes32esi0,AES32ESI0)
|
||||
FUN2F(aes32esi1,AES32ESI1)
|
||||
FUN2F(aes32esi2,AES32ESI2)
|
||||
FUN2F(aes32esi3,AES32ESI3)
|
||||
|
||||
#define AES_ROUND1T(TAB,I,X0,X1,X2,X3,Y0,Y1,Y2,Y3) \
|
||||
{ \
|
||||
|
|
16
data_aes.txt
16
data_aes.txt
|
@ -7,14 +7,14 @@
|
|||
//bs 11001 rs2 rs1==rd 000 rd 0110011 aes32esi
|
||||
|
||||
|
||||
I aes32esmi0 aes32esmi0 0011011----------000-----0110011 aes0 Zkne
|
||||
I aes32esmi1 aes32esmi1 0111011----------000-----0110011 aes0 Zkne
|
||||
I aes32esmi2 aes32esmi2 1011011----------000-----0110011 aes0 Zkne
|
||||
I aes32esmi3 aes32esmi3 1111011----------000-----0110011 aes0 Zkne
|
||||
I aes32esi0 aes32esi0 0011001----------000-----0110011 aes1 Zkne
|
||||
I aes32esi1 aes32esi1 0111001----------000-----0110011 aes1 Zkne
|
||||
I aes32esi2 aes32esi2 1011001----------000-----0110011 aes1 Zkne
|
||||
I aes32esi3 aes32esi3 1111001----------000-----0110011 aes1 Zkne
|
||||
I aes32esmi0 aes32esmi0 0011011----------000000000110011 aes0 Zkne
|
||||
I aes32esmi1 aes32esmi1 0111011----------000000000110011 aes0 Zkne
|
||||
I aes32esmi2 aes32esmi2 1011011----------000000000110011 aes0 Zkne
|
||||
I aes32esmi3 aes32esmi3 1111011----------000000000110011 aes0 Zkne
|
||||
I aes32esi0 aes32esi0 0011001----------000000000110011 aes1 Zkne
|
||||
I aes32esi1 aes32esi1 0111001----------000000000110011 aes1 Zkne
|
||||
I aes32esi2 aes32esi2 1011001----------000000000110011 aes1 Zkne
|
||||
I aes32esi3 aes32esi3 1111001----------000000000110011 aes1 Zkne
|
||||
|
||||
S aes32esmi0 "fun_aesx_0(input(SRC2), input(SRC1))"
|
||||
S aes32esmi1 "fun_aesx_1(input(SRC2), input(SRC1))"
|
||||
|
|
Loading…
Add table
Reference in a new issue