Webcentive RISC-V Reference

vxrm

Fixed-point rounding mode

Address
0x00A
Group
Unprivileged and user-level CSRs
Privilege
URW (privileged spec CSR listing, Unprivileged Vector CSRs)
Access
read/write; lowest privilege U (user/unprivileged)
Address range
Standard read/write
Name in riscv-unified-db
Vector Fixed-Point Rounding Mode

Privileged spec: Fixed-point rounding mode

Description

Holds a 2-bit read-write rounding-mode field in the least-significant bits

From riscv-unified-db, reformatted.

Fields

FieldBitsTypeDescription
VALUERV32 31-0 / RV64 63-0RW-H

The vector fixed-point rounding-mode register holds a two-bit read-write rounding-mode field in the least-significant bits (vxrm[1:0]). The upper bits, vxrm[XLEN-1:2], should be written as zeros. The vector fixed-point rounding-mode is given a separate CSR address to allow independent access, but is also reflected as a field in vcsr.

Note: A new rounding mode can be set while saving the original rounding mode using a single csrwi instruction.

The fixed-point rounding algorithm is specified as follows. Suppose the pre-rounding result is v, and d bits of that result are to be rounded off. Then the rounded result is (v >> d) + r, where r depends on the rounding mode as specified in the following table of vxrm[1:0] values.

vxrm[1:0]AbbreviationRounding ModeRounding increment, r
00rnuround-to-nearest-up (add +0.5 LSB)v[d-1]
01rneround-to-nearest-evenv[d-1] & (v[d-2:0]!=0 | v[d])
10rdnround-down (truncate)0
11rodround-to-odd (OR bits into LSB, aka "jam")!v[d] & v[d-1:0]!=0

Fields from riscv-unified-db; field types computed by IDL functions there are not shown.

Specification and related pages