mirror of
https://github.com/rdolbeau/VexRiscvBPluginGenerator.git
synced 2025-04-18 18:44:42 -04:00
100 lines
4 KiB
Text
100 lines
4 KiB
Text
//#define MASK_SHA256SUM0 0xfff0707f
|
|
//#define MATCH_SHA256SUM0 0x10001013
|
|
//#define MASK_SHA256SUM1 0xfff0707f
|
|
//#define MATCH_SHA256SUM1 0x10101013
|
|
//#define MASK_SHA256SIG0 0xfff0707f
|
|
//#define MATCH_SHA256SIG0 0x10201013
|
|
//#define MASK_SHA256SIG1 0xfff0707f
|
|
//#define MATCH_SHA256SIG1 0x10301013
|
|
//00 01000 00010 rs1 001 rd 0010011 sha256sig0
|
|
//00 01000 00011 rs1 001 rd 0010011 sha256sig1
|
|
//00 01000 00000 rs1 001 rd 0010011 sha256sum0
|
|
//00 01000 00001 rs1 001 rd 0010011 sha256sum1
|
|
|
|
I sha256sig0 sha256sig0 000100000010-----001-----0010011 sha256sig Zknh
|
|
I sha256sig1 sha256sig1 000100000011-----001-----0010011 sha256sig Zknh
|
|
I sha256sum0 sha256sum0 000100000000-----001-----0010011 sha256sum Zknh
|
|
I sha256sum1 sha256sum1 000100000001-----001-----0010011 sha256sum Zknh
|
|
|
|
S sha256sig0 "fun_sha256sig0(input(SRC1))"
|
|
S sha256sig1 "fun_sha256sig1(input(SRC1))"
|
|
S sha256sum0 "fun_sha256sum0(input(SRC1))"
|
|
S sha256sum1 "fun_sha256sum1(input(SRC1))"
|
|
|
|
//#define MASK_SHA512SUM0R 0xfe00707f
|
|
//#define MATCH_SHA512SUM0R 0x50000033
|
|
//#define MASK_SHA512SUM1R 0xfe00707f
|
|
//#define MATCH_SHA512SUM1R 0x52000033
|
|
//#define MASK_SHA512SIG0L 0xfe00707f
|
|
//#define MATCH_SHA512SIG0L 0x54000033
|
|
//#define MASK_SHA512SIG0H 0xfe00707f
|
|
//#define MATCH_SHA512SIG0H 0x5c000033
|
|
//#define MASK_SHA512SIG1L 0xfe00707f
|
|
//#define MATCH_SHA512SIG1L 0x56000033
|
|
//#define MASK_SHA512SIG1H 0xfe00707f
|
|
//#define MATCH_SHA512SIG1H 0x5e000033
|
|
|
|
//01 01010 rs2 rs1 000 rd 0110011 sha512sig0l
|
|
//01 01110 rs2 rs1 000 rd 0110011 sha512sig0h
|
|
//01 01011 rs2 rs1 000 rd 0110011 sha512sig1l
|
|
//01 01111 rs2 rs1 000 rd 0110011 sha512sig1h
|
|
//01 01000 rs2 rs1 000 rd 0110011 sha512sum0r
|
|
//01 01001 rs2 rs1 000 rd 0110011 sha512sum1r
|
|
|
|
I sha512sig0l sha512sig0l 0101010----------000-----0110011 sha512sig Zknh
|
|
I sha512sig0h sha512sig0h 0101110----------000-----0110011 sha512sig Zknh
|
|
I sha512sig1l sha512sig1l 0101011----------000-----0110011 sha512sig Zknh
|
|
I sha512sig1h sha512sig1h 0101111----------000-----0110011 sha512sig Zknh
|
|
I sha512sum0r sha512sum0r 0101000----------000-----0110011 sha512sum Zknh
|
|
I sha512sum1r sha512sum1r 0101001----------000-----0110011 sha512sum Zknh
|
|
|
|
S sha512sig0l "fun_sha512sig0l(input(SRC1),input(SRC2))"
|
|
S sha512sig0h "fun_sha512sig0h(input(SRC1),input(SRC2))"
|
|
S sha512sig1l "fun_sha512sig1l(input(SRC1),input(SRC2))"
|
|
S sha512sig1h "fun_sha512sig1h(input(SRC1),input(SRC2))"
|
|
S sha512sum0r "fun_sha512sum0r(input(SRC1),input(SRC2))"
|
|
S sha512sum1r "fun_sha512sum1r(input(SRC1),input(SRC2))"
|
|
|
|
P """
|
|
def fun_sha256sig0(rs1:Bits) : Bits = {
|
|
val r = rs1.rotateRight(7) ^ rs1.rotateRight(18) ^ (rs1 |>> 3)
|
|
r // return value
|
|
}
|
|
def fun_sha256sig1(rs1:Bits) : Bits = {
|
|
val r = rs1.rotateRight(17) ^ rs1.rotateRight(19) ^ (rs1 |>> 10)
|
|
r // return value
|
|
}
|
|
def fun_sha256sum0(rs1:Bits) : Bits = {
|
|
val r = rs1.rotateRight(2) ^ rs1.rotateRight(13) ^ rs1.rotateRight(22)
|
|
r // return value
|
|
}
|
|
def fun_sha256sum1(rs1:Bits) : Bits = {
|
|
val r = rs1.rotateRight(6) ^ rs1.rotateRight(11) ^ rs1.rotateRight(25)
|
|
r // return value
|
|
}
|
|
|
|
def fun_sha512sig0l(rs1:Bits, rs2:Bits) : Bits = {
|
|
val r = (rs1 |>> 1) ^ (rs1 |>> 7) ^ (rs1 |>> 8) ^ (rs2 |<< 31) ^ (rs2 |<< 25) ^ (rs2 |<< 24)
|
|
r // return value
|
|
}
|
|
def fun_sha512sig0h(rs1:Bits, rs2:Bits) : Bits = {
|
|
val r = (rs1 |>> 1) ^ (rs1 |>> 7) ^ (rs1 |>> 8) ^ (rs2 |<< 31) ^ (rs2 |<< 24)
|
|
r // return value
|
|
}
|
|
def fun_sha512sig1l(rs1:Bits, rs2:Bits) : Bits = {
|
|
val r = (rs1 |<< 3) ^ (rs1 |>> 6) ^ (rs1 |>> 19) ^ (rs2 |>> 29) ^ (rs2 |<< 26) ^ (rs2 |<< 13)
|
|
r // return value
|
|
}
|
|
def fun_sha512sig1h(rs1:Bits, rs2:Bits) : Bits = {
|
|
val r = (rs1 |<< 3) ^ (rs1 |>> 6) ^ (rs1 |>> 19) ^ (rs2 |>> 29) ^ (rs2 |<< 13)
|
|
r // return value
|
|
}
|
|
def fun_sha512sum0r(rs1:Bits, rs2:Bits) : Bits = {
|
|
val r = (rs1 |<< 25) ^ (rs1 |<< 30) ^ (rs1 |>> 28) ^ (rs2 |>> 7) ^ (rs2 |>> 2) ^ (rs2 |<< 4)
|
|
r // return value
|
|
}
|
|
def fun_sha512sum1r(rs1:Bits, rs2:Bits) : Bits = {
|
|
val r = (rs1 |<< 23) ^ (rs1 |>> 14) ^ (rs1 |>> 18) ^ (rs2 |>> 9) ^ (rs2 |<< 18) ^ (rs2 |<< 14)
|
|
r // return value
|
|
}
|
|
"""
|