Skip to content

Commit 74fd833

Browse files
committed
Update Zbkx
1 parent b2abecc commit 74fd833

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

arch/inst/Zbkx/xperm4.yaml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
$schema: inst_schema.json#
44
kind: instruction
55
name: xperm4
6-
long_name: No synopsis available.
6+
long_name: Nibble-wise lookup of indicies into a vector.
77
description: |
8-
No description available.
8+
The xperm4 instruction operates on nibbles. The rs1 register contains a vector of XLEN/4 4-bit
9+
elements. The rs2 register contains a vector of XLEN/4 4-bit indexes. The result is each element in
10+
rs2 replaced by the indexed element in rs1, or zero if the index into rs2 is out of bounds.
911
definedBy:
1012
anyOf: [B, Zbkx, Zk, Zkn, Zks]
1113
assembly: xd, xs1, xs2
@@ -25,3 +27,19 @@ access:
2527
vu: always
2628
data_independent_timing: false
2729
operation(): |
30+
if (implemented?(ExtensionName::B) && (CSR[misa].Zbkx == 1'b0)) {
31+
raise (ExceptionCode::IllegalInstruction, mode(), $encoding);
32+
}
33+
34+
val xperm4_lookup : (bits(4), xlenbits) -> bits(4)
35+
function xperm4_lookup (idx, lut) = {
36+
(lut >> (idx @ 0b00))[3..0]
37+
}
38+
function clause execute ( XPERM_4 (rs2,rs1,rd)) = {
39+
result : xlenbits = EXTZ(0b0);
40+
foreach(i from 0 to xlen by 4) {
41+
result[i+3..i] = xperm4_lookup(X(rs2)[i+3..i], X(rs1));
42+
};
43+
X(rd) = result;
44+
RETIRE_SUCCESS
45+
}

arch/inst/Zbkx/xperm8.yaml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
$schema: inst_schema.json#
44
kind: instruction
55
name: xperm8
6-
long_name: No synopsis available.
6+
long_name: Byte-wise lookup of indicies into a vector.
77
description: |
8-
No description available.
8+
The xperm8 instruction operates on bytes. The rs1 register contains a vector of XLEN/8 8-bit
9+
elements. The rs2 register contains a vector of XLEN/8 8-bit indexes. The result is each element in
10+
rs2 replaced by the indexed element in rs1, or zero if the index into rs2 is out of bounds.
911
definedBy:
1012
anyOf: [B, Zbkx, Zk, Zkn, Zks]
1113
assembly: xd, xs1, xs2
@@ -25,3 +27,19 @@ access:
2527
vu: always
2628
data_independent_timing: false
2729
operation(): |
30+
if (implemented?(ExtensionName::B) && (CSR[misa].Zbkx == 1'b0)) {
31+
raise (ExceptionCode::IllegalInstruction, mode(), $encoding);
32+
}
33+
34+
val xperm8_lookup : (bits(8), xlenbits) -> bits(8)
35+
function xperm8_lookup (idx, lut) = {
36+
(lut >> (idx @ 0b00))[7..0]
37+
}
38+
function clause execute ( XPERM_8 (rs2,rs1,rd)) = {
39+
result : xlenbits = EXTZ(0b0);
40+
foreach(i from 0 to xlen by 8) {
41+
result[i+7..i] = xperm4_lookup(X(rs2)[i+7..i], X(rs1));
42+
};
43+
X(rd) = result;
44+
RETIRE_SUCCESS
45+
}

0 commit comments

Comments
 (0)