Webcentive RISC-V Reference

vadd.vv

Vector-vector integer addition

Extension
V
XLEN
RV32 and RV64
Assembly (riscv-unified-db)
vadd.vv vd, vs2, vs1, vm
Length
32-bit

Encoding

31262524201915141211760
000000vmvs2vs1000vd1010111

Match 0x00000057, mask 0xfc00707f. Source: vadd.vv 31..26=0x00 vm vs2 vs1 14..12=0x0 vd 6..0=0x57 in riscv-opcodes/extensions/rv_v.

FieldBitsriscv-opcodes name
vm25vm
vs224:20vs2
vs119:15vs1
vd11:7vd

Description

Add source vector register groups from vs1 and vs2 according to mask vm and store results in vd.

Description from riscv-unified-db, reformatted.

Operation

VectorState state = vector_state();
VectorLmulType lmul_type = state.lmul_type;

XReg vlen = VLEN;
XReg vlmax;
if (lmul_type == VectorLmulType::Multiply) {
  vlmax = (vlen << state.log2_lmul) >> state.log2_sew;
} else {
  # (lmul_type == VectorLmulType::Divide)
  vlmax = (vlen >> state.log2_lmul) >> state.log2_sew;
}

for (U32 i = CSR[vstart].VALUE; i < CSR[vl].VALUE; i++) {
  U32 start_bit_pos = i * state.sew;
  U32 end_bit_pos = start_bit_pos + state.sew - 1;
  V[vd][end_bit_pos:start_bit_pos] = V[vs2][end_bit_pos:start_bit_pos] + V[vs1][end_bit_pos:start_bit_pos];
}

CSR[vstart].VALUE = 0;

Pseudocode in riscv-unified-db’s IDL, quoted unchanged.

Specification and related pages