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
| 3126 | 25 | 2420 | 1915 | 1412 | 117 | 60 | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 000000 | vm | vs2 | vs1 | 000 | vd | 1010111 | |||||||||||||||||||||||||
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.
| Field | Bits | riscv-opcodes name |
|---|---|---|
| vm | 25 | vm |
| vs2 | 24:20 | vs2 |
| vs1 | 19:15 | vs1 |
| vd | 11:7 | vd |
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.