Check vl first
The current vl determines the number of body elements. Typical code executes vsetvli, vsetivli, or vsetvl before this instruction.
Writes each active element index i to destination integer vector vd, using the current SEW for each index value.
VID.V is the RISC-V V extension element-index generation instruction. For each active body element i, it writes the unsigned element number i to vd[i]; with vm=0 only elements selected by v0.t are updated, while vm=1 updates all body elements within vl. It reads neither memory nor an ordinary source vector.
Starts from OP-V encoding fields, then shows how VID.V reads no source vector and writes each active lane index into an integer vector.
vid.v uses OP-V encoding; the vs1 field is fixed to 10001, and the vs2 field is also fixed to reserved value 00000.
This animation shows only ISA-visible relationships from the official V extension: OP-V field decode, active mask-bit scan within vl, and destination integer-vector writeback. It does not model pipelines, caches, or timing.
VID.V is a vector index generator: active lane i writes i, while disabled lanes do not produce a deterministic writeback.
When reading VID.V, do not stop at the mnemonic. Official V-extension semantics also depend on the current vl, vtype, and mask state. The suffix and operand form determine whether sources are vector, scalar, or immediate values.
The current vl determines the number of body elements. Typical code executes vsetvli, vsetivli, or vsetvl before this instruction.
The current vtype supplies SEW, LMUL, tail policy, and mask policy; these affect element width, register-group size, and inactive/tail destination elements.
For ordinary vector instructions with vm, vm=0 uses v0 as the execution mask and vm=1 is unmasked. A few forms such as VMERGE use v0 as data-selection input.
Understand this scenario with real code like «vsetvli t0, a0, e32, m1, ta, ma vid.v v1, v0.t # active vd[i] = i».
Understand this scenario with real code like «vsetvli t0, a0, e32, m1, ta, ma vid.v v1, v0.t # active vd[i] = i».
Understand this scenario with real code like «vsetvli t0, a0, e32, m1, ta, ma vid.v v1, v0.t # active vd[i] = i».
No. VID.V writes the element number i starting from 0; forming byte addresses later requires element width or explicit scaling.
No. VID.V uses the same OP-V class, but its reserved source field must be 00000 and the assembly syntax has no vs2 source operand.
They should not be interpreted as deterministic zero. With vm=0 and v0.t=0, the element does not write back and follows the current mask policy; tail elements follow the tail policy.