Skip to content

Commit

Permalink
Make mstatus[VS] dirty when vstart is written
Browse files Browse the repository at this point in the history
Set `mstatus[VS]` to dirty when `vstart` is written. There are still some writes to vector CSRs that are missing calls to `dirty_v_context()` but these will be fixed in a future.

This also removes `dirty_v_context_if_present()` because the vector extension is always supported when this function is called.

Co-authored-by: Yui5427 <[email protected]>
  • Loading branch information
rez5427 and Yui5427 authored Nov 29, 2024
1 parent ac42b46 commit a0d99dc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion model/riscv_vext_control.sail
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function clause read_CSR(0xC20) = vl
function clause read_CSR(0xC21) = vtype.bits
function clause read_CSR(0xC22) = get_vlenb()

function clause write_CSR(0x008, value) = { let vstart_length = get_vlen_pow(); vstart = zero_extend(16, value[(vstart_length - 1) .. 0]); zero_extend(vstart) }
function clause write_CSR(0x008, value) = { dirty_v_context(); let vstart_length = get_vlen_pow(); vstart = zero_extend(16, value[(vstart_length - 1) .. 0]); zero_extend(vstart) }
function clause write_CSR(0x009, value) = { ext_write_vcsr (vcsr[vxrm], value[0 .. 0]); zero_extend(vcsr[vxsat]) }
function clause write_CSR(0x00A, value) = { ext_write_vcsr (value[1 .. 0], vcsr[vxsat]); zero_extend(vcsr[vxrm]) }
function clause write_CSR(0x00F, value) = { ext_write_vcsr (value [2 .. 1], value [0 .. 0]); zero_extend(vcsr.bits) }
6 changes: 1 addition & 5 deletions model/riscv_vext_regs.sail
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ function dirty_v_context() -> unit = {
mstatus[SD] = 0b1
}

function dirty_v_context_if_present() -> unit = {
if sys_enable_vext() then dirty_v_context()
}

function rV (r : regno) -> vregtype = {
match r {
0 => vr0,
Expand Down Expand Up @@ -222,7 +218,7 @@ val ext_write_vcsr : (bits(2), bits(1)) -> unit
function ext_write_vcsr (vxrm_val, vxsat_val) = {
vcsr[vxrm] = vxrm_val; /* Note: frm can be an illegal value, 101, 110, 111 */
vcsr[vxsat] = vxsat_val;
dirty_v_context_if_present()
dirty_v_context()
}

/* num_elem means max(VLMAX,VLEN/SEW)) according to Section 5.4 of RVV spec */
Expand Down

0 comments on commit a0d99dc

Please sign in to comment.