Skip to content

Latest commit

 

History

History
67 lines (56 loc) · 1.3 KB

vrev8.adoc

File metadata and controls

67 lines (56 loc) · 1.3 KB

vrev8.v

Synopsis

Vector Reverse Bytes

Mnemonic

vrev8.v vd, vs2, vm

Encoding (Vector)
{reg:[
{bits: 7, name: 'OP-V'},
{bits: 5, name: 'vd'},
{bits: 3, name: 'OPMVV'},
{bits: 5, name: '01001'},
{bits: 5, name: 'vs2'},
{bits: 1, name: 'vm'},
{bits: 6, name: '010010'},
]}
Arguments
Register Direction Definition

Vs2

input

Input elements

Vd

output

Byte-reversed elements

Description

A byte reversal is performed on each element of vs2, effectively performing an endian swap.

Note

This element-wise endian swapping is needed for several cryptographic algorithms including SHA2 and SM3.

Operation
function clause execute (VREV8(vs2)) = {
  foreach (i from vstart to vl-1) {
    input = get_velem(vs2, SEW, i);
    let output : SEW = 0;
    let j = SEW - 1;
    foreach (k from 0 to (SEW - 8) by 8) {
      output[k..(k + 7)] = input[(j - 7)..j];
      j = j - 8;
    set_velem(vd, SEW, i, output)
  }
  RETIRE_SUCCESS
}