Skip to content

Commit 068a4fd

Browse files
authored
Merge branch 'main' into xqci
2 parents e92d436 + 6e05606 commit 068a4fd

File tree

5 files changed

+122
-20
lines changed

5 files changed

+122
-20
lines changed

arch/inst/Zbkb/brev8.yaml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
$schema: inst_schema.json#
44
kind: instruction
55
name: brev8
6-
long_name: No synopsis available.
6+
long_name: Reverse bits in bytes
77
description: |
8-
No description available.
9-
definedBy:
10-
anyOf: [B, Zbkb, Zk, Zkn, Zks]
8+
This instruction reverses the order of the bits in every byte of a register.
9+
definedBy: Zbkb
1110
assembly: xd, xs1
1211
encoding:
1312
match: 011010000111-----101-----0010011
@@ -23,3 +22,20 @@ access:
2322
vu: always
2423
data_independent_timing: false
2524
operation(): |
25+
XReg input = X[rs1];
26+
XReg output = 0;
27+
28+
for(U32 i=0; i<(xlen()-8); i = i+8) {
29+
for(U32 j=0; j<8; j = j+1) {
30+
output[(i*8)+(7-j)] = input[(i*8)+j];
31+
}
32+
}
33+
34+
X[rd] = output;
35+
36+
sail(): |
37+
result : xlenbits = EXTZ(0b0);
38+
foreach (i from 0 to sizeof(xlen) by 8) {
39+
result[i+7..i] = reverse_bits_in_byte(X(rs1)[i+7..i]);
40+
};
41+
X(rd) = result;

arch/inst/Zbkb/unzip.yaml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
$schema: inst_schema.json#
44
kind: instruction
55
name: unzip
6-
long_name: No synopsis available.
6+
long_name: Bit deinterleave
77
description: |
8-
No description available.
9-
definedBy:
10-
anyOf: [B, Zbkb, Zk, Zkn, Zks]
8+
This instruction gathers bits from the high and low halves of the source word into odd/even bit
9+
positions in the destination word. It is the inverse of the zip instruction. This instruction is
10+
available only on RV32.
11+
definedBy: Zbkb
1112
assembly: xd, xs1
1213
encoding:
1314
match: 000010001111-----101-----0010011
@@ -24,3 +25,18 @@ access:
2425
data_independent_timing: false
2526
base: 32
2627
operation(): |
28+
XReg input = X[rs1];
29+
XReg output = 0;
30+
31+
for(U32 i=0; i<(xlen()/2-1); i = i+1) {
32+
output[i] = input[2*i];
33+
output[i+xlen()/2] = input[2*i+1];
34+
}
35+
36+
X[rd] = output;
37+
38+
sail(): |
39+
foreach (i from 0 to xlen/2-1) {
40+
X(rd)[i] = X(rs1)[2*i];
41+
X(rd)[i+xlen/2] = X(rs1)[2*i+1];
42+
}

arch/inst/Zbkb/zip.yaml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
$schema: inst_schema.json#
44
kind: instruction
55
name: zip
6-
long_name: No synopsis available.
6+
long_name: Bit interleave
77
description: |
8-
No description available.
9-
definedBy:
10-
anyOf: [B, Zbkb, Zk, Zkn, Zks]
8+
This instruction scatters all of the odd and even bits of a source word into the high and low halves
9+
of a destination word. It is the inverse of the unzip instruction. This instruction is available only on
10+
RV32.
11+
definedBy: Zbkb
1112
assembly: xd, xs1
1213
encoding:
1314
match: 000010001111-----001-----0010011
@@ -24,3 +25,18 @@ access:
2425
data_independent_timing: false
2526
base: 32
2627
operation(): |
28+
XReg input = X[rs1];
29+
XReg output = 0;
30+
31+
for(U32 i=0; i<(xlen()/2-1); i = i+1){
32+
output[2*i] = input[i];
33+
output[2*i+1] = input[i+xlen()/2];
34+
}
35+
36+
X[rd] = output;
37+
38+
sail(): |
39+
foreach (i from 0 to xlen/2-1) {
40+
X(rd)[2*i] = X(rs1)[i];
41+
X(rd)[2*i+1] = X(rs1)[i+xlen/2];
42+
}

arch/inst/Zbkx/xperm4.yaml

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
$schema: inst_schema.json#
44
kind: instruction
55
name: xperm4
6-
long_name: No synopsis available.
6+
long_name: Crossbar permutation (nibbles)
77
description: |
8-
No description available.
9-
definedBy:
10-
anyOf: [B, Zbkx, Zk, Zkn, Zks]
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.
11+
definedBy: Zbkx
1112
assembly: xd, xs1, xs2
1213
encoding:
1314
match: 0010100----------010-----0110011
@@ -25,3 +26,29 @@ access:
2526
vu: always
2627
data_independent_timing: false
2728
operation(): |
29+
XReg input1 = X[rs1];
30+
XReg input2 = X[rs2];
31+
XReg output = 0;
32+
33+
for(U32 i=0; i<(xlen()-4); i = i+4) {
34+
XReg index = input2[i+3:i];
35+
if(4*index < xlen()) {
36+
output[i+3:i] = input1[4*index+3:4*index];
37+
}
38+
}
39+
40+
X[rd] = output;
41+
42+
sail(): |
43+
val xperm4_lookup : (bits(4), xlenbits) -> bits(4)
44+
function xperm4_lookup (idx, lut) = {
45+
(lut >> (idx @ 0b00))[3..0]
46+
}
47+
function clause execute ( XPERM_4 (rs2,rs1,rd)) = {
48+
result : xlenbits = EXTZ(0b0);
49+
foreach(i from 0 to xlen by 4) {
50+
result[i+3..i] = xperm4_lookup(X(rs2)[i+3..i], X(rs1));
51+
};
52+
X(rd) = result;
53+
RETIRE_SUCCESS
54+
}

arch/inst/Zbkx/xperm8.yaml

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
$schema: inst_schema.json#
44
kind: instruction
55
name: xperm8
6-
long_name: No synopsis available.
6+
long_name: Crossbar permutation (bytes)
77
description: |
8-
No description available.
9-
definedBy:
10-
anyOf: [B, Zbkx, Zk, Zkn, Zks]
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.
11+
definedBy: Zbkx
1112
assembly: xd, xs1, xs2
1213
encoding:
1314
match: 0010100----------100-----0110011
@@ -25,3 +26,29 @@ access:
2526
vu: always
2627
data_independent_timing: false
2728
operation(): |
29+
XReg input1 = X[rs1];
30+
XReg input2 = X[rs2];
31+
XReg output = 0;
32+
33+
for(U32 i=0; i<(xlen()-8); i = i+8) {
34+
XReg index = input2[i+7:i];
35+
if(8*index < xlen()) {
36+
output[i+7:i] = input1[8*index+7:8*index];
37+
}
38+
}
39+
40+
X[rd] = output;
41+
42+
sail(): |
43+
val xperm8_lookup : (bits(8), xlenbits) -> bits(8)
44+
function xperm8_lookup (idx, lut) = {
45+
(lut >> (idx @ 0b00))[7..0]
46+
}
47+
function clause execute ( XPERM_8 (rs2,rs1,rd)) = {
48+
result : xlenbits = EXTZ(0b0);
49+
foreach(i from 0 to xlen by 8) {
50+
result[i+7..i] = xperm8_lookup(X(rs2)[i+7..i], X(rs1));
51+
};
52+
X(rd) = result;
53+
RETIRE_SUCCESS
54+
}

0 commit comments

Comments
 (0)