contributed by < ranvd
>
In the following section, I will provide a brief overview of the vector extension and outline the fundamental aspects of how vector operations function. Regrettably, in my term project to RVVM, I have only incorporated the vset{i}vl{i}
instructions and lack familiarity with the JIT (Just-In-Time) compilation aspect of RVVM.
Within the RISC-V Vector (RVV) framework, several vector Control and Status Register (CSR) registers govern the handling of vector operations. Of utmost significance are the vtype
and vl
components. Prior to delving into the intricacies of register encoding, it is imperative to introduce certain terminologies specific to RVV.
vwaddu
, vnsrl
)The vtype
register can only be configured through the vset{i}vl{i}
instruction within RVV. Additionally, the vill
bit at the XLEN-1 position should be set if the specified vsew
and vlmul
values are deemed invalid. This ensures proper handling of invalid configurations within the vector operation context.
The vl register can exclusively be configured through the vset{i}vl{i} instruction. This instruction plays a pivotal role in setting the vector length (vl) during vector operations.
In the Makefile, I define the macro USE_RVV
as the control flag responsible for enabling or disabling the Vector extension.
Several Vector Control Status Registers (CSRs) should be incorporated into the csr
struct within the rvvm_hart_t
function. At present, I have exclusively implemented the vtype
and vl
registers. These two registers delineate crucial parameters such as the element width, register group, mask policy, and other pertinent specifications.
Given that the Vector extension is enabled, the mstatus.VS
field should be configured to either Initial(1) or Clean(2). Upon the execution of any vector instruction by the CPU, the mstatus.VS
field will be updated to Dirty(3). During the initialization of a hart, certain fixed parameters must be set, such as VLEN
, ELEN
, SEW_min
, and mstatus.VS
.
Within the RVVM project, all privileged instructions are registered through the riscv_priv_init()
function. Consequently, I have registered the vset{i}vl{i}
instructions within this function.
Given that the OP
code and func3
field in vsetvl
, vsetvli
, and vsetivli
share identical values, the decoding operation is performed within the riscv_v_vsetvl()
function. In my implementation, I have opted for a switch-case statement to handle this decoding process.
As the Application Vector Length (AVL) value relies on the input values of the rs1 and rd fields, the encoding policy is as below. The vl will be set to the AVL only if the vl value is valid. This validity is determined by the sew and lmul values in the vtype register. Consequently, it is necessary to configure the vtype register first before setting the vl value.
In RVVM, each Control and Status Register (CSR) is associated with its own handler. Currently, I have implemented handlers for the vtype
and vl
registers.
For vtype csr handler, it is necessary to validate the input values. If the provided values are deemed invalid, the vtype[XLEN-1]
bit should be set accordingly. This ensures proper handling of invalid input values within the context of the specific CSR handler.
I simply insert printf
function to inspect the vl and vltype value.
Also, while reading the rvv-intrinsic-doc, I pull request to rvv-intrinsic-doc to fix a typo. XD
Lack of the coverage of vector specific instructions.