Vector Set Vector Type Immediate and Vector Length Immediate
Set the vtype and vl CSRs, and write the new value of vl into xd.
vsetivli xd, uimm, vtypei
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 11 | vtypei | uimm | 111 | xd | 1 | 0 | 1 | 0 | 111 | ||||||||||||||||||||||
| Variable | Bits | Width |
|---|---|---|
vtypei | [29:20] | 10 |
uimm | [19:15] | 5 |
xd | [11:7] | 5 |
XReg new_vtype = vtypei;
if ((new_vtype[xlen() - 1] == 1'b1) # software is setting the illegal bit
|| ((new_vtype & 8'd0) != 0) # reserved bits
|| (new_vtype[5] == 1) # reserved vsew encoding
|| (new_vtype[2:0] == 3'b100) # reserved vlmul encoding
|| (xlen() == 32 && new_vtype[2:0] == 3'b101)) # reserved LMUL in RV32
{
CSR[vtype].VILL = 1;
CSR[vtype].VMA = 0;
CSR[vtype].VTA = 0;
CSR[vtype].VSEW = 0;
CSR[vtype].VLMUL = 0;
} else {
# valid, do the write
CSR[vtype].VILL = 0;
CSR[vtype].VMA = new_vtype[7];
CSR[vtype].VTA = new_vtype[6];
CSR[vtype].VSEW = new_vtype[5:3];
CSR[vtype].VLMUL = new_vtype[2:0];
}
VectorState state = vector_state();
XReg vlen = VLEN;
XReg vlmax = (vlen << state.log2_lmul) >> state.log2_sew;
XReg AVL = uimm;
XReg CEIL_AVL_OVER_TWO = (AVL + 1) / 2;
if (AVL <= vlmax) {
CSR[vl].VALUE = AVL;
} else if (AVL < 2 * vlmax) {
if (RVV_VL_WHEN_AVL_LT_DOUBLE_VLMAX == "ceil(AVL/2)") {
CSR[vl].VALUE = CEIL_AVL_OVER_TWO;
} else if (RVV_VL_WHEN_AVL_LT_DOUBLE_VLMAX == "VLMAX") {
CSR[vl].VALUE = vlmax;
} else {
unpredictable("Implementations may choose a custom value for vl in the case AVL < (2*VLMAX), so long as ceil(AVL/2) <= vl <= VLMAX");
}
} else {
CSR[vl].VALUE = vlmax;
}
X[xd] = CSR[vl].VALUE;
CSR[vstart].VALUE = 0;
Zvl32b
| S | U | VS | VU |
|---|---|---|---|
| Always | Always | Always | Always |
Version af3eaf9+cheriot.f635218
Data from the RISC-V Unified Database, copyright RISC-V International and contributors.
CHERIoT extensions from the CHERIoT specification and Sail model, copyright Microsoft and the CHERIoT Platform contributors.
This site is provided as a community resource and is NOT affiliated with nor endorsed by RISC-V International.