xperm8

Crossbar permutation (bytes)

The xperm8 instruction operates on bytes. The xs1 register contains a vector of XLEN/8 8-bit elements. The xs2 register contains a vector of XLEN/8 8-bit indexes. The result is each element in xs2 replaced by the indexed element in xs1, or zero if the index into xs2 is out of bounds.

Assembly format

xperm8 rd, rs1, rs2

Decode Variables

Bits<5> xs2 = $encoding[24:20];
Bits<5> xs1 = $encoding[19:15];
Bits<5> xd = $encoding[11:7];

Execution

  • IDL

  • Sail

XReg input1 = X[xs1];
XReg input2 = X[xs2];
XReg output = 0;
for (U32 i = 0; i < (xlen() - 8); i = i + 8) {
  XReg index = input2[i + 7:i];
  if (8 * index < xlen()) {
    output[i + 7:i] = input1[8 * index + 7:8 * index];
  }
}
X[xd] = output;
val xperm8_lookup : (bits(8), xlenbits) -> bits(8)
function xperm8_lookup (idx, lut) = {
  (lut >> (idx @ 0b00))[7..0]
}
function clause execute ( XPERM_8 (rs2,rs1,rd)) = {
  result : xlenbits = EXTZ(0b0);
  foreach(i from 0 to xlen by 8) {
    result[i+7..i] = xperm8_lookup(X(rs2)[i+7..i], X(rs1));
  };
  X(rd) = result;
  RETIRE_SUCCESS
}

Encoding

svg

Defining extension

Zbkx, version >= Zbkx@1.0.0

Access

M

Always

Containing profiles

  • Mandatory:

  • Optional: RVA22S64, RVA22U64, RVA23M64, RVA23S64, RVB23M64, RVB23S64, RVB23U64