vscause

Virtual Supervisor Cause

Reports the cause of the latest exception taken in VS-mode.

Attributes

Defining Extension

  • H, version >= 0

CSR Address

0x242

Virtual CSR Address

0x142

Length

32 when CSR[hstatus].VSXL == 0 64 when CSR[hstatus].VSXL == 1

Privilege Mode

VS

Format

This CSR format changes dynamically.

vscause Format when CSR[hstatus].VSXL == 0
Figure 1. vscause Format when CSR[hstatus].VSXL == 0
vscause Format when CSR[hstatus].VSXL == 1
Figure 2. vscause Format when CSR[hstatus].VSXL == 1

Field Summary

Name Location Type Reset Value

vscause.INT

* 31 when CSR[hstatus].VSXL == 0 * 63 when CSR[hstatus].VSXL == 1

RW-RH

UNDEFINED_LEGAL

vscause.CODE

* 30:0 when CSR[hstatus].VSXL == 0 * 62:0 when CSR[hstatus].VSXL == 1

RW-RH

UNDEFINED_LEGAL

Fields

INT

Location
  • 31 when CSR[hstatus].VSXL == 0

  • 63 when CSR[hstatus].VSXL == 1

Description

Written by hardware when a trap is taken into VS-mode.

When set, the last exception was caused by an asynchronous Interrupt.

vscause.INT is writeable.

If vscause is written with an undefined cause (combination of vscause.INT and vscause.CODE), an Illegal Instruction exception occurs.
If vscause is written with an undefined cause (combination of vscause.INT and vscause.CODE), neither vscause.INT nor vscause.CODE are modified.
Type

RW-RH

Reset value

UNDEFINED_LEGAL

CODE

Location
  • 30:0 when CSR[hstatus].VSXL == 0

  • 62:0 when CSR[hstatus].VSXL == 1

Description

Written by hardware when a trap is taken into VS-mode.

Holds the interrupt or exception code for the last taken trap.

vscause.CODE is writeable.

If vscause is written with an undefined cause (combination of vscause.INT and vscause.CODE), an Illegal Instruction exception occurs.
If vscause is written with an undefined cause (combination of vscause.INT and vscause.CODE), neither vscause.INT nor vscause.CODE are modified.

Valid interrupt codes are:

<%- interrupt_codes.sort_by { |code| code.num }.each do |code| -%>

<%= code.num %>

<%= code.name %> <%- end -%>

Valid exception codes are:

<%- exception_codes.sort_by { |code| code.num }.each do |code| -%>

<%= code.num %>

<%= code.name %> <%- end -%>

Type

RW-RH

Reset value

UNDEFINED_LEGAL

Software write

This CSR may store a value that is different from what software attempts to write.

When a software write occurs (e.g., through csrrw), the following determines the written value:

INT = # the write only holds if the INT/CODE combination is valid
# otherwise, the old value is retained
if (csr_value.INT == 1) {
  if (valid_interrupt_code?(csr_value.CODE)) {
    return 1;
  }
  return ILLEGAL_WLRL;
} else {
  if (valid_exception_code?(csr_value.CODE)) {
    return 1;
  }
  return ILLEGAL_WLRL;
}

CODE = # the write only holds if the INT/CODE combination is valid
# otherwise, the old value is retained
if (csr_value.INT == 1) {
  if (valid_interrupt_code?(csr_value.CODE)) {
    return csr_value.CODE;
  }
  return ILLEGAL_WLRL;
} else {
  if (valid_exception_code?(csr_value.CODE)) {
    return csr_value.CODE;
  }
  return ILLEGAL_WLRL;
}