From b9e7b1960dce504aa94495253353cdc2e478ded5 Mon Sep 17 00:00:00 2001 From: Tim Hutt Date: Mon, 7 Oct 2024 09:42:19 +0100 Subject: [PATCH] Allow writing CBO bits in xenvcfg This was accidentally missed from the CBO implementation. --- model/riscv_sys_regs.sail | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/model/riscv_sys_regs.sail b/model/riscv_sys_regs.sail index c9a81ddc6..9cd281f3c 100644 --- a/model/riscv_sys_regs.sail +++ b/model/riscv_sys_regs.sail @@ -349,6 +349,9 @@ function legalize_menvcfg(o : MEnvcfg, v : bits(64)) -> MEnvcfg = { let v = Mk_MEnvcfg(v); [o with FIOM = if sys_enable_writable_fiom() then v[FIOM] else 0b0, + CBZE = if extensionEnabled(Ext_Zicboz) then v[CBZE] else 0b0, + CBCFE = if extensionEnabled(Ext_Zicbom) then v[CBCFE] else 0b0, + CBIE = if extensionEnabled(Ext_Zicbom) then (if v[CBIE] != 0b10 then v[CBIE] else 0b00) else 0b00, STCE = if extensionEnabled(Ext_Sstc) then v[STCE] else 0b0, // Other extensions are not implemented yet so all other fields are read only zero. ] @@ -358,12 +361,16 @@ function legalize_senvcfg(o : SEnvcfg, v : xlenbits) -> SEnvcfg = { let v = Mk_SEnvcfg(v); [o with FIOM = if sys_enable_writable_fiom() then v[FIOM] else 0b0, + CBZE = if extensionEnabled(Ext_Zicboz) then v[CBZE] else 0b0, + CBCFE = if extensionEnabled(Ext_Zicbom) then v[CBCFE] else 0b0, + CBIE = if extensionEnabled(Ext_Zicbom) then (if v[CBIE] != 0b10 then v[CBIE] else 0b00) else 0b00, // Other extensions are not implemented yet so all other fields are read only zero. - ]; + ] } -register menvcfg : MEnvcfg -register senvcfg : SEnvcfg +// Initialised to legal values in case some bits are hard-coded to 1. +register menvcfg : MEnvcfg = legalize_menvcfg(Mk_MEnvcfg(zeros()), zeros()) +register senvcfg : SEnvcfg = legalize_senvcfg(Mk_SEnvcfg(zeros()), zeros()) mapping clause csr_name_map = 0x30A <-> "menvcfg" mapping clause csr_name_map = 0x31A <-> "menvcfgh"