mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
target/riscv: rvv-1.0: add vcsr register
Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> Signed-off-by: Frank Chang <frank.chang@sifive.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-Id: <20211210075704.23951-10-frank.chang@sifive.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
9bd291f6e3
commit
4594fa5a96
2 changed files with 24 additions and 0 deletions
|
@ -60,9 +60,16 @@
|
|||
#define CSR_VSTART 0x008
|
||||
#define CSR_VXSAT 0x009
|
||||
#define CSR_VXRM 0x00a
|
||||
#define CSR_VCSR 0x00f
|
||||
#define CSR_VL 0xc20
|
||||
#define CSR_VTYPE 0xc21
|
||||
|
||||
/* VCSR fields */
|
||||
#define VCSR_VXSAT_SHIFT 0
|
||||
#define VCSR_VXSAT (0x1 << VCSR_VXSAT_SHIFT)
|
||||
#define VCSR_VXRM_SHIFT 1
|
||||
#define VCSR_VXRM (0x3 << VCSR_VXRM_SHIFT)
|
||||
|
||||
/* User Timers and Counters */
|
||||
#define CSR_CYCLE 0xc00
|
||||
#define CSR_TIME 0xc01
|
||||
|
|
|
@ -336,6 +336,22 @@ static RISCVException write_vstart(CPURISCVState *env, int csrno,
|
|||
return RISCV_EXCP_NONE;
|
||||
}
|
||||
|
||||
static int read_vcsr(CPURISCVState *env, int csrno, target_ulong *val)
|
||||
{
|
||||
*val = (env->vxrm << VCSR_VXRM_SHIFT) | (env->vxsat << VCSR_VXSAT_SHIFT);
|
||||
return RISCV_EXCP_NONE;
|
||||
}
|
||||
|
||||
static int write_vcsr(CPURISCVState *env, int csrno, target_ulong val)
|
||||
{
|
||||
#if !defined(CONFIG_USER_ONLY)
|
||||
env->mstatus |= MSTATUS_VS;
|
||||
#endif
|
||||
env->vxrm = (val & VCSR_VXRM) >> VCSR_VXRM_SHIFT;
|
||||
env->vxsat = (val & VCSR_VXSAT) >> VCSR_VXSAT_SHIFT;
|
||||
return RISCV_EXCP_NONE;
|
||||
}
|
||||
|
||||
/* User Timers and Counters */
|
||||
static RISCVException read_instret(CPURISCVState *env, int csrno,
|
||||
target_ulong *val)
|
||||
|
@ -1816,6 +1832,7 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = {
|
|||
[CSR_VSTART] = { "vstart", vs, read_vstart, write_vstart },
|
||||
[CSR_VXSAT] = { "vxsat", vs, read_vxsat, write_vxsat },
|
||||
[CSR_VXRM] = { "vxrm", vs, read_vxrm, write_vxrm },
|
||||
[CSR_VCSR] = { "vcsr", vs, read_vcsr, write_vcsr },
|
||||
[CSR_VL] = { "vl", vs, read_vl },
|
||||
[CSR_VTYPE] = { "vtype", vs, read_vtype },
|
||||
/* User Timers and Counters */
|
||||
|
|
Loading…
Reference in a new issue