Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added constraint for SXLEN and UXLEN #530

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions model/riscv_sys_regs.sail
Original file line number Diff line number Diff line change
Expand Up @@ -204,29 +204,35 @@ function effectivePrivilege(t : AccessType(ext_access_type), m : Mstatus, priv :
function get_mstatus_SXL(m : Mstatus) -> arch_xlen = {
if sizeof(xlen) == 32
then arch_to_bits(RV32)
else m.bits[35 .. 34]
else
if not(have_privLevel(privLevel_to_bits(Supervisor)))
then 0b00
else m.bits[35 .. 34]
}

function set_mstatus_SXL(m : Mstatus, a : arch_xlen) -> Mstatus = {
if sizeof(xlen) == 32
then m
else {
let m = vector_update_subrange(m.bits, 35, 34, a);
let m = vector_update_subrange(m.bits, 35, 34, a);
Mk_Mstatus(m)
}
}

function get_mstatus_UXL(m : Mstatus) -> arch_xlen = {
if sizeof(xlen) == 32
then arch_to_bits(RV32)
else m.bits[33 .. 32]
else
if not(have_privLevel(privLevel_to_bits(User)))
then 0b00
else m.bits[33 .. 32]
}

function set_mstatus_UXL(m : Mstatus, a : arch_xlen) -> Mstatus = {
if sizeof(xlen) == 32
then m
else {
let m = vector_update_subrange(m.bits, 33, 32, a);
let m = vector_update_subrange(m.bits, 33, 32, a);
Mk_Mstatus(m)
}
}
Expand Down Expand Up @@ -257,6 +263,10 @@ function legalize_mstatus(o : Mstatus, v : xlenbits) -> Mstatus = {
let m = [m with SD = bool_to_bits(dirty)];

/* We don't support dynamic changes to SXL and UXL. */
match (arch_xlen_to_int(get_mstatus_SXL(o)), arch_xlen_to_int(get_mstatus_UXL(o))) {
(Some(sxl), Some(uxl)) => assert(sxl >= uxl),
_ => ()
};
let m = set_mstatus_SXL(m, get_mstatus_SXL(o));
let m = set_mstatus_UXL(m, get_mstatus_UXL(o));

Expand Down
7 changes: 7 additions & 0 deletions model/riscv_types.sail
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ function arch_to_bits(a : Architecture) -> arch_xlen =
RV128 => 0b11
}

function arch_xlen_to_int(a : arch_xlen) -> option(int) =
match a {
0b01 => Some(32),
0b10 => Some(64),
0b11 => Some(128),
0b00 => None()
}

/* model-internal exceptions */

Expand Down