Skip to content

Commit

Permalink
Add extensionEnabled checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Timmmm committed Dec 16, 2024
1 parent 01f0f1c commit 05fd1f9
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions model/riscv_sys_regs.sail
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,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 = v[CBZE],
CBCFE = v[CBCFE],
CBIE = if v[CBIE] != 0b10 then v[CBIE] else 0b00,
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.
]
Expand All @@ -364,15 +364,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 = v[CBZE],
CBCFE = v[CBCFE],
CBIE = if v[CBIE] != 0b10 then v[CBIE] else 0b00,
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()), mseccfg, zeros())
register senvcfg : SEnvcfg = legalize_senvcfg(Mk_SEnvcfg(zeros()), menvcfg, zeros())

mapping clause csr_name_map = 0x30A <-> "menvcfg"
mapping clause csr_name_map = 0x31A <-> "menvcfgh"
Expand Down

0 comments on commit 05fd1f9

Please sign in to comment.