Skip to content

Commit

Permalink
update to new syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
ved-rivos committed Jul 18, 2024
1 parent 421f664 commit 5703495
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 7 additions & 3 deletions model/riscv_sys_control.sail
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ function is_CSR_defined (csr : csreg) -> bool =
0x180 => haveSupMode(), // satp

/* supervisor mode: resource management configurations */
0x181 => haveSsqosid() & ((p == Machine) |
((p == Supervisor) & haveSmstateen() & (mstateen0.PRIV_V1P14() == 0b1)) |
((p == Supervisor) & not(haveSmstateen()))), // srmcfg
0x181 => haveSsqosid(), // srmcfg

/* user mode: counters */
0xC00 => haveUsrMode(), // cycle
Expand Down Expand Up @@ -142,12 +140,18 @@ function check_seed_CSR (csr : csreg, p : Privilege, isWrite : bool) -> bool = {
}
}

function check_srmcfg(csr : csreg, p : Privilege) -> bool =
csr == 0x181
& p == Supervisor
& ((haveSmstateen() & mstateen0.PRIV_V1P14() == 0b1) | not(haveSmstateen()))

function check_CSR(csr : csreg, p : Privilege, isWrite : bool) -> bool =
is_CSR_defined(csr)
& check_CSR_access(csrAccess(csr), csrPriv(csr), p, isWrite)
& check_TVM_SATP(csr, p)
& check_Counteren(csr, p)
& check_seed_CSR(csr, p, isWrite)
& check_srmcfg(csr, p)

/* Reservation handling for LR/SC.
*
Expand Down
5 changes: 2 additions & 3 deletions model/riscv_sys_regs.sail
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ function have_PRIV_V1P14_Extensions() -> bool = {

function legalize_mstateen0(o : Mstateen0, v : bits(64)) -> Mstateen0 = {
let v = Mk_Mstateen0(v);
let o = update_PRIV_V1P14(o, if have_PRIV_V1P14_Extensions() then v.PRIV_V1P14() else 0b0);
let o = [o with PRIV_V1P14 = if have_PRIV_V1P14_Extensions() then v[PRIV_V1P14] else 0b0];
// Other extensions are not implemented yet so all other fields are read only zero.
o
}
Expand Down Expand Up @@ -990,7 +990,6 @@ bitfield Srmcfg : xlenbits = {
register srmcfg : Srmcfg

function legalize_srmcfg(s : Srmcfg, v : xlenbits) -> Srmcfg = {
let s = update_MCID(s, v[27 .. 16]);
let s = update_RCID(s, v[11 .. 0]);
let s = [s with MCID = v[27 .. 16], RCID = v[11 .. 0]];
s
}

0 comments on commit 5703495

Please sign in to comment.