Skip to content

Commit

Permalink
Move function declaration of extension
Browse files Browse the repository at this point in the history
- The declaration of the extension function is moved
  upwards to ensure that it is being declared before
  the other instances of have* usage so that it can be
  utilized in it
  • Loading branch information
jriyyya committed Apr 18, 2024
1 parent 35020f7 commit e9658f1
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions model/riscv_sys_regs.sail
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,43 @@ function set_mstatus_UXL(m : Mstatus, a : arch_xlen) -> Mstatus = {
}
}

val extension : (string) -> bool

function extension(ext) = {
match ext {
"A" => misa.A() == 0b1,
"C" => misa.C() == 0b1,
"D" => (misa.D() == 0b1) & (mstatus.FS() != 0b00),
"F" => (misa.F() == 0b1) & (mstatus.FS() != 0b00),
"M" => misa.M() == 0b1,
"N" => misa.N() == 0b1,
"U" => misa.U() == 0b1,
"S" => misa.S() == 0b1,
"V" => (misa.V() == 0b1) & (mstatus.VS() != 0b00),
"Zba" => true,
"Zbb" => true,
"Zbc" => true,
"Zbkb" => true,
"Zbkc" => true,
"Zbkx" => true,
"Zbs" => true,
"Zfa" => true,
"Zfh" => (misa.F() == 0b1) & (mstatus.FS() != 0b00),
"Zdinx" => sys_enable_zfinx() & sizeof(flen) >= 64,
"Zfinx" => sys_enable_zfinx(),
"Zhinx" => sys_enable_zfinx(),
"Zicond" => true,
"Zkr" => true,
"Zksh" => true,
"Zksed" => true,
"Zknd" => true,
"Zkne" => true,
"Zknh" => true,
"Zmmul" => true,
_ => false
}
}

function legalize_mstatus(o : Mstatus, v : xlenbits) -> Mstatus = {
/*
* Populate all defined fields using the bits of v, stripping anything
Expand Down Expand Up @@ -964,40 +1001,3 @@ function get_vtype_vma() = decode_agtype(vtype.vma())

val get_vtype_vta : unit -> agtype effect {rreg}
function get_vtype_vta() = decode_agtype(vtype.vta())

val extension : (string) -> bool

function extension(ext) = {
match ext {
"A" => misa.A() == 0b1,
"C" => misa.C() == 0b1,
"D" => (misa.D() == 0b1) & (mstatus.FS() != 0b00),
"F" => (misa.F() == 0b1) & (mstatus.FS() != 0b00),
"M" => misa.M() == 0b1,
"N" => misa.N() == 0b1,
"U" => misa.U() == 0b1,
"S" => misa.S() == 0b1,
"V" => (misa.V() == 0b1) & (mstatus.VS() != 0b00),
"Zba" => true,
"Zbb" => true,
"Zbc" => true,
"Zbkb" => true,
"Zbkc" => true,
"Zbkx" => true,
"Zbs" => true,
"Zfa" => true,
"Zfh" => (misa.F() == 0b1) & (mstatus.FS() != 0b00),
"Zdinx" => sys_enable_zfinx() & sizeof(flen) >= 64,
"Zfinx" => sys_enable_zfinx(),
"Zhinx" => sys_enable_zfinx(),
"Zicond" => true,
"Zkr" => true,
"Zksh" => true,
"Zksed" => true,
"Zknd" => true,
"Zkne" => true,
"Zknh" => true,
"Zmmul" => true,
_ => false
}
}

0 comments on commit e9658f1

Please sign in to comment.